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. */
775 DEFUN (bgp_multiple_instance_func
,
776 bgp_multiple_instance_cmd
,
777 "bgp multiple-instance",
779 "Enable bgp multiple instance\n")
781 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
785 DEFUN (no_bgp_multiple_instance
,
786 no_bgp_multiple_instance_cmd
,
787 "no bgp multiple-instance",
790 "BGP multiple instance\n")
794 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
796 vty_out(vty
, "%% There are more than two BGP instances\n");
797 return CMD_WARNING_CONFIG_FAILED
;
802 DEFUN (bgp_config_type
,
804 "bgp config-type <cisco|zebra>",
806 "Configuration type\n"
811 if (argv_find(argv
, argc
, "cisco", &idx
))
812 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
814 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
819 DEFUN (no_bgp_config_type
,
820 no_bgp_config_type_cmd
,
821 "no bgp config-type [<cisco|zebra>]",
824 "Display configuration type\n"
828 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
833 DEFUN (no_synchronization
,
834 no_synchronization_cmd
,
835 "no synchronization",
837 "Perform IGP synchronization\n")
842 DEFUN (no_auto_summary
,
846 "Enable automatic network number summarization\n")
851 /* "router bgp" commands. */
852 DEFUN_NOSH (router_bgp
,
854 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
858 BGP_INSTANCE_HELP_STR
)
861 int idx_view_vrf
= 3;
866 const char *name
= NULL
;
867 enum bgp_instance_type inst_type
;
869 // "router bgp" without an ASN
871 // Pending: Make VRF option available for ASN less config
872 bgp
= bgp_get_default();
875 vty_out(vty
, "%% No BGP process is configured\n");
876 return CMD_WARNING_CONFIG_FAILED
;
879 if (listcount(bm
->bgp
) > 1) {
880 vty_out(vty
, "%% Please specify ASN and VRF\n");
881 return CMD_WARNING_CONFIG_FAILED
;
887 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
889 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
891 name
= argv
[idx_vrf
]->arg
;
893 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf"))
894 inst_type
= BGP_INSTANCE_TYPE_VRF
;
895 else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
896 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
899 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
901 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
903 "Please specify 'bgp multiple-instance' first\n");
904 return CMD_WARNING_CONFIG_FAILED
;
905 case BGP_ERR_AS_MISMATCH
:
906 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
907 return CMD_WARNING_CONFIG_FAILED
;
908 case BGP_ERR_INSTANCE_MISMATCH
:
910 "BGP instance name and AS number mismatch\n");
912 "BGP instance is already running; AS is %u\n",
914 return CMD_WARNING_CONFIG_FAILED
;
917 /* Pending: handle when user tries to change a view to vrf n vv.
921 /* unset the auto created flag as the user config is now present */
922 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
923 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
928 /* "no router bgp" commands. */
929 DEFUN (no_router_bgp
,
931 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
936 BGP_INSTANCE_HELP_STR
)
942 const char *name
= NULL
;
944 // "no router bgp" without an ASN
946 // Pending: Make VRF option available for ASN less config
947 bgp
= bgp_get_default();
950 vty_out(vty
, "%% No BGP process is configured\n");
951 return CMD_WARNING_CONFIG_FAILED
;
954 if (listcount(bm
->bgp
) > 1) {
955 vty_out(vty
, "%% Please specify ASN and VRF\n");
956 return CMD_WARNING_CONFIG_FAILED
;
960 vty_out(vty
, "%% Please unconfigure l3vni %u",
962 return CMD_WARNING_CONFIG_FAILED
;
965 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
968 name
= argv
[idx_vrf
]->arg
;
970 /* Lookup bgp structure. */
971 bgp
= bgp_lookup(as
, name
);
973 vty_out(vty
, "%% Can't find BGP instance\n");
974 return CMD_WARNING_CONFIG_FAILED
;
978 vty_out(vty
, "%% Please unconfigure l3vni %u",
980 return CMD_WARNING_CONFIG_FAILED
;
992 DEFPY (bgp_router_id
,
994 "bgp router-id A.B.C.D",
996 "Override configured router identifier\n"
997 "Manually configured router identifier\n")
999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1000 bgp_router_id_static_set(bgp
, router_id
);
1004 DEFPY (no_bgp_router_id
,
1005 no_bgp_router_id_cmd
,
1006 "no 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
);
1014 if (router_id_str
) {
1015 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1016 vty_out(vty
, "%% BGP router-id doesn't match\n");
1017 return CMD_WARNING_CONFIG_FAILED
;
1021 router_id
.s_addr
= 0;
1022 bgp_router_id_static_set(bgp
, router_id
);
1028 /* BGP Cluster ID. */
1029 DEFUN (bgp_cluster_id
,
1031 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1033 "Configure Route-Reflector Cluster-id\n"
1034 "Route-Reflector Cluster-id in IP address format\n"
1035 "Route-Reflector Cluster-id as 32 bit quantity\n")
1037 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1040 struct in_addr cluster
;
1042 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1044 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1045 return CMD_WARNING_CONFIG_FAILED
;
1048 bgp_cluster_id_set(bgp
, &cluster
);
1049 bgp_clear_star_soft_out(vty
, bgp
->name
);
1054 DEFUN (no_bgp_cluster_id
,
1055 no_bgp_cluster_id_cmd
,
1056 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1059 "Configure Route-Reflector Cluster-id\n"
1060 "Route-Reflector Cluster-id in IP address format\n"
1061 "Route-Reflector Cluster-id as 32 bit quantity\n")
1063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1064 bgp_cluster_id_unset(bgp
);
1065 bgp_clear_star_soft_out(vty
, bgp
->name
);
1070 DEFUN (bgp_confederation_identifier
,
1071 bgp_confederation_identifier_cmd
,
1072 "bgp confederation identifier (1-4294967295)",
1073 "BGP specific commands\n"
1074 "AS confederation parameters\n"
1076 "Set routing domain confederation AS\n")
1078 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1082 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1084 bgp_confederation_id_set(bgp
, as
);
1089 DEFUN (no_bgp_confederation_identifier
,
1090 no_bgp_confederation_identifier_cmd
,
1091 "no bgp confederation identifier [(1-4294967295)]",
1093 "BGP specific commands\n"
1094 "AS confederation parameters\n"
1096 "Set routing domain confederation AS\n")
1098 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1099 bgp_confederation_id_unset(bgp
);
1104 DEFUN (bgp_confederation_peers
,
1105 bgp_confederation_peers_cmd
,
1106 "bgp confederation peers (1-4294967295)...",
1107 "BGP specific commands\n"
1108 "AS confederation parameters\n"
1109 "Peer ASs in BGP confederation\n"
1112 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1117 for (i
= idx_asn
; i
< argc
; i
++) {
1118 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1120 if (bgp
->as
== as
) {
1122 "%% Local member-AS not allowed in confed peer list\n");
1126 bgp_confederation_peers_add(bgp
, as
);
1131 DEFUN (no_bgp_confederation_peers
,
1132 no_bgp_confederation_peers_cmd
,
1133 "no bgp confederation peers (1-4294967295)...",
1135 "BGP specific commands\n"
1136 "AS confederation parameters\n"
1137 "Peer ASs in BGP confederation\n"
1140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1145 for (i
= idx_asn
; i
< argc
; i
++) {
1146 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1148 bgp_confederation_peers_remove(bgp
, as
);
1154 * Central routine for maximum-paths configuration.
1155 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1156 * @set: 1 for setting values, 0 for removing the max-paths config.
1158 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1159 const char *mpaths
, uint16_t options
,
1162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1163 uint16_t maxpaths
= 0;
1168 afi
= bgp_node_afi(vty
);
1169 safi
= bgp_node_safi(vty
);
1172 maxpaths
= strtol(mpaths
, NULL
, 10);
1173 if (maxpaths
> multipath_num
) {
1175 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1176 maxpaths
, multipath_num
);
1177 return CMD_WARNING_CONFIG_FAILED
;
1179 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1182 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1186 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1187 (set
== 1) ? "" : "un",
1188 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1189 maxpaths
, afi
, safi
);
1190 return CMD_WARNING_CONFIG_FAILED
;
1193 bgp_recalculate_all_bestpaths(bgp
);
1198 DEFUN (bgp_maxmed_admin
,
1199 bgp_maxmed_admin_cmd
,
1200 "bgp max-med administrative ",
1202 "Advertise routes with max-med\n"
1203 "Administratively applied, for an indefinite period\n")
1205 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1207 bgp
->v_maxmed_admin
= 1;
1208 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1210 bgp_maxmed_update(bgp
);
1215 DEFUN (bgp_maxmed_admin_medv
,
1216 bgp_maxmed_admin_medv_cmd
,
1217 "bgp max-med administrative (0-4294967295)",
1219 "Advertise routes with max-med\n"
1220 "Administratively applied, for an indefinite period\n"
1221 "Max MED value to be used\n")
1223 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1226 bgp
->v_maxmed_admin
= 1;
1227 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1229 bgp_maxmed_update(bgp
);
1234 DEFUN (no_bgp_maxmed_admin
,
1235 no_bgp_maxmed_admin_cmd
,
1236 "no bgp max-med administrative [(0-4294967295)]",
1239 "Advertise routes with max-med\n"
1240 "Administratively applied, for an indefinite period\n"
1241 "Max MED value to be used\n")
1243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1244 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1245 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1246 bgp_maxmed_update(bgp
);
1251 DEFUN (bgp_maxmed_onstartup
,
1252 bgp_maxmed_onstartup_cmd
,
1253 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1255 "Advertise routes with max-med\n"
1256 "Effective on a startup\n"
1257 "Time (seconds) period for max-med\n"
1258 "Max MED value to be used\n")
1260 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1263 argv_find(argv
, argc
, "(5-86400)", &idx
);
1264 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1265 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1266 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1268 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1270 bgp_maxmed_update(bgp
);
1275 DEFUN (no_bgp_maxmed_onstartup
,
1276 no_bgp_maxmed_onstartup_cmd
,
1277 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1280 "Advertise routes with max-med\n"
1281 "Effective on a startup\n"
1282 "Time (seconds) period for max-med\n"
1283 "Max MED value to be used\n")
1285 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1287 /* Cancel max-med onstartup if its on */
1288 if (bgp
->t_maxmed_onstartup
) {
1289 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1290 bgp
->maxmed_onstartup_over
= 1;
1293 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1294 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1296 bgp_maxmed_update(bgp
);
1301 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1304 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1305 uint16_t update_delay
;
1306 uint16_t establish_wait
;
1308 update_delay
= strtoul(delay
, NULL
, 10);
1310 if (!wait
) /* update-delay <delay> */
1312 bgp
->v_update_delay
= update_delay
;
1313 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1317 /* update-delay <delay> <establish-wait> */
1318 establish_wait
= atoi(wait
);
1319 if (update_delay
< establish_wait
) {
1321 "%%Failed: update-delay less than the establish-wait!\n");
1322 return CMD_WARNING_CONFIG_FAILED
;
1325 bgp
->v_update_delay
= update_delay
;
1326 bgp
->v_establish_wait
= establish_wait
;
1331 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1333 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1335 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1336 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1341 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1343 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1344 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1345 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1346 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1352 /* Update-delay configuration */
1353 DEFUN (bgp_update_delay
,
1354 bgp_update_delay_cmd
,
1355 "update-delay (0-3600)",
1356 "Force initial delay for best-path and updates\n"
1360 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1363 DEFUN (bgp_update_delay_establish_wait
,
1364 bgp_update_delay_establish_wait_cmd
,
1365 "update-delay (0-3600) (1-3600)",
1366 "Force initial delay for best-path and updates\n"
1371 int idx_number_2
= 2;
1372 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1373 argv
[idx_number_2
]->arg
);
1376 /* Update-delay deconfiguration */
1377 DEFUN (no_bgp_update_delay
,
1378 no_bgp_update_delay_cmd
,
1379 "no update-delay [(0-3600) [(1-3600)]]",
1381 "Force initial delay for best-path and updates\n"
1385 return bgp_update_delay_deconfig_vty(vty
);
1389 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1392 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1395 uint32_t quanta
= strtoul(num
, NULL
, 10);
1396 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1397 memory_order_relaxed
);
1399 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1400 memory_order_relaxed
);
1406 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1409 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1412 uint32_t quanta
= strtoul(num
, NULL
, 10);
1413 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1414 memory_order_relaxed
);
1416 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1417 memory_order_relaxed
);
1423 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1426 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1427 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1428 vty_out(vty
, " write-quanta %d\n", quanta
);
1431 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1434 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1435 if (quanta
!= BGP_READ_PACKET_MAX
)
1436 vty_out(vty
, " read-quanta %d\n", quanta
);
1439 /* Packet quanta configuration */
1440 DEFUN (bgp_wpkt_quanta
,
1441 bgp_wpkt_quanta_cmd
,
1442 "write-quanta (1-10)",
1443 "How many packets to write to peer socket per run\n"
1444 "Number of packets\n")
1447 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1450 DEFUN (no_bgp_wpkt_quanta
,
1451 no_bgp_wpkt_quanta_cmd
,
1452 "no write-quanta (1-10)",
1454 "How many packets to write to peer socket per I/O cycle\n"
1455 "Number of packets\n")
1458 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1461 DEFUN (bgp_rpkt_quanta
,
1462 bgp_rpkt_quanta_cmd
,
1463 "read-quanta (1-10)",
1464 "How many packets to read from peer socket per I/O cycle\n"
1465 "Number of packets\n")
1468 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1471 DEFUN (no_bgp_rpkt_quanta
,
1472 no_bgp_rpkt_quanta_cmd
,
1473 "no read-quanta (1-10)",
1475 "How many packets to read from peer socket per I/O cycle\n"
1476 "Number of packets\n")
1479 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1482 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1484 if (!bgp
->heuristic_coalesce
)
1485 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1489 DEFUN (bgp_coalesce_time
,
1490 bgp_coalesce_time_cmd
,
1491 "coalesce-time (0-4294967295)",
1492 "Subgroup coalesce timer\n"
1493 "Subgroup coalesce timer value (in ms)\n")
1495 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1498 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1499 bgp
->heuristic_coalesce
= false;
1500 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1504 DEFUN (no_bgp_coalesce_time
,
1505 no_bgp_coalesce_time_cmd
,
1506 "no coalesce-time (0-4294967295)",
1508 "Subgroup coalesce timer\n"
1509 "Subgroup coalesce timer value (in ms)\n")
1511 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1513 bgp
->heuristic_coalesce
= true;
1514 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1518 /* Maximum-paths configuration */
1519 DEFUN (bgp_maxpaths
,
1521 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1522 "Forward packets over multiple paths\n"
1523 "Number of paths\n")
1526 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1527 argv
[idx_number
]->arg
, 0, 1);
1530 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1531 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1532 "Forward packets over multiple paths\n"
1533 "Number of paths\n")
1535 DEFUN (bgp_maxpaths_ibgp
,
1536 bgp_maxpaths_ibgp_cmd
,
1537 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1538 "Forward packets over multiple paths\n"
1540 "Number of paths\n")
1543 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1544 argv
[idx_number
]->arg
, 0, 1);
1547 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1548 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1549 "Forward packets over multiple paths\n"
1551 "Number of paths\n")
1553 DEFUN (bgp_maxpaths_ibgp_cluster
,
1554 bgp_maxpaths_ibgp_cluster_cmd
,
1555 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1556 "Forward packets over multiple paths\n"
1559 "Match the cluster length\n")
1562 return bgp_maxpaths_config_vty(
1563 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1564 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1567 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1568 "maximum-paths ibgp " CMD_RANGE_STR(
1569 1, MULTIPATH_NUM
) " equal-cluster-length",
1570 "Forward packets over multiple paths\n"
1573 "Match the cluster length\n")
1575 DEFUN (no_bgp_maxpaths
,
1576 no_bgp_maxpaths_cmd
,
1577 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1579 "Forward packets over multiple paths\n"
1580 "Number of paths\n")
1582 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1585 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1586 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1587 "Forward packets over multiple paths\n"
1588 "Number of paths\n")
1590 DEFUN (no_bgp_maxpaths_ibgp
,
1591 no_bgp_maxpaths_ibgp_cmd
,
1592 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1594 "Forward packets over multiple paths\n"
1597 "Match the cluster length\n")
1599 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1602 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1603 "no maximum-paths ibgp [" CMD_RANGE_STR(
1604 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1606 "Forward packets over multiple paths\n"
1609 "Match the cluster length\n")
1611 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1614 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1615 vty_out(vty
, " maximum-paths %d\n",
1616 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1619 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1620 vty_out(vty
, " maximum-paths ibgp %d",
1621 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1622 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1623 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1624 vty_out(vty
, " equal-cluster-length");
1633 "timers bgp (0-65535) (0-65535)",
1634 "Adjust routing timers\n"
1636 "Keepalive interval\n"
1639 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1641 int idx_number_2
= 3;
1642 unsigned long keepalive
= 0;
1643 unsigned long holdtime
= 0;
1645 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1646 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1648 /* Holdtime value check. */
1649 if (holdtime
< 3 && holdtime
!= 0) {
1651 "%% hold time value must be either 0 or greater than 3\n");
1652 return CMD_WARNING_CONFIG_FAILED
;
1655 bgp_timers_set(bgp
, keepalive
, holdtime
);
1660 DEFUN (no_bgp_timers
,
1662 "no timers bgp [(0-65535) (0-65535)]",
1664 "Adjust routing timers\n"
1666 "Keepalive interval\n"
1669 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1670 bgp_timers_unset(bgp
);
1676 DEFUN (bgp_client_to_client_reflection
,
1677 bgp_client_to_client_reflection_cmd
,
1678 "bgp client-to-client reflection",
1679 "BGP specific commands\n"
1680 "Configure client to client route reflection\n"
1681 "reflection of routes allowed\n")
1683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1684 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1685 bgp_clear_star_soft_out(vty
, bgp
->name
);
1690 DEFUN (no_bgp_client_to_client_reflection
,
1691 no_bgp_client_to_client_reflection_cmd
,
1692 "no bgp client-to-client reflection",
1694 "BGP specific commands\n"
1695 "Configure client to client route reflection\n"
1696 "reflection of routes allowed\n")
1698 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1699 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1700 bgp_clear_star_soft_out(vty
, bgp
->name
);
1705 /* "bgp always-compare-med" configuration. */
1706 DEFUN (bgp_always_compare_med
,
1707 bgp_always_compare_med_cmd
,
1708 "bgp always-compare-med",
1709 "BGP specific commands\n"
1710 "Allow comparing MED from different neighbors\n")
1712 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1713 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1714 bgp_recalculate_all_bestpaths(bgp
);
1719 DEFUN (no_bgp_always_compare_med
,
1720 no_bgp_always_compare_med_cmd
,
1721 "no bgp always-compare-med",
1723 "BGP specific commands\n"
1724 "Allow comparing MED from different neighbors\n")
1726 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1727 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1728 bgp_recalculate_all_bestpaths(bgp
);
1733 /* "bgp deterministic-med" configuration. */
1734 DEFUN (bgp_deterministic_med
,
1735 bgp_deterministic_med_cmd
,
1736 "bgp deterministic-med",
1737 "BGP specific commands\n"
1738 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1740 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1742 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1743 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1744 bgp_recalculate_all_bestpaths(bgp
);
1750 DEFUN (no_bgp_deterministic_med
,
1751 no_bgp_deterministic_med_cmd
,
1752 "no bgp deterministic-med",
1754 "BGP specific commands\n"
1755 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1757 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1758 int bestpath_per_as_used
;
1762 struct listnode
*node
, *nnode
;
1764 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1765 bestpath_per_as_used
= 0;
1767 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1768 FOREACH_AFI_SAFI (afi
, safi
)
1770 peer
->af_flags
[afi
][safi
],
1771 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1772 bestpath_per_as_used
= 1;
1776 if (bestpath_per_as_used
)
1780 if (bestpath_per_as_used
) {
1782 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1783 return CMD_WARNING_CONFIG_FAILED
;
1785 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1786 bgp_recalculate_all_bestpaths(bgp
);
1793 /* "bgp graceful-restart" configuration. */
1794 DEFUN (bgp_graceful_restart
,
1795 bgp_graceful_restart_cmd
,
1796 "bgp graceful-restart",
1797 "BGP specific commands\n"
1798 "Graceful restart capability parameters\n")
1800 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1801 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1805 DEFUN (no_bgp_graceful_restart
,
1806 no_bgp_graceful_restart_cmd
,
1807 "no bgp graceful-restart",
1809 "BGP specific commands\n"
1810 "Graceful restart capability parameters\n")
1812 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1813 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1817 DEFUN (bgp_graceful_restart_stalepath_time
,
1818 bgp_graceful_restart_stalepath_time_cmd
,
1819 "bgp graceful-restart stalepath-time (1-3600)",
1820 "BGP specific commands\n"
1821 "Graceful restart capability parameters\n"
1822 "Set the max time to hold onto restarting peer's stale paths\n"
1823 "Delay value (seconds)\n")
1825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1829 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1830 bgp
->stalepath_time
= stalepath
;
1834 DEFUN (bgp_graceful_restart_restart_time
,
1835 bgp_graceful_restart_restart_time_cmd
,
1836 "bgp graceful-restart restart-time (1-3600)",
1837 "BGP specific commands\n"
1838 "Graceful restart capability parameters\n"
1839 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1840 "Delay value (seconds)\n")
1842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1846 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1847 bgp
->restart_time
= restart
;
1851 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1852 no_bgp_graceful_restart_stalepath_time_cmd
,
1853 "no bgp graceful-restart stalepath-time [(1-3600)]",
1855 "BGP specific commands\n"
1856 "Graceful restart capability parameters\n"
1857 "Set the max time to hold onto restarting peer's stale paths\n"
1858 "Delay value (seconds)\n")
1860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1862 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1866 DEFUN (no_bgp_graceful_restart_restart_time
,
1867 no_bgp_graceful_restart_restart_time_cmd
,
1868 "no bgp graceful-restart restart-time [(1-3600)]",
1870 "BGP specific commands\n"
1871 "Graceful restart capability parameters\n"
1872 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1873 "Delay value (seconds)\n")
1875 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1877 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1881 DEFUN (bgp_graceful_restart_preserve_fw
,
1882 bgp_graceful_restart_preserve_fw_cmd
,
1883 "bgp graceful-restart preserve-fw-state",
1884 "BGP specific commands\n"
1885 "Graceful restart capability parameters\n"
1886 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1889 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1893 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1894 no_bgp_graceful_restart_preserve_fw_cmd
,
1895 "no bgp graceful-restart preserve-fw-state",
1897 "BGP specific commands\n"
1898 "Graceful restart capability parameters\n"
1899 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1902 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1906 static void bgp_redistribute_redo(struct bgp
*bgp
)
1910 struct list
*red_list
;
1911 struct listnode
*node
;
1912 struct bgp_redist
*red
;
1914 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1915 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1917 red_list
= bgp
->redist
[afi
][i
];
1921 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1922 bgp_redistribute_resend(bgp
, afi
, i
,
1929 /* "bgp graceful-shutdown" configuration */
1930 DEFUN (bgp_graceful_shutdown
,
1931 bgp_graceful_shutdown_cmd
,
1932 "bgp graceful-shutdown",
1934 "Graceful shutdown parameters\n")
1936 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1938 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1939 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1940 bgp_static_redo_import_check(bgp
);
1941 bgp_redistribute_redo(bgp
);
1942 bgp_clear_star_soft_out(vty
, bgp
->name
);
1943 bgp_clear_star_soft_in(vty
, bgp
->name
);
1949 DEFUN (no_bgp_graceful_shutdown
,
1950 no_bgp_graceful_shutdown_cmd
,
1951 "no bgp graceful-shutdown",
1954 "Graceful shutdown parameters\n")
1956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1958 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1959 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1960 bgp_static_redo_import_check(bgp
);
1961 bgp_redistribute_redo(bgp
);
1962 bgp_clear_star_soft_out(vty
, bgp
->name
);
1963 bgp_clear_star_soft_in(vty
, bgp
->name
);
1969 /* "bgp fast-external-failover" configuration. */
1970 DEFUN (bgp_fast_external_failover
,
1971 bgp_fast_external_failover_cmd
,
1972 "bgp fast-external-failover",
1974 "Immediately reset session if a link to a directly connected external peer goes down\n")
1976 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1977 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1981 DEFUN (no_bgp_fast_external_failover
,
1982 no_bgp_fast_external_failover_cmd
,
1983 "no bgp fast-external-failover",
1986 "Immediately reset session if a link to a directly connected external peer goes down\n")
1988 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1989 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1993 /* "bgp enforce-first-as" configuration. */
1994 #if defined(VERSION_TYPE_DEV) && CONFDATE > 20180517
1995 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
1998 DEFUN_DEPRECATED (bgp_enforce_first_as
,
1999 bgp_enforce_first_as_cmd
,
2000 "bgp enforce-first-as",
2002 "Enforce the first AS for EBGP routes\n")
2004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2005 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2010 DEFUN_DEPRECATED (no_bgp_enforce_first_as
,
2011 no_bgp_enforce_first_as_cmd
,
2012 "no bgp enforce-first-as",
2015 "Enforce the first AS for EBGP routes\n")
2017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2018 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2023 /* "bgp bestpath compare-routerid" configuration. */
2024 DEFUN (bgp_bestpath_compare_router_id
,
2025 bgp_bestpath_compare_router_id_cmd
,
2026 "bgp bestpath compare-routerid",
2027 "BGP specific commands\n"
2028 "Change the default bestpath selection\n"
2029 "Compare router-id for identical EBGP paths\n")
2031 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2032 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2033 bgp_recalculate_all_bestpaths(bgp
);
2038 DEFUN (no_bgp_bestpath_compare_router_id
,
2039 no_bgp_bestpath_compare_router_id_cmd
,
2040 "no bgp bestpath compare-routerid",
2042 "BGP specific commands\n"
2043 "Change the default bestpath selection\n"
2044 "Compare router-id for identical EBGP paths\n")
2046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2047 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2048 bgp_recalculate_all_bestpaths(bgp
);
2053 /* "bgp bestpath as-path ignore" configuration. */
2054 DEFUN (bgp_bestpath_aspath_ignore
,
2055 bgp_bestpath_aspath_ignore_cmd
,
2056 "bgp bestpath as-path ignore",
2057 "BGP specific commands\n"
2058 "Change the default bestpath selection\n"
2059 "AS-path attribute\n"
2060 "Ignore as-path length in selecting a route\n")
2062 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2063 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2064 bgp_recalculate_all_bestpaths(bgp
);
2069 DEFUN (no_bgp_bestpath_aspath_ignore
,
2070 no_bgp_bestpath_aspath_ignore_cmd
,
2071 "no bgp bestpath as-path ignore",
2073 "BGP specific commands\n"
2074 "Change the default bestpath selection\n"
2075 "AS-path attribute\n"
2076 "Ignore as-path length in selecting a route\n")
2078 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2079 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2080 bgp_recalculate_all_bestpaths(bgp
);
2085 /* "bgp bestpath as-path confed" configuration. */
2086 DEFUN (bgp_bestpath_aspath_confed
,
2087 bgp_bestpath_aspath_confed_cmd
,
2088 "bgp bestpath as-path confed",
2089 "BGP specific commands\n"
2090 "Change the default bestpath selection\n"
2091 "AS-path attribute\n"
2092 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2094 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2095 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2096 bgp_recalculate_all_bestpaths(bgp
);
2101 DEFUN (no_bgp_bestpath_aspath_confed
,
2102 no_bgp_bestpath_aspath_confed_cmd
,
2103 "no bgp bestpath as-path confed",
2105 "BGP specific commands\n"
2106 "Change the default bestpath selection\n"
2107 "AS-path attribute\n"
2108 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2111 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2112 bgp_recalculate_all_bestpaths(bgp
);
2117 /* "bgp bestpath as-path multipath-relax" configuration. */
2118 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2119 bgp_bestpath_aspath_multipath_relax_cmd
,
2120 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2121 "BGP specific commands\n"
2122 "Change the default bestpath selection\n"
2123 "AS-path attribute\n"
2124 "Allow load sharing across routes that have different AS paths (but same length)\n"
2125 "Generate an AS_SET\n"
2126 "Do not generate an AS_SET\n")
2128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2130 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2132 /* no-as-set is now the default behavior so we can silently
2134 if (argv_find(argv
, argc
, "as-set", &idx
))
2135 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2137 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2139 bgp_recalculate_all_bestpaths(bgp
);
2144 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2145 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2146 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2148 "BGP specific commands\n"
2149 "Change the default bestpath selection\n"
2150 "AS-path attribute\n"
2151 "Allow load sharing across routes that have different AS paths (but same length)\n"
2152 "Generate an AS_SET\n"
2153 "Do not generate an AS_SET\n")
2155 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2156 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2157 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2158 bgp_recalculate_all_bestpaths(bgp
);
2163 /* "bgp log-neighbor-changes" configuration. */
2164 DEFUN (bgp_log_neighbor_changes
,
2165 bgp_log_neighbor_changes_cmd
,
2166 "bgp log-neighbor-changes",
2167 "BGP specific commands\n"
2168 "Log neighbor up/down and reset reason\n")
2170 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2171 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2175 DEFUN (no_bgp_log_neighbor_changes
,
2176 no_bgp_log_neighbor_changes_cmd
,
2177 "no bgp log-neighbor-changes",
2179 "BGP specific commands\n"
2180 "Log neighbor up/down and reset reason\n")
2182 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2183 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2187 /* "bgp bestpath med" configuration. */
2188 DEFUN (bgp_bestpath_med
,
2189 bgp_bestpath_med_cmd
,
2190 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2191 "BGP specific commands\n"
2192 "Change the default bestpath selection\n"
2194 "Compare MED among confederation paths\n"
2195 "Treat missing MED as the least preferred one\n"
2196 "Treat missing MED as the least preferred one\n"
2197 "Compare MED among confederation paths\n")
2199 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2202 if (argv_find(argv
, argc
, "confed", &idx
))
2203 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2205 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2206 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2208 bgp_recalculate_all_bestpaths(bgp
);
2213 DEFUN (no_bgp_bestpath_med
,
2214 no_bgp_bestpath_med_cmd
,
2215 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2217 "BGP specific commands\n"
2218 "Change the default bestpath selection\n"
2220 "Compare MED among confederation paths\n"
2221 "Treat missing MED as the least preferred one\n"
2222 "Treat missing MED as the least preferred one\n"
2223 "Compare MED among confederation paths\n")
2225 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2228 if (argv_find(argv
, argc
, "confed", &idx
))
2229 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2231 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2232 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2234 bgp_recalculate_all_bestpaths(bgp
);
2239 /* "no bgp default ipv4-unicast". */
2240 DEFUN (no_bgp_default_ipv4_unicast
,
2241 no_bgp_default_ipv4_unicast_cmd
,
2242 "no bgp default ipv4-unicast",
2244 "BGP specific commands\n"
2245 "Configure BGP defaults\n"
2246 "Activate ipv4-unicast for a peer by default\n")
2248 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2249 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2253 DEFUN (bgp_default_ipv4_unicast
,
2254 bgp_default_ipv4_unicast_cmd
,
2255 "bgp default ipv4-unicast",
2256 "BGP specific commands\n"
2257 "Configure BGP defaults\n"
2258 "Activate ipv4-unicast for a peer by default\n")
2260 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2261 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2265 /* Display hostname in certain command outputs */
2266 DEFUN (bgp_default_show_hostname
,
2267 bgp_default_show_hostname_cmd
,
2268 "bgp default show-hostname",
2269 "BGP specific commands\n"
2270 "Configure BGP defaults\n"
2271 "Show hostname in certain command ouputs\n")
2273 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2274 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2278 DEFUN (no_bgp_default_show_hostname
,
2279 no_bgp_default_show_hostname_cmd
,
2280 "no 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_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2291 /* "bgp network import-check" configuration. */
2292 DEFUN (bgp_network_import_check
,
2293 bgp_network_import_check_cmd
,
2294 "bgp network import-check",
2295 "BGP specific commands\n"
2296 "BGP network command\n"
2297 "Check BGP network route exists in IGP\n")
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2300 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2301 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2302 bgp_static_redo_import_check(bgp
);
2308 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2309 "bgp network import-check exact",
2310 "BGP specific commands\n"
2311 "BGP network command\n"
2312 "Check BGP network route exists in IGP\n"
2313 "Match route precisely\n")
2315 DEFUN (no_bgp_network_import_check
,
2316 no_bgp_network_import_check_cmd
,
2317 "no bgp network import-check",
2319 "BGP specific commands\n"
2320 "BGP network command\n"
2321 "Check BGP network route exists in IGP\n")
2323 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2324 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2325 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2326 bgp_static_redo_import_check(bgp
);
2332 DEFUN (bgp_default_local_preference
,
2333 bgp_default_local_preference_cmd
,
2334 "bgp default local-preference (0-4294967295)",
2335 "BGP specific commands\n"
2336 "Configure BGP defaults\n"
2337 "local preference (higher=more preferred)\n"
2338 "Configure default local preference value\n")
2340 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2342 uint32_t local_pref
;
2344 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2346 bgp_default_local_preference_set(bgp
, local_pref
);
2347 bgp_clear_star_soft_in(vty
, bgp
->name
);
2352 DEFUN (no_bgp_default_local_preference
,
2353 no_bgp_default_local_preference_cmd
,
2354 "no bgp default local-preference [(0-4294967295)]",
2356 "BGP specific commands\n"
2357 "Configure BGP defaults\n"
2358 "local preference (higher=more preferred)\n"
2359 "Configure default local preference value\n")
2361 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2362 bgp_default_local_preference_unset(bgp
);
2363 bgp_clear_star_soft_in(vty
, bgp
->name
);
2369 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2370 bgp_default_subgroup_pkt_queue_max_cmd
,
2371 "bgp default subgroup-pkt-queue-max (20-100)",
2372 "BGP specific commands\n"
2373 "Configure BGP defaults\n"
2374 "subgroup-pkt-queue-max\n"
2375 "Configure subgroup packet queue max\n")
2377 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2381 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2383 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2388 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2389 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2390 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2392 "BGP specific commands\n"
2393 "Configure BGP defaults\n"
2394 "subgroup-pkt-queue-max\n"
2395 "Configure subgroup packet queue max\n")
2397 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2398 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2403 DEFUN (bgp_rr_allow_outbound_policy
,
2404 bgp_rr_allow_outbound_policy_cmd
,
2405 "bgp route-reflector allow-outbound-policy",
2406 "BGP specific commands\n"
2407 "Allow modifications made by out route-map\n"
2408 "on ibgp neighbors\n")
2410 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2412 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2413 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2414 update_group_announce_rrclients(bgp
);
2415 bgp_clear_star_soft_out(vty
, bgp
->name
);
2421 DEFUN (no_bgp_rr_allow_outbound_policy
,
2422 no_bgp_rr_allow_outbound_policy_cmd
,
2423 "no bgp route-reflector allow-outbound-policy",
2425 "BGP specific commands\n"
2426 "Allow modifications made by out route-map\n"
2427 "on ibgp neighbors\n")
2429 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2431 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2432 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2433 update_group_announce_rrclients(bgp
);
2434 bgp_clear_star_soft_out(vty
, bgp
->name
);
2440 DEFUN (bgp_listen_limit
,
2441 bgp_listen_limit_cmd
,
2442 "bgp listen limit (1-5000)",
2443 "BGP specific commands\n"
2444 "Configure BGP defaults\n"
2445 "maximum number of BGP Dynamic Neighbors that can be created\n"
2446 "Configure Dynamic Neighbors listen limit value\n")
2448 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2452 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2454 bgp_listen_limit_set(bgp
, listen_limit
);
2459 DEFUN (no_bgp_listen_limit
,
2460 no_bgp_listen_limit_cmd
,
2461 "no bgp listen limit [(1-5000)]",
2462 "BGP specific commands\n"
2463 "Configure BGP defaults\n"
2464 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2465 "Configure Dynamic Neighbors listen limit value to default\n"
2466 "Configure Dynamic Neighbors listen limit value\n")
2468 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2469 bgp_listen_limit_unset(bgp
);
2475 * Check if this listen range is already configured. Check for exact
2476 * match or overlap based on input.
2478 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2479 struct prefix
*range
, int exact
)
2481 struct listnode
*node
, *nnode
;
2482 struct listnode
*node1
, *nnode1
;
2483 struct peer_group
*group
;
2488 afi
= family2afi(range
->family
);
2489 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2490 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2493 match
= prefix_same(range
, lr
);
2495 match
= (prefix_match(range
, lr
)
2496 || prefix_match(lr
, range
));
2505 DEFUN (bgp_listen_range
,
2506 bgp_listen_range_cmd
,
2507 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2508 "BGP specific commands\n"
2509 "Configure BGP dynamic neighbors listen range\n"
2510 "Configure BGP dynamic neighbors listen range\n"
2512 "Member of the peer-group\n"
2513 "Peer-group name\n")
2515 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2516 struct prefix range
;
2517 struct peer_group
*group
, *existing_group
;
2522 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2523 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2524 char *prefix
= argv
[idx
]->arg
;
2525 argv_find(argv
, argc
, "WORD", &idx
);
2526 char *peergroup
= argv
[idx
]->arg
;
2528 /* Convert IP prefix string to struct prefix. */
2529 ret
= str2prefix(prefix
, &range
);
2531 vty_out(vty
, "%% Malformed listen range\n");
2532 return CMD_WARNING_CONFIG_FAILED
;
2535 afi
= family2afi(range
.family
);
2537 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2539 "%% Malformed listen range (link-local address)\n");
2540 return CMD_WARNING_CONFIG_FAILED
;
2545 /* Check if same listen range is already configured. */
2546 existing_group
= listen_range_exists(bgp
, &range
, 1);
2547 if (existing_group
) {
2548 if (strcmp(existing_group
->name
, peergroup
) == 0)
2552 "%% Same listen range is attached to peer-group %s\n",
2553 existing_group
->name
);
2554 return CMD_WARNING_CONFIG_FAILED
;
2558 /* Check if an overlapping listen range exists. */
2559 if (listen_range_exists(bgp
, &range
, 0)) {
2561 "%% Listen range overlaps with existing listen range\n");
2562 return CMD_WARNING_CONFIG_FAILED
;
2565 group
= peer_group_lookup(bgp
, peergroup
);
2567 vty_out(vty
, "%% Configure the peer-group first\n");
2568 return CMD_WARNING_CONFIG_FAILED
;
2571 ret
= peer_group_listen_range_add(group
, &range
);
2572 return bgp_vty_return(vty
, ret
);
2575 DEFUN (no_bgp_listen_range
,
2576 no_bgp_listen_range_cmd
,
2577 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2579 "BGP specific commands\n"
2580 "Unconfigure BGP dynamic neighbors listen range\n"
2581 "Unconfigure BGP dynamic neighbors listen range\n"
2583 "Member of the peer-group\n"
2584 "Peer-group name\n")
2586 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2587 struct prefix range
;
2588 struct peer_group
*group
;
2593 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2594 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2595 char *prefix
= argv
[idx
]->arg
;
2596 argv_find(argv
, argc
, "WORD", &idx
);
2597 char *peergroup
= argv
[idx
]->arg
;
2599 /* Convert IP prefix string to struct prefix. */
2600 ret
= str2prefix(prefix
, &range
);
2602 vty_out(vty
, "%% Malformed listen range\n");
2603 return CMD_WARNING_CONFIG_FAILED
;
2606 afi
= family2afi(range
.family
);
2608 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2610 "%% Malformed listen range (link-local address)\n");
2611 return CMD_WARNING_CONFIG_FAILED
;
2616 group
= peer_group_lookup(bgp
, peergroup
);
2618 vty_out(vty
, "%% Peer-group does not exist\n");
2619 return CMD_WARNING_CONFIG_FAILED
;
2622 ret
= peer_group_listen_range_del(group
, &range
);
2623 return bgp_vty_return(vty
, ret
);
2626 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2628 struct peer_group
*group
;
2629 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2630 struct prefix
*range
;
2632 char buf
[PREFIX2STR_BUFFER
];
2634 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2635 vty_out(vty
, " bgp listen limit %d\n",
2636 bgp
->dynamic_neighbors_limit
);
2638 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2639 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2640 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2642 prefix2str(range
, buf
, sizeof(buf
));
2644 " bgp listen range %s peer-group %s\n",
2652 DEFUN (bgp_disable_connected_route_check
,
2653 bgp_disable_connected_route_check_cmd
,
2654 "bgp disable-ebgp-connected-route-check",
2655 "BGP specific commands\n"
2656 "Disable checking if nexthop is connected on ebgp sessions\n")
2658 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2659 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2660 bgp_clear_star_soft_in(vty
, bgp
->name
);
2665 DEFUN (no_bgp_disable_connected_route_check
,
2666 no_bgp_disable_connected_route_check_cmd
,
2667 "no bgp disable-ebgp-connected-route-check",
2669 "BGP specific commands\n"
2670 "Disable checking if nexthop is connected on ebgp sessions\n")
2672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2673 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2674 bgp_clear_star_soft_in(vty
, bgp
->name
);
2680 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2681 const char *as_str
, afi_t afi
, safi_t safi
)
2683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2686 int as_type
= AS_SPECIFIED
;
2689 if (as_str
[0] == 'i') {
2691 as_type
= AS_INTERNAL
;
2692 } else if (as_str
[0] == 'e') {
2694 as_type
= AS_EXTERNAL
;
2696 /* Get AS number. */
2697 as
= strtoul(as_str
, NULL
, 10);
2700 /* If peer is peer group, call proper function. */
2701 ret
= str2sockunion(peer_str
, &su
);
2703 /* Check for peer by interface */
2704 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2707 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2710 "%% Create the peer-group or interface first\n");
2711 return CMD_WARNING_CONFIG_FAILED
;
2716 if (peer_address_self_check(bgp
, &su
)) {
2718 "%% Can not configure the local system as neighbor\n");
2719 return CMD_WARNING_CONFIG_FAILED
;
2721 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2724 /* This peer belongs to peer group. */
2726 case BGP_ERR_PEER_GROUP_MEMBER
:
2728 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2730 return CMD_WARNING_CONFIG_FAILED
;
2731 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2733 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2735 return CMD_WARNING_CONFIG_FAILED
;
2737 return bgp_vty_return(vty
, ret
);
2740 DEFUN (bgp_default_shutdown
,
2741 bgp_default_shutdown_cmd
,
2742 "[no] bgp default shutdown",
2745 "Configure BGP defaults\n"
2746 "Apply administrative shutdown to newly configured peers\n")
2748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2749 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2753 DEFUN (neighbor_remote_as
,
2754 neighbor_remote_as_cmd
,
2755 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2758 "Specify a BGP neighbor\n"
2760 "Internal BGP peer\n"
2761 "External BGP peer\n")
2764 int idx_remote_as
= 3;
2765 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2766 argv
[idx_remote_as
]->arg
, AFI_IP
,
2770 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2771 afi_t afi
, safi_t safi
, int v6only
,
2772 const char *peer_group_name
,
2775 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2777 int as_type
= AS_UNSPECIFIED
;
2779 struct peer_group
*group
;
2783 group
= peer_group_lookup(bgp
, conf_if
);
2786 vty_out(vty
, "%% Name conflict with peer-group \n");
2787 return CMD_WARNING_CONFIG_FAILED
;
2791 if (as_str
[0] == 'i') {
2792 as_type
= AS_INTERNAL
;
2793 } else if (as_str
[0] == 'e') {
2794 as_type
= AS_EXTERNAL
;
2796 /* Get AS number. */
2797 as
= strtoul(as_str
, NULL
, 10);
2798 as_type
= AS_SPECIFIED
;
2802 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2805 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2808 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2809 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2810 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2811 as_type
, 0, 0, NULL
);
2813 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2814 as_type
, afi
, safi
, NULL
);
2817 vty_out(vty
, "%% BGP failed to create peer\n");
2818 return CMD_WARNING_CONFIG_FAILED
;
2822 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2824 /* Request zebra to initiate IPv6 RAs on this interface. We do
2826 * any unnumbered peer in order to not worry about run-time
2828 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2830 * gets deleted later etc.)
2833 bgp_zebra_initiate_radv(bgp
, peer
);
2836 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2837 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2839 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2841 UNSET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2843 /* v6only flag changed. Reset bgp seesion */
2844 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2845 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2846 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2847 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2849 bgp_session_reset(peer
);
2852 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
2853 peer_flag_set(peer
, PEER_FLAG_CAPABILITY_ENHE
);
2855 if (peer_group_name
) {
2856 group
= peer_group_lookup(bgp
, peer_group_name
);
2858 vty_out(vty
, "%% Configure the peer-group first\n");
2859 return CMD_WARNING_CONFIG_FAILED
;
2862 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2865 return bgp_vty_return(vty
, ret
);
2868 DEFUN (neighbor_interface_config
,
2869 neighbor_interface_config_cmd
,
2870 "neighbor WORD interface [peer-group WORD]",
2872 "Interface name or neighbor tag\n"
2873 "Enable BGP on interface\n"
2874 "Member of the peer-group\n"
2875 "Peer-group name\n")
2878 int idx_peer_group_word
= 4;
2880 if (argc
> idx_peer_group_word
)
2881 return peer_conf_interface_get(
2882 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2883 argv
[idx_peer_group_word
]->arg
, NULL
);
2885 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2886 SAFI_UNICAST
, 0, NULL
, NULL
);
2889 DEFUN (neighbor_interface_config_v6only
,
2890 neighbor_interface_config_v6only_cmd
,
2891 "neighbor WORD interface v6only [peer-group WORD]",
2893 "Interface name or neighbor tag\n"
2894 "Enable BGP on interface\n"
2895 "Enable BGP with v6 link-local only\n"
2896 "Member of the peer-group\n"
2897 "Peer-group name\n")
2900 int idx_peer_group_word
= 5;
2902 if (argc
> idx_peer_group_word
)
2903 return peer_conf_interface_get(
2904 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2905 argv
[idx_peer_group_word
]->arg
, NULL
);
2907 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2908 SAFI_UNICAST
, 1, NULL
, NULL
);
2912 DEFUN (neighbor_interface_config_remote_as
,
2913 neighbor_interface_config_remote_as_cmd
,
2914 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2916 "Interface name or neighbor tag\n"
2917 "Enable BGP on interface\n"
2918 "Specify a BGP neighbor\n"
2920 "Internal BGP peer\n"
2921 "External BGP peer\n")
2924 int idx_remote_as
= 4;
2925 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2926 SAFI_UNICAST
, 0, NULL
,
2927 argv
[idx_remote_as
]->arg
);
2930 DEFUN (neighbor_interface_v6only_config_remote_as
,
2931 neighbor_interface_v6only_config_remote_as_cmd
,
2932 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2934 "Interface name or neighbor tag\n"
2935 "Enable BGP with v6 link-local only\n"
2936 "Enable BGP on interface\n"
2937 "Specify a BGP neighbor\n"
2939 "Internal BGP peer\n"
2940 "External BGP peer\n")
2943 int idx_remote_as
= 5;
2944 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2945 SAFI_UNICAST
, 1, NULL
,
2946 argv
[idx_remote_as
]->arg
);
2949 DEFUN (neighbor_peer_group
,
2950 neighbor_peer_group_cmd
,
2951 "neighbor WORD peer-group",
2953 "Interface name or neighbor tag\n"
2954 "Configure peer-group\n")
2956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2959 struct peer_group
*group
;
2961 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2963 vty_out(vty
, "%% Name conflict with interface: \n");
2964 return CMD_WARNING_CONFIG_FAILED
;
2967 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2969 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2970 return CMD_WARNING_CONFIG_FAILED
;
2978 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
2982 "Specify a BGP neighbor\n"
2984 "Internal BGP peer\n"
2985 "External BGP peer\n")
2987 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2991 struct peer_group
*group
;
2995 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
2997 /* look up for neighbor by interface name config. */
2998 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3000 /* Request zebra to terminate IPv6 RAs on this
3003 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3008 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3010 peer_group_delete(group
);
3012 vty_out(vty
, "%% Create the peer-group first\n");
3013 return CMD_WARNING_CONFIG_FAILED
;
3016 peer
= peer_lookup(bgp
, &su
);
3018 if (peer_dynamic_neighbor(peer
)) {
3020 "%% Operation not allowed on a dynamic neighbor\n");
3021 return CMD_WARNING_CONFIG_FAILED
;
3024 other
= peer
->doppelganger
;
3026 if (other
&& other
->status
!= Deleted
)
3034 DEFUN (no_neighbor_interface_config
,
3035 no_neighbor_interface_config_cmd
,
3036 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3040 "Configure BGP on interface\n"
3041 "Enable BGP with v6 link-local only\n"
3042 "Member of the peer-group\n"
3044 "Specify a BGP neighbor\n"
3046 "Internal BGP peer\n"
3047 "External BGP peer\n")
3049 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3053 /* look up for neighbor by interface name config. */
3054 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3056 /* Request zebra to terminate IPv6 RAs on this interface. */
3058 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3061 vty_out(vty
, "%% Create the bgp interface first\n");
3062 return CMD_WARNING_CONFIG_FAILED
;
3067 DEFUN (no_neighbor_peer_group
,
3068 no_neighbor_peer_group_cmd
,
3069 "no neighbor WORD peer-group",
3073 "Configure peer-group\n")
3075 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3077 struct peer_group
*group
;
3079 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3081 peer_group_delete(group
);
3083 vty_out(vty
, "%% Create the peer-group first\n");
3084 return CMD_WARNING_CONFIG_FAILED
;
3089 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3090 no_neighbor_interface_peer_group_remote_as_cmd
,
3091 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3094 "Interface name or neighbor tag\n"
3095 "Specify a BGP neighbor\n"
3097 "Internal BGP peer\n"
3098 "External BGP peer\n")
3100 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3102 struct peer_group
*group
;
3105 /* look up for neighbor by interface name config. */
3106 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3108 peer_as_change(peer
, 0, AS_SPECIFIED
);
3112 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3114 peer_group_remote_as_delete(group
);
3116 vty_out(vty
, "%% Create the peer-group or interface first\n");
3117 return CMD_WARNING_CONFIG_FAILED
;
3122 DEFUN (neighbor_local_as
,
3123 neighbor_local_as_cmd
,
3124 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3127 "Specify a local-as number\n"
3128 "AS number used as local AS\n")
3136 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3138 return CMD_WARNING_CONFIG_FAILED
;
3140 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3141 ret
= peer_local_as_set(peer
, as
, 0, 0);
3142 return bgp_vty_return(vty
, ret
);
3145 DEFUN (neighbor_local_as_no_prepend
,
3146 neighbor_local_as_no_prepend_cmd
,
3147 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3150 "Specify a local-as number\n"
3151 "AS number used as local AS\n"
3152 "Do not prepend local-as to updates from ebgp peers\n")
3160 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3162 return CMD_WARNING_CONFIG_FAILED
;
3164 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3165 ret
= peer_local_as_set(peer
, as
, 1, 0);
3166 return bgp_vty_return(vty
, ret
);
3169 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3170 neighbor_local_as_no_prepend_replace_as_cmd
,
3171 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3174 "Specify a local-as number\n"
3175 "AS number used as local AS\n"
3176 "Do not prepend local-as to updates from ebgp peers\n"
3177 "Do not prepend local-as to updates from ibgp peers\n")
3185 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3187 return CMD_WARNING_CONFIG_FAILED
;
3189 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3190 ret
= peer_local_as_set(peer
, as
, 1, 1);
3191 return bgp_vty_return(vty
, ret
);
3194 DEFUN (no_neighbor_local_as
,
3195 no_neighbor_local_as_cmd
,
3196 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3200 "Specify a local-as number\n"
3201 "AS number used as local AS\n"
3202 "Do not prepend local-as to updates from ebgp peers\n"
3203 "Do not prepend local-as to updates from ibgp peers\n")
3209 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3211 return CMD_WARNING_CONFIG_FAILED
;
3213 ret
= peer_local_as_unset(peer
);
3214 return bgp_vty_return(vty
, ret
);
3218 DEFUN (neighbor_solo
,
3220 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3223 "Solo peer - part of its own update group\n")
3229 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3231 return CMD_WARNING_CONFIG_FAILED
;
3233 ret
= update_group_adjust_soloness(peer
, 1);
3234 return bgp_vty_return(vty
, ret
);
3237 DEFUN (no_neighbor_solo
,
3238 no_neighbor_solo_cmd
,
3239 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3243 "Solo peer - part of its own update group\n")
3249 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3251 return CMD_WARNING_CONFIG_FAILED
;
3253 ret
= update_group_adjust_soloness(peer
, 0);
3254 return bgp_vty_return(vty
, ret
);
3257 DEFUN (neighbor_password
,
3258 neighbor_password_cmd
,
3259 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3270 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3272 return CMD_WARNING_CONFIG_FAILED
;
3274 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3275 return bgp_vty_return(vty
, ret
);
3278 DEFUN (no_neighbor_password
,
3279 no_neighbor_password_cmd
,
3280 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3291 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3293 return CMD_WARNING_CONFIG_FAILED
;
3295 ret
= peer_password_unset(peer
);
3296 return bgp_vty_return(vty
, ret
);
3299 DEFUN (neighbor_activate
,
3300 neighbor_activate_cmd
,
3301 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3304 "Enable the Address Family for this Neighbor\n")
3310 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3312 return CMD_WARNING_CONFIG_FAILED
;
3314 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3315 return bgp_vty_return(vty
, ret
);
3318 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3319 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3320 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3321 "Enable the Address Family for this Neighbor\n")
3323 DEFUN (no_neighbor_activate
,
3324 no_neighbor_activate_cmd
,
3325 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3329 "Enable the Address Family for this Neighbor\n")
3336 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3338 return CMD_WARNING_CONFIG_FAILED
;
3340 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3341 return bgp_vty_return(vty
, ret
);
3344 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3345 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3346 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3347 "Enable the Address Family for this Neighbor\n")
3349 DEFUN (neighbor_set_peer_group
,
3350 neighbor_set_peer_group_cmd
,
3351 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3354 "Member of the peer-group\n"
3355 "Peer-group name\n")
3357 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3364 struct peer_group
*group
;
3368 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3370 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3372 vty_out(vty
, "%% Malformed address or name: %s\n",
3373 argv
[idx_peer
]->arg
);
3374 return CMD_WARNING_CONFIG_FAILED
;
3377 if (peer_address_self_check(bgp
, &su
)) {
3379 "%% Can not configure the local system as neighbor\n");
3380 return CMD_WARNING_CONFIG_FAILED
;
3383 /* Disallow for dynamic neighbor. */
3384 peer
= peer_lookup(bgp
, &su
);
3385 if (peer
&& peer_dynamic_neighbor(peer
)) {
3387 "%% Operation not allowed on a dynamic neighbor\n");
3388 return CMD_WARNING_CONFIG_FAILED
;
3392 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3394 vty_out(vty
, "%% Configure the peer-group first\n");
3395 return CMD_WARNING_CONFIG_FAILED
;
3398 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3400 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3402 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3404 return CMD_WARNING_CONFIG_FAILED
;
3407 return bgp_vty_return(vty
, ret
);
3410 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3411 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3412 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3413 "Member of the peer-group\n"
3414 "Peer-group name\n")
3416 DEFUN (no_neighbor_set_peer_group
,
3417 no_neighbor_set_peer_group_cmd
,
3418 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3422 "Member of the peer-group\n"
3423 "Peer-group name\n")
3425 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3430 struct peer_group
*group
;
3432 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3434 return CMD_WARNING_CONFIG_FAILED
;
3436 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3438 vty_out(vty
, "%% Configure the peer-group first\n");
3439 return CMD_WARNING_CONFIG_FAILED
;
3442 ret
= peer_delete(peer
);
3444 return bgp_vty_return(vty
, ret
);
3447 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3448 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3449 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3450 "Member of the peer-group\n"
3451 "Peer-group name\n")
3453 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3454 uint32_t flag
, int set
)
3459 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3461 return CMD_WARNING_CONFIG_FAILED
;
3464 * If 'neighbor <interface>', then this is for directly connected peers,
3465 * we should not accept disable-connected-check.
3467 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3469 "%s is directly connected peer, cannot accept disable-"
3470 "connected-check\n",
3472 return CMD_WARNING_CONFIG_FAILED
;
3475 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3476 peer_tx_shutdown_message_unset(peer
);
3479 ret
= peer_flag_set(peer
, flag
);
3481 ret
= peer_flag_unset(peer
, flag
);
3483 return bgp_vty_return(vty
, ret
);
3486 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3488 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3491 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3494 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3497 /* neighbor passive. */
3498 DEFUN (neighbor_passive
,
3499 neighbor_passive_cmd
,
3500 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3503 "Don't send open messages to this neighbor\n")
3506 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3509 DEFUN (no_neighbor_passive
,
3510 no_neighbor_passive_cmd
,
3511 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3515 "Don't send open messages to this neighbor\n")
3518 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3521 /* neighbor shutdown. */
3522 DEFUN (neighbor_shutdown_msg
,
3523 neighbor_shutdown_msg_cmd
,
3524 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3527 "Administratively shut down this neighbor\n"
3528 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3529 "Shutdown message\n")
3535 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3539 return CMD_WARNING_CONFIG_FAILED
;
3540 message
= argv_concat(argv
, argc
, 4);
3541 peer_tx_shutdown_message_set(peer
, message
);
3542 XFREE(MTYPE_TMP
, message
);
3545 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3548 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3549 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3550 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3551 "Administratively shut down this neighbor\n")
3553 DEFUN (no_neighbor_shutdown_msg
,
3554 no_neighbor_shutdown_msg_cmd
,
3555 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3559 "Administratively shut down this neighbor\n"
3560 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3561 "Shutdown message\n")
3565 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3566 PEER_FLAG_SHUTDOWN
);
3569 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3570 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3571 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3572 "Administratively shut down this neighbor\n")
3574 /* neighbor capability dynamic. */
3575 DEFUN (neighbor_capability_dynamic
,
3576 neighbor_capability_dynamic_cmd
,
3577 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3580 "Advertise capability to the peer\n"
3581 "Advertise dynamic capability to this neighbor\n")
3584 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3585 PEER_FLAG_DYNAMIC_CAPABILITY
);
3588 DEFUN (no_neighbor_capability_dynamic
,
3589 no_neighbor_capability_dynamic_cmd
,
3590 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3594 "Advertise capability to the peer\n"
3595 "Advertise dynamic capability to this neighbor\n")
3598 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3599 PEER_FLAG_DYNAMIC_CAPABILITY
);
3602 /* neighbor dont-capability-negotiate */
3603 DEFUN (neighbor_dont_capability_negotiate
,
3604 neighbor_dont_capability_negotiate_cmd
,
3605 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3608 "Do not perform capability negotiation\n")
3611 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3612 PEER_FLAG_DONT_CAPABILITY
);
3615 DEFUN (no_neighbor_dont_capability_negotiate
,
3616 no_neighbor_dont_capability_negotiate_cmd
,
3617 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3621 "Do not perform capability negotiation\n")
3624 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3625 PEER_FLAG_DONT_CAPABILITY
);
3628 /* neighbor capability extended next hop encoding */
3629 DEFUN (neighbor_capability_enhe
,
3630 neighbor_capability_enhe_cmd
,
3631 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3634 "Advertise capability to the peer\n"
3635 "Advertise extended next-hop capability to the peer\n")
3638 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3639 PEER_FLAG_CAPABILITY_ENHE
);
3642 DEFUN (no_neighbor_capability_enhe
,
3643 no_neighbor_capability_enhe_cmd
,
3644 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3648 "Advertise capability to the peer\n"
3649 "Advertise extended next-hop capability to the peer\n")
3652 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3653 PEER_FLAG_CAPABILITY_ENHE
);
3656 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3657 afi_t afi
, safi_t safi
, uint32_t flag
,
3663 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3665 return CMD_WARNING_CONFIG_FAILED
;
3668 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3670 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3672 return bgp_vty_return(vty
, ret
);
3675 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3676 afi_t afi
, safi_t safi
, uint32_t flag
)
3678 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3681 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3682 afi_t afi
, safi_t safi
, uint32_t flag
)
3684 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3687 /* neighbor capability orf prefix-list. */
3688 DEFUN (neighbor_capability_orf_prefix
,
3689 neighbor_capability_orf_prefix_cmd
,
3690 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3693 "Advertise capability to the peer\n"
3694 "Advertise ORF capability to the peer\n"
3695 "Advertise prefixlist ORF capability to this neighbor\n"
3696 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3697 "Capability to RECEIVE the ORF from this neighbor\n"
3698 "Capability to SEND the ORF to this neighbor\n")
3701 int idx_send_recv
= 5;
3704 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3705 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3706 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3707 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3708 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3709 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3711 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3712 return CMD_WARNING_CONFIG_FAILED
;
3715 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3716 bgp_node_safi(vty
), flag
);
3720 neighbor_capability_orf_prefix
,
3721 neighbor_capability_orf_prefix_hidden_cmd
,
3722 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3723 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3724 "Advertise capability to the peer\n"
3725 "Advertise ORF capability to the peer\n"
3726 "Advertise prefixlist ORF capability to this neighbor\n"
3727 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3728 "Capability to RECEIVE the ORF from this neighbor\n"
3729 "Capability to SEND the ORF to this neighbor\n")
3731 DEFUN (no_neighbor_capability_orf_prefix
,
3732 no_neighbor_capability_orf_prefix_cmd
,
3733 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
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")
3745 int idx_send_recv
= 6;
3748 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3749 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3750 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3751 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3752 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3753 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3755 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3756 return CMD_WARNING_CONFIG_FAILED
;
3759 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3760 bgp_node_afi(vty
), bgp_node_safi(vty
),
3765 no_neighbor_capability_orf_prefix
,
3766 no_neighbor_capability_orf_prefix_hidden_cmd
,
3767 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3768 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3769 "Advertise capability to the peer\n"
3770 "Advertise ORF capability to the peer\n"
3771 "Advertise prefixlist ORF capability to this neighbor\n"
3772 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3773 "Capability to RECEIVE the ORF from this neighbor\n"
3774 "Capability to SEND the ORF to this neighbor\n")
3776 /* neighbor next-hop-self. */
3777 DEFUN (neighbor_nexthop_self
,
3778 neighbor_nexthop_self_cmd
,
3779 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3782 "Disable the next hop calculation for this neighbor\n")
3785 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3786 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3789 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3790 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3791 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3792 "Disable the next hop calculation for this neighbor\n")
3794 /* neighbor next-hop-self. */
3795 DEFUN (neighbor_nexthop_self_force
,
3796 neighbor_nexthop_self_force_cmd
,
3797 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3800 "Disable the next hop calculation for this neighbor\n"
3801 "Set the next hop to self for reflected routes\n")
3804 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3806 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3809 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3810 neighbor_nexthop_self_force_hidden_cmd
,
3811 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3812 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3813 "Disable the next hop calculation for this neighbor\n"
3814 "Set the next hop to self for reflected routes\n")
3816 DEFUN (no_neighbor_nexthop_self
,
3817 no_neighbor_nexthop_self_cmd
,
3818 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3822 "Disable the next hop calculation for this neighbor\n")
3825 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3826 bgp_node_afi(vty
), bgp_node_safi(vty
),
3827 PEER_FLAG_NEXTHOP_SELF
);
3830 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3831 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3832 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3833 "Disable the next hop calculation for this neighbor\n")
3835 DEFUN (no_neighbor_nexthop_self_force
,
3836 no_neighbor_nexthop_self_force_cmd
,
3837 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3841 "Disable the next hop calculation for this neighbor\n"
3842 "Set the next hop to self for reflected routes\n")
3845 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3846 bgp_node_afi(vty
), bgp_node_safi(vty
),
3847 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3850 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3851 no_neighbor_nexthop_self_force_hidden_cmd
,
3852 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3853 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3854 "Disable the next hop calculation for this neighbor\n"
3855 "Set the next hop to self for reflected routes\n")
3857 /* neighbor as-override */
3858 DEFUN (neighbor_as_override
,
3859 neighbor_as_override_cmd
,
3860 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3863 "Override ASNs in outbound updates if aspath equals remote-as\n")
3866 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3867 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3870 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3871 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3872 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3873 "Override ASNs in outbound updates if aspath equals remote-as\n")
3875 DEFUN (no_neighbor_as_override
,
3876 no_neighbor_as_override_cmd
,
3877 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3881 "Override ASNs in outbound updates if aspath equals remote-as\n")
3884 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3885 bgp_node_afi(vty
), bgp_node_safi(vty
),
3886 PEER_FLAG_AS_OVERRIDE
);
3889 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3890 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3891 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3892 "Override ASNs in outbound updates if aspath equals remote-as\n")
3894 /* neighbor remove-private-AS. */
3895 DEFUN (neighbor_remove_private_as
,
3896 neighbor_remove_private_as_cmd
,
3897 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3900 "Remove private ASNs in outbound updates\n")
3903 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3905 PEER_FLAG_REMOVE_PRIVATE_AS
);
3908 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3909 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3910 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3911 "Remove private ASNs in outbound updates\n")
3913 DEFUN (neighbor_remove_private_as_all
,
3914 neighbor_remove_private_as_all_cmd
,
3915 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3918 "Remove private ASNs in outbound updates\n"
3919 "Apply to all AS numbers\n")
3922 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3924 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3927 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3928 neighbor_remove_private_as_all_hidden_cmd
,
3929 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3930 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3931 "Remove private ASNs in outbound updates\n"
3932 "Apply to all AS numbers")
3934 DEFUN (neighbor_remove_private_as_replace_as
,
3935 neighbor_remove_private_as_replace_as_cmd
,
3936 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3939 "Remove private ASNs in outbound updates\n"
3940 "Replace private ASNs with our ASN in outbound updates\n")
3943 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3945 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3948 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3949 neighbor_remove_private_as_replace_as_hidden_cmd
,
3950 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3951 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3952 "Remove private ASNs in outbound updates\n"
3953 "Replace private ASNs with our ASN in outbound updates\n")
3955 DEFUN (neighbor_remove_private_as_all_replace_as
,
3956 neighbor_remove_private_as_all_replace_as_cmd
,
3957 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3960 "Remove private ASNs in outbound updates\n"
3961 "Apply to all AS numbers\n"
3962 "Replace private ASNs with our ASN in outbound updates\n")
3965 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3967 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3971 neighbor_remove_private_as_all_replace_as
,
3972 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3973 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3974 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3975 "Remove private ASNs in outbound updates\n"
3976 "Apply to all AS numbers\n"
3977 "Replace private ASNs with our ASN in outbound updates\n")
3979 DEFUN (no_neighbor_remove_private_as
,
3980 no_neighbor_remove_private_as_cmd
,
3981 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3985 "Remove private ASNs in outbound updates\n")
3988 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3989 bgp_node_afi(vty
), bgp_node_safi(vty
),
3990 PEER_FLAG_REMOVE_PRIVATE_AS
);
3993 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
3994 no_neighbor_remove_private_as_hidden_cmd
,
3995 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3996 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3997 "Remove private ASNs in outbound updates\n")
3999 DEFUN (no_neighbor_remove_private_as_all
,
4000 no_neighbor_remove_private_as_all_cmd
,
4001 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4005 "Remove private ASNs in outbound updates\n"
4006 "Apply to all AS numbers\n")
4009 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4010 bgp_node_afi(vty
), bgp_node_safi(vty
),
4011 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4014 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4015 no_neighbor_remove_private_as_all_hidden_cmd
,
4016 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4017 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4018 "Remove private ASNs in outbound updates\n"
4019 "Apply to all AS numbers\n")
4021 DEFUN (no_neighbor_remove_private_as_replace_as
,
4022 no_neighbor_remove_private_as_replace_as_cmd
,
4023 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4027 "Remove private ASNs in outbound updates\n"
4028 "Replace private ASNs with our ASN in outbound updates\n")
4031 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4032 bgp_node_afi(vty
), bgp_node_safi(vty
),
4033 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4036 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4037 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4038 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4039 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4040 "Remove private ASNs in outbound updates\n"
4041 "Replace private ASNs with our ASN in outbound updates\n")
4043 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4044 no_neighbor_remove_private_as_all_replace_as_cmd
,
4045 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4049 "Remove private ASNs in outbound updates\n"
4050 "Apply to all AS numbers\n"
4051 "Replace private ASNs with our ASN in outbound updates\n")
4054 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4055 bgp_node_afi(vty
), bgp_node_safi(vty
),
4056 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4060 no_neighbor_remove_private_as_all_replace_as
,
4061 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4062 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4063 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4064 "Remove private ASNs in outbound updates\n"
4065 "Apply to all AS numbers\n"
4066 "Replace private ASNs with our ASN in outbound updates\n")
4069 /* neighbor send-community. */
4070 DEFUN (neighbor_send_community
,
4071 neighbor_send_community_cmd
,
4072 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4075 "Send Community attribute to this neighbor\n")
4078 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4080 PEER_FLAG_SEND_COMMUNITY
);
4083 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4084 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4085 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4086 "Send Community attribute to this neighbor\n")
4088 DEFUN (no_neighbor_send_community
,
4089 no_neighbor_send_community_cmd
,
4090 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4094 "Send Community attribute to this neighbor\n")
4097 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4098 bgp_node_afi(vty
), bgp_node_safi(vty
),
4099 PEER_FLAG_SEND_COMMUNITY
);
4102 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4103 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4104 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4105 "Send Community attribute to this neighbor\n")
4107 /* neighbor send-community extended. */
4108 DEFUN (neighbor_send_community_type
,
4109 neighbor_send_community_type_cmd
,
4110 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4113 "Send Community attribute to this neighbor\n"
4114 "Send Standard and Extended Community attributes\n"
4115 "Send Standard, Large and Extended Community attributes\n"
4116 "Send Extended Community attributes\n"
4117 "Send Standard Community attributes\n"
4118 "Send Large Community attributes\n")
4123 char *peer
= argv
[1]->arg
;
4125 if (argv_find(argv
, argc
, "standard", &idx
))
4126 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4127 else if (argv_find(argv
, argc
, "extended", &idx
))
4128 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4129 else if (argv_find(argv
, argc
, "large", &idx
))
4130 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4131 else if (argv_find(argv
, argc
, "both", &idx
)) {
4132 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4133 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4135 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4136 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4137 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4140 return peer_af_flag_set_vty(vty
, peer
, bgp_node_afi(vty
),
4141 bgp_node_safi(vty
), flag
);
4145 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4146 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4147 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4148 "Send Community attribute to this neighbor\n"
4149 "Send Standard and Extended Community attributes\n"
4150 "Send Standard, Large and Extended Community attributes\n"
4151 "Send Extended Community attributes\n"
4152 "Send Standard Community attributes\n"
4153 "Send Large Community attributes\n")
4155 DEFUN (no_neighbor_send_community_type
,
4156 no_neighbor_send_community_type_cmd
,
4157 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4161 "Send Community attribute to this neighbor\n"
4162 "Send Standard and Extended Community attributes\n"
4163 "Send Standard, Large and Extended Community attributes\n"
4164 "Send Extended Community attributes\n"
4165 "Send Standard Community attributes\n"
4166 "Send Large Community attributes\n")
4170 const char *type
= argv
[argc
- 1]->text
;
4172 if (strmatch(type
, "standard"))
4173 return peer_af_flag_unset_vty(
4174 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4175 bgp_node_safi(vty
), PEER_FLAG_SEND_COMMUNITY
);
4176 if (strmatch(type
, "extended"))
4177 return peer_af_flag_unset_vty(
4178 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4179 bgp_node_safi(vty
), PEER_FLAG_SEND_EXT_COMMUNITY
);
4180 if (strmatch(type
, "large"))
4181 return peer_af_flag_unset_vty(
4182 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4183 bgp_node_safi(vty
), PEER_FLAG_SEND_LARGE_COMMUNITY
);
4184 if (strmatch(type
, "both"))
4185 return peer_af_flag_unset_vty(
4186 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4188 PEER_FLAG_SEND_COMMUNITY
4189 | PEER_FLAG_SEND_EXT_COMMUNITY
);
4191 /* if (strmatch (type, "all")) */
4192 return peer_af_flag_unset_vty(
4193 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4194 (PEER_FLAG_SEND_COMMUNITY
| PEER_FLAG_SEND_EXT_COMMUNITY
4195 | PEER_FLAG_SEND_LARGE_COMMUNITY
));
4199 no_neighbor_send_community_type
,
4200 no_neighbor_send_community_type_hidden_cmd
,
4201 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4202 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4203 "Send Community attribute to this neighbor\n"
4204 "Send Standard and Extended Community attributes\n"
4205 "Send Standard, Large and Extended Community attributes\n"
4206 "Send Extended Community attributes\n"
4207 "Send Standard Community attributes\n"
4208 "Send Large Community attributes\n")
4210 /* neighbor soft-reconfig. */
4211 DEFUN (neighbor_soft_reconfiguration
,
4212 neighbor_soft_reconfiguration_cmd
,
4213 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4216 "Per neighbor soft reconfiguration\n"
4217 "Allow inbound soft reconfiguration for this neighbor\n")
4220 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4222 PEER_FLAG_SOFT_RECONFIG
);
4225 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4226 neighbor_soft_reconfiguration_hidden_cmd
,
4227 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4228 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4229 "Per neighbor soft reconfiguration\n"
4230 "Allow inbound soft reconfiguration for this neighbor\n")
4232 DEFUN (no_neighbor_soft_reconfiguration
,
4233 no_neighbor_soft_reconfiguration_cmd
,
4234 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4238 "Per neighbor soft reconfiguration\n"
4239 "Allow inbound soft reconfiguration for this neighbor\n")
4242 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4243 bgp_node_afi(vty
), bgp_node_safi(vty
),
4244 PEER_FLAG_SOFT_RECONFIG
);
4247 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4248 no_neighbor_soft_reconfiguration_hidden_cmd
,
4249 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4250 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4251 "Per neighbor soft reconfiguration\n"
4252 "Allow inbound soft reconfiguration for this neighbor\n")
4254 DEFUN (neighbor_route_reflector_client
,
4255 neighbor_route_reflector_client_cmd
,
4256 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4259 "Configure a neighbor as Route Reflector client\n")
4265 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4267 return CMD_WARNING_CONFIG_FAILED
;
4269 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4271 PEER_FLAG_REFLECTOR_CLIENT
);
4274 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4275 neighbor_route_reflector_client_hidden_cmd
,
4276 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4277 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4278 "Configure a neighbor as Route Reflector client\n")
4280 DEFUN (no_neighbor_route_reflector_client
,
4281 no_neighbor_route_reflector_client_cmd
,
4282 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4286 "Configure a neighbor as Route Reflector client\n")
4289 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4290 bgp_node_afi(vty
), bgp_node_safi(vty
),
4291 PEER_FLAG_REFLECTOR_CLIENT
);
4294 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4295 no_neighbor_route_reflector_client_hidden_cmd
,
4296 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4297 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4298 "Configure a neighbor as Route Reflector client\n")
4300 /* neighbor route-server-client. */
4301 DEFUN (neighbor_route_server_client
,
4302 neighbor_route_server_client_cmd
,
4303 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4306 "Configure a neighbor as Route Server client\n")
4311 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4313 return CMD_WARNING_CONFIG_FAILED
;
4314 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4316 PEER_FLAG_RSERVER_CLIENT
);
4319 ALIAS_HIDDEN(neighbor_route_server_client
,
4320 neighbor_route_server_client_hidden_cmd
,
4321 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4322 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4323 "Configure a neighbor as Route Server client\n")
4325 DEFUN (no_neighbor_route_server_client
,
4326 no_neighbor_route_server_client_cmd
,
4327 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4331 "Configure a neighbor as Route Server client\n")
4334 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4335 bgp_node_afi(vty
), bgp_node_safi(vty
),
4336 PEER_FLAG_RSERVER_CLIENT
);
4339 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4340 no_neighbor_route_server_client_hidden_cmd
,
4341 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4342 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4343 "Configure a neighbor as Route Server client\n")
4345 DEFUN (neighbor_nexthop_local_unchanged
,
4346 neighbor_nexthop_local_unchanged_cmd
,
4347 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4350 "Configure treatment of outgoing link-local nexthop attribute\n"
4351 "Leave link-local nexthop unchanged for this peer\n")
4354 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4356 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4359 DEFUN (no_neighbor_nexthop_local_unchanged
,
4360 no_neighbor_nexthop_local_unchanged_cmd
,
4361 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4365 "Configure treatment of outgoing link-local-nexthop attribute\n"
4366 "Leave link-local nexthop unchanged for this peer\n")
4369 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4370 bgp_node_afi(vty
), bgp_node_safi(vty
),
4371 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4374 DEFUN (neighbor_attr_unchanged
,
4375 neighbor_attr_unchanged_cmd
,
4376 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4379 "BGP attribute is propagated unchanged to this neighbor\n"
4380 "As-path attribute\n"
4381 "Nexthop attribute\n"
4385 char *peer_str
= argv
[1]->arg
;
4388 afi_t afi
= bgp_node_afi(vty
);
4389 safi_t safi
= bgp_node_safi(vty
);
4391 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4393 return CMD_WARNING_CONFIG_FAILED
;
4395 if (argv_find(argv
, argc
, "as-path", &idx
))
4396 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4398 if (argv_find(argv
, argc
, "next-hop", &idx
))
4399 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4401 if (argv_find(argv
, argc
, "med", &idx
))
4402 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4404 /* no flags means all of them! */
4406 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4407 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4408 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4410 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4411 && peer_af_flag_check(peer
, afi
, safi
,
4412 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4413 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4414 PEER_FLAG_AS_PATH_UNCHANGED
);
4417 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4418 && peer_af_flag_check(peer
, afi
, safi
,
4419 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4420 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4421 PEER_FLAG_NEXTHOP_UNCHANGED
);
4424 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4425 && peer_af_flag_check(peer
, afi
, safi
,
4426 PEER_FLAG_MED_UNCHANGED
)) {
4427 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4428 PEER_FLAG_MED_UNCHANGED
);
4432 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4436 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4437 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4438 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4439 "BGP attribute is propagated unchanged to this neighbor\n"
4440 "As-path attribute\n"
4441 "Nexthop attribute\n"
4444 DEFUN (no_neighbor_attr_unchanged
,
4445 no_neighbor_attr_unchanged_cmd
,
4446 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4450 "BGP attribute is propagated unchanged to this neighbor\n"
4451 "As-path attribute\n"
4452 "Nexthop attribute\n"
4456 char *peer
= argv
[2]->arg
;
4459 if (argv_find(argv
, argc
, "as-path", &idx
))
4460 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4462 if (argv_find(argv
, argc
, "next-hop", &idx
))
4463 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4465 if (argv_find(argv
, argc
, "med", &idx
))
4466 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4468 if (!flags
) // no flags means all of them!
4470 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4471 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4472 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4475 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4476 bgp_node_safi(vty
), flags
);
4480 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4481 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4482 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4483 "BGP attribute is propagated unchanged to this neighbor\n"
4484 "As-path attribute\n"
4485 "Nexthop attribute\n"
4488 /* EBGP multihop configuration. */
4489 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4490 const char *ttl_str
)
4495 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4497 return CMD_WARNING_CONFIG_FAILED
;
4500 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4505 ttl
= strtoul(ttl_str
, NULL
, 10);
4507 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4510 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4514 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4516 return CMD_WARNING_CONFIG_FAILED
;
4518 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4521 /* neighbor ebgp-multihop. */
4522 DEFUN (neighbor_ebgp_multihop
,
4523 neighbor_ebgp_multihop_cmd
,
4524 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4527 "Allow EBGP neighbors not on directly connected networks\n")
4530 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4533 DEFUN (neighbor_ebgp_multihop_ttl
,
4534 neighbor_ebgp_multihop_ttl_cmd
,
4535 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4538 "Allow EBGP neighbors not on directly connected networks\n"
4539 "maximum hop count\n")
4543 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4544 argv
[idx_number
]->arg
);
4547 DEFUN (no_neighbor_ebgp_multihop
,
4548 no_neighbor_ebgp_multihop_cmd
,
4549 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4553 "Allow EBGP neighbors not on directly connected networks\n"
4554 "maximum hop count\n")
4557 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4561 /* disable-connected-check */
4562 DEFUN (neighbor_disable_connected_check
,
4563 neighbor_disable_connected_check_cmd
,
4564 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4567 "one-hop away EBGP peer using loopback address\n"
4568 "Enforce EBGP neighbors perform multihop\n")
4571 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4572 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4575 DEFUN (no_neighbor_disable_connected_check
,
4576 no_neighbor_disable_connected_check_cmd
,
4577 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4581 "one-hop away EBGP peer using loopback address\n"
4582 "Enforce EBGP neighbors perform multihop\n")
4585 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4586 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4590 /* enforce-first-as */
4591 DEFUN (neighbor_enforce_first_as
,
4592 neighbor_enforce_first_as_cmd
,
4593 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4596 "Enforce the first AS for EBGP routes\n")
4600 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4601 PEER_FLAG_ENFORCE_FIRST_AS
);
4604 DEFUN (no_neighbor_enforce_first_as
,
4605 no_neighbor_enforce_first_as_cmd
,
4606 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4610 "Enforce the first AS for EBGP routes\n")
4614 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4615 PEER_FLAG_ENFORCE_FIRST_AS
);
4619 DEFUN (neighbor_description
,
4620 neighbor_description_cmd
,
4621 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4624 "Neighbor specific description\n"
4625 "Up to 80 characters describing this neighbor\n")
4632 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4634 return CMD_WARNING_CONFIG_FAILED
;
4636 str
= argv_concat(argv
, argc
, idx_line
);
4638 peer_description_set(peer
, str
);
4640 XFREE(MTYPE_TMP
, str
);
4645 DEFUN (no_neighbor_description
,
4646 no_neighbor_description_cmd
,
4647 "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]",
4651 "Neighbor specific description\n"
4652 "Up to 80 characters describing this neighbor\n")
4657 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4659 return CMD_WARNING_CONFIG_FAILED
;
4661 peer_description_unset(peer
);
4667 /* Neighbor update-source. */
4668 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4669 const char *source_str
)
4674 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4676 return CMD_WARNING_CONFIG_FAILED
;
4683 int ret
= str2sockunion(source_str
, &su
);
4686 peer_update_source_addr_set(peer
, &su
);
4688 if (str2prefix(source_str
, &p
)) {
4690 "%% Invalid update-source, remove prefix length \n");
4691 return CMD_WARNING_CONFIG_FAILED
;
4693 peer_update_source_if_set(peer
, source_str
);
4696 peer_update_source_unset(peer
);
4701 #define BGP_UPDATE_SOURCE_HELP_STR \
4704 "Interface name (requires zebra to be running)\n"
4706 DEFUN (neighbor_update_source
,
4707 neighbor_update_source_cmd
,
4708 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4711 "Source of routing updates\n"
4712 BGP_UPDATE_SOURCE_HELP_STR
)
4716 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4717 argv
[idx_peer_2
]->arg
);
4720 DEFUN (no_neighbor_update_source
,
4721 no_neighbor_update_source_cmd
,
4722 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4726 "Source of routing updates\n"
4727 BGP_UPDATE_SOURCE_HELP_STR
)
4730 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4733 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4734 afi_t afi
, safi_t safi
,
4735 const char *rmap
, int set
)
4740 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4742 return CMD_WARNING_CONFIG_FAILED
;
4745 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4747 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4749 return bgp_vty_return(vty
, ret
);
4752 /* neighbor default-originate. */
4753 DEFUN (neighbor_default_originate
,
4754 neighbor_default_originate_cmd
,
4755 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4758 "Originate default route to this neighbor\n")
4761 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4763 bgp_node_safi(vty
), NULL
, 1);
4766 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4767 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4768 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4769 "Originate default route to this neighbor\n")
4771 DEFUN (neighbor_default_originate_rmap
,
4772 neighbor_default_originate_rmap_cmd
,
4773 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4776 "Originate default route to this neighbor\n"
4777 "Route-map to specify criteria to originate default\n"
4782 return peer_default_originate_set_vty(
4783 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4784 argv
[idx_word
]->arg
, 1);
4788 neighbor_default_originate_rmap
,
4789 neighbor_default_originate_rmap_hidden_cmd
,
4790 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4791 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4792 "Originate default route to this neighbor\n"
4793 "Route-map to specify criteria to originate default\n"
4796 DEFUN (no_neighbor_default_originate
,
4797 no_neighbor_default_originate_cmd
,
4798 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4802 "Originate default route to this neighbor\n"
4803 "Route-map to specify criteria to originate default\n"
4807 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4809 bgp_node_safi(vty
), NULL
, 0);
4813 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4814 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4815 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4816 "Originate default route to this neighbor\n"
4817 "Route-map to specify criteria to originate default\n"
4821 /* Set neighbor's BGP port. */
4822 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4823 const char *port_str
)
4829 peer
= peer_lookup_vty(vty
, ip_str
);
4831 return CMD_WARNING_CONFIG_FAILED
;
4834 sp
= getservbyname("bgp", "tcp");
4835 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4837 port
= strtoul(port_str
, NULL
, 10);
4840 peer_port_set(peer
, port
);
4845 /* Set specified peer's BGP port. */
4846 DEFUN (neighbor_port
,
4848 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4851 "Neighbor's BGP port\n"
4852 "TCP port number\n")
4856 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4857 argv
[idx_number
]->arg
);
4860 DEFUN (no_neighbor_port
,
4861 no_neighbor_port_cmd
,
4862 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4866 "Neighbor's BGP port\n"
4867 "TCP port number\n")
4870 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4874 /* neighbor weight. */
4875 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4876 safi_t safi
, const char *weight_str
)
4880 unsigned long weight
;
4882 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4884 return CMD_WARNING_CONFIG_FAILED
;
4886 weight
= strtoul(weight_str
, NULL
, 10);
4888 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4889 return bgp_vty_return(vty
, ret
);
4892 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4898 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4900 return CMD_WARNING_CONFIG_FAILED
;
4902 ret
= peer_weight_unset(peer
, afi
, safi
);
4903 return bgp_vty_return(vty
, ret
);
4906 DEFUN (neighbor_weight
,
4907 neighbor_weight_cmd
,
4908 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4911 "Set default weight for routes from this neighbor\n"
4916 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4917 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4920 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4921 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4922 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4923 "Set default weight for routes from this neighbor\n"
4926 DEFUN (no_neighbor_weight
,
4927 no_neighbor_weight_cmd
,
4928 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4932 "Set default weight for routes from this neighbor\n"
4936 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4937 bgp_node_afi(vty
), bgp_node_safi(vty
));
4940 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4941 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4942 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4943 "Set default weight for routes from this neighbor\n"
4947 /* Override capability negotiation. */
4948 DEFUN (neighbor_override_capability
,
4949 neighbor_override_capability_cmd
,
4950 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4953 "Override capability negotiation result\n")
4956 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4957 PEER_FLAG_OVERRIDE_CAPABILITY
);
4960 DEFUN (no_neighbor_override_capability
,
4961 no_neighbor_override_capability_cmd
,
4962 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4966 "Override capability negotiation result\n")
4969 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4970 PEER_FLAG_OVERRIDE_CAPABILITY
);
4973 DEFUN (neighbor_strict_capability
,
4974 neighbor_strict_capability_cmd
,
4975 "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4978 "Strict capability negotiation match\n")
4981 return peer_flag_set_vty(vty
, argv
[idx_ip
]->arg
,
4982 PEER_FLAG_STRICT_CAP_MATCH
);
4985 DEFUN (no_neighbor_strict_capability
,
4986 no_neighbor_strict_capability_cmd
,
4987 "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4991 "Strict capability negotiation match\n")
4994 return peer_flag_unset_vty(vty
, argv
[idx_ip
]->arg
,
4995 PEER_FLAG_STRICT_CAP_MATCH
);
4998 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
4999 const char *keep_str
, const char *hold_str
)
5006 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5008 return CMD_WARNING_CONFIG_FAILED
;
5010 keepalive
= strtoul(keep_str
, NULL
, 10);
5011 holdtime
= strtoul(hold_str
, NULL
, 10);
5013 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5015 return bgp_vty_return(vty
, ret
);
5018 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5023 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5025 return CMD_WARNING_CONFIG_FAILED
;
5027 ret
= peer_timers_unset(peer
);
5029 return bgp_vty_return(vty
, ret
);
5032 DEFUN (neighbor_timers
,
5033 neighbor_timers_cmd
,
5034 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5037 "BGP per neighbor timers\n"
5038 "Keepalive interval\n"
5043 int idx_number_2
= 4;
5044 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5045 argv
[idx_number
]->arg
,
5046 argv
[idx_number_2
]->arg
);
5049 DEFUN (no_neighbor_timers
,
5050 no_neighbor_timers_cmd
,
5051 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5055 "BGP per neighbor timers\n"
5056 "Keepalive interval\n"
5060 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5064 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5065 const char *time_str
)
5071 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5073 return CMD_WARNING_CONFIG_FAILED
;
5075 connect
= strtoul(time_str
, NULL
, 10);
5077 ret
= peer_timers_connect_set(peer
, connect
);
5079 return bgp_vty_return(vty
, ret
);
5082 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5087 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5089 return CMD_WARNING_CONFIG_FAILED
;
5091 ret
= peer_timers_connect_unset(peer
);
5093 return bgp_vty_return(vty
, ret
);
5096 DEFUN (neighbor_timers_connect
,
5097 neighbor_timers_connect_cmd
,
5098 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5101 "BGP per neighbor timers\n"
5102 "BGP connect timer\n"
5107 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5108 argv
[idx_number
]->arg
);
5111 DEFUN (no_neighbor_timers_connect
,
5112 no_neighbor_timers_connect_cmd
,
5113 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5117 "BGP per neighbor timers\n"
5118 "BGP connect timer\n"
5122 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5126 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5127 const char *time_str
, int set
)
5131 uint32_t routeadv
= 0;
5133 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5135 return CMD_WARNING_CONFIG_FAILED
;
5138 routeadv
= strtoul(time_str
, NULL
, 10);
5141 ret
= peer_advertise_interval_set(peer
, routeadv
);
5143 ret
= peer_advertise_interval_unset(peer
);
5145 return bgp_vty_return(vty
, ret
);
5148 DEFUN (neighbor_advertise_interval
,
5149 neighbor_advertise_interval_cmd
,
5150 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5153 "Minimum interval between sending BGP routing updates\n"
5154 "time in seconds\n")
5158 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5159 argv
[idx_number
]->arg
, 1);
5162 DEFUN (no_neighbor_advertise_interval
,
5163 no_neighbor_advertise_interval_cmd
,
5164 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5168 "Minimum interval between sending BGP routing updates\n"
5169 "time in seconds\n")
5172 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5176 /* Time to wait before processing route-map updates */
5177 DEFUN (bgp_set_route_map_delay_timer
,
5178 bgp_set_route_map_delay_timer_cmd
,
5179 "bgp route-map delay-timer (0-600)",
5181 "BGP route-map delay timer\n"
5182 "Time in secs to wait before processing route-map changes\n"
5183 "0 disables the timer, no route updates happen when route-maps change\n")
5186 uint32_t rmap_delay_timer
;
5188 if (argv
[idx_number
]->arg
) {
5189 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5190 bm
->rmap_update_timer
= rmap_delay_timer
;
5192 /* if the dynamic update handling is being disabled, and a timer
5194 * running, stop the timer and act as if the timer has already
5197 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5198 BGP_TIMER_OFF(bm
->t_rmap_update
);
5199 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5204 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5205 return CMD_WARNING_CONFIG_FAILED
;
5209 DEFUN (no_bgp_set_route_map_delay_timer
,
5210 no_bgp_set_route_map_delay_timer_cmd
,
5211 "no bgp route-map delay-timer [(0-600)]",
5214 "Default BGP route-map delay timer\n"
5215 "Reset to default time to wait for processing route-map changes\n"
5216 "0 disables the timer, no route updates happen when route-maps change\n")
5219 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5225 /* neighbor interface */
5226 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5231 peer
= peer_lookup_vty(vty
, ip_str
);
5232 if (!peer
|| peer
->conf_if
) {
5233 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5234 return CMD_WARNING_CONFIG_FAILED
;
5238 peer_interface_set(peer
, str
);
5240 peer_interface_unset(peer
);
5245 DEFUN (neighbor_interface
,
5246 neighbor_interface_cmd
,
5247 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5255 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5258 DEFUN (no_neighbor_interface
,
5259 no_neighbor_interface_cmd
,
5260 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5268 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5271 DEFUN (neighbor_distribute_list
,
5272 neighbor_distribute_list_cmd
,
5273 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5276 "Filter updates to/from this neighbor\n"
5277 "IP access-list number\n"
5278 "IP access-list number (expanded range)\n"
5279 "IP Access-list name\n"
5280 "Filter incoming updates\n"
5281 "Filter outgoing updates\n")
5288 const char *pstr
= argv
[idx_peer
]->arg
;
5289 const char *acl
= argv
[idx_acl
]->arg
;
5290 const char *inout
= argv
[argc
- 1]->text
;
5292 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5294 return CMD_WARNING_CONFIG_FAILED
;
5296 /* Check filter direction. */
5297 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5298 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5301 return bgp_vty_return(vty
, ret
);
5305 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5306 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5307 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5308 "Filter updates to/from this neighbor\n"
5309 "IP access-list number\n"
5310 "IP access-list number (expanded range)\n"
5311 "IP Access-list name\n"
5312 "Filter incoming updates\n"
5313 "Filter outgoing updates\n")
5315 DEFUN (no_neighbor_distribute_list
,
5316 no_neighbor_distribute_list_cmd
,
5317 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5321 "Filter updates to/from this neighbor\n"
5322 "IP access-list number\n"
5323 "IP access-list number (expanded range)\n"
5324 "IP Access-list name\n"
5325 "Filter incoming updates\n"
5326 "Filter outgoing updates\n")
5332 const char *pstr
= argv
[idx_peer
]->arg
;
5333 const char *inout
= argv
[argc
- 1]->text
;
5335 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5337 return CMD_WARNING_CONFIG_FAILED
;
5339 /* Check filter direction. */
5340 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5341 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5344 return bgp_vty_return(vty
, ret
);
5348 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5349 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5350 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5351 "Filter updates to/from this neighbor\n"
5352 "IP access-list number\n"
5353 "IP access-list number (expanded range)\n"
5354 "IP Access-list name\n"
5355 "Filter incoming updates\n"
5356 "Filter outgoing updates\n")
5358 /* Set prefix list to the peer. */
5359 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5360 afi_t afi
, safi_t safi
,
5361 const char *name_str
,
5362 const char *direct_str
)
5366 int direct
= FILTER_IN
;
5368 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5370 return CMD_WARNING_CONFIG_FAILED
;
5372 /* Check filter direction. */
5373 if (strncmp(direct_str
, "i", 1) == 0)
5375 else if (strncmp(direct_str
, "o", 1) == 0)
5376 direct
= FILTER_OUT
;
5378 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5380 return bgp_vty_return(vty
, ret
);
5383 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5384 afi_t afi
, safi_t safi
,
5385 const char *direct_str
)
5389 int direct
= FILTER_IN
;
5391 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5393 return CMD_WARNING_CONFIG_FAILED
;
5395 /* Check filter direction. */
5396 if (strncmp(direct_str
, "i", 1) == 0)
5398 else if (strncmp(direct_str
, "o", 1) == 0)
5399 direct
= FILTER_OUT
;
5401 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5403 return bgp_vty_return(vty
, ret
);
5406 DEFUN (neighbor_prefix_list
,
5407 neighbor_prefix_list_cmd
,
5408 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5411 "Filter updates to/from this neighbor\n"
5412 "Name of a prefix list\n"
5413 "Filter incoming updates\n"
5414 "Filter outgoing updates\n")
5419 return peer_prefix_list_set_vty(
5420 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5421 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5424 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5425 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5426 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5427 "Filter updates to/from this neighbor\n"
5428 "Name of a prefix list\n"
5429 "Filter incoming updates\n"
5430 "Filter outgoing updates\n")
5432 DEFUN (no_neighbor_prefix_list
,
5433 no_neighbor_prefix_list_cmd
,
5434 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5438 "Filter updates to/from this neighbor\n"
5439 "Name of a prefix list\n"
5440 "Filter incoming updates\n"
5441 "Filter outgoing updates\n")
5445 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5446 bgp_node_afi(vty
), bgp_node_safi(vty
),
5447 argv
[idx_in_out
]->arg
);
5450 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5451 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5452 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5453 "Filter updates to/from this neighbor\n"
5454 "Name of a prefix list\n"
5455 "Filter incoming updates\n"
5456 "Filter outgoing updates\n")
5458 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5459 safi_t safi
, const char *name_str
,
5460 const char *direct_str
)
5464 int direct
= FILTER_IN
;
5466 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5468 return CMD_WARNING_CONFIG_FAILED
;
5470 /* Check filter direction. */
5471 if (strncmp(direct_str
, "i", 1) == 0)
5473 else if (strncmp(direct_str
, "o", 1) == 0)
5474 direct
= FILTER_OUT
;
5476 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5478 return bgp_vty_return(vty
, ret
);
5481 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5482 safi_t safi
, const char *direct_str
)
5486 int direct
= FILTER_IN
;
5488 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5490 return CMD_WARNING_CONFIG_FAILED
;
5492 /* Check filter direction. */
5493 if (strncmp(direct_str
, "i", 1) == 0)
5495 else if (strncmp(direct_str
, "o", 1) == 0)
5496 direct
= FILTER_OUT
;
5498 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5500 return bgp_vty_return(vty
, ret
);
5503 DEFUN (neighbor_filter_list
,
5504 neighbor_filter_list_cmd
,
5505 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5508 "Establish BGP filters\n"
5509 "AS path access-list name\n"
5510 "Filter incoming routes\n"
5511 "Filter outgoing routes\n")
5516 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5517 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5518 argv
[idx_in_out
]->arg
);
5521 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5522 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5523 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5524 "Establish BGP filters\n"
5525 "AS path access-list name\n"
5526 "Filter incoming routes\n"
5527 "Filter outgoing routes\n")
5529 DEFUN (no_neighbor_filter_list
,
5530 no_neighbor_filter_list_cmd
,
5531 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5535 "Establish BGP filters\n"
5536 "AS path access-list name\n"
5537 "Filter incoming routes\n"
5538 "Filter outgoing routes\n")
5542 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5543 bgp_node_afi(vty
), bgp_node_safi(vty
),
5544 argv
[idx_in_out
]->arg
);
5547 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5548 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5549 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5550 "Establish BGP filters\n"
5551 "AS path access-list name\n"
5552 "Filter incoming routes\n"
5553 "Filter outgoing routes\n")
5555 /* Set route-map to the peer. */
5556 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5557 afi_t afi
, safi_t safi
, const char *name_str
,
5558 const char *direct_str
)
5562 int direct
= RMAP_IN
;
5564 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5566 return CMD_WARNING_CONFIG_FAILED
;
5568 /* Check filter direction. */
5569 if (strncmp(direct_str
, "in", 2) == 0)
5571 else if (strncmp(direct_str
, "o", 1) == 0)
5574 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5576 return bgp_vty_return(vty
, ret
);
5579 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5580 afi_t afi
, safi_t safi
,
5581 const char *direct_str
)
5585 int direct
= RMAP_IN
;
5587 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5589 return CMD_WARNING_CONFIG_FAILED
;
5591 /* Check filter direction. */
5592 if (strncmp(direct_str
, "in", 2) == 0)
5594 else if (strncmp(direct_str
, "o", 1) == 0)
5597 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5599 return bgp_vty_return(vty
, ret
);
5602 DEFUN (neighbor_route_map
,
5603 neighbor_route_map_cmd
,
5604 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5607 "Apply route map to neighbor\n"
5608 "Name of route map\n"
5609 "Apply map to incoming routes\n"
5610 "Apply map to outbound routes\n")
5615 return peer_route_map_set_vty(
5616 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5617 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5620 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5621 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5622 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5623 "Apply route map to neighbor\n"
5624 "Name of route map\n"
5625 "Apply map to incoming routes\n"
5626 "Apply map to outbound routes\n")
5628 DEFUN (no_neighbor_route_map
,
5629 no_neighbor_route_map_cmd
,
5630 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5634 "Apply route map to neighbor\n"
5635 "Name of route map\n"
5636 "Apply map to incoming routes\n"
5637 "Apply map to outbound routes\n")
5641 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5642 bgp_node_afi(vty
), bgp_node_safi(vty
),
5643 argv
[idx_in_out
]->arg
);
5646 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5647 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5648 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5649 "Apply route map to neighbor\n"
5650 "Name of route map\n"
5651 "Apply map to incoming routes\n"
5652 "Apply map to outbound routes\n")
5654 /* Set unsuppress-map to the peer. */
5655 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5656 afi_t afi
, safi_t safi
,
5657 const char *name_str
)
5662 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5664 return CMD_WARNING_CONFIG_FAILED
;
5666 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5668 return bgp_vty_return(vty
, ret
);
5671 /* Unset route-map from the peer. */
5672 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5673 afi_t afi
, safi_t safi
)
5678 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5680 return CMD_WARNING_CONFIG_FAILED
;
5682 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5684 return bgp_vty_return(vty
, ret
);
5687 DEFUN (neighbor_unsuppress_map
,
5688 neighbor_unsuppress_map_cmd
,
5689 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5692 "Route-map to selectively unsuppress suppressed routes\n"
5693 "Name of route map\n")
5697 return peer_unsuppress_map_set_vty(
5698 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5699 argv
[idx_word
]->arg
);
5702 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5703 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5704 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5705 "Route-map to selectively unsuppress suppressed routes\n"
5706 "Name of route map\n")
5708 DEFUN (no_neighbor_unsuppress_map
,
5709 no_neighbor_unsuppress_map_cmd
,
5710 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5714 "Route-map to selectively unsuppress suppressed routes\n"
5715 "Name of route map\n")
5718 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5720 bgp_node_safi(vty
));
5723 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5724 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5725 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5726 "Route-map to selectively unsuppress suppressed routes\n"
5727 "Name of route map\n")
5729 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5730 afi_t afi
, safi_t safi
,
5731 const char *num_str
,
5732 const char *threshold_str
, int warning
,
5733 const char *restart_str
)
5741 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5743 return CMD_WARNING_CONFIG_FAILED
;
5745 max
= strtoul(num_str
, NULL
, 10);
5747 threshold
= atoi(threshold_str
);
5749 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5752 restart
= atoi(restart_str
);
5756 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5759 return bgp_vty_return(vty
, ret
);
5762 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5763 afi_t afi
, safi_t safi
)
5768 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5770 return CMD_WARNING_CONFIG_FAILED
;
5772 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5774 return bgp_vty_return(vty
, ret
);
5777 /* Maximum number of prefix configuration. prefix count is different
5778 for each peer configuration. So this configuration can be set for
5779 each peer configuration. */
5780 DEFUN (neighbor_maximum_prefix
,
5781 neighbor_maximum_prefix_cmd
,
5782 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5785 "Maximum number of prefix accept from this peer\n"
5786 "maximum no. of prefix limit\n")
5790 return peer_maximum_prefix_set_vty(
5791 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5792 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5795 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5796 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5797 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5798 "Maximum number of prefix accept from this peer\n"
5799 "maximum no. of prefix limit\n")
5801 DEFUN (neighbor_maximum_prefix_threshold
,
5802 neighbor_maximum_prefix_threshold_cmd
,
5803 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5806 "Maximum number of prefix accept from this peer\n"
5807 "maximum no. of prefix limit\n"
5808 "Threshold value (%) at which to generate a warning msg\n")
5812 int idx_number_2
= 4;
5813 return peer_maximum_prefix_set_vty(
5814 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5815 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5819 neighbor_maximum_prefix_threshold
,
5820 neighbor_maximum_prefix_threshold_hidden_cmd
,
5821 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5822 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5823 "Maximum number of prefix accept from this peer\n"
5824 "maximum no. of prefix limit\n"
5825 "Threshold value (%) at which to generate a warning msg\n")
5827 DEFUN (neighbor_maximum_prefix_warning
,
5828 neighbor_maximum_prefix_warning_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5832 "Maximum number of prefix accept from this peer\n"
5833 "maximum no. of prefix limit\n"
5834 "Only give warning message when limit is exceeded\n")
5838 return peer_maximum_prefix_set_vty(
5839 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5840 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5844 neighbor_maximum_prefix_warning
,
5845 neighbor_maximum_prefix_warning_hidden_cmd
,
5846 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5847 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5848 "Maximum number of prefix accept from this peer\n"
5849 "maximum no. of prefix limit\n"
5850 "Only give warning message when limit is exceeded\n")
5852 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5853 neighbor_maximum_prefix_threshold_warning_cmd
,
5854 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5857 "Maximum number of prefix accept from this peer\n"
5858 "maximum no. of prefix limit\n"
5859 "Threshold value (%) at which to generate a warning msg\n"
5860 "Only give warning message when limit is exceeded\n")
5864 int idx_number_2
= 4;
5865 return peer_maximum_prefix_set_vty(
5866 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5867 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5871 neighbor_maximum_prefix_threshold_warning
,
5872 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5873 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5874 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5875 "Maximum number of prefix accept from this peer\n"
5876 "maximum no. of prefix limit\n"
5877 "Threshold value (%) at which to generate a warning msg\n"
5878 "Only give warning message when limit is exceeded\n")
5880 DEFUN (neighbor_maximum_prefix_restart
,
5881 neighbor_maximum_prefix_restart_cmd
,
5882 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5885 "Maximum number of prefix accept from this peer\n"
5886 "maximum no. of prefix limit\n"
5887 "Restart bgp connection after limit is exceeded\n"
5888 "Restart interval in minutes\n")
5892 int idx_number_2
= 5;
5893 return peer_maximum_prefix_set_vty(
5894 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5895 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5899 neighbor_maximum_prefix_restart
,
5900 neighbor_maximum_prefix_restart_hidden_cmd
,
5901 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5902 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5903 "Maximum number of prefix accept from this peer\n"
5904 "maximum no. of prefix limit\n"
5905 "Restart bgp connection after limit is exceeded\n"
5906 "Restart interval in minutes\n")
5908 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5909 neighbor_maximum_prefix_threshold_restart_cmd
,
5910 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5913 "Maximum number of prefixes to accept from this peer\n"
5914 "maximum no. of prefix limit\n"
5915 "Threshold value (%) at which to generate a warning msg\n"
5916 "Restart bgp connection after limit is exceeded\n"
5917 "Restart interval in minutes\n")
5921 int idx_number_2
= 4;
5922 int idx_number_3
= 6;
5923 return peer_maximum_prefix_set_vty(
5924 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5925 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5926 argv
[idx_number_3
]->arg
);
5930 neighbor_maximum_prefix_threshold_restart
,
5931 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5932 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5933 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5934 "Maximum number of prefixes to accept from this peer\n"
5935 "maximum no. of prefix limit\n"
5936 "Threshold value (%) at which to generate a warning msg\n"
5937 "Restart bgp connection after limit is exceeded\n"
5938 "Restart interval in minutes\n")
5940 DEFUN (no_neighbor_maximum_prefix
,
5941 no_neighbor_maximum_prefix_cmd
,
5942 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5946 "Maximum number of prefixes to accept from this peer\n"
5947 "maximum no. of prefix limit\n"
5948 "Threshold value (%) at which to generate a warning msg\n"
5949 "Restart bgp connection after limit is exceeded\n"
5950 "Restart interval in minutes\n"
5951 "Only give warning message when limit is exceeded\n")
5954 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5956 bgp_node_safi(vty
));
5960 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5961 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5962 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5963 "Maximum number of prefixes to accept from this peer\n"
5964 "maximum no. of prefix limit\n"
5965 "Threshold value (%) at which to generate a warning msg\n"
5966 "Restart bgp connection after limit is exceeded\n"
5967 "Restart interval in minutes\n"
5968 "Only give warning message when limit is exceeded\n")
5971 /* "neighbor allowas-in" */
5972 DEFUN (neighbor_allowas_in
,
5973 neighbor_allowas_in_cmd
,
5974 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5977 "Accept as-path with my AS present in it\n"
5978 "Number of occurances of AS number\n"
5979 "Only accept my AS in the as-path if the route was originated in my AS\n")
5982 int idx_number_origin
= 3;
5988 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5990 return CMD_WARNING_CONFIG_FAILED
;
5992 if (argc
<= idx_number_origin
)
5995 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
5998 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6001 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6004 return bgp_vty_return(vty
, ret
);
6008 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6009 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6010 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6011 "Accept as-path with my AS present in it\n"
6012 "Number of occurances of AS number\n"
6013 "Only accept my AS in the as-path if the route was originated in my AS\n")
6015 DEFUN (no_neighbor_allowas_in
,
6016 no_neighbor_allowas_in_cmd
,
6017 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6021 "allow local ASN appears in aspath attribute\n"
6022 "Number of occurances of AS number\n"
6023 "Only accept my AS in the as-path if the route was originated in my AS\n")
6029 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6031 return CMD_WARNING_CONFIG_FAILED
;
6033 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6034 bgp_node_safi(vty
));
6036 return bgp_vty_return(vty
, ret
);
6040 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6041 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6042 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6043 "allow local ASN appears in aspath attribute\n"
6044 "Number of occurances of AS number\n"
6045 "Only accept my AS in the as-path if the route was originated in my AS\n")
6047 DEFUN (neighbor_ttl_security
,
6048 neighbor_ttl_security_cmd
,
6049 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6052 "BGP ttl-security parameters\n"
6053 "Specify the maximum number of hops to the BGP peer\n"
6054 "Number of hops to BGP peer\n")
6061 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6063 return CMD_WARNING_CONFIG_FAILED
;
6065 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6068 * If 'neighbor swpX', then this is for directly connected peers,
6069 * we should not accept a ttl-security hops value greater than 1.
6071 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6073 "%s is directly connected peer, hops cannot exceed 1\n",
6074 argv
[idx_peer
]->arg
);
6075 return CMD_WARNING_CONFIG_FAILED
;
6078 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6081 DEFUN (no_neighbor_ttl_security
,
6082 no_neighbor_ttl_security_cmd
,
6083 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6087 "BGP ttl-security parameters\n"
6088 "Specify the maximum number of hops to the BGP peer\n"
6089 "Number of hops to BGP peer\n")
6094 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6096 return CMD_WARNING_CONFIG_FAILED
;
6098 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6101 DEFUN (neighbor_addpath_tx_all_paths
,
6102 neighbor_addpath_tx_all_paths_cmd
,
6103 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6106 "Use addpath to advertise all paths to a neighbor\n")
6111 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6113 return CMD_WARNING_CONFIG_FAILED
;
6115 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6117 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6120 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6121 neighbor_addpath_tx_all_paths_hidden_cmd
,
6122 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6123 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6124 "Use addpath to advertise all paths to a neighbor\n")
6126 DEFUN (no_neighbor_addpath_tx_all_paths
,
6127 no_neighbor_addpath_tx_all_paths_cmd
,
6128 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6132 "Use addpath to advertise all paths to a neighbor\n")
6135 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6136 bgp_node_afi(vty
), bgp_node_safi(vty
),
6137 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6140 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6141 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6142 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6143 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6144 "Use addpath to advertise all paths to a neighbor\n")
6146 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6147 neighbor_addpath_tx_bestpath_per_as_cmd
,
6148 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6151 "Use addpath to advertise the bestpath per each neighboring AS\n")
6156 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6158 return CMD_WARNING_CONFIG_FAILED
;
6160 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6162 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6165 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6166 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6167 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6168 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6169 "Use addpath to advertise the bestpath per each neighboring AS\n")
6171 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6172 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6173 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6177 "Use addpath to advertise the bestpath per each neighboring AS\n")
6180 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6181 bgp_node_afi(vty
), bgp_node_safi(vty
),
6182 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6185 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6186 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6187 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6188 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6189 "Use addpath to advertise the bestpath per each neighboring AS\n")
6191 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6192 struct ecommunity
**list
)
6194 struct ecommunity
*ecom
= NULL
;
6195 struct ecommunity
*ecomadd
;
6197 for (; argc
; --argc
, ++argv
) {
6199 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6200 ECOMMUNITY_ROUTE_TARGET
, 0);
6202 vty_out(vty
, "Malformed community-list value\n");
6204 ecommunity_free(&ecom
);
6205 return CMD_WARNING_CONFIG_FAILED
;
6209 ecommunity_merge(ecom
, ecomadd
);
6210 ecommunity_free(&ecomadd
);
6217 ecommunity_free(&*list
);
6225 * v2vimport is true if we are handling a `import vrf ...` command
6227 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6231 switch (vty
->node
) {
6240 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6245 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6246 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6247 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6248 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6250 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6254 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6255 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6256 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6257 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6259 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6266 DEFPY (af_rd_vpn_export
,
6267 af_rd_vpn_export_cmd
,
6268 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6270 "Specify route distinguisher\n"
6271 "Between current address-family and vpn\n"
6272 "For routes leaked from current address-family to vpn\n"
6273 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6275 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6276 struct prefix_rd prd
;
6282 if (argv_find(argv
, argc
, "no", &idx
))
6286 ret
= str2prefix_rd(rd_str
, &prd
);
6288 vty_out(vty
, "%% Malformed rd\n");
6289 return CMD_WARNING_CONFIG_FAILED
;
6293 afi
= vpn_policy_getafi(vty
, bgp
, false);
6295 return CMD_WARNING_CONFIG_FAILED
;
6298 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6300 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6301 bgp_get_default(), bgp
);
6304 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6305 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6306 BGP_VPN_POLICY_TOVPN_RD_SET
);
6308 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6309 BGP_VPN_POLICY_TOVPN_RD_SET
);
6312 /* post-change: re-export vpn routes */
6313 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6314 bgp_get_default(), bgp
);
6319 ALIAS (af_rd_vpn_export
,
6320 af_no_rd_vpn_export_cmd
,
6323 "Specify route distinguisher\n"
6324 "Between current address-family and vpn\n"
6325 "For routes leaked from current address-family to vpn\n")
6327 DEFPY (af_label_vpn_export
,
6328 af_label_vpn_export_cmd
,
6329 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6331 "label value for VRF\n"
6332 "Between current address-family and vpn\n"
6333 "For routes leaked from current address-family to vpn\n"
6334 "Label Value <0-1048575>\n"
6335 "Automatically assign a label\n")
6337 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6338 mpls_label_t label
= MPLS_LABEL_NONE
;
6343 if (argv_find(argv
, argc
, "no", &idx
))
6346 /* If "no ...", squash trailing parameter */
6352 label
= label_val
; /* parser should force unsigned */
6355 afi
= vpn_policy_getafi(vty
, bgp
, false);
6357 return CMD_WARNING_CONFIG_FAILED
;
6360 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6361 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6366 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6368 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6369 bgp_get_default(), bgp
);
6371 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6372 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6374 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6377 * label has previously been automatically
6378 * assigned by labelpool: release it
6380 * NB if tovpn_label == MPLS_LABEL_NONE it
6381 * means the automatic assignment is in flight
6382 * and therefore the labelpool callback must
6383 * detect that the auto label is not needed.
6386 bgp_lp_release(LP_TYPE_VRF
,
6387 &bgp
->vpn_policy
[afi
],
6388 bgp
->vpn_policy
[afi
].tovpn_label
);
6390 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6391 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6394 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6396 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6397 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6398 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6399 vpn_leak_label_callback
);
6402 /* post-change: re-export vpn routes */
6403 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6404 bgp_get_default(), bgp
);
6409 ALIAS (af_label_vpn_export
,
6410 af_no_label_vpn_export_cmd
,
6411 "no label vpn export",
6413 "label value for VRF\n"
6414 "Between current address-family and vpn\n"
6415 "For routes leaked from current address-family to vpn\n")
6417 DEFPY (af_nexthop_vpn_export
,
6418 af_nexthop_vpn_export_cmd
,
6419 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6421 "Specify next hop to use for VRF advertised prefixes\n"
6422 "Between current address-family and vpn\n"
6423 "For routes leaked from current address-family to vpn\n"
6427 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6433 if (argv_find(argv
, argc
, "no", &idx
))
6437 if (!sockunion2hostprefix(nexthop_str
, &p
))
6438 return CMD_WARNING_CONFIG_FAILED
;
6441 afi
= vpn_policy_getafi(vty
, bgp
, false);
6443 return CMD_WARNING_CONFIG_FAILED
;
6446 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6448 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6449 bgp_get_default(), bgp
);
6452 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6453 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6454 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6456 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6457 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6460 /* post-change: re-export vpn routes */
6461 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6462 bgp_get_default(), bgp
);
6467 ALIAS (af_nexthop_vpn_export
,
6468 af_no_nexthop_vpn_export_cmd
,
6469 "no nexthop vpn export",
6471 "Specify next hop to use for VRF advertised prefixes\n"
6472 "Between current address-family and vpn\n"
6473 "For routes leaked from current address-family to vpn\n")
6475 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6477 if (!strcmp(dstr
, "import")) {
6478 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6479 } else if (!strcmp(dstr
, "export")) {
6480 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6481 } else if (!strcmp(dstr
, "both")) {
6482 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6483 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6485 vty_out(vty
, "%% direction parse error\n");
6486 return CMD_WARNING_CONFIG_FAILED
;
6491 DEFPY (af_rt_vpn_imexport
,
6492 af_rt_vpn_imexport_cmd
,
6493 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6495 "Specify route target list\n"
6496 "Specify route target list\n"
6497 "Between current address-family and vpn\n"
6498 "For routes leaked from vpn to current address-family: match any\n"
6499 "For routes leaked from current address-family to vpn: set\n"
6500 "both import: match any and export: set\n"
6501 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6503 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6505 struct ecommunity
*ecom
= NULL
;
6506 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6507 vpn_policy_direction_t dir
;
6512 if (argv_find(argv
, argc
, "no", &idx
))
6515 afi
= vpn_policy_getafi(vty
, bgp
, false);
6517 return CMD_WARNING_CONFIG_FAILED
;
6519 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6520 if (ret
!= CMD_SUCCESS
)
6524 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6525 vty_out(vty
, "%% Missing RTLIST\n");
6526 return CMD_WARNING_CONFIG_FAILED
;
6528 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6529 if (ret
!= CMD_SUCCESS
) {
6534 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6538 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6541 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6543 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6544 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6545 ecommunity_dup(ecom
);
6547 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6549 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6550 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6553 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6557 ecommunity_free(&ecom
);
6562 ALIAS (af_rt_vpn_imexport
,
6563 af_no_rt_vpn_imexport_cmd
,
6564 "no <rt|route-target> vpn <import|export|both>$direction_str",
6566 "Specify route target list\n"
6567 "Specify route target list\n"
6568 "Between current address-family and vpn\n"
6569 "For routes leaked from vpn to current address-family\n"
6570 "For routes leaked from current address-family to vpn\n"
6571 "both import and export\n")
6573 DEFPY (af_route_map_vpn_imexport
,
6574 af_route_map_vpn_imexport_cmd
,
6575 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6576 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6578 "Specify route map\n"
6579 "Between current address-family and vpn\n"
6580 "For routes leaked from vpn to current address-family\n"
6581 "For routes leaked from current address-family to vpn\n"
6582 "name of route-map\n")
6584 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6586 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6587 vpn_policy_direction_t dir
;
6592 if (argv_find(argv
, argc
, "no", &idx
))
6595 afi
= vpn_policy_getafi(vty
, bgp
, false);
6597 return CMD_WARNING_CONFIG_FAILED
;
6599 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6600 if (ret
!= CMD_SUCCESS
)
6603 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6607 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6610 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6611 XFREE(MTYPE_ROUTE_MAP_NAME
,
6612 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6613 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6614 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6615 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6616 route_map_lookup_by_name(rmap_str
);
6617 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6620 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6621 XFREE(MTYPE_ROUTE_MAP_NAME
,
6622 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6623 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6624 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6627 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6633 ALIAS (af_route_map_vpn_imexport
,
6634 af_no_route_map_vpn_imexport_cmd
,
6635 "no route-map vpn <import|export>$direction_str",
6637 "Specify route map\n"
6638 "Between current address-family and vpn\n"
6639 "For routes leaked from vpn to current address-family\n"
6640 "For routes leaked from current address-family to vpn\n")
6642 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6643 "[no] import vrf route-map RMAP$rmap_str",
6645 "Import routes from another VRF\n"
6646 "Vrf routes being filtered\n"
6647 "Specify route map\n"
6648 "name of route-map\n")
6650 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6651 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6655 struct bgp
*bgp_default
;
6657 if (argv_find(argv
, argc
, "no", &idx
))
6660 afi
= vpn_policy_getafi(vty
, bgp
, true);
6662 return CMD_WARNING_CONFIG_FAILED
;
6664 bgp_default
= bgp_get_default();
6669 /* Auto-create assuming the same AS */
6670 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6671 BGP_INSTANCE_TYPE_DEFAULT
);
6675 "VRF default is not configured as a bgp instance\n");
6680 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6683 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6684 XFREE(MTYPE_ROUTE_MAP_NAME
,
6685 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6686 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6687 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6688 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6689 route_map_lookup_by_name(rmap_str
);
6690 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6693 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6694 XFREE(MTYPE_ROUTE_MAP_NAME
,
6695 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6696 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6697 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6700 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6705 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6706 "no import vrf route-map",
6708 "Import routes from another VRF\n"
6709 "Vrf routes being filtered\n"
6710 "Specify route map\n")
6712 DEFPY (bgp_imexport_vrf
,
6713 bgp_imexport_vrf_cmd
,
6714 "[no] import vrf NAME$import_name",
6716 "Import routes from another VRF\n"
6717 "VRF to import from\n"
6718 "The name of the VRF\n")
6720 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6721 struct listnode
*node
;
6722 struct bgp
*vrf_bgp
, *bgp_default
;
6725 bool remove
= false;
6728 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6732 if (argv_find(argv
, argc
, "no", &idx
))
6735 afi
= vpn_policy_getafi(vty
, bgp
, true);
6737 return CMD_WARNING_CONFIG_FAILED
;
6739 safi
= bgp_node_safi(vty
);
6741 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6742 && (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0))
6743 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6744 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6745 remove
? "unimport" : "import", import_name
);
6749 bgp_default
= bgp_get_default();
6751 /* Auto-create assuming the same AS */
6752 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6753 BGP_INSTANCE_TYPE_DEFAULT
);
6757 "VRF default is not configured as a bgp instance\n");
6762 vrf_bgp
= bgp_lookup_by_name(import_name
);
6764 if (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0)
6765 vrf_bgp
= bgp_default
;
6767 /* Auto-create assuming the same AS */
6768 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6772 "VRF %s is not configured as a bgp instance\n",
6779 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6781 /* Already importing from "import_vrf"? */
6782 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6784 if (strcmp(vname
, import_name
) == 0)
6788 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6794 /* This command is valid only in a bgp vrf instance or the default instance */
6795 DEFPY (bgp_imexport_vpn
,
6796 bgp_imexport_vpn_cmd
,
6797 "[no] <import|export>$direction_str vpn",
6799 "Import routes to this address-family\n"
6800 "Export routes from this address-family\n"
6801 "to/from default instance VPN RIB\n")
6803 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6810 vpn_policy_direction_t dir
;
6812 if (argv_find(argv
, argc
, "no", &idx
))
6815 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6816 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6818 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6819 return CMD_WARNING_CONFIG_FAILED
;
6822 afi
= bgp_node_afi(vty
);
6823 safi
= bgp_node_safi(vty
);
6824 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6825 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6826 return CMD_WARNING_CONFIG_FAILED
;
6829 if (!strcmp(direction_str
, "import")) {
6830 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6831 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6832 } else if (!strcmp(direction_str
, "export")) {
6833 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6834 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6836 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6837 return CMD_WARNING_CONFIG_FAILED
;
6840 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6843 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6844 if (!previous_state
) {
6845 /* trigger export current vrf */
6846 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6849 if (previous_state
) {
6850 /* trigger un-export current vrf */
6851 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6853 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6859 DEFPY (af_routetarget_import
,
6860 af_routetarget_import_cmd
,
6861 "[no] <rt|route-target> redirect import RTLIST...",
6863 "Specify route target list\n"
6864 "Specify route target list\n"
6865 "Flow-spec redirect type route target\n"
6866 "Import routes to this address-family\n"
6867 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6871 struct ecommunity
*ecom
= NULL
;
6876 if (argv_find(argv
, argc
, "no", &idx
))
6879 afi
= vpn_policy_getafi(vty
, bgp
, false);
6881 return CMD_WARNING_CONFIG_FAILED
;
6884 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6885 vty_out(vty
, "%% Missing RTLIST\n");
6886 return CMD_WARNING_CONFIG_FAILED
;
6888 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6889 if (ret
!= CMD_SUCCESS
)
6894 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6895 ecommunity_free(&bgp
->vpn_policy
[afi
]
6896 .import_redirect_rtlist
);
6897 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
6898 ecommunity_dup(ecom
);
6900 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6901 ecommunity_free(&bgp
->vpn_policy
[afi
]
6902 .import_redirect_rtlist
);
6903 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
6907 ecommunity_free(&ecom
);
6912 DEFUN_NOSH (address_family_ipv4_safi
,
6913 address_family_ipv4_safi_cmd
,
6914 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6915 "Enter Address Family command mode\n"
6917 BGP_SAFI_WITH_LABEL_HELP_STR
)
6921 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6922 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6923 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6924 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6925 && safi
!= SAFI_EVPN
) {
6927 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6928 return CMD_WARNING_CONFIG_FAILED
;
6930 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6932 vty
->node
= BGP_IPV4_NODE
;
6937 DEFUN_NOSH (address_family_ipv6_safi
,
6938 address_family_ipv6_safi_cmd
,
6939 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6940 "Enter Address Family command mode\n"
6942 BGP_SAFI_WITH_LABEL_HELP_STR
)
6945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6946 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6947 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6948 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6949 && safi
!= SAFI_EVPN
) {
6951 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6952 return CMD_WARNING_CONFIG_FAILED
;
6954 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6956 vty
->node
= BGP_IPV6_NODE
;
6961 #ifdef KEEP_OLD_VPN_COMMANDS
6962 DEFUN_NOSH (address_family_vpnv4
,
6963 address_family_vpnv4_cmd
,
6964 "address-family vpnv4 [unicast]",
6965 "Enter Address Family command mode\n"
6967 "Address Family modifier\n")
6969 vty
->node
= BGP_VPNV4_NODE
;
6973 DEFUN_NOSH (address_family_vpnv6
,
6974 address_family_vpnv6_cmd
,
6975 "address-family vpnv6 [unicast]",
6976 "Enter Address Family command mode\n"
6978 "Address Family modifier\n")
6980 vty
->node
= BGP_VPNV6_NODE
;
6985 DEFUN_NOSH (address_family_evpn
,
6986 address_family_evpn_cmd
,
6987 "address-family l2vpn evpn",
6988 "Enter Address Family command mode\n"
6990 "Address Family modifier\n")
6992 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6993 vty
->node
= BGP_EVPN_NODE
;
6997 DEFUN_NOSH (exit_address_family
,
6998 exit_address_family_cmd
,
6999 "exit-address-family",
7000 "Exit from Address Family configuration mode\n")
7002 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7003 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7004 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7005 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7006 || vty
->node
== BGP_EVPN_NODE
7007 || vty
->node
== BGP_FLOWSPECV4_NODE
7008 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7009 vty
->node
= BGP_NODE
;
7013 /* Recalculate bestpath and re-advertise a prefix */
7014 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7015 const char *ip_str
, afi_t afi
, safi_t safi
,
7016 struct prefix_rd
*prd
)
7019 struct prefix match
;
7020 struct bgp_node
*rn
;
7021 struct bgp_node
*rm
;
7023 struct bgp_table
*table
;
7024 struct bgp_table
*rib
;
7026 /* BGP structure lookup. */
7028 bgp
= bgp_lookup_by_name(view_name
);
7030 vty_out(vty
, "%% Can't find BGP instance %s\n",
7035 bgp
= bgp_get_default();
7037 vty_out(vty
, "%% No BGP process is configured\n");
7042 /* Check IP address argument. */
7043 ret
= str2prefix(ip_str
, &match
);
7045 vty_out(vty
, "%% address is malformed\n");
7049 match
.family
= afi2family(afi
);
7050 rib
= bgp
->rib
[afi
][safi
];
7052 if (safi
== SAFI_MPLS_VPN
) {
7053 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7054 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7057 if ((table
= rn
->info
) != NULL
) {
7058 if ((rm
= bgp_node_match(table
, &match
))
7061 == match
.prefixlen
) {
7063 BGP_NODE_USER_CLEAR
);
7064 bgp_process(bgp
, rm
, afi
, safi
);
7066 bgp_unlock_node(rm
);
7071 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7072 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7073 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7074 bgp_process(bgp
, rn
, afi
, safi
);
7076 bgp_unlock_node(rn
);
7083 /* one clear bgp command to rule them all */
7084 DEFUN (clear_ip_bgp_all
,
7085 clear_ip_bgp_all_cmd
,
7086 "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>]",
7090 BGP_INSTANCE_HELP_STR
7092 BGP_SAFI_WITH_LABEL_HELP_STR
7094 "BGP neighbor address to clear\n"
7095 "BGP IPv6 neighbor to clear\n"
7096 "BGP neighbor on interface to clear\n"
7097 "Clear peers with the AS number\n"
7098 "Clear all external peers\n"
7099 "Clear all members of peer-group\n"
7100 "BGP peer-group name\n"
7105 "Push out prefix-list ORF and do inbound soft reconfig\n"
7110 afi_t afi
= AFI_IP6
;
7111 safi_t safi
= SAFI_UNICAST
;
7112 enum clear_sort clr_sort
= clear_peer
;
7113 enum bgp_clear_type clr_type
;
7114 char *clr_arg
= NULL
;
7118 /* clear [ip] bgp */
7119 if (argv_find(argv
, argc
, "ip", &idx
))
7122 /* [<view|vrf> VIEWVRFNAME] */
7123 if (argv_find(argv
, argc
, "view", &idx
)
7124 || argv_find(argv
, argc
, "vrf", &idx
)) {
7125 vrf
= argv
[idx
+ 1]->arg
;
7129 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7130 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7131 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7133 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7134 if (argv_find(argv
, argc
, "*", &idx
)) {
7135 clr_sort
= clear_all
;
7136 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7137 clr_sort
= clear_peer
;
7138 clr_arg
= argv
[idx
]->arg
;
7139 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7140 clr_sort
= clear_peer
;
7141 clr_arg
= argv
[idx
]->arg
;
7142 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7143 clr_sort
= clear_group
;
7145 clr_arg
= argv
[idx
]->arg
;
7146 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7147 clr_sort
= clear_peer
;
7148 clr_arg
= argv
[idx
]->arg
;
7149 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7150 clr_sort
= clear_as
;
7151 clr_arg
= argv
[idx
]->arg
;
7152 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7153 clr_sort
= clear_external
;
7156 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7157 if (argv_find(argv
, argc
, "soft", &idx
)) {
7158 if (argv_find(argv
, argc
, "in", &idx
)
7159 || argv_find(argv
, argc
, "out", &idx
))
7160 clr_type
= strmatch(argv
[idx
]->text
, "in")
7162 : BGP_CLEAR_SOFT_OUT
;
7164 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7165 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7166 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7167 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7168 : BGP_CLEAR_SOFT_IN
;
7169 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7170 clr_type
= BGP_CLEAR_SOFT_OUT
;
7172 clr_type
= BGP_CLEAR_SOFT_NONE
;
7174 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7177 DEFUN (clear_ip_bgp_prefix
,
7178 clear_ip_bgp_prefix_cmd
,
7179 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7183 BGP_INSTANCE_HELP_STR
7184 "Clear bestpath and re-advertise\n"
7188 char *prefix
= NULL
;
7192 /* [<view|vrf> VIEWVRFNAME] */
7193 if (argv_find(argv
, argc
, "VIEWVRFNAME", &idx
))
7194 vrf
= argv
[idx
]->arg
;
7196 prefix
= argv
[argc
- 1]->arg
;
7198 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7201 DEFUN (clear_bgp_ipv6_safi_prefix
,
7202 clear_bgp_ipv6_safi_prefix_cmd
,
7203 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7209 "Clear bestpath and re-advertise\n"
7213 int idx_ipv6_prefix
= 0;
7214 safi_t safi
= SAFI_UNICAST
;
7215 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7216 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7218 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7219 return bgp_clear_prefix(
7220 vty
, NULL
, prefix
, AFI_IP6
,
7224 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7225 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7226 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7230 BGP_INSTANCE_HELP_STR
7233 "Clear bestpath and re-advertise\n"
7238 int idx_ipv6_prefix
= 0;
7239 safi_t safi
= SAFI_UNICAST
;
7240 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7241 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7242 /* [<view|vrf> VIEWVRFNAME] */
7243 char *vrfview
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx_word
) ?
7244 argv
[idx_word
]->arg
: NULL
;
7246 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7248 return bgp_clear_prefix(
7249 vty
, vrfview
, prefix
,
7250 AFI_IP6
, safi
, NULL
);
7253 DEFUN (show_bgp_views
,
7255 "show [ip] bgp views",
7259 "Show the defined BGP views\n")
7261 struct list
*inst
= bm
->bgp
;
7262 struct listnode
*node
;
7265 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7266 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7270 vty_out(vty
, "Defined BGP views:\n");
7271 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7273 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7275 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7282 DEFUN (show_bgp_vrfs
,
7284 "show [ip] bgp vrfs [json]",
7291 char buf
[ETHER_ADDR_STRLEN
];
7292 struct list
*inst
= bm
->bgp
;
7293 struct listnode
*node
;
7295 uint8_t uj
= use_json(argc
, argv
);
7296 json_object
*json
= NULL
;
7297 json_object
*json_vrfs
= NULL
;
7300 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7301 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7306 json
= json_object_new_object();
7307 json_vrfs
= json_object_new_object();
7310 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7311 const char *name
, *type
;
7313 struct listnode
*node
, *nnode
;
7314 int peers_cfg
, peers_estb
;
7315 json_object
*json_vrf
= NULL
;
7318 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7322 if (!uj
&& count
== 1)
7324 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7325 "Type", "Id", "routerId", "#PeersVfg",
7326 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7328 peers_cfg
= peers_estb
= 0;
7330 json_vrf
= json_object_new_object();
7333 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7334 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7337 if (peer
->status
== Established
)
7341 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7351 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7353 : (int64_t)bgp
->vrf_id
;
7354 json_object_string_add(json_vrf
, "type", type
);
7355 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7356 json_object_string_add(json_vrf
, "routerId",
7357 inet_ntoa(bgp
->router_id
));
7358 json_object_int_add(json_vrf
, "numConfiguredPeers",
7360 json_object_int_add(json_vrf
, "numEstablishedPeers",
7363 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7364 json_object_string_add(
7366 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7367 json_object_object_add(json_vrfs
, name
, json_vrf
);
7370 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7372 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7374 inet_ntoa(bgp
->router_id
), peers_cfg
,
7375 peers_estb
, name
, bgp
->l3vni
,
7376 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7380 json_object_object_add(json
, "vrfs", json_vrfs
);
7382 json_object_int_add(json
, "totalVrfs", count
);
7384 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7385 json
, JSON_C_TO_STRING_PRETTY
));
7386 json_object_free(json
);
7390 "\nTotal number of VRFs (including default): %d\n",
7397 static void show_address_entry(struct hash_backet
*backet
, void *args
)
7399 struct vty
*vty
= (struct vty
*)args
;
7400 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
7402 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
7406 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7408 struct vty
*vty
= (struct vty
*)args
;
7409 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7411 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7415 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7417 vty_out(vty
, "self nexthop database:\n");
7418 hash_iterate(bgp
->address_hash
,
7419 (void (*)(struct hash_backet
*, void *))show_address_entry
,
7422 vty_out(vty
, "Tunnel-ip database:\n");
7423 hash_iterate(bgp
->tip_hash
,
7424 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7428 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7429 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7430 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7431 "martian next-hops\n"
7432 "martian next-hop database\n")
7434 struct bgp
*bgp
= NULL
;
7437 if (argv_find(argv
, argc
, "view", &idx
)
7438 || argv_find(argv
, argc
, "vrf", &idx
))
7439 bgp
= bgp_lookup_by_name(argv
[idx
+ 1]->arg
);
7441 bgp
= bgp_get_default();
7444 vty_out(vty
, "%% No BGP process is configured\n");
7447 bgp_show_martian_nexthops(vty
, bgp
);
7452 DEFUN (show_bgp_memory
,
7453 show_bgp_memory_cmd
,
7454 "show [ip] bgp memory",
7458 "Global BGP memory statistics\n")
7460 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7461 unsigned long count
;
7463 /* RIB related usage stats */
7464 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7465 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7466 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7467 count
* sizeof(struct bgp_node
)));
7469 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7470 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7471 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7472 count
* sizeof(struct bgp_info
)));
7473 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7474 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7476 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7477 count
* sizeof(struct bgp_info_extra
)));
7479 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7480 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7481 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7482 count
* sizeof(struct bgp_static
)));
7484 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7485 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7486 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7487 count
* sizeof(struct bpacket
)));
7490 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7491 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7492 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7493 count
* sizeof(struct bgp_adj_in
)));
7494 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7495 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7496 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7497 count
* sizeof(struct bgp_adj_out
)));
7499 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7500 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7502 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7503 count
* sizeof(struct bgp_nexthop_cache
)));
7505 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7506 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7508 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7509 count
* sizeof(struct bgp_damp_info
)));
7512 count
= attr_count();
7513 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7514 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7515 count
* sizeof(struct attr
)));
7517 if ((count
= attr_unknown_count()))
7518 vty_out(vty
, "%ld unknown attributes\n", count
);
7520 /* AS_PATH attributes */
7521 count
= aspath_count();
7522 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7523 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7524 count
* sizeof(struct aspath
)));
7526 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7527 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7528 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7529 count
* sizeof(struct assegment
)));
7531 /* Other attributes */
7532 if ((count
= community_count()))
7533 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7534 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7535 count
* sizeof(struct community
)));
7536 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7537 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7538 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7539 count
* sizeof(struct ecommunity
)));
7540 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7542 "%ld BGP large-community entries, using %s of memory\n",
7543 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7544 count
* sizeof(struct lcommunity
)));
7546 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7547 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7548 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7549 count
* sizeof(struct cluster_list
)));
7551 /* Peer related usage */
7552 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7553 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7554 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7555 count
* sizeof(struct peer
)));
7557 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7558 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7559 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7560 count
* sizeof(struct peer_group
)));
7563 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7564 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7565 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7566 count
* sizeof(struct hash
)));
7567 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7568 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7569 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7570 count
* sizeof(struct hash_backet
)));
7571 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7572 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7573 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7574 count
* sizeof(regex_t
)));
7578 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7580 json_object
*bestpath
= json_object_new_object();
7582 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7583 json_object_string_add(bestpath
, "asPath", "ignore");
7585 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7586 json_object_string_add(bestpath
, "asPath", "confed");
7588 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7589 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7590 json_object_string_add(bestpath
, "multiPathRelax",
7593 json_object_string_add(bestpath
, "multiPathRelax",
7596 json_object_string_add(bestpath
, "multiPathRelax", "false");
7598 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7599 json_object_string_add(bestpath
, "compareRouterId", "true");
7600 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7601 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7602 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7603 json_object_string_add(bestpath
, "med", "confed");
7604 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7605 json_object_string_add(bestpath
, "med",
7606 "missing-as-worst");
7608 json_object_string_add(bestpath
, "med", "true");
7611 json_object_object_add(json
, "bestPath", bestpath
);
7614 /* Show BGP peer's summary information. */
7615 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7616 uint8_t use_json
, json_object
*json
)
7619 struct listnode
*node
, *nnode
;
7620 unsigned int count
= 0, dn_count
= 0;
7621 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7622 char neighbor_buf
[VTY_BUFSIZ
];
7623 int neighbor_col_default_width
= 16;
7625 int max_neighbor_width
= 0;
7627 json_object
*json_peer
= NULL
;
7628 json_object
*json_peers
= NULL
;
7630 /* labeled-unicast routes are installed in the unicast table so in order
7632 * display the correct PfxRcd value we must look at SAFI_UNICAST
7634 if (safi
== SAFI_LABELED_UNICAST
)
7635 pfx_rcd_safi
= SAFI_UNICAST
;
7637 pfx_rcd_safi
= safi
;
7641 json
= json_object_new_object();
7643 json_peers
= json_object_new_object();
7645 /* Loop over all neighbors that will be displayed to determine
7647 * characters are needed for the Neighbor column
7649 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7650 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7653 if (peer
->afc
[afi
][safi
]) {
7654 memset(dn_flag
, '\0', sizeof(dn_flag
));
7655 if (peer_dynamic_neighbor(peer
))
7659 && bgp_flag_check(bgp
,
7660 BGP_FLAG_SHOW_HOSTNAME
))
7661 sprintf(neighbor_buf
, "%s%s(%s) ",
7662 dn_flag
, peer
->hostname
,
7665 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7668 len
= strlen(neighbor_buf
);
7670 if (len
> max_neighbor_width
)
7671 max_neighbor_width
= len
;
7675 /* Originally we displayed the Neighbor column as 16
7676 * characters wide so make that the default
7678 if (max_neighbor_width
< neighbor_col_default_width
)
7679 max_neighbor_width
= neighbor_col_default_width
;
7682 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7683 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7686 if (!peer
->afc
[afi
][safi
])
7691 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7694 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7696 : (int64_t)bgp
->vrf_id
;
7698 /* Usage summary and header */
7700 json_object_string_add(
7702 inet_ntoa(bgp
->router_id
));
7703 json_object_int_add(json
, "as", bgp
->as
);
7704 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7705 json_object_string_add(
7708 == BGP_INSTANCE_TYPE_DEFAULT
)
7713 "BGP router identifier %s, local AS number %u vrf-id %d",
7714 inet_ntoa(bgp
->router_id
), bgp
->as
,
7715 bgp
->vrf_id
== VRF_UNKNOWN
7717 : (int)bgp
->vrf_id
);
7721 if (bgp_update_delay_configured(bgp
)) {
7723 json_object_int_add(
7724 json
, "updateDelayLimit",
7725 bgp
->v_update_delay
);
7727 if (bgp
->v_update_delay
7728 != bgp
->v_establish_wait
)
7729 json_object_int_add(
7731 "updateDelayEstablishWait",
7732 bgp
->v_establish_wait
);
7734 if (bgp_update_delay_active(bgp
)) {
7735 json_object_string_add(
7737 "updateDelayFirstNeighbor",
7738 bgp
->update_delay_begin_time
);
7739 json_object_boolean_true_add(
7741 "updateDelayInProgress");
7743 if (bgp
->update_delay_over
) {
7744 json_object_string_add(
7746 "updateDelayFirstNeighbor",
7747 bgp
->update_delay_begin_time
);
7748 json_object_string_add(
7750 "updateDelayBestpathResumed",
7751 bgp
->update_delay_end_time
);
7752 json_object_string_add(
7754 "updateDelayZebraUpdateResume",
7755 bgp
->update_delay_zebra_resume_time
);
7756 json_object_string_add(
7758 "updateDelayPeerUpdateResume",
7759 bgp
->update_delay_peers_resume_time
);
7764 "Read-only mode update-delay limit: %d seconds\n",
7765 bgp
->v_update_delay
);
7766 if (bgp
->v_update_delay
7767 != bgp
->v_establish_wait
)
7769 " Establish wait: %d seconds\n",
7770 bgp
->v_establish_wait
);
7772 if (bgp_update_delay_active(bgp
)) {
7774 " First neighbor established: %s\n",
7775 bgp
->update_delay_begin_time
);
7777 " Delay in progress\n");
7779 if (bgp
->update_delay_over
) {
7781 " First neighbor established: %s\n",
7782 bgp
->update_delay_begin_time
);
7784 " Best-paths resumed: %s\n",
7785 bgp
->update_delay_end_time
);
7787 " zebra update resumed: %s\n",
7788 bgp
->update_delay_zebra_resume_time
);
7790 " peers update resumed: %s\n",
7791 bgp
->update_delay_peers_resume_time
);
7798 if (bgp_maxmed_onstartup_configured(bgp
)
7799 && bgp
->maxmed_active
)
7800 json_object_boolean_true_add(
7801 json
, "maxMedOnStartup");
7802 if (bgp
->v_maxmed_admin
)
7803 json_object_boolean_true_add(
7804 json
, "maxMedAdministrative");
7806 json_object_int_add(
7807 json
, "tableVersion",
7808 bgp_table_version(bgp
->rib
[afi
][safi
]));
7810 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7811 json_object_int_add(json
, "ribCount", ents
);
7812 json_object_int_add(
7814 ents
* sizeof(struct bgp_node
));
7816 ents
= listcount(bgp
->peer
);
7817 json_object_int_add(json
, "peerCount", ents
);
7818 json_object_int_add(json
, "peerMemory",
7819 ents
* sizeof(struct peer
));
7821 if ((ents
= listcount(bgp
->group
))) {
7822 json_object_int_add(
7823 json
, "peerGroupCount", ents
);
7824 json_object_int_add(
7825 json
, "peerGroupMemory",
7826 ents
* sizeof(struct
7830 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7831 BGP_CONFIG_DAMPENING
))
7832 json_object_boolean_true_add(
7833 json
, "dampeningEnabled");
7835 if (bgp_maxmed_onstartup_configured(bgp
)
7836 && bgp
->maxmed_active
)
7838 "Max-med on-startup active\n");
7839 if (bgp
->v_maxmed_admin
)
7841 "Max-med administrative active\n");
7843 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7844 bgp_table_version(bgp
->rib
[afi
][safi
]));
7846 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7848 "RIB entries %ld, using %s of memory\n",
7850 mtype_memstr(memstrbuf
,
7852 ents
* sizeof(struct
7855 /* Peer related usage */
7856 ents
= listcount(bgp
->peer
);
7857 vty_out(vty
, "Peers %ld, using %s of memory\n",
7860 memstrbuf
, sizeof(memstrbuf
),
7861 ents
* sizeof(struct peer
)));
7863 if ((ents
= listcount(bgp
->group
)))
7865 "Peer groups %ld, using %s of memory\n",
7870 ents
* sizeof(struct
7873 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7874 BGP_CONFIG_DAMPENING
))
7875 vty_out(vty
, "Dampening enabled.\n");
7878 /* Subtract 8 here because 'Neighbor' is
7880 vty_out(vty
, "Neighbor");
7881 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7884 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7891 json_peer
= json_object_new_object();
7893 if (peer_dynamic_neighbor(peer
))
7894 json_object_boolean_true_add(json_peer
,
7898 json_object_string_add(json_peer
, "hostname",
7901 if (peer
->domainname
)
7902 json_object_string_add(json_peer
, "domainname",
7905 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7906 json_object_int_add(json_peer
, "version", 4);
7907 json_object_int_add(json_peer
, "msgRcvd",
7908 PEER_TOTAL_RX(peer
));
7909 json_object_int_add(json_peer
, "msgSent",
7910 PEER_TOTAL_TX(peer
));
7912 json_object_int_add(json_peer
, "tableVersion",
7913 peer
->version
[afi
][safi
]);
7914 json_object_int_add(json_peer
, "outq",
7916 json_object_int_add(json_peer
, "inq", 0);
7917 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7918 use_json
, json_peer
);
7919 json_object_int_add(json_peer
, "prefixReceivedCount",
7920 peer
->pcount
[afi
][pfx_rcd_safi
]);
7922 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7923 json_object_string_add(json_peer
, "state",
7925 else if (CHECK_FLAG(peer
->sflags
,
7926 PEER_STATUS_PREFIX_OVERFLOW
))
7927 json_object_string_add(json_peer
, "state",
7930 json_object_string_add(
7932 lookup_msg(bgp_status_msg
, peer
->status
,
7936 json_object_string_add(json_peer
, "idType",
7938 else if (peer
->su
.sa
.sa_family
== AF_INET
)
7939 json_object_string_add(json_peer
, "idType",
7941 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
7942 json_object_string_add(json_peer
, "idType",
7945 json_object_object_add(json_peers
, peer
->host
,
7948 memset(dn_flag
, '\0', sizeof(dn_flag
));
7949 if (peer_dynamic_neighbor(peer
)) {
7955 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7956 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7957 peer
->hostname
, peer
->host
);
7959 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7961 /* pad the neighbor column with spaces */
7962 if (len
< max_neighbor_width
)
7963 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7966 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
7967 peer
->as
, PEER_TOTAL_RX(peer
),
7968 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
7969 0, peer
->obuf
->count
,
7970 peer_uptime(peer
->uptime
, timebuf
,
7971 BGP_UPTIME_LEN
, 0, NULL
));
7973 if (peer
->status
== Established
)
7974 if (peer
->afc_recv
[afi
][pfx_rcd_safi
])
7975 vty_out(vty
, " %12ld",
7979 vty_out(vty
, " NoNeg");
7981 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7982 vty_out(vty
, " Idle (Admin)");
7983 else if (CHECK_FLAG(
7985 PEER_STATUS_PREFIX_OVERFLOW
))
7986 vty_out(vty
, " Idle (PfxCt)");
7988 vty_out(vty
, " %12s",
7989 lookup_msg(bgp_status_msg
,
7990 peer
->status
, NULL
));
7997 json_object_object_add(json
, "peers", json_peers
);
7999 json_object_int_add(json
, "totalPeers", count
);
8000 json_object_int_add(json
, "dynamicPeers", dn_count
);
8002 bgp_show_bestpath_json(bgp
, json
);
8004 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8005 json
, JSON_C_TO_STRING_PRETTY
));
8006 json_object_free(json
);
8009 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8013 "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n",
8014 afi_safi_print(afi
, safi
));
8016 vty_out(vty
, "No %s neighbor is configured\n",
8017 afi_safi_print(afi
, safi
));
8020 if (dn_count
&& !use_json
) {
8021 vty_out(vty
, "* - dynamic neighbor\n");
8022 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8023 dn_count
, bgp
->dynamic_neighbors_limit
);
8030 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8031 int safi
, uint8_t use_json
,
8035 int afi_wildcard
= (afi
== AFI_MAX
);
8036 int safi_wildcard
= (safi
== SAFI_MAX
);
8037 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8038 bool json_output
= false;
8040 if (use_json
&& is_wildcard
)
8041 vty_out(vty
, "{\n");
8043 afi
= 1; /* AFI_IP */
8044 while (afi
< AFI_MAX
) {
8046 safi
= 1; /* SAFI_UNICAST */
8047 while (safi
< SAFI_MAX
) {
8048 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8052 * So limit output to those afi/safi
8054 * actualy have something interesting in
8058 json
= json_object_new_object();
8061 vty_out(vty
, ",\n");
8065 vty_out(vty
, "\"%s\":",
8069 vty_out(vty
, "\n%s Summary:\n",
8074 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8086 if (use_json
&& is_wildcard
)
8087 vty_out(vty
, "}\n");
8088 else if (use_json
&& !json_output
)
8089 vty_out(vty
, "{}\n");
8092 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8093 safi_t safi
, uint8_t use_json
)
8095 struct listnode
*node
, *nnode
;
8097 json_object
*json
= NULL
;
8101 vty_out(vty
, "{\n");
8103 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8105 json
= json_object_new_object();
8108 vty_out(vty
, ",\n");
8112 vty_out(vty
, "\"%s\":",
8113 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8117 vty_out(vty
, "\nInstance %s:\n",
8118 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8122 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8126 vty_out(vty
, "}\n");
8129 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8130 safi_t safi
, uint8_t use_json
)
8135 if (strmatch(name
, "all")) {
8136 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8140 bgp
= bgp_lookup_by_name(name
);
8144 vty_out(vty
, "{}\n");
8147 "%% No such BGP instance exist\n");
8151 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8157 bgp
= bgp_get_default();
8160 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8165 /* `show [ip] bgp summary' commands. */
8166 DEFUN (show_ip_bgp_summary
,
8167 show_ip_bgp_summary_cmd
,
8168 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8172 BGP_INSTANCE_HELP_STR
8174 BGP_SAFI_WITH_LABEL_HELP_STR
8175 "Summary of BGP neighbor status\n"
8179 afi_t afi
= AFI_MAX
;
8180 safi_t safi
= SAFI_MAX
;
8185 if (argv_find(argv
, argc
, "ip", &idx
))
8187 /* [<view|vrf> VIEWVRFNAME] */
8188 if (argv_find(argv
, argc
, "view", &idx
)
8189 || argv_find(argv
, argc
, "vrf", &idx
))
8190 vrf
= argv
[++idx
]->arg
;
8191 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8192 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8193 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8196 int uj
= use_json(argc
, argv
);
8198 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8201 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8203 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8204 return "IPv4 Unicast";
8205 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8206 return "IPv4 Multicast";
8207 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8208 return "IPv4 Labeled Unicast";
8209 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8211 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8212 return "IPv4 Encap";
8213 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8214 return "IPv4 Flowspec";
8215 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8216 return "IPv6 Unicast";
8217 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8218 return "IPv6 Multicast";
8219 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8220 return "IPv6 Labeled Unicast";
8221 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8223 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8224 return "IPv6 Encap";
8225 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8226 return "IPv6 Flowspec";
8227 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8228 return "L2VPN EVPN";
8234 * Please note that we have intentionally camelCased
8235 * the return strings here. So if you want
8236 * to use this function, please ensure you
8237 * are doing this within json output
8239 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8241 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8242 return "ipv4Unicast";
8243 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8244 return "ipv4Multicast";
8245 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8246 return "ipv4LabeledUnicast";
8247 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8249 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8251 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8252 return "ipv4Flowspec";
8253 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8254 return "ipv6Unicast";
8255 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8256 return "ipv6Multicast";
8257 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8258 return "ipv6LabeledUnicast";
8259 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8261 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8263 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8264 return "ipv6Flowspec";
8265 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8271 /* Show BGP peer's information. */
8272 enum show_type
{ show_all
, show_peer
};
8274 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8275 afi_t afi
, safi_t safi
,
8276 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8277 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8278 uint8_t use_json
, json_object
*json_pref
)
8281 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8282 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8284 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8285 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8286 json_object_string_add(json_pref
, "sendMode",
8287 "advertisedAndReceived");
8288 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8289 json_object_string_add(json_pref
, "sendMode",
8291 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8292 json_object_string_add(json_pref
, "sendMode",
8295 vty_out(vty
, " Send-mode: ");
8296 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8297 vty_out(vty
, "advertised");
8298 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8299 vty_out(vty
, "%sreceived",
8300 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8309 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8310 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8312 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8313 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8314 json_object_string_add(json_pref
, "recvMode",
8315 "advertisedAndReceived");
8316 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8317 json_object_string_add(json_pref
, "recvMode",
8319 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8320 json_object_string_add(json_pref
, "recvMode",
8323 vty_out(vty
, " Receive-mode: ");
8324 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8325 vty_out(vty
, "advertised");
8326 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8327 vty_out(vty
, "%sreceived",
8328 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8337 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8338 safi_t safi
, uint8_t use_json
,
8339 json_object
*json_neigh
)
8341 struct bgp_filter
*filter
;
8342 struct peer_af
*paf
;
8343 char orf_pfx_name
[BUFSIZ
];
8345 json_object
*json_af
= NULL
;
8346 json_object
*json_prefA
= NULL
;
8347 json_object
*json_prefB
= NULL
;
8348 json_object
*json_addr
= NULL
;
8351 json_addr
= json_object_new_object();
8352 json_af
= json_object_new_object();
8353 filter
= &p
->filter
[afi
][safi
];
8355 if (peer_group_active(p
))
8356 json_object_string_add(json_addr
, "peerGroupMember",
8359 paf
= peer_af_find(p
, afi
, safi
);
8360 if (paf
&& PAF_SUBGRP(paf
)) {
8361 json_object_int_add(json_addr
, "updateGroupId",
8362 PAF_UPDGRP(paf
)->id
);
8363 json_object_int_add(json_addr
, "subGroupId",
8364 PAF_SUBGRP(paf
)->id
);
8365 json_object_int_add(json_addr
, "packetQueueLength",
8366 bpacket_queue_virtual_length(paf
));
8369 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8370 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8371 PEER_CAP_ORF_PREFIX_SM_RCV
)
8372 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8373 PEER_CAP_ORF_PREFIX_RM_ADV
)
8374 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8375 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8376 json_object_int_add(json_af
, "orfType",
8378 json_prefA
= json_object_new_object();
8379 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8380 PEER_CAP_ORF_PREFIX_SM_ADV
,
8381 PEER_CAP_ORF_PREFIX_RM_ADV
,
8382 PEER_CAP_ORF_PREFIX_SM_RCV
,
8383 PEER_CAP_ORF_PREFIX_RM_RCV
,
8384 use_json
, json_prefA
);
8385 json_object_object_add(json_af
, "orfPrefixList",
8389 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8390 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8391 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8392 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8393 PEER_CAP_ORF_PREFIX_RM_ADV
)
8394 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8395 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8396 json_object_int_add(json_af
, "orfOldType",
8397 ORF_TYPE_PREFIX_OLD
);
8398 json_prefB
= json_object_new_object();
8399 bgp_show_peer_afi_orf_cap(
8400 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8401 PEER_CAP_ORF_PREFIX_RM_ADV
,
8402 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8403 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8405 json_object_object_add(json_af
, "orfOldPrefixList",
8409 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8410 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8411 PEER_CAP_ORF_PREFIX_SM_RCV
)
8412 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8413 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8414 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8415 PEER_CAP_ORF_PREFIX_RM_ADV
)
8416 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8417 PEER_CAP_ORF_PREFIX_RM_RCV
)
8418 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8419 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8420 json_object_object_add(json_addr
, "afDependentCap",
8423 json_object_free(json_af
);
8425 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8426 orf_pfx_count
= prefix_bgp_show_prefix_list(
8427 NULL
, afi
, orf_pfx_name
, use_json
);
8429 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8430 PEER_STATUS_ORF_PREFIX_SEND
)
8432 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8433 PEER_STATUS_ORF_PREFIX_SEND
))
8434 json_object_boolean_true_add(json_neigh
,
8437 json_object_int_add(json_addr
, "orfRecvCounter",
8440 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8441 PEER_STATUS_ORF_WAIT_REFRESH
))
8442 json_object_string_add(
8443 json_addr
, "orfFirstUpdate",
8444 "deferredUntilORFOrRouteRefreshRecvd");
8446 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8447 PEER_FLAG_REFLECTOR_CLIENT
))
8448 json_object_boolean_true_add(json_addr
,
8449 "routeReflectorClient");
8450 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8451 PEER_FLAG_RSERVER_CLIENT
))
8452 json_object_boolean_true_add(json_addr
,
8453 "routeServerClient");
8454 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8455 json_object_boolean_true_add(json_addr
,
8456 "inboundSoftConfigPermit");
8458 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8459 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8460 json_object_boolean_true_add(
8462 "privateAsNumsAllReplacedInUpdatesToNbr");
8463 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8464 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8465 json_object_boolean_true_add(
8467 "privateAsNumsReplacedInUpdatesToNbr");
8468 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8469 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8470 json_object_boolean_true_add(
8472 "privateAsNumsAllRemovedInUpdatesToNbr");
8473 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8474 PEER_FLAG_REMOVE_PRIVATE_AS
))
8475 json_object_boolean_true_add(
8477 "privateAsNumsRemovedInUpdatesToNbr");
8479 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8480 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8481 json_object_boolean_true_add(json_addr
,
8482 "addpathTxAllPaths");
8484 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8485 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8486 json_object_boolean_true_add(json_addr
,
8487 "addpathTxBestpathPerAS");
8489 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8490 json_object_string_add(json_addr
,
8491 "overrideASNsInOutboundUpdates",
8492 "ifAspathEqualRemoteAs");
8494 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8495 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8496 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8497 json_object_boolean_true_add(json_addr
,
8498 "routerAlwaysNextHop");
8499 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8500 PEER_FLAG_AS_PATH_UNCHANGED
))
8501 json_object_boolean_true_add(
8502 json_addr
, "unchangedAsPathPropogatedToNbr");
8503 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8504 PEER_FLAG_NEXTHOP_UNCHANGED
))
8505 json_object_boolean_true_add(
8506 json_addr
, "unchangedNextHopPropogatedToNbr");
8507 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8508 json_object_boolean_true_add(
8509 json_addr
, "unchangedMedPropogatedToNbr");
8510 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8511 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8512 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8513 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8514 PEER_FLAG_SEND_COMMUNITY
)
8515 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8516 PEER_FLAG_SEND_EXT_COMMUNITY
))
8517 json_object_string_add(json_addr
,
8518 "commAttriSentToNbr",
8519 "extendedAndStandard");
8520 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8521 PEER_FLAG_SEND_EXT_COMMUNITY
))
8522 json_object_string_add(json_addr
,
8523 "commAttriSentToNbr",
8526 json_object_string_add(json_addr
,
8527 "commAttriSentToNbr",
8530 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8531 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8532 if (p
->default_rmap
[afi
][safi
].name
)
8533 json_object_string_add(
8534 json_addr
, "defaultRouteMap",
8535 p
->default_rmap
[afi
][safi
].name
);
8537 if (paf
&& PAF_SUBGRP(paf
)
8538 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8539 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8540 json_object_boolean_true_add(json_addr
,
8543 json_object_boolean_true_add(json_addr
,
8547 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8548 if (is_evpn_enabled())
8549 json_object_boolean_true_add(
8550 json_addr
, "advertiseAllVnis");
8553 if (filter
->plist
[FILTER_IN
].name
8554 || filter
->dlist
[FILTER_IN
].name
8555 || filter
->aslist
[FILTER_IN
].name
8556 || filter
->map
[RMAP_IN
].name
)
8557 json_object_boolean_true_add(json_addr
,
8558 "inboundPathPolicyConfig");
8559 if (filter
->plist
[FILTER_OUT
].name
8560 || filter
->dlist
[FILTER_OUT
].name
8561 || filter
->aslist
[FILTER_OUT
].name
8562 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8563 json_object_boolean_true_add(
8564 json_addr
, "outboundPathPolicyConfig");
8567 if (filter
->plist
[FILTER_IN
].name
)
8568 json_object_string_add(json_addr
,
8569 "incomingUpdatePrefixFilterList",
8570 filter
->plist
[FILTER_IN
].name
);
8571 if (filter
->plist
[FILTER_OUT
].name
)
8572 json_object_string_add(json_addr
,
8573 "outgoingUpdatePrefixFilterList",
8574 filter
->plist
[FILTER_OUT
].name
);
8576 /* distribute-list */
8577 if (filter
->dlist
[FILTER_IN
].name
)
8578 json_object_string_add(
8579 json_addr
, "incomingUpdateNetworkFilterList",
8580 filter
->dlist
[FILTER_IN
].name
);
8581 if (filter
->dlist
[FILTER_OUT
].name
)
8582 json_object_string_add(
8583 json_addr
, "outgoingUpdateNetworkFilterList",
8584 filter
->dlist
[FILTER_OUT
].name
);
8587 if (filter
->aslist
[FILTER_IN
].name
)
8588 json_object_string_add(json_addr
,
8589 "incomingUpdateAsPathFilterList",
8590 filter
->aslist
[FILTER_IN
].name
);
8591 if (filter
->aslist
[FILTER_OUT
].name
)
8592 json_object_string_add(json_addr
,
8593 "outgoingUpdateAsPathFilterList",
8594 filter
->aslist
[FILTER_OUT
].name
);
8597 if (filter
->map
[RMAP_IN
].name
)
8598 json_object_string_add(
8599 json_addr
, "routeMapForIncomingAdvertisements",
8600 filter
->map
[RMAP_IN
].name
);
8601 if (filter
->map
[RMAP_OUT
].name
)
8602 json_object_string_add(
8603 json_addr
, "routeMapForOutgoingAdvertisements",
8604 filter
->map
[RMAP_OUT
].name
);
8606 /* unsuppress-map */
8607 if (filter
->usmap
.name
)
8608 json_object_string_add(json_addr
,
8609 "selectiveUnsuppressRouteMap",
8610 filter
->usmap
.name
);
8612 /* Receive prefix count */
8613 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8614 p
->pcount
[afi
][safi
]);
8616 /* Maximum prefix */
8617 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8618 json_object_int_add(json_addr
, "prefixAllowedMax",
8619 p
->pmax
[afi
][safi
]);
8620 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8621 PEER_FLAG_MAX_PREFIX_WARNING
))
8622 json_object_boolean_true_add(
8623 json_addr
, "prefixAllowedMaxWarning");
8624 json_object_int_add(json_addr
,
8625 "prefixAllowedWarningThresh",
8626 p
->pmax_threshold
[afi
][safi
]);
8627 if (p
->pmax_restart
[afi
][safi
])
8628 json_object_int_add(
8630 "prefixAllowedRestartIntervalMsecs",
8631 p
->pmax_restart
[afi
][safi
] * 60000);
8633 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8637 filter
= &p
->filter
[afi
][safi
];
8639 vty_out(vty
, " For address family: %s\n",
8640 afi_safi_print(afi
, safi
));
8642 if (peer_group_active(p
))
8643 vty_out(vty
, " %s peer-group member\n",
8646 paf
= peer_af_find(p
, afi
, safi
);
8647 if (paf
&& PAF_SUBGRP(paf
)) {
8648 vty_out(vty
, " Update group %" PRIu64
8649 ", subgroup %" PRIu64
"\n",
8650 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8651 vty_out(vty
, " Packet Queue length %d\n",
8652 bpacket_queue_virtual_length(paf
));
8654 vty_out(vty
, " Not part of any update group\n");
8656 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8657 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8658 PEER_CAP_ORF_PREFIX_SM_RCV
)
8659 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8660 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8661 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8662 PEER_CAP_ORF_PREFIX_RM_ADV
)
8663 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8664 PEER_CAP_ORF_PREFIX_RM_RCV
)
8665 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8666 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8667 vty_out(vty
, " AF-dependant capabilities:\n");
8669 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8670 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8671 PEER_CAP_ORF_PREFIX_SM_RCV
)
8672 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8673 PEER_CAP_ORF_PREFIX_RM_ADV
)
8674 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8675 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8677 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8679 bgp_show_peer_afi_orf_cap(
8680 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8681 PEER_CAP_ORF_PREFIX_RM_ADV
,
8682 PEER_CAP_ORF_PREFIX_SM_RCV
,
8683 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8685 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8686 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8687 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8688 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8689 PEER_CAP_ORF_PREFIX_RM_ADV
)
8690 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8691 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8693 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8694 ORF_TYPE_PREFIX_OLD
);
8695 bgp_show_peer_afi_orf_cap(
8696 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8697 PEER_CAP_ORF_PREFIX_RM_ADV
,
8698 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8699 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8702 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8703 orf_pfx_count
= prefix_bgp_show_prefix_list(
8704 NULL
, afi
, orf_pfx_name
, use_json
);
8706 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8707 PEER_STATUS_ORF_PREFIX_SEND
)
8709 vty_out(vty
, " Outbound Route Filter (ORF):");
8710 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8711 PEER_STATUS_ORF_PREFIX_SEND
))
8712 vty_out(vty
, " sent;");
8714 vty_out(vty
, " received (%d entries)",
8718 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8719 PEER_STATUS_ORF_WAIT_REFRESH
))
8721 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8723 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8724 PEER_FLAG_REFLECTOR_CLIENT
))
8725 vty_out(vty
, " Route-Reflector Client\n");
8726 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8727 PEER_FLAG_RSERVER_CLIENT
))
8728 vty_out(vty
, " Route-Server Client\n");
8729 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8731 " Inbound soft reconfiguration allowed\n");
8733 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8734 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8736 " Private AS numbers (all) replaced in updates to this neighbor\n");
8737 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8738 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8740 " Private AS numbers replaced in updates to this neighbor\n");
8741 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8742 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8744 " Private AS numbers (all) removed in updates to this neighbor\n");
8745 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8746 PEER_FLAG_REMOVE_PRIVATE_AS
))
8748 " Private AS numbers removed in updates to this neighbor\n");
8750 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8751 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8752 vty_out(vty
, " Advertise all paths via addpath\n");
8754 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8755 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8757 " Advertise bestpath per AS via addpath\n");
8759 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8761 " Override ASNs in outbound updates if aspath equals remote-as\n");
8763 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8764 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8765 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8766 vty_out(vty
, " NEXT_HOP is always this router\n");
8767 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8768 PEER_FLAG_AS_PATH_UNCHANGED
))
8770 " AS_PATH is propagated unchanged to this neighbor\n");
8771 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8772 PEER_FLAG_NEXTHOP_UNCHANGED
))
8774 " NEXT_HOP is propagated unchanged to this neighbor\n");
8775 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8777 " MED is propagated unchanged to this neighbor\n");
8778 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8779 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8780 PEER_FLAG_SEND_EXT_COMMUNITY
)
8781 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8782 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8784 " Community attribute sent to this neighbor");
8785 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8786 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
))
8791 vty_out(vty
, "(all)\n");
8792 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8793 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8794 vty_out(vty
, "(large)\n");
8795 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8796 PEER_FLAG_SEND_EXT_COMMUNITY
))
8797 vty_out(vty
, "(extended)\n");
8799 vty_out(vty
, "(standard)\n");
8801 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8802 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8803 vty_out(vty
, " Default information originate,");
8805 if (p
->default_rmap
[afi
][safi
].name
)
8806 vty_out(vty
, " default route-map %s%s,",
8807 p
->default_rmap
[afi
][safi
].map
? "*"
8809 p
->default_rmap
[afi
][safi
].name
);
8810 if (paf
&& PAF_SUBGRP(paf
)
8811 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8812 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8813 vty_out(vty
, " default sent\n");
8815 vty_out(vty
, " default not sent\n");
8818 /* advertise-vni-all */
8819 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8820 if (is_evpn_enabled())
8821 vty_out(vty
, " advertise-all-vni\n");
8824 if (filter
->plist
[FILTER_IN
].name
8825 || filter
->dlist
[FILTER_IN
].name
8826 || filter
->aslist
[FILTER_IN
].name
8827 || filter
->map
[RMAP_IN
].name
)
8828 vty_out(vty
, " Inbound path policy configured\n");
8829 if (filter
->plist
[FILTER_OUT
].name
8830 || filter
->dlist
[FILTER_OUT
].name
8831 || filter
->aslist
[FILTER_OUT
].name
8832 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8833 vty_out(vty
, " Outbound path policy configured\n");
8836 if (filter
->plist
[FILTER_IN
].name
)
8838 " Incoming update prefix filter list is %s%s\n",
8839 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8840 filter
->plist
[FILTER_IN
].name
);
8841 if (filter
->plist
[FILTER_OUT
].name
)
8843 " Outgoing update prefix filter list is %s%s\n",
8844 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8845 filter
->plist
[FILTER_OUT
].name
);
8847 /* distribute-list */
8848 if (filter
->dlist
[FILTER_IN
].name
)
8850 " Incoming update network filter list is %s%s\n",
8851 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8852 filter
->dlist
[FILTER_IN
].name
);
8853 if (filter
->dlist
[FILTER_OUT
].name
)
8855 " Outgoing update network filter list is %s%s\n",
8856 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8857 filter
->dlist
[FILTER_OUT
].name
);
8860 if (filter
->aslist
[FILTER_IN
].name
)
8862 " Incoming update AS path filter list is %s%s\n",
8863 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8864 filter
->aslist
[FILTER_IN
].name
);
8865 if (filter
->aslist
[FILTER_OUT
].name
)
8867 " Outgoing update AS path filter list is %s%s\n",
8868 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8869 filter
->aslist
[FILTER_OUT
].name
);
8872 if (filter
->map
[RMAP_IN
].name
)
8874 " Route map for incoming advertisements is %s%s\n",
8875 filter
->map
[RMAP_IN
].map
? "*" : "",
8876 filter
->map
[RMAP_IN
].name
);
8877 if (filter
->map
[RMAP_OUT
].name
)
8879 " Route map for outgoing advertisements is %s%s\n",
8880 filter
->map
[RMAP_OUT
].map
? "*" : "",
8881 filter
->map
[RMAP_OUT
].name
);
8883 /* unsuppress-map */
8884 if (filter
->usmap
.name
)
8886 " Route map for selective unsuppress is %s%s\n",
8887 filter
->usmap
.map
? "*" : "",
8888 filter
->usmap
.name
);
8890 /* Receive prefix count */
8891 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8893 /* Maximum prefix */
8894 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8895 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8897 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8898 PEER_FLAG_MAX_PREFIX_WARNING
)
8901 vty_out(vty
, " Threshold for warning message %d%%",
8902 p
->pmax_threshold
[afi
][safi
]);
8903 if (p
->pmax_restart
[afi
][safi
])
8904 vty_out(vty
, ", restart interval %d min",
8905 p
->pmax_restart
[afi
][safi
]);
8913 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, uint8_t use_json
,
8917 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8918 char timebuf
[BGP_UPTIME_LEN
];
8920 const char *subcode_str
;
8921 const char *code_str
;
8926 json_object
*json_neigh
= NULL
;
8932 json_neigh
= json_object_new_object();
8934 memset(dn_flag
, '\0', sizeof(dn_flag
));
8935 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
8939 if (p
->conf_if
) /* Configured interface name. */
8940 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
8941 BGP_PEER_SU_UNSPEC(p
)
8943 : sockunion2str(&p
->su
, buf
,
8945 else /* Configured IP address. */
8946 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
8951 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
8952 json_object_string_add(json_neigh
, "bgpNeighborAddr",
8954 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
8955 json_object_string_add(
8956 json_neigh
, "bgpNeighborAddr",
8957 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
8959 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8961 if (p
->change_local_as
)
8962 json_object_int_add(json_neigh
, "localAs",
8963 p
->change_local_as
);
8965 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8967 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8968 json_object_boolean_true_add(json_neigh
,
8969 "localAsNoPrepend");
8971 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8972 json_object_boolean_true_add(json_neigh
,
8973 "localAsReplaceAs");
8975 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
8976 || (p
->as_type
== AS_INTERNAL
))
8977 vty_out(vty
, "remote AS %u, ", p
->as
);
8979 vty_out(vty
, "remote AS Unspecified, ");
8980 vty_out(vty
, "local AS %u%s%s, ",
8981 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
8982 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
8985 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
8989 /* peer type internal, external, confed-internal or confed-external */
8990 if (p
->as
== p
->local_as
) {
8992 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8993 json_object_boolean_true_add(
8994 json_neigh
, "nbrConfedInternalLink");
8996 json_object_boolean_true_add(json_neigh
,
8999 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9000 vty_out(vty
, "confed-internal link\n");
9002 vty_out(vty
, "internal link\n");
9006 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9007 json_object_boolean_true_add(
9008 json_neigh
, "nbrConfedExternalLink");
9010 json_object_boolean_true_add(json_neigh
,
9013 if (bgp_confederation_peers_check(bgp
, p
->as
))
9014 vty_out(vty
, "confed-external link\n");
9016 vty_out(vty
, "external link\n");
9023 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9025 vty_out(vty
, " Description: %s\n", p
->desc
);
9031 json_object_string_add(json_neigh
, "hostname",
9035 json_object_string_add(json_neigh
, "domainname",
9038 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9039 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9042 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9049 json_object_string_add(json_neigh
, "peerGroup",
9053 struct prefix prefix
, *range
= NULL
;
9055 sockunion2hostprefix(&(p
->su
), &prefix
);
9056 range
= peer_group_lookup_dynamic_neighbor_range(
9060 prefix2str(range
, buf1
, sizeof(buf1
));
9061 json_object_string_add(
9063 "peerSubnetRangeGroup", buf1
);
9068 " Member of peer-group %s for session parameters\n",
9072 struct prefix prefix
, *range
= NULL
;
9074 sockunion2hostprefix(&(p
->su
), &prefix
);
9075 range
= peer_group_lookup_dynamic_neighbor_range(
9079 prefix2str(range
, buf1
, sizeof(buf1
));
9081 " Belongs to the subnet range group: %s\n",
9089 /* Administrative shutdown. */
9090 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9091 json_object_boolean_true_add(json_neigh
,
9095 json_object_int_add(json_neigh
, "bgpVersion", 4);
9096 json_object_string_add(
9097 json_neigh
, "remoteRouterId",
9098 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9101 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9102 && bgp_confederation_peers_check(bgp
, p
->as
))
9103 json_object_boolean_true_add(json_neigh
,
9107 json_object_string_add(
9108 json_neigh
, "bgpState",
9109 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9111 if (p
->status
== Established
) {
9114 uptime
= bgp_clock();
9115 uptime
-= p
->uptime
;
9116 epoch_tbuf
= time(NULL
) - uptime
;
9118 #if defined(VERSION_TYPE_DEV) && CONFDATE > 20200101
9120 "bgpTimerUp should be deprecated and can be removed now");
9123 * bgpTimerUp was miliseconds that was accurate
9124 * up to 1 day, then the value returned
9125 * became garbage. So in order to provide
9126 * some level of backwards compatability,
9127 * we still provde the data, but now
9128 * we are returning the correct value
9129 * and also adding a new bgpTimerUpMsec
9130 * which will allow us to deprecate
9133 json_object_int_add(json_neigh
, "bgpTimerUp",
9135 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9137 json_object_string_add(json_neigh
, "bgpTimerUpString",
9138 peer_uptime(p
->uptime
, timebuf
,
9141 json_object_int_add(json_neigh
,
9142 "bgpTimerUpEstablishedEpoch",
9146 else if (p
->status
== Active
) {
9147 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9148 json_object_string_add(json_neigh
, "bgpStateIs",
9150 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9151 json_object_string_add(json_neigh
, "bgpStateIs",
9159 uptime
= bgp_clock();
9160 uptime
-= p
->readtime
;
9161 tm
= gmtime(&uptime
);
9162 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9163 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9164 + (tm
->tm_hour
* 3600000));
9166 uptime
= bgp_clock();
9167 uptime
-= p
->last_write
;
9168 tm
= gmtime(&uptime
);
9169 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9170 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9171 + (tm
->tm_hour
* 3600000));
9173 uptime
= bgp_clock();
9174 uptime
-= p
->update_time
;
9175 tm
= gmtime(&uptime
);
9176 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9177 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9178 + (tm
->tm_hour
* 3600000));
9180 /* Configured timer values. */
9181 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9182 p
->v_holdtime
* 1000);
9183 json_object_int_add(json_neigh
,
9184 "bgpTimerKeepAliveIntervalMsecs",
9185 p
->v_keepalive
* 1000);
9187 if (PEER_OR_GROUP_TIMER_SET(p
)) {
9188 json_object_int_add(json_neigh
,
9189 "bgpTimerConfiguredHoldTimeMsecs",
9190 p
->holdtime
* 1000);
9191 json_object_int_add(
9193 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9194 p
->keepalive
* 1000);
9195 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9196 || (bgp
->default_keepalive
9197 != BGP_DEFAULT_KEEPALIVE
)) {
9198 json_object_int_add(json_neigh
,
9199 "bgpTimerConfiguredHoldTimeMsecs",
9200 bgp
->default_holdtime
);
9201 json_object_int_add(
9203 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9204 bgp
->default_keepalive
);
9207 /* Administrative shutdown. */
9208 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9209 vty_out(vty
, " Administratively shut down\n");
9212 vty_out(vty
, " BGP version 4");
9213 vty_out(vty
, ", remote router ID %s\n",
9214 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9217 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9218 && bgp_confederation_peers_check(bgp
, p
->as
))
9220 " Neighbor under common administration\n");
9223 vty_out(vty
, " BGP state = %s",
9224 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9226 if (p
->status
== Established
)
9227 vty_out(vty
, ", up for %8s",
9228 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9231 else if (p
->status
== Active
) {
9232 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9233 vty_out(vty
, " (passive)");
9234 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9235 vty_out(vty
, " (NSF passive)");
9240 vty_out(vty
, " Last read %s",
9241 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9243 vty_out(vty
, ", Last write %s\n",
9244 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9247 /* Configured timer values. */
9249 " Hold time is %d, keepalive interval is %d seconds\n",
9250 p
->v_holdtime
, p
->v_keepalive
);
9251 if (PEER_OR_GROUP_TIMER_SET(p
)) {
9252 vty_out(vty
, " Configured hold time is %d",
9254 vty_out(vty
, ", keepalive interval is %d seconds\n",
9256 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9257 || (bgp
->default_keepalive
9258 != BGP_DEFAULT_KEEPALIVE
)) {
9259 vty_out(vty
, " Configured hold time is %d",
9260 bgp
->default_holdtime
);
9261 vty_out(vty
, ", keepalive interval is %d seconds\n",
9262 bgp
->default_keepalive
);
9266 if (p
->status
== Established
) {
9267 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9268 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9269 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9270 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9271 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9272 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9273 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9274 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9275 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9276 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9277 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9278 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9279 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9280 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9281 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9282 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9283 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9284 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9285 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9286 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9288 json_object
*json_cap
= NULL
;
9290 json_cap
= json_object_new_object();
9293 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9294 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9295 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9296 && CHECK_FLAG(p
->cap
,
9298 json_object_string_add(
9299 json_cap
, "4byteAs",
9300 "advertisedAndReceived");
9301 else if (CHECK_FLAG(p
->cap
,
9303 json_object_string_add(
9304 json_cap
, "4byteAs",
9306 else if (CHECK_FLAG(p
->cap
,
9308 json_object_string_add(
9309 json_cap
, "4byteAs",
9314 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9315 || CHECK_FLAG(p
->cap
,
9316 PEER_CAP_ADDPATH_ADV
)) {
9317 json_object
*json_add
= NULL
;
9318 const char *print_store
;
9320 json_add
= json_object_new_object();
9322 FOREACH_AFI_SAFI (afi
, safi
) {
9323 json_object
*json_sub
= NULL
;
9325 json_object_new_object();
9326 print_store
= afi_safi_print(
9332 PEER_CAP_ADDPATH_AF_TX_ADV
)
9336 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9341 PEER_CAP_ADDPATH_AF_TX_ADV
)
9346 PEER_CAP_ADDPATH_AF_TX_RCV
))
9347 json_object_boolean_true_add(
9349 "txAdvertisedAndReceived");
9355 PEER_CAP_ADDPATH_AF_TX_ADV
))
9356 json_object_boolean_true_add(
9364 PEER_CAP_ADDPATH_AF_TX_RCV
))
9365 json_object_boolean_true_add(
9373 PEER_CAP_ADDPATH_AF_RX_ADV
)
9377 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9382 PEER_CAP_ADDPATH_AF_RX_ADV
)
9387 PEER_CAP_ADDPATH_AF_RX_RCV
))
9388 json_object_boolean_true_add(
9390 "rxAdvertisedAndReceived");
9396 PEER_CAP_ADDPATH_AF_RX_ADV
))
9397 json_object_boolean_true_add(
9405 PEER_CAP_ADDPATH_AF_RX_RCV
))
9406 json_object_boolean_true_add(
9414 PEER_CAP_ADDPATH_AF_TX_ADV
)
9418 PEER_CAP_ADDPATH_AF_TX_RCV
)
9422 PEER_CAP_ADDPATH_AF_RX_ADV
)
9426 PEER_CAP_ADDPATH_AF_RX_RCV
))
9427 json_object_object_add(
9436 json_object_object_add(
9437 json_cap
, "addPath", json_add
);
9441 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9442 || CHECK_FLAG(p
->cap
,
9443 PEER_CAP_DYNAMIC_ADV
)) {
9444 if (CHECK_FLAG(p
->cap
,
9445 PEER_CAP_DYNAMIC_ADV
)
9446 && CHECK_FLAG(p
->cap
,
9447 PEER_CAP_DYNAMIC_RCV
))
9448 json_object_string_add(
9449 json_cap
, "dynamic",
9450 "advertisedAndReceived");
9451 else if (CHECK_FLAG(
9453 PEER_CAP_DYNAMIC_ADV
))
9454 json_object_string_add(
9455 json_cap
, "dynamic",
9457 else if (CHECK_FLAG(
9459 PEER_CAP_DYNAMIC_RCV
))
9460 json_object_string_add(
9461 json_cap
, "dynamic",
9465 /* Extended nexthop */
9466 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9467 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9468 json_object
*json_nxt
= NULL
;
9469 const char *print_store
;
9472 if (CHECK_FLAG(p
->cap
,
9474 && CHECK_FLAG(p
->cap
,
9476 json_object_string_add(
9479 "advertisedAndReceived");
9480 else if (CHECK_FLAG(p
->cap
,
9482 json_object_string_add(
9486 else if (CHECK_FLAG(p
->cap
,
9488 json_object_string_add(
9493 if (CHECK_FLAG(p
->cap
,
9494 PEER_CAP_ENHE_RCV
)) {
9496 json_object_new_object();
9498 for (safi
= SAFI_UNICAST
;
9499 safi
< SAFI_MAX
; safi
++) {
9504 PEER_CAP_ENHE_AF_RCV
)) {
9505 print_store
= afi_safi_print(
9508 json_object_string_add(
9514 json_object_object_add(
9516 "extendedNexthopFamililesByPeer",
9522 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9523 || CHECK_FLAG(p
->cap
,
9524 PEER_CAP_REFRESH_NEW_RCV
)
9525 || CHECK_FLAG(p
->cap
,
9526 PEER_CAP_REFRESH_OLD_RCV
)) {
9527 if (CHECK_FLAG(p
->cap
,
9528 PEER_CAP_REFRESH_ADV
)
9531 PEER_CAP_REFRESH_NEW_RCV
)
9534 PEER_CAP_REFRESH_OLD_RCV
))) {
9537 PEER_CAP_REFRESH_OLD_RCV
)
9540 PEER_CAP_REFRESH_NEW_RCV
))
9541 json_object_string_add(
9544 "advertisedAndReceivedOldNew");
9548 PEER_CAP_REFRESH_OLD_RCV
))
9549 json_object_string_add(
9552 "advertisedAndReceivedOld");
9554 json_object_string_add(
9557 "advertisedAndReceivedNew");
9562 PEER_CAP_REFRESH_ADV
))
9563 json_object_string_add(
9570 PEER_CAP_REFRESH_NEW_RCV
)
9573 PEER_CAP_REFRESH_OLD_RCV
))
9574 json_object_string_add(
9580 /* Multiprotocol Extensions */
9581 json_object
*json_multi
= NULL
;
9582 json_multi
= json_object_new_object();
9584 FOREACH_AFI_SAFI (afi
, safi
) {
9585 if (p
->afc_adv
[afi
][safi
]
9586 || p
->afc_recv
[afi
][safi
]) {
9587 json_object
*json_exten
= NULL
;
9589 json_object_new_object();
9591 if (p
->afc_adv
[afi
][safi
]
9592 && p
->afc_recv
[afi
][safi
])
9593 json_object_boolean_true_add(
9595 "advertisedAndReceived");
9596 else if (p
->afc_adv
[afi
][safi
])
9597 json_object_boolean_true_add(
9600 else if (p
->afc_recv
[afi
][safi
])
9601 json_object_boolean_true_add(
9605 json_object_object_add(
9612 json_object_object_add(
9613 json_cap
, "multiprotocolExtensions",
9616 /* Hostname capabilities */
9617 json_object
*json_hname
= NULL
;
9619 json_hname
= json_object_new_object();
9621 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9622 json_object_string_add(
9623 json_hname
, "advHostName",
9624 bgp
->peer_self
->hostname
9628 json_object_string_add(
9629 json_hname
, "advDomainName",
9630 bgp
->peer_self
->domainname
9637 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9638 json_object_string_add(
9639 json_hname
, "rcvHostName",
9640 p
->hostname
? p
->hostname
9642 json_object_string_add(
9643 json_hname
, "rcvDomainName",
9644 p
->domainname
? p
->domainname
9648 json_object_object_add(json_cap
, "hostName",
9651 /* Gracefull Restart */
9652 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9653 || CHECK_FLAG(p
->cap
,
9654 PEER_CAP_RESTART_ADV
)) {
9655 if (CHECK_FLAG(p
->cap
,
9656 PEER_CAP_RESTART_ADV
)
9657 && CHECK_FLAG(p
->cap
,
9658 PEER_CAP_RESTART_RCV
))
9659 json_object_string_add(
9662 "advertisedAndReceived");
9663 else if (CHECK_FLAG(
9665 PEER_CAP_RESTART_ADV
))
9666 json_object_string_add(
9668 "gracefulRestartCapability",
9670 else if (CHECK_FLAG(
9672 PEER_CAP_RESTART_RCV
))
9673 json_object_string_add(
9675 "gracefulRestartCapability",
9678 if (CHECK_FLAG(p
->cap
,
9679 PEER_CAP_RESTART_RCV
)) {
9680 int restart_af_count
= 0;
9681 json_object
*json_restart
=
9684 json_object_new_object();
9686 json_object_int_add(
9688 "gracefulRestartRemoteTimerMsecs",
9689 p
->v_gr_restart
* 1000);
9691 FOREACH_AFI_SAFI (afi
, safi
) {
9696 PEER_CAP_RESTART_AF_RCV
)) {
9701 json_object_new_object();
9707 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9708 json_object_boolean_true_add(
9712 json_object_object_add(
9720 if (!restart_af_count
) {
9721 json_object_string_add(
9723 "addressFamiliesByPeer",
9728 json_object_object_add(
9730 "addressFamiliesByPeer",
9734 json_object_object_add(json_neigh
,
9735 "neighborCapabilities",
9738 vty_out(vty
, " Neighbor capabilities:\n");
9741 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9742 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9743 vty_out(vty
, " 4 Byte AS:");
9744 if (CHECK_FLAG(p
->cap
,
9746 vty_out(vty
, " advertised");
9747 if (CHECK_FLAG(p
->cap
,
9749 vty_out(vty
, " %sreceived",
9759 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9760 || CHECK_FLAG(p
->cap
,
9761 PEER_CAP_ADDPATH_ADV
)) {
9762 vty_out(vty
, " AddPath:\n");
9764 FOREACH_AFI_SAFI (afi
, safi
) {
9768 PEER_CAP_ADDPATH_AF_TX_ADV
)
9772 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9783 PEER_CAP_ADDPATH_AF_TX_ADV
))
9794 PEER_CAP_ADDPATH_AF_TX_RCV
))
9801 PEER_CAP_ADDPATH_AF_TX_ADV
)
9811 PEER_CAP_ADDPATH_AF_RX_ADV
)
9815 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9826 PEER_CAP_ADDPATH_AF_RX_ADV
))
9837 PEER_CAP_ADDPATH_AF_RX_RCV
))
9844 PEER_CAP_ADDPATH_AF_RX_ADV
)
9854 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9855 || CHECK_FLAG(p
->cap
,
9856 PEER_CAP_DYNAMIC_ADV
)) {
9857 vty_out(vty
, " Dynamic:");
9858 if (CHECK_FLAG(p
->cap
,
9859 PEER_CAP_DYNAMIC_ADV
))
9860 vty_out(vty
, " advertised");
9861 if (CHECK_FLAG(p
->cap
,
9862 PEER_CAP_DYNAMIC_RCV
))
9863 vty_out(vty
, " %sreceived",
9866 PEER_CAP_DYNAMIC_ADV
)
9872 /* Extended nexthop */
9873 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9874 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9875 vty_out(vty
, " Extended nexthop:");
9876 if (CHECK_FLAG(p
->cap
,
9878 vty_out(vty
, " advertised");
9879 if (CHECK_FLAG(p
->cap
,
9881 vty_out(vty
, " %sreceived",
9889 if (CHECK_FLAG(p
->cap
,
9890 PEER_CAP_ENHE_RCV
)) {
9892 " Address families by peer:\n ");
9893 for (safi
= SAFI_UNICAST
;
9894 safi
< SAFI_MAX
; safi
++)
9899 PEER_CAP_ENHE_AF_RCV
))
9909 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9910 || CHECK_FLAG(p
->cap
,
9911 PEER_CAP_REFRESH_NEW_RCV
)
9912 || CHECK_FLAG(p
->cap
,
9913 PEER_CAP_REFRESH_OLD_RCV
)) {
9914 vty_out(vty
, " Route refresh:");
9915 if (CHECK_FLAG(p
->cap
,
9916 PEER_CAP_REFRESH_ADV
))
9917 vty_out(vty
, " advertised");
9918 if (CHECK_FLAG(p
->cap
,
9919 PEER_CAP_REFRESH_NEW_RCV
)
9922 PEER_CAP_REFRESH_OLD_RCV
))
9923 vty_out(vty
, " %sreceived(%s)",
9926 PEER_CAP_REFRESH_ADV
)
9931 PEER_CAP_REFRESH_OLD_RCV
)
9934 PEER_CAP_REFRESH_NEW_RCV
))
9938 PEER_CAP_REFRESH_OLD_RCV
)
9945 /* Multiprotocol Extensions */
9946 FOREACH_AFI_SAFI (afi
, safi
)
9947 if (p
->afc_adv
[afi
][safi
]
9948 || p
->afc_recv
[afi
][safi
]) {
9950 " Address Family %s:",
9953 if (p
->afc_adv
[afi
][safi
])
9956 if (p
->afc_recv
[afi
][safi
])
9966 /* Hostname capability */
9967 vty_out(vty
, " Hostname Capability:");
9969 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9971 " advertised (name: %s,domain name: %s)",
9972 bgp
->peer_self
->hostname
9976 bgp
->peer_self
->domainname
9981 vty_out(vty
, " not advertised");
9984 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9986 " received (name: %s,domain name: %s)",
9987 p
->hostname
? p
->hostname
9989 p
->domainname
? p
->domainname
9992 vty_out(vty
, " not received");
9997 /* Gracefull Restart */
9998 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9999 || CHECK_FLAG(p
->cap
,
10000 PEER_CAP_RESTART_ADV
)) {
10002 " Graceful Restart Capabilty:");
10003 if (CHECK_FLAG(p
->cap
,
10004 PEER_CAP_RESTART_ADV
))
10005 vty_out(vty
, " advertised");
10006 if (CHECK_FLAG(p
->cap
,
10007 PEER_CAP_RESTART_RCV
))
10008 vty_out(vty
, " %sreceived",
10011 PEER_CAP_RESTART_ADV
)
10014 vty_out(vty
, "\n");
10016 if (CHECK_FLAG(p
->cap
,
10017 PEER_CAP_RESTART_RCV
)) {
10018 int restart_af_count
= 0;
10021 " Remote Restart timer is %d seconds\n",
10024 " Address families by peer:\n ");
10026 FOREACH_AFI_SAFI (afi
, safi
)
10031 PEER_CAP_RESTART_AF_RCV
)) {
10044 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10046 : "not preserved");
10047 restart_af_count
++;
10049 if (!restart_af_count
)
10050 vty_out(vty
, "none");
10051 vty_out(vty
, "\n");
10058 /* graceful restart information */
10059 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10060 || p
->t_gr_stale
) {
10061 json_object
*json_grace
= NULL
;
10062 json_object
*json_grace_send
= NULL
;
10063 json_object
*json_grace_recv
= NULL
;
10064 int eor_send_af_count
= 0;
10065 int eor_receive_af_count
= 0;
10068 json_grace
= json_object_new_object();
10069 json_grace_send
= json_object_new_object();
10070 json_grace_recv
= json_object_new_object();
10072 if (p
->status
== Established
) {
10073 FOREACH_AFI_SAFI (afi
, safi
) {
10074 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10075 PEER_STATUS_EOR_SEND
)) {
10076 json_object_boolean_true_add(
10078 afi_safi_print(afi
,
10080 eor_send_af_count
++;
10083 FOREACH_AFI_SAFI (afi
, safi
) {
10085 p
->af_sflags
[afi
][safi
],
10086 PEER_STATUS_EOR_RECEIVED
)) {
10087 json_object_boolean_true_add(
10089 afi_safi_print(afi
,
10091 eor_receive_af_count
++;
10096 json_object_object_add(json_grace
, "endOfRibSend",
10098 json_object_object_add(json_grace
, "endOfRibRecv",
10101 if (p
->t_gr_restart
)
10102 json_object_int_add(json_grace
,
10103 "gracefulRestartTimerMsecs",
10104 thread_timer_remain_second(
10109 json_object_int_add(
10111 "gracefulStalepathTimerMsecs",
10112 thread_timer_remain_second(
10116 json_object_object_add(
10117 json_neigh
, "gracefulRestartInfo", json_grace
);
10119 vty_out(vty
, " Graceful restart informations:\n");
10120 if (p
->status
== Established
) {
10121 vty_out(vty
, " End-of-RIB send: ");
10122 FOREACH_AFI_SAFI (afi
, safi
) {
10123 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10124 PEER_STATUS_EOR_SEND
)) {
10125 vty_out(vty
, "%s%s",
10126 eor_send_af_count
? ", "
10128 afi_safi_print(afi
,
10130 eor_send_af_count
++;
10133 vty_out(vty
, "\n");
10134 vty_out(vty
, " End-of-RIB received: ");
10135 FOREACH_AFI_SAFI (afi
, safi
) {
10137 p
->af_sflags
[afi
][safi
],
10138 PEER_STATUS_EOR_RECEIVED
)) {
10139 vty_out(vty
, "%s%s",
10140 eor_receive_af_count
10143 afi_safi_print(afi
,
10145 eor_receive_af_count
++;
10148 vty_out(vty
, "\n");
10151 if (p
->t_gr_restart
)
10153 " The remaining time of restart timer is %ld\n",
10154 thread_timer_remain_second(
10159 " The remaining time of stalepath timer is %ld\n",
10160 thread_timer_remain_second(
10165 json_object
*json_stat
= NULL
;
10166 json_stat
= json_object_new_object();
10167 /* Packet counts. */
10168 json_object_int_add(json_stat
, "depthInq", 0);
10169 json_object_int_add(json_stat
, "depthOutq",
10170 (unsigned long)p
->obuf
->count
);
10171 json_object_int_add(json_stat
, "opensSent",
10172 atomic_load_explicit(&p
->open_out
,
10173 memory_order_relaxed
));
10174 json_object_int_add(json_stat
, "opensRecv",
10175 atomic_load_explicit(&p
->open_in
,
10176 memory_order_relaxed
));
10177 json_object_int_add(json_stat
, "notificationsSent",
10178 atomic_load_explicit(&p
->notify_out
,
10179 memory_order_relaxed
));
10180 json_object_int_add(json_stat
, "notificationsRecv",
10181 atomic_load_explicit(&p
->notify_in
,
10182 memory_order_relaxed
));
10183 json_object_int_add(json_stat
, "updatesSent",
10184 atomic_load_explicit(&p
->update_out
,
10185 memory_order_relaxed
));
10186 json_object_int_add(json_stat
, "updatesRecv",
10187 atomic_load_explicit(&p
->update_in
,
10188 memory_order_relaxed
));
10189 json_object_int_add(json_stat
, "keepalivesSent",
10190 atomic_load_explicit(&p
->keepalive_out
,
10191 memory_order_relaxed
));
10192 json_object_int_add(json_stat
, "keepalivesRecv",
10193 atomic_load_explicit(&p
->keepalive_in
,
10194 memory_order_relaxed
));
10195 json_object_int_add(json_stat
, "routeRefreshSent",
10196 atomic_load_explicit(&p
->refresh_out
,
10197 memory_order_relaxed
));
10198 json_object_int_add(json_stat
, "routeRefreshRecv",
10199 atomic_load_explicit(&p
->refresh_in
,
10200 memory_order_relaxed
));
10201 json_object_int_add(json_stat
, "capabilitySent",
10202 atomic_load_explicit(&p
->dynamic_cap_out
,
10203 memory_order_relaxed
));
10204 json_object_int_add(json_stat
, "capabilityRecv",
10205 atomic_load_explicit(&p
->dynamic_cap_in
,
10206 memory_order_relaxed
));
10207 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10208 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10209 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10211 /* Packet counts. */
10212 vty_out(vty
, " Message statistics:\n");
10213 vty_out(vty
, " Inq depth is 0\n");
10214 vty_out(vty
, " Outq depth is %lu\n",
10215 (unsigned long)p
->obuf
->count
);
10216 vty_out(vty
, " Sent Rcvd\n");
10217 vty_out(vty
, " Opens: %10d %10d\n",
10218 atomic_load_explicit(&p
->open_out
,
10219 memory_order_relaxed
),
10220 atomic_load_explicit(&p
->open_in
,
10221 memory_order_relaxed
));
10222 vty_out(vty
, " Notifications: %10d %10d\n",
10223 atomic_load_explicit(&p
->notify_out
,
10224 memory_order_relaxed
),
10225 atomic_load_explicit(&p
->notify_in
,
10226 memory_order_relaxed
));
10227 vty_out(vty
, " Updates: %10d %10d\n",
10228 atomic_load_explicit(&p
->update_out
,
10229 memory_order_relaxed
),
10230 atomic_load_explicit(&p
->update_in
,
10231 memory_order_relaxed
));
10232 vty_out(vty
, " Keepalives: %10d %10d\n",
10233 atomic_load_explicit(&p
->keepalive_out
,
10234 memory_order_relaxed
),
10235 atomic_load_explicit(&p
->keepalive_in
,
10236 memory_order_relaxed
));
10237 vty_out(vty
, " Route Refresh: %10d %10d\n",
10238 atomic_load_explicit(&p
->refresh_out
,
10239 memory_order_relaxed
),
10240 atomic_load_explicit(&p
->refresh_in
,
10241 memory_order_relaxed
));
10242 vty_out(vty
, " Capability: %10d %10d\n",
10243 atomic_load_explicit(&p
->dynamic_cap_out
,
10244 memory_order_relaxed
),
10245 atomic_load_explicit(&p
->dynamic_cap_in
,
10246 memory_order_relaxed
));
10247 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10252 /* advertisement-interval */
10253 json_object_int_add(json_neigh
,
10254 "minBtwnAdvertisementRunsTimerMsecs",
10255 p
->v_routeadv
* 1000);
10257 /* Update-source. */
10258 if (p
->update_if
|| p
->update_source
) {
10260 json_object_string_add(json_neigh
,
10263 else if (p
->update_source
)
10264 json_object_string_add(
10265 json_neigh
, "updateSource",
10266 sockunion2str(p
->update_source
, buf1
,
10270 /* advertisement-interval */
10272 " Minimum time between advertisement runs is %d seconds\n",
10275 /* Update-source. */
10276 if (p
->update_if
|| p
->update_source
) {
10277 vty_out(vty
, " Update source is ");
10279 vty_out(vty
, "%s", p
->update_if
);
10280 else if (p
->update_source
)
10282 sockunion2str(p
->update_source
, buf1
,
10284 vty_out(vty
, "\n");
10287 vty_out(vty
, "\n");
10290 /* Address Family Information */
10291 json_object
*json_hold
= NULL
;
10294 json_hold
= json_object_new_object();
10296 FOREACH_AFI_SAFI (afi
, safi
)
10297 if (p
->afc
[afi
][safi
])
10298 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10302 json_object_object_add(json_neigh
, "addressFamilyInfo",
10304 json_object_int_add(json_neigh
, "connectionsEstablished",
10306 json_object_int_add(json_neigh
, "connectionsDropped",
10309 vty_out(vty
, " Connections established %d; dropped %d\n",
10310 p
->established
, p
->dropped
);
10312 if (!p
->last_reset
) {
10314 json_object_string_add(json_neigh
, "lastReset",
10317 vty_out(vty
, " Last reset never\n");
10323 uptime
= bgp_clock();
10324 uptime
-= p
->resettime
;
10325 tm
= gmtime(&uptime
);
10326 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10327 (tm
->tm_sec
* 1000)
10328 + (tm
->tm_min
* 60000)
10329 + (tm
->tm_hour
* 3600000));
10330 json_object_string_add(
10331 json_neigh
, "lastResetDueTo",
10332 peer_down_str
[(int)p
->last_reset
]);
10333 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10334 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10335 char errorcodesubcode_hexstr
[5];
10336 char errorcodesubcode_str
[256];
10338 code_str
= bgp_notify_code_str(p
->notify
.code
);
10339 subcode_str
= bgp_notify_subcode_str(
10340 p
->notify
.code
, p
->notify
.subcode
);
10342 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10343 p
->notify
.code
, p
->notify
.subcode
);
10344 json_object_string_add(json_neigh
,
10345 "lastErrorCodeSubcode",
10346 errorcodesubcode_hexstr
);
10347 snprintf(errorcodesubcode_str
, 255, "%s%s",
10348 code_str
, subcode_str
);
10349 json_object_string_add(json_neigh
,
10350 "lastNotificationReason",
10351 errorcodesubcode_str
);
10352 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10353 && p
->notify
.code
== BGP_NOTIFY_CEASE
10354 && (p
->notify
.subcode
10355 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10356 || p
->notify
.subcode
10357 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10358 && p
->notify
.length
) {
10360 const char *msg_str
;
10362 msg_str
= bgp_notify_admin_message(
10363 msgbuf
, sizeof(msgbuf
),
10364 (uint8_t *)p
->notify
.data
,
10367 json_object_string_add(
10369 "lastShutdownDescription",
10374 vty_out(vty
, " Last reset %s, ",
10375 peer_uptime(p
->resettime
, timebuf
,
10376 BGP_UPTIME_LEN
, 0, NULL
));
10378 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10379 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10380 code_str
= bgp_notify_code_str(p
->notify
.code
);
10381 subcode_str
= bgp_notify_subcode_str(
10382 p
->notify
.code
, p
->notify
.subcode
);
10383 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10384 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10387 code_str
, subcode_str
);
10388 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10389 && p
->notify
.code
== BGP_NOTIFY_CEASE
10390 && (p
->notify
.subcode
10391 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10392 || p
->notify
.subcode
10393 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10394 && p
->notify
.length
) {
10396 const char *msg_str
;
10398 msg_str
= bgp_notify_admin_message(
10399 msgbuf
, sizeof(msgbuf
),
10400 (uint8_t *)p
->notify
.data
,
10404 " Message: \"%s\"\n",
10408 vty_out(vty
, "due to %s\n",
10409 peer_down_str
[(int)p
->last_reset
]);
10412 if (p
->last_reset_cause_size
) {
10413 msg
= p
->last_reset_cause
;
10415 " Message received that caused BGP to send a NOTIFICATION:\n ");
10416 for (i
= 1; i
<= p
->last_reset_cause_size
;
10418 vty_out(vty
, "%02X", *msg
++);
10420 if (i
!= p
->last_reset_cause_size
) {
10422 vty_out(vty
, "\n ");
10423 } else if (i
% 4 == 0) {
10428 vty_out(vty
, "\n");
10433 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10435 json_object_boolean_true_add(json_neigh
,
10436 "prefixesConfigExceedMax");
10439 " Peer had exceeded the max. no. of prefixes configured.\n");
10441 if (p
->t_pmax_restart
) {
10443 json_object_boolean_true_add(
10444 json_neigh
, "reducePrefixNumFrom");
10445 json_object_int_add(json_neigh
,
10446 "restartInTimerMsec",
10447 thread_timer_remain_second(
10452 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10453 p
->host
, thread_timer_remain_second(
10454 p
->t_pmax_restart
));
10457 json_object_boolean_true_add(
10459 "reducePrefixNumAndClearIpBgp");
10462 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10467 /* EBGP Multihop and GTSM */
10468 if (p
->sort
!= BGP_PEER_IBGP
) {
10470 if (p
->gtsm_hops
> 0)
10471 json_object_int_add(json_neigh
,
10472 "externalBgpNbrMaxHopsAway",
10474 else if (p
->ttl
> 1)
10475 json_object_int_add(json_neigh
,
10476 "externalBgpNbrMaxHopsAway",
10479 if (p
->gtsm_hops
> 0)
10481 " External BGP neighbor may be up to %d hops away.\n",
10483 else if (p
->ttl
> 1)
10485 " External BGP neighbor may be up to %d hops away.\n",
10489 if (p
->gtsm_hops
> 0) {
10491 json_object_int_add(json_neigh
,
10492 "internalBgpNbrMaxHopsAway",
10496 " Internal BGP neighbor may be up to %d hops away.\n",
10501 /* Local address. */
10504 json_object_string_add(json_neigh
, "hostLocal",
10505 sockunion2str(p
->su_local
, buf1
,
10507 json_object_int_add(json_neigh
, "portLocal",
10508 ntohs(p
->su_local
->sin
.sin_port
));
10510 vty_out(vty
, "Local host: %s, Local port: %d\n",
10511 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10512 ntohs(p
->su_local
->sin
.sin_port
));
10515 /* Remote address. */
10516 if (p
->su_remote
) {
10518 json_object_string_add(json_neigh
, "hostForeign",
10519 sockunion2str(p
->su_remote
, buf1
,
10521 json_object_int_add(json_neigh
, "portForeign",
10522 ntohs(p
->su_remote
->sin
.sin_port
));
10524 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10525 sockunion2str(p
->su_remote
, buf1
,
10527 ntohs(p
->su_remote
->sin
.sin_port
));
10530 /* Nexthop display. */
10533 json_object_string_add(json_neigh
, "nexthop",
10535 &p
->nexthop
.v4
, buf1
,
10537 json_object_string_add(json_neigh
, "nexthopGlobal",
10538 inet_ntop(AF_INET6
,
10539 &p
->nexthop
.v6_global
,
10540 buf1
, sizeof(buf1
)));
10541 json_object_string_add(json_neigh
, "nexthopLocal",
10542 inet_ntop(AF_INET6
,
10543 &p
->nexthop
.v6_local
,
10544 buf1
, sizeof(buf1
)));
10545 if (p
->shared_network
)
10546 json_object_string_add(json_neigh
,
10550 json_object_string_add(json_neigh
,
10552 "nonSharedNetwork");
10554 vty_out(vty
, "Nexthop: %s\n",
10555 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10557 vty_out(vty
, "Nexthop global: %s\n",
10558 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10560 vty_out(vty
, "Nexthop local: %s\n",
10561 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10563 vty_out(vty
, "BGP connection: %s\n",
10564 p
->shared_network
? "shared network"
10565 : "non shared network");
10569 /* Timer information. */
10571 json_object_int_add(json_neigh
, "connectRetryTimer",
10573 if (p
->status
== Established
&& p
->rtt
)
10574 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10577 json_object_int_add(
10578 json_neigh
, "nextStartTimerDueInMsecs",
10579 thread_timer_remain_second(p
->t_start
) * 1000);
10581 json_object_int_add(
10582 json_neigh
, "nextConnectTimerDueInMsecs",
10583 thread_timer_remain_second(p
->t_connect
)
10585 if (p
->t_routeadv
) {
10586 json_object_int_add(json_neigh
, "mraiInterval",
10588 json_object_int_add(
10589 json_neigh
, "mraiTimerExpireInMsecs",
10590 thread_timer_remain_second(p
->t_routeadv
)
10594 json_object_int_add(json_neigh
, "authenticationEnabled",
10598 json_object_string_add(json_neigh
, "readThread", "on");
10600 json_object_string_add(json_neigh
, "readThread", "off");
10602 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10603 json_object_string_add(json_neigh
, "writeThread", "on");
10605 json_object_string_add(json_neigh
, "writeThread",
10608 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10610 if (p
->status
== Established
&& p
->rtt
)
10611 vty_out(vty
, "Estimated round trip time: %d ms\n",
10614 vty_out(vty
, "Next start timer due in %ld seconds\n",
10615 thread_timer_remain_second(p
->t_start
));
10617 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10618 thread_timer_remain_second(p
->t_connect
));
10621 "MRAI (interval %u) timer expires in %ld seconds\n",
10623 thread_timer_remain_second(p
->t_routeadv
));
10625 vty_out(vty
, "Peer Authentication Enabled\n");
10627 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10628 p
->t_read
? "on" : "off",
10629 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10634 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10635 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10636 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10639 vty_out(vty
, "\n");
10641 /* BFD information. */
10642 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10645 if (p
->conf_if
) /* Configured interface name. */
10646 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10647 else /* Configured IP address. */
10648 json_object_object_add(json
, p
->host
, json_neigh
);
10652 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10653 enum show_type type
, union sockunion
*su
,
10654 const char *conf_if
, uint8_t use_json
,
10657 struct listnode
*node
, *nnode
;
10661 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10662 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10667 bgp_show_peer(vty
, peer
, use_json
, json
);
10672 && !strcmp(peer
->conf_if
, conf_if
))
10674 && !strcmp(peer
->hostname
, conf_if
))) {
10676 bgp_show_peer(vty
, peer
, use_json
,
10680 if (sockunion_same(&peer
->su
, su
)) {
10682 bgp_show_peer(vty
, peer
, use_json
,
10690 if (type
== show_peer
&& !find
) {
10692 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10694 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10698 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10699 json
, JSON_C_TO_STRING_PRETTY
));
10700 json_object_free(json
);
10702 vty_out(vty
, "\n");
10705 return CMD_SUCCESS
;
10708 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10709 enum show_type type
,
10710 const char *ip_str
,
10713 struct listnode
*node
, *nnode
;
10715 union sockunion su
;
10716 json_object
*json
= NULL
;
10717 int ret
, is_first
= 1;
10720 vty_out(vty
, "{\n");
10722 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10724 if (!(json
= json_object_new_object())) {
10726 "Unable to allocate memory for JSON object");
10728 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10732 json_object_int_add(json
, "vrfId",
10733 (bgp
->vrf_id
== VRF_UNKNOWN
)
10735 : (int64_t)bgp
->vrf_id
);
10736 json_object_string_add(
10738 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10743 vty_out(vty
, ",\n");
10747 vty_out(vty
, "\"%s\":",
10748 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10752 vty_out(vty
, "\nInstance %s:\n",
10753 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10758 if (type
== show_peer
) {
10759 ret
= str2sockunion(ip_str
, &su
);
10761 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10764 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10767 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10773 vty_out(vty
, "}\n");
10776 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10777 enum show_type type
, const char *ip_str
,
10782 union sockunion su
;
10783 json_object
*json
= NULL
;
10786 if (strmatch(name
, "all")) {
10787 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10789 return CMD_SUCCESS
;
10791 bgp
= bgp_lookup_by_name(name
);
10794 json
= json_object_new_object();
10795 json_object_boolean_true_add(
10796 json
, "bgpNoSuchInstance");
10797 vty_out(vty
, "%s\n",
10798 json_object_to_json_string_ext(
10800 JSON_C_TO_STRING_PRETTY
));
10801 json_object_free(json
);
10804 "%% No such BGP instance exist\n");
10806 return CMD_WARNING
;
10810 bgp
= bgp_get_default();
10814 json
= json_object_new_object();
10816 ret
= str2sockunion(ip_str
, &su
);
10818 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10821 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10824 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10827 json_object_free(json
);
10830 return CMD_SUCCESS
;
10833 /* "show [ip] bgp neighbors" commands. */
10834 DEFUN (show_ip_bgp_neighbors
,
10835 show_ip_bgp_neighbors_cmd
,
10836 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10840 BGP_INSTANCE_HELP_STR
10843 "Detailed information on TCP and BGP neighbor connections\n"
10844 "Neighbor to display information about\n"
10845 "Neighbor to display information about\n"
10846 "Neighbor on BGP configured interface\n"
10850 char *sh_arg
= NULL
;
10851 enum show_type sh_type
;
10853 uint8_t uj
= use_json(argc
, argv
);
10857 if (argv_find(argv
, argc
, "view", &idx
)
10858 || argv_find(argv
, argc
, "vrf", &idx
))
10859 vrf
= argv
[idx
+ 1]->arg
;
10862 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10863 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10864 || argv_find(argv
, argc
, "WORD", &idx
)) {
10865 sh_type
= show_peer
;
10866 sh_arg
= argv
[idx
]->arg
;
10868 sh_type
= show_all
;
10870 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10873 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10874 paths' and `show ip mbgp paths'. Those functions results are the
10876 DEFUN (show_ip_bgp_paths
,
10877 show_ip_bgp_paths_cmd
,
10878 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10883 "Path information\n")
10885 vty_out(vty
, "Address Refcnt Path\n");
10886 aspath_print_all_vty(vty
);
10887 return CMD_SUCCESS
;
10892 static void community_show_all_iterator(struct hash_backet
*backet
,
10895 struct community
*com
;
10897 com
= (struct community
*)backet
->data
;
10898 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10899 community_str(com
, false));
10902 /* Show BGP's community internal data. */
10903 DEFUN (show_ip_bgp_community_info
,
10904 show_ip_bgp_community_info_cmd
,
10905 "show [ip] bgp community-info",
10909 "List all bgp community information\n")
10911 vty_out(vty
, "Address Refcnt Community\n");
10913 hash_iterate(community_hash(),
10914 (void (*)(struct hash_backet
*,
10915 void *))community_show_all_iterator
,
10918 return CMD_SUCCESS
;
10921 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
10924 struct lcommunity
*lcom
;
10926 lcom
= (struct lcommunity
*)backet
->data
;
10927 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
10928 lcommunity_str(lcom
, false));
10931 /* Show BGP's community internal data. */
10932 DEFUN (show_ip_bgp_lcommunity_info
,
10933 show_ip_bgp_lcommunity_info_cmd
,
10934 "show ip bgp large-community-info",
10938 "List all bgp large-community information\n")
10940 vty_out(vty
, "Address Refcnt Large-community\n");
10942 hash_iterate(lcommunity_hash(),
10943 (void (*)(struct hash_backet
*,
10944 void *))lcommunity_show_all_iterator
,
10947 return CMD_SUCCESS
;
10951 DEFUN (show_ip_bgp_attr_info
,
10952 show_ip_bgp_attr_info_cmd
,
10953 "show [ip] bgp attribute-info",
10957 "List all bgp attribute information\n")
10959 attr_show_all(vty
);
10960 return CMD_SUCCESS
;
10963 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
10964 afi_t afi
, safi_t safi
)
10967 struct listnode
*node
;
10969 char buf1
[INET6_ADDRSTRLEN
];
10971 vpn_policy_direction_t dir
;
10974 bgp
= bgp_lookup_by_name(name
);
10976 vty_out(vty
, "%% No such BGP instance exist\n");
10977 return CMD_WARNING
;
10980 bgp
= bgp_get_default();
10983 "%% Default BGP instance does not exist\n");
10984 return CMD_WARNING
;
10988 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10989 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
10991 "This VRF is not importing %s routes from any other VRF\n",
10992 afi_safi_print(afi
, safi
));
10995 "This VRF is importing %s routes from the following VRFs:\n",
10996 afi_safi_print(afi
, safi
));
10997 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
10999 vty_out(vty
, " %s\n", vname
);
11001 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11002 ecom_str
= ecommunity_ecom2str(
11003 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11004 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11005 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11006 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11009 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11010 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11012 "This VRF is not exporting %s routes to any other VRF\n",
11013 afi_safi_print(afi
, safi
));
11016 "This VRF is exporting %s routes to the following VRFs:\n",
11017 afi_safi_print(afi
, safi
));
11018 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].export_vrf
, node
,
11020 vty_out(vty
, " %s\n", vname
);
11022 vty_out(vty
, "RD: %s\n",
11023 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11024 buf1
, RD_ADDRSTRLEN
));
11025 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11026 ecom_str
= ecommunity_ecom2str(
11027 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11028 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11029 vty_out(vty
, "Emport RT: %s\n", ecom_str
);
11030 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11033 return CMD_SUCCESS
;
11036 /* "show [ip] bgp route-leak" command. */
11037 DEFUN (show_ip_bgp_route_leak
,
11038 show_ip_bgp_route_leak_cmd
,
11039 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak",
11043 BGP_INSTANCE_HELP_STR
11046 "Route leaking information\n")
11049 afi_t afi
= AFI_MAX
;
11050 safi_t safi
= SAFI_MAX
;
11054 /* show [ip] bgp */
11055 if (argv_find(argv
, argc
, "ip", &idx
)) {
11057 safi
= SAFI_UNICAST
;
11059 /* [vrf VIEWVRFNAME] */
11060 if (argv_find(argv
, argc
, "view", &idx
)) {
11062 "%% This command is not applicable to BGP views\n");
11063 return CMD_WARNING
;
11066 if (argv_find(argv
, argc
, "vrf", &idx
))
11067 vrf
= argv
[++idx
]->arg
;
11068 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11069 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11070 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11073 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11075 "%% This command is applicable only for unicast ipv4|ipv6\n");
11076 return CMD_WARNING
;
11079 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
);
11082 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11085 struct listnode
*node
, *nnode
;
11088 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11089 vty_out(vty
, "\nInstance %s:\n",
11090 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11093 update_group_show(bgp
, afi
, safi
, vty
, 0);
11097 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11098 int safi
, uint64_t subgrp_id
)
11103 if (strmatch(name
, "all")) {
11104 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11105 return CMD_SUCCESS
;
11107 bgp
= bgp_lookup_by_name(name
);
11110 bgp
= bgp_get_default();
11114 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11115 return CMD_SUCCESS
;
11118 DEFUN (show_ip_bgp_updgrps
,
11119 show_ip_bgp_updgrps_cmd
,
11120 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11124 BGP_INSTANCE_HELP_STR
11126 BGP_SAFI_WITH_LABEL_HELP_STR
11127 "Detailed info about dynamic update groups\n"
11128 "Specific subgroup to display detailed info for\n")
11131 afi_t afi
= AFI_IP6
;
11132 safi_t safi
= SAFI_UNICAST
;
11133 uint64_t subgrp_id
= 0;
11137 /* show [ip] bgp */
11138 if (argv_find(argv
, argc
, "ip", &idx
))
11140 /* [<view|vrf> VIEWVRFNAME] */
11141 if (argv_find(argv
, argc
, "view", &idx
)
11142 || argv_find(argv
, argc
, "vrf", &idx
))
11143 vrf
= argv
[++idx
]->arg
;
11144 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11145 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11146 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11149 /* get subgroup id, if provided */
11151 if (argv
[idx
]->type
== VARIABLE_TKN
)
11152 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11154 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11157 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11158 show_bgp_instance_all_ipv6_updgrps_cmd
,
11159 "show [ip] bgp <view|vrf> all update-groups",
11163 BGP_INSTANCE_ALL_HELP_STR
11164 "Detailed info about dynamic update groups\n")
11166 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11167 return CMD_SUCCESS
;
11170 DEFUN (show_bgp_updgrps_stats
,
11171 show_bgp_updgrps_stats_cmd
,
11172 "show [ip] bgp update-groups statistics",
11176 "Detailed info about dynamic update groups\n"
11181 bgp
= bgp_get_default();
11183 update_group_show_stats(bgp
, vty
);
11185 return CMD_SUCCESS
;
11188 DEFUN (show_bgp_instance_updgrps_stats
,
11189 show_bgp_instance_updgrps_stats_cmd
,
11190 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11194 BGP_INSTANCE_HELP_STR
11195 "Detailed info about dynamic update groups\n"
11201 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11203 update_group_show_stats(bgp
, vty
);
11205 return CMD_SUCCESS
;
11208 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11209 afi_t afi
, safi_t safi
,
11210 const char *what
, uint64_t subgrp_id
)
11215 bgp
= bgp_lookup_by_name(name
);
11217 bgp
= bgp_get_default();
11220 if (!strcmp(what
, "advertise-queue"))
11221 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11223 else if (!strcmp(what
, "advertised-routes"))
11224 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11226 else if (!strcmp(what
, "packet-queue"))
11227 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11232 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11233 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11234 "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",
11235 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11237 "Detailed info about dynamic update groups\n"
11238 "Specific subgroup to display info for\n"
11239 "Advertisement queue\n"
11240 "Announced routes\n"
11243 uint64_t subgrp_id
= 0;
11247 subgrp_id
= strtoull(sgid
, NULL
, 10);
11252 afiz
= bgp_vty_afi_from_str(afi
);
11256 afiz
= bgp_vty_afi_from_str(afi
);
11257 if (afiz
!= AFI_IP
)
11259 "%% Cannot specify both 'ip' and 'ipv6'\n");
11260 return CMD_WARNING
;
11263 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11265 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11266 return CMD_SUCCESS
;
11269 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11271 struct listnode
*node
, *nnode
;
11272 struct prefix
*range
;
11275 char buf
[PREFIX2STR_BUFFER
];
11278 const char *peer_status
;
11279 const char *af_str
;
11284 conf
= group
->conf
;
11286 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11287 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11289 } else if (conf
->as_type
== AS_INTERNAL
) {
11290 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11293 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11296 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11297 vty_out(vty
, " Peer-group type is internal\n");
11299 vty_out(vty
, " Peer-group type is external\n");
11301 /* Display AFs configured. */
11302 vty_out(vty
, " Configured address-families:");
11303 FOREACH_AFI_SAFI (afi
, safi
) {
11304 if (conf
->afc
[afi
][safi
]) {
11306 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11310 vty_out(vty
, " none\n");
11312 vty_out(vty
, "\n");
11314 /* Display listen ranges (for dynamic neighbors), if any */
11315 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11318 else if (afi
== AFI_IP6
)
11322 lr_count
= listcount(group
->listen_range
[afi
]);
11324 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11328 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11330 prefix2str(range
, buf
, sizeof(buf
));
11331 vty_out(vty
, " %s\n", buf
);
11336 /* Display group members and their status */
11337 if (listcount(group
->peer
)) {
11338 vty_out(vty
, " Peer-group members:\n");
11339 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11340 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11341 peer_status
= "Idle (Admin)";
11342 else if (CHECK_FLAG(peer
->sflags
,
11343 PEER_STATUS_PREFIX_OVERFLOW
))
11344 peer_status
= "Idle (PfxCt)";
11346 peer_status
= lookup_msg(bgp_status_msg
,
11347 peer
->status
, NULL
);
11349 dynamic
= peer_dynamic_neighbor(peer
);
11350 vty_out(vty
, " %s %s %s \n", peer
->host
,
11351 dynamic
? "(dynamic)" : "", peer_status
);
11355 return CMD_SUCCESS
;
11358 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11359 const char *group_name
)
11362 struct listnode
*node
, *nnode
;
11363 struct peer_group
*group
;
11364 bool found
= false;
11366 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11369 vty_out(vty
, "%% No such BGP instance exists\n");
11370 return CMD_WARNING
;
11373 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11375 if (strmatch(group
->name
, group_name
)) {
11376 bgp_show_one_peer_group(vty
, group
);
11381 bgp_show_one_peer_group(vty
, group
);
11385 if (group_name
&& !found
)
11386 vty_out(vty
, "%% No such peer-group\n");
11388 return CMD_SUCCESS
;
11391 DEFUN (show_ip_bgp_peer_groups
,
11392 show_ip_bgp_peer_groups_cmd
,
11393 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11397 BGP_INSTANCE_HELP_STR
11398 "Detailed information on BGP peer groups\n"
11399 "Peer group name\n")
11405 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11407 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11409 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11413 /* Redistribute VTY commands. */
11415 DEFUN (bgp_redistribute_ipv4
,
11416 bgp_redistribute_ipv4_cmd
,
11417 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11418 "Redistribute information from another routing protocol\n"
11419 FRR_IP_REDIST_HELP_STR_BGPD
)
11421 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11422 int idx_protocol
= 1;
11425 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11427 vty_out(vty
, "%% Invalid route type\n");
11428 return CMD_WARNING_CONFIG_FAILED
;
11431 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11432 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11436 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11437 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11438 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11440 DEFUN (bgp_redistribute_ipv4_rmap
,
11441 bgp_redistribute_ipv4_rmap_cmd
,
11442 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11443 "Redistribute information from another routing protocol\n"
11444 FRR_IP_REDIST_HELP_STR_BGPD
11445 "Route map reference\n"
11446 "Pointer to route-map entries\n")
11448 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11449 int idx_protocol
= 1;
11452 struct bgp_redist
*red
;
11454 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11456 vty_out(vty
, "%% Invalid route type\n");
11457 return CMD_WARNING_CONFIG_FAILED
;
11460 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11461 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11462 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11466 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11467 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11468 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11469 "Route map reference\n"
11470 "Pointer to route-map entries\n")
11472 DEFUN (bgp_redistribute_ipv4_metric
,
11473 bgp_redistribute_ipv4_metric_cmd
,
11474 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11475 "Redistribute information from another routing protocol\n"
11476 FRR_IP_REDIST_HELP_STR_BGPD
11477 "Metric for redistributed routes\n"
11478 "Default metric\n")
11480 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11481 int idx_protocol
= 1;
11482 int idx_number
= 3;
11485 struct bgp_redist
*red
;
11487 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11489 vty_out(vty
, "%% Invalid route type\n");
11490 return CMD_WARNING_CONFIG_FAILED
;
11492 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11494 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11495 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11496 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11500 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11501 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11502 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11503 "Metric for redistributed routes\n"
11504 "Default metric\n")
11506 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11507 bgp_redistribute_ipv4_rmap_metric_cmd
,
11508 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11509 "Redistribute information from another routing protocol\n"
11510 FRR_IP_REDIST_HELP_STR_BGPD
11511 "Route map reference\n"
11512 "Pointer to route-map entries\n"
11513 "Metric for redistributed routes\n"
11514 "Default metric\n")
11516 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11517 int idx_protocol
= 1;
11519 int idx_number
= 5;
11522 struct bgp_redist
*red
;
11524 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11526 vty_out(vty
, "%% Invalid route type\n");
11527 return CMD_WARNING_CONFIG_FAILED
;
11529 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11531 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11532 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11533 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11534 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11538 bgp_redistribute_ipv4_rmap_metric
,
11539 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11540 "redistribute " FRR_IP_REDIST_STR_BGPD
11541 " route-map WORD metric (0-4294967295)",
11542 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11543 "Route map reference\n"
11544 "Pointer to route-map entries\n"
11545 "Metric for redistributed routes\n"
11546 "Default metric\n")
11548 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11549 bgp_redistribute_ipv4_metric_rmap_cmd
,
11550 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11551 "Redistribute information from another routing protocol\n"
11552 FRR_IP_REDIST_HELP_STR_BGPD
11553 "Metric for redistributed routes\n"
11555 "Route map reference\n"
11556 "Pointer to route-map entries\n")
11558 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11559 int idx_protocol
= 1;
11560 int idx_number
= 3;
11564 struct bgp_redist
*red
;
11566 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11568 vty_out(vty
, "%% Invalid route type\n");
11569 return CMD_WARNING_CONFIG_FAILED
;
11571 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11573 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11574 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11575 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11576 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11580 bgp_redistribute_ipv4_metric_rmap
,
11581 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11582 "redistribute " FRR_IP_REDIST_STR_BGPD
11583 " metric (0-4294967295) route-map WORD",
11584 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11585 "Metric for redistributed routes\n"
11587 "Route map reference\n"
11588 "Pointer to route-map entries\n")
11590 DEFUN (bgp_redistribute_ipv4_ospf
,
11591 bgp_redistribute_ipv4_ospf_cmd
,
11592 "redistribute <ospf|table> (1-65535)",
11593 "Redistribute information from another routing protocol\n"
11594 "Open Shortest Path First (OSPFv2)\n"
11595 "Non-main Kernel Routing Table\n"
11596 "Instance ID/Table ID\n")
11598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11599 int idx_ospf_table
= 1;
11600 int idx_number
= 2;
11601 unsigned short instance
;
11602 unsigned short protocol
;
11604 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11606 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11607 protocol
= ZEBRA_ROUTE_OSPF
;
11609 protocol
= ZEBRA_ROUTE_TABLE
;
11611 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11612 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11615 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11616 "redistribute <ospf|table> (1-65535)",
11617 "Redistribute information from another routing protocol\n"
11618 "Open Shortest Path First (OSPFv2)\n"
11619 "Non-main Kernel Routing Table\n"
11620 "Instance ID/Table ID\n")
11622 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11623 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11624 "redistribute <ospf|table> (1-65535) route-map WORD",
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"
11629 "Route map reference\n"
11630 "Pointer to route-map entries\n")
11632 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11633 int idx_ospf_table
= 1;
11634 int idx_number
= 2;
11636 struct bgp_redist
*red
;
11637 unsigned short instance
;
11640 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11641 protocol
= ZEBRA_ROUTE_OSPF
;
11643 protocol
= ZEBRA_ROUTE_TABLE
;
11645 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11646 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11647 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11648 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11651 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11652 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11653 "redistribute <ospf|table> (1-65535) route-map WORD",
11654 "Redistribute information from another routing protocol\n"
11655 "Open Shortest Path First (OSPFv2)\n"
11656 "Non-main Kernel Routing Table\n"
11657 "Instance ID/Table ID\n"
11658 "Route map reference\n"
11659 "Pointer to route-map entries\n")
11661 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11662 bgp_redistribute_ipv4_ospf_metric_cmd
,
11663 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11664 "Redistribute information from another routing protocol\n"
11665 "Open Shortest Path First (OSPFv2)\n"
11666 "Non-main Kernel Routing Table\n"
11667 "Instance ID/Table ID\n"
11668 "Metric for redistributed routes\n"
11669 "Default metric\n")
11671 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11672 int idx_ospf_table
= 1;
11673 int idx_number
= 2;
11674 int idx_number_2
= 4;
11676 struct bgp_redist
*red
;
11677 unsigned short instance
;
11680 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11681 protocol
= ZEBRA_ROUTE_OSPF
;
11683 protocol
= ZEBRA_ROUTE_TABLE
;
11685 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11686 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11688 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11689 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11690 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11693 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11694 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11695 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11696 "Redistribute information from another routing protocol\n"
11697 "Open Shortest Path First (OSPFv2)\n"
11698 "Non-main Kernel Routing Table\n"
11699 "Instance ID/Table ID\n"
11700 "Metric for redistributed routes\n"
11701 "Default metric\n")
11703 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11704 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11705 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11706 "Redistribute information from another routing protocol\n"
11707 "Open Shortest Path First (OSPFv2)\n"
11708 "Non-main Kernel Routing Table\n"
11709 "Instance ID/Table ID\n"
11710 "Route map reference\n"
11711 "Pointer to route-map entries\n"
11712 "Metric for redistributed routes\n"
11713 "Default metric\n")
11715 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11716 int idx_ospf_table
= 1;
11717 int idx_number
= 2;
11719 int idx_number_2
= 6;
11721 struct bgp_redist
*red
;
11722 unsigned short instance
;
11725 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11726 protocol
= ZEBRA_ROUTE_OSPF
;
11728 protocol
= ZEBRA_ROUTE_TABLE
;
11730 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11731 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11733 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11734 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11735 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11736 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11740 bgp_redistribute_ipv4_ospf_rmap_metric
,
11741 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11742 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11743 "Redistribute information from another routing protocol\n"
11744 "Open Shortest Path First (OSPFv2)\n"
11745 "Non-main Kernel Routing Table\n"
11746 "Instance ID/Table ID\n"
11747 "Route map reference\n"
11748 "Pointer to route-map entries\n"
11749 "Metric for redistributed routes\n"
11750 "Default metric\n")
11752 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11753 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11754 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11755 "Redistribute information from another routing protocol\n"
11756 "Open Shortest Path First (OSPFv2)\n"
11757 "Non-main Kernel Routing Table\n"
11758 "Instance ID/Table ID\n"
11759 "Metric for redistributed routes\n"
11761 "Route map reference\n"
11762 "Pointer to route-map entries\n")
11764 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11765 int idx_ospf_table
= 1;
11766 int idx_number
= 2;
11767 int idx_number_2
= 4;
11770 struct bgp_redist
*red
;
11771 unsigned short instance
;
11774 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11775 protocol
= ZEBRA_ROUTE_OSPF
;
11777 protocol
= ZEBRA_ROUTE_TABLE
;
11779 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11780 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11782 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11783 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11784 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11785 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11789 bgp_redistribute_ipv4_ospf_metric_rmap
,
11790 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11791 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11792 "Redistribute information from another routing protocol\n"
11793 "Open Shortest Path First (OSPFv2)\n"
11794 "Non-main Kernel Routing Table\n"
11795 "Instance ID/Table ID\n"
11796 "Metric for redistributed routes\n"
11798 "Route map reference\n"
11799 "Pointer to route-map entries\n")
11801 DEFUN (no_bgp_redistribute_ipv4_ospf
,
11802 no_bgp_redistribute_ipv4_ospf_cmd
,
11803 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11805 "Redistribute information from another routing protocol\n"
11806 "Open Shortest Path First (OSPFv2)\n"
11807 "Non-main Kernel Routing Table\n"
11808 "Instance ID/Table ID\n"
11809 "Metric for redistributed routes\n"
11811 "Route map reference\n"
11812 "Pointer to route-map entries\n")
11814 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11815 int idx_ospf_table
= 2;
11816 int idx_number
= 3;
11817 unsigned short instance
;
11820 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11821 protocol
= ZEBRA_ROUTE_OSPF
;
11823 protocol
= ZEBRA_ROUTE_TABLE
;
11825 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11826 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
11830 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
11831 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11833 "Redistribute information from another routing protocol\n"
11834 "Open Shortest Path First (OSPFv2)\n"
11835 "Non-main Kernel Routing Table\n"
11836 "Instance ID/Table ID\n"
11837 "Metric for redistributed routes\n"
11839 "Route map reference\n"
11840 "Pointer to route-map entries\n")
11842 DEFUN (no_bgp_redistribute_ipv4
,
11843 no_bgp_redistribute_ipv4_cmd
,
11844 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11846 "Redistribute information from another routing protocol\n"
11847 FRR_IP_REDIST_HELP_STR_BGPD
11848 "Metric for redistributed routes\n"
11850 "Route map reference\n"
11851 "Pointer to route-map entries\n")
11853 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11854 int idx_protocol
= 2;
11857 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11859 vty_out(vty
, "%% Invalid route type\n");
11860 return CMD_WARNING_CONFIG_FAILED
;
11862 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
11866 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
11867 "no redistribute " FRR_IP_REDIST_STR_BGPD
11868 " [metric (0-4294967295)] [route-map WORD]",
11870 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11871 "Metric for redistributed routes\n"
11873 "Route map reference\n"
11874 "Pointer to route-map entries\n")
11876 DEFUN (bgp_redistribute_ipv6
,
11877 bgp_redistribute_ipv6_cmd
,
11878 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11879 "Redistribute information from another routing protocol\n"
11880 FRR_IP6_REDIST_HELP_STR_BGPD
)
11882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11883 int idx_protocol
= 1;
11886 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11888 vty_out(vty
, "%% Invalid route type\n");
11889 return CMD_WARNING_CONFIG_FAILED
;
11892 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11893 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11896 DEFUN (bgp_redistribute_ipv6_rmap
,
11897 bgp_redistribute_ipv6_rmap_cmd
,
11898 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
11899 "Redistribute information from another routing protocol\n"
11900 FRR_IP6_REDIST_HELP_STR_BGPD
11901 "Route map reference\n"
11902 "Pointer to route-map entries\n")
11904 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11905 int idx_protocol
= 1;
11908 struct bgp_redist
*red
;
11910 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11912 vty_out(vty
, "%% Invalid route type\n");
11913 return CMD_WARNING_CONFIG_FAILED
;
11916 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11917 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11918 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11921 DEFUN (bgp_redistribute_ipv6_metric
,
11922 bgp_redistribute_ipv6_metric_cmd
,
11923 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
11924 "Redistribute information from another routing protocol\n"
11925 FRR_IP6_REDIST_HELP_STR_BGPD
11926 "Metric for redistributed routes\n"
11927 "Default metric\n")
11929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11930 int idx_protocol
= 1;
11931 int idx_number
= 3;
11934 struct bgp_redist
*red
;
11936 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11938 vty_out(vty
, "%% Invalid route type\n");
11939 return CMD_WARNING_CONFIG_FAILED
;
11941 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11943 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11944 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11945 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11948 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
11949 bgp_redistribute_ipv6_rmap_metric_cmd
,
11950 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11951 "Redistribute information from another routing protocol\n"
11952 FRR_IP6_REDIST_HELP_STR_BGPD
11953 "Route map reference\n"
11954 "Pointer to route-map entries\n"
11955 "Metric for redistributed routes\n"
11956 "Default metric\n")
11958 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11959 int idx_protocol
= 1;
11961 int idx_number
= 5;
11964 struct bgp_redist
*red
;
11966 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11968 vty_out(vty
, "%% Invalid route type\n");
11969 return CMD_WARNING_CONFIG_FAILED
;
11971 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11973 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11974 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11975 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11976 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11979 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
11980 bgp_redistribute_ipv6_metric_rmap_cmd
,
11981 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11982 "Redistribute information from another routing protocol\n"
11983 FRR_IP6_REDIST_HELP_STR_BGPD
11984 "Metric for redistributed routes\n"
11986 "Route map reference\n"
11987 "Pointer to route-map entries\n")
11989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11990 int idx_protocol
= 1;
11991 int idx_number
= 3;
11995 struct bgp_redist
*red
;
11997 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11999 vty_out(vty
, "%% Invalid route type\n");
12000 return CMD_WARNING_CONFIG_FAILED
;
12002 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12004 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12005 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
12006 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12007 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12010 DEFUN (no_bgp_redistribute_ipv6
,
12011 no_bgp_redistribute_ipv6_cmd
,
12012 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12014 "Redistribute information from another routing protocol\n"
12015 FRR_IP6_REDIST_HELP_STR_BGPD
12016 "Metric for redistributed routes\n"
12018 "Route map reference\n"
12019 "Pointer to route-map entries\n")
12021 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12022 int idx_protocol
= 2;
12025 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12027 vty_out(vty
, "%% Invalid route type\n");
12028 return CMD_WARNING_CONFIG_FAILED
;
12031 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12034 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12039 /* Unicast redistribution only. */
12040 if (safi
!= SAFI_UNICAST
)
12043 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12044 /* Redistribute BGP does not make sense. */
12045 if (i
!= ZEBRA_ROUTE_BGP
) {
12046 struct list
*red_list
;
12047 struct listnode
*node
;
12048 struct bgp_redist
*red
;
12050 red_list
= bgp
->redist
[afi
][i
];
12054 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12055 /* "redistribute" configuration. */
12056 vty_out(vty
, " redistribute %s",
12057 zebra_route_string(i
));
12059 vty_out(vty
, " %d", red
->instance
);
12060 if (red
->redist_metric_flag
)
12061 vty_out(vty
, " metric %u",
12062 red
->redist_metric
);
12063 if (red
->rmap
.name
)
12064 vty_out(vty
, " route-map %s",
12066 vty_out(vty
, "\n");
12072 /* This is part of the address-family block (unicast only) */
12073 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12078 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
])
12079 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12080 bgp
->vpn_policy
[afi
]
12081 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12083 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12084 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12085 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12086 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12089 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12090 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12092 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12095 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12096 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12097 bgp
->vpn_policy
[afi
].tovpn_label
);
12100 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12101 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12102 char buf
[RD_ADDRSTRLEN
];
12103 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12104 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12107 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12108 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12110 char buf
[PREFIX_STRLEN
];
12111 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12112 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12115 vty_out(vty
, "%*snexthop vpn export %s\n",
12119 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12120 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12122 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12123 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12125 char *b
= ecommunity_ecom2str(
12126 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12127 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12128 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12129 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12131 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12132 char *b
= ecommunity_ecom2str(
12133 bgp
->vpn_policy
[afi
]
12134 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12135 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12136 ECOMMUNITY_ROUTE_TARGET
);
12137 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12138 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12140 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12141 char *b
= ecommunity_ecom2str(
12142 bgp
->vpn_policy
[afi
]
12143 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12144 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12145 ECOMMUNITY_ROUTE_TARGET
);
12146 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12147 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12151 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12152 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12153 bgp
->vpn_policy
[afi
]
12154 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12156 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12157 char *b
= ecommunity_ecom2str(
12158 bgp
->vpn_policy
[afi
]
12159 .import_redirect_rtlist
,
12160 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12161 ECOMMUNITY_ROUTE_TARGET
);
12163 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12164 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12169 /* BGP node structure. */
12170 static struct cmd_node bgp_node
= {
12171 BGP_NODE
, "%s(config-router)# ", 1,
12174 static struct cmd_node bgp_ipv4_unicast_node
= {
12175 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12178 static struct cmd_node bgp_ipv4_multicast_node
= {
12179 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12182 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12183 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12186 static struct cmd_node bgp_ipv6_unicast_node
= {
12187 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12190 static struct cmd_node bgp_ipv6_multicast_node
= {
12191 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12194 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12195 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12198 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12199 "%s(config-router-af)# ", 1};
12201 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12202 "%s(config-router-af-vpnv6)# ", 1};
12204 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12205 "%s(config-router-evpn)# ", 1};
12207 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12208 "%s(config-router-af-vni)# ", 1};
12210 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12211 "%s(config-router-af)# ", 1};
12213 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12214 "%s(config-router-af-vpnv6)# ", 1};
12216 static void community_list_vty(void);
12218 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12222 struct listnode
*lnbgp
, *lnpeer
;
12224 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12225 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12226 /* only provide suggestions on the appropriate input
12228 * they'll otherwise show up multiple times */
12229 enum cmd_token_type match_type
;
12230 char *name
= peer
->host
;
12232 if (peer
->conf_if
) {
12233 match_type
= VARIABLE_TKN
;
12234 name
= peer
->conf_if
;
12235 } else if (strchr(peer
->host
, ':'))
12236 match_type
= IPV6_TKN
;
12238 match_type
= IPV4_TKN
;
12240 if (token
->type
!= match_type
)
12243 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12248 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12249 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12250 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12251 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12252 {.completions
= NULL
}};
12254 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12257 struct peer_group
*group
;
12258 struct listnode
*lnbgp
, *lnpeer
;
12260 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12261 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12262 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12267 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12268 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12269 {.completions
= NULL
} };
12271 void bgp_vty_init(void)
12273 cmd_variable_handler_register(bgp_var_neighbor
);
12274 cmd_variable_handler_register(bgp_var_peergroup
);
12276 /* Install bgp top node. */
12277 install_node(&bgp_node
, bgp_config_write
);
12278 install_node(&bgp_ipv4_unicast_node
, NULL
);
12279 install_node(&bgp_ipv4_multicast_node
, NULL
);
12280 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12281 install_node(&bgp_ipv6_unicast_node
, NULL
);
12282 install_node(&bgp_ipv6_multicast_node
, NULL
);
12283 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12284 install_node(&bgp_vpnv4_node
, NULL
);
12285 install_node(&bgp_vpnv6_node
, NULL
);
12286 install_node(&bgp_evpn_node
, NULL
);
12287 install_node(&bgp_evpn_vni_node
, NULL
);
12288 install_node(&bgp_flowspecv4_node
, NULL
);
12289 install_node(&bgp_flowspecv6_node
, NULL
);
12291 /* Install default VTY commands to new nodes. */
12292 install_default(BGP_NODE
);
12293 install_default(BGP_IPV4_NODE
);
12294 install_default(BGP_IPV4M_NODE
);
12295 install_default(BGP_IPV4L_NODE
);
12296 install_default(BGP_IPV6_NODE
);
12297 install_default(BGP_IPV6M_NODE
);
12298 install_default(BGP_IPV6L_NODE
);
12299 install_default(BGP_VPNV4_NODE
);
12300 install_default(BGP_VPNV6_NODE
);
12301 install_default(BGP_FLOWSPECV4_NODE
);
12302 install_default(BGP_FLOWSPECV6_NODE
);
12303 install_default(BGP_EVPN_NODE
);
12304 install_default(BGP_EVPN_VNI_NODE
);
12306 /* "bgp multiple-instance" commands. */
12307 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12308 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12310 /* "bgp config-type" commands. */
12311 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12312 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12314 /* bgp route-map delay-timer commands. */
12315 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12316 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12318 /* Dummy commands (Currently not supported) */
12319 install_element(BGP_NODE
, &no_synchronization_cmd
);
12320 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12322 /* "router bgp" commands. */
12323 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12325 /* "no router bgp" commands. */
12326 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12328 /* "bgp router-id" commands. */
12329 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12330 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12332 /* "bgp cluster-id" commands. */
12333 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12334 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12336 /* "bgp confederation" commands. */
12337 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12338 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12340 /* "bgp confederation peers" commands. */
12341 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12342 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12344 /* bgp max-med command */
12345 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12346 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12347 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12348 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12349 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12351 /* bgp disable-ebgp-connected-nh-check */
12352 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12353 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12355 /* bgp update-delay command */
12356 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12357 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12358 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12360 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12361 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12362 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12363 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12365 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12366 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12368 /* "maximum-paths" commands. */
12369 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12370 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12371 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12372 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12373 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12374 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12375 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12376 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12377 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12378 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12379 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12380 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12381 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12382 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12383 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12385 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12386 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12387 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12388 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12389 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12391 /* "timers bgp" commands. */
12392 install_element(BGP_NODE
, &bgp_timers_cmd
);
12393 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12395 /* route-map delay-timer commands - per instance for backwards compat.
12397 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12398 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12400 /* "bgp client-to-client reflection" commands */
12401 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12402 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12404 /* "bgp always-compare-med" commands */
12405 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12406 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12408 /* "bgp deterministic-med" commands */
12409 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12410 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12412 /* "bgp graceful-restart" commands */
12413 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12414 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12415 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12416 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12417 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12418 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12420 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12421 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12423 /* "bgp graceful-shutdown" commands */
12424 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12425 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12427 /* "bgp fast-external-failover" commands */
12428 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12429 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12431 /* "bgp enforce-first-as" commands */
12432 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12433 install_element(BGP_NODE
, &no_bgp_enforce_first_as_cmd
);
12435 /* "bgp bestpath compare-routerid" commands */
12436 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12437 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12439 /* "bgp bestpath as-path ignore" commands */
12440 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12441 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12443 /* "bgp bestpath as-path confed" commands */
12444 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12445 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12447 /* "bgp bestpath as-path multipath-relax" commands */
12448 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12449 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12451 /* "bgp log-neighbor-changes" commands */
12452 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12453 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12455 /* "bgp bestpath med" commands */
12456 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12457 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12459 /* "no bgp default ipv4-unicast" commands. */
12460 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12461 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12463 /* "bgp network import-check" commands. */
12464 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12465 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12466 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12468 /* "bgp default local-preference" commands. */
12469 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12470 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12472 /* bgp default show-hostname */
12473 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12474 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12476 /* "bgp default subgroup-pkt-queue-max" commands. */
12477 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12478 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12480 /* bgp ibgp-allow-policy-mods command */
12481 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12482 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12484 /* "bgp listen limit" commands. */
12485 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12486 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12488 /* "bgp listen range" commands. */
12489 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12490 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12492 /* "bgp default shutdown" command */
12493 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12495 /* "neighbor remote-as" commands. */
12496 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12497 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12498 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12499 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12500 install_element(BGP_NODE
,
12501 &neighbor_interface_v6only_config_remote_as_cmd
);
12502 install_element(BGP_NODE
, &no_neighbor_cmd
);
12503 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12505 /* "neighbor peer-group" commands. */
12506 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12507 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12508 install_element(BGP_NODE
,
12509 &no_neighbor_interface_peer_group_remote_as_cmd
);
12511 /* "neighbor local-as" commands. */
12512 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12513 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12514 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12515 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12517 /* "neighbor solo" commands. */
12518 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12519 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12521 /* "neighbor password" commands. */
12522 install_element(BGP_NODE
, &neighbor_password_cmd
);
12523 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12525 /* "neighbor activate" commands. */
12526 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12527 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12528 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12529 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12530 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12531 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12532 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12533 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12534 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12535 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12536 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12537 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12539 /* "no neighbor activate" commands. */
12540 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12541 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12542 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12543 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12544 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12545 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12546 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12547 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12548 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12549 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12550 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12551 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12553 /* "neighbor peer-group" set commands. */
12554 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12555 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12556 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12557 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12558 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12559 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12560 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12561 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12562 install_element(BGP_FLOWSPECV4_NODE
,
12563 &neighbor_set_peer_group_hidden_cmd
);
12564 install_element(BGP_FLOWSPECV6_NODE
,
12565 &neighbor_set_peer_group_hidden_cmd
);
12567 /* "no neighbor peer-group unset" commands. */
12568 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12569 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12570 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12571 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12572 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12573 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12574 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12575 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12576 install_element(BGP_FLOWSPECV4_NODE
,
12577 &no_neighbor_set_peer_group_hidden_cmd
);
12578 install_element(BGP_FLOWSPECV6_NODE
,
12579 &no_neighbor_set_peer_group_hidden_cmd
);
12581 /* "neighbor softreconfiguration inbound" commands.*/
12582 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12583 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12584 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12585 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12586 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12587 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12588 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12589 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12590 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12591 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12592 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12593 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12594 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12595 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12596 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12597 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12598 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12599 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12600 install_element(BGP_FLOWSPECV4_NODE
,
12601 &neighbor_soft_reconfiguration_cmd
);
12602 install_element(BGP_FLOWSPECV4_NODE
,
12603 &no_neighbor_soft_reconfiguration_cmd
);
12604 install_element(BGP_FLOWSPECV6_NODE
,
12605 &neighbor_soft_reconfiguration_cmd
);
12606 install_element(BGP_FLOWSPECV6_NODE
,
12607 &no_neighbor_soft_reconfiguration_cmd
);
12609 /* "neighbor attribute-unchanged" commands. */
12610 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12611 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12612 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12613 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12614 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12615 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12616 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12617 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12618 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12619 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12620 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12621 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12622 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12623 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12624 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12625 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12626 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12627 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12629 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12630 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12632 /* "nexthop-local unchanged" commands */
12633 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12634 install_element(BGP_IPV6_NODE
,
12635 &no_neighbor_nexthop_local_unchanged_cmd
);
12637 /* "neighbor next-hop-self" commands. */
12638 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12639 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12640 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12641 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12642 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12643 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12644 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12645 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12646 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12647 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12648 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12649 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12650 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12651 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12652 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12653 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12654 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12655 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12656 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
12657 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
12659 /* "neighbor next-hop-self force" commands. */
12660 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12661 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12662 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12663 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12664 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12665 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12666 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12667 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12668 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12669 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12670 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12671 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12672 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12673 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12674 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12675 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12676 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12677 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12679 /* "neighbor as-override" commands. */
12680 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12681 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12682 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12683 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12684 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12685 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12686 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12687 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12688 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12689 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12690 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12691 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12692 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12693 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12694 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12695 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12696 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12697 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12699 /* "neighbor remove-private-AS" commands. */
12700 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12701 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12702 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12703 install_element(BGP_NODE
,
12704 &no_neighbor_remove_private_as_all_hidden_cmd
);
12705 install_element(BGP_NODE
,
12706 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12707 install_element(BGP_NODE
,
12708 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12709 install_element(BGP_NODE
,
12710 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12713 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12714 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12715 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12716 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12717 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12718 install_element(BGP_IPV4_NODE
,
12719 &neighbor_remove_private_as_replace_as_cmd
);
12720 install_element(BGP_IPV4_NODE
,
12721 &no_neighbor_remove_private_as_replace_as_cmd
);
12722 install_element(BGP_IPV4_NODE
,
12723 &neighbor_remove_private_as_all_replace_as_cmd
);
12724 install_element(BGP_IPV4_NODE
,
12725 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12726 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12727 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12728 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12729 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12730 install_element(BGP_IPV4M_NODE
,
12731 &neighbor_remove_private_as_replace_as_cmd
);
12732 install_element(BGP_IPV4M_NODE
,
12733 &no_neighbor_remove_private_as_replace_as_cmd
);
12734 install_element(BGP_IPV4M_NODE
,
12735 &neighbor_remove_private_as_all_replace_as_cmd
);
12736 install_element(BGP_IPV4M_NODE
,
12737 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12738 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12739 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12740 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12741 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12742 install_element(BGP_IPV4L_NODE
,
12743 &neighbor_remove_private_as_replace_as_cmd
);
12744 install_element(BGP_IPV4L_NODE
,
12745 &no_neighbor_remove_private_as_replace_as_cmd
);
12746 install_element(BGP_IPV4L_NODE
,
12747 &neighbor_remove_private_as_all_replace_as_cmd
);
12748 install_element(BGP_IPV4L_NODE
,
12749 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12750 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12751 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12752 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12753 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12754 install_element(BGP_IPV6_NODE
,
12755 &neighbor_remove_private_as_replace_as_cmd
);
12756 install_element(BGP_IPV6_NODE
,
12757 &no_neighbor_remove_private_as_replace_as_cmd
);
12758 install_element(BGP_IPV6_NODE
,
12759 &neighbor_remove_private_as_all_replace_as_cmd
);
12760 install_element(BGP_IPV6_NODE
,
12761 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12762 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12763 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12764 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12765 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12766 install_element(BGP_IPV6M_NODE
,
12767 &neighbor_remove_private_as_replace_as_cmd
);
12768 install_element(BGP_IPV6M_NODE
,
12769 &no_neighbor_remove_private_as_replace_as_cmd
);
12770 install_element(BGP_IPV6M_NODE
,
12771 &neighbor_remove_private_as_all_replace_as_cmd
);
12772 install_element(BGP_IPV6M_NODE
,
12773 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12774 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12775 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12776 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12777 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12778 install_element(BGP_IPV6L_NODE
,
12779 &neighbor_remove_private_as_replace_as_cmd
);
12780 install_element(BGP_IPV6L_NODE
,
12781 &no_neighbor_remove_private_as_replace_as_cmd
);
12782 install_element(BGP_IPV6L_NODE
,
12783 &neighbor_remove_private_as_all_replace_as_cmd
);
12784 install_element(BGP_IPV6L_NODE
,
12785 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12786 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
12787 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12788 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12789 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12790 install_element(BGP_VPNV4_NODE
,
12791 &neighbor_remove_private_as_replace_as_cmd
);
12792 install_element(BGP_VPNV4_NODE
,
12793 &no_neighbor_remove_private_as_replace_as_cmd
);
12794 install_element(BGP_VPNV4_NODE
,
12795 &neighbor_remove_private_as_all_replace_as_cmd
);
12796 install_element(BGP_VPNV4_NODE
,
12797 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12798 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
12799 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12800 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12801 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12802 install_element(BGP_VPNV6_NODE
,
12803 &neighbor_remove_private_as_replace_as_cmd
);
12804 install_element(BGP_VPNV6_NODE
,
12805 &no_neighbor_remove_private_as_replace_as_cmd
);
12806 install_element(BGP_VPNV6_NODE
,
12807 &neighbor_remove_private_as_all_replace_as_cmd
);
12808 install_element(BGP_VPNV6_NODE
,
12809 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12811 /* "neighbor send-community" commands.*/
12812 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
12813 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
12814 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
12815 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
12816 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
12817 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
12818 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
12819 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
12820 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
12821 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
12822 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
12823 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
12824 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
12825 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
12826 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
12827 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
12828 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
12829 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
12830 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
12831 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
12832 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
12833 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
12834 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
12835 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
12836 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
12837 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
12838 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
12839 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
12840 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
12841 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
12842 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
12843 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
12844 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
12845 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
12846 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
12847 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
12849 /* "neighbor route-reflector" commands.*/
12850 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
12851 install_element(BGP_NODE
,
12852 &no_neighbor_route_reflector_client_hidden_cmd
);
12853 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
12854 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
12855 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
12856 install_element(BGP_IPV4M_NODE
,
12857 &no_neighbor_route_reflector_client_cmd
);
12858 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
12859 install_element(BGP_IPV4L_NODE
,
12860 &no_neighbor_route_reflector_client_cmd
);
12861 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
12862 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
12863 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
12864 install_element(BGP_IPV6M_NODE
,
12865 &no_neighbor_route_reflector_client_cmd
);
12866 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
12867 install_element(BGP_IPV6L_NODE
,
12868 &no_neighbor_route_reflector_client_cmd
);
12869 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
12870 install_element(BGP_VPNV4_NODE
,
12871 &no_neighbor_route_reflector_client_cmd
);
12872 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
12873 install_element(BGP_VPNV6_NODE
,
12874 &no_neighbor_route_reflector_client_cmd
);
12875 install_element(BGP_FLOWSPECV4_NODE
,
12876 &neighbor_route_reflector_client_cmd
);
12877 install_element(BGP_FLOWSPECV4_NODE
,
12878 &no_neighbor_route_reflector_client_cmd
);
12879 install_element(BGP_FLOWSPECV6_NODE
,
12880 &neighbor_route_reflector_client_cmd
);
12881 install_element(BGP_FLOWSPECV6_NODE
,
12882 &no_neighbor_route_reflector_client_cmd
);
12883 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
12884 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
12886 /* "neighbor route-server" commands.*/
12887 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
12888 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
12889 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
12890 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
12891 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
12892 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
12893 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
12894 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
12895 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
12896 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
12897 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
12898 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
12899 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
12900 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
12901 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
12902 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
12903 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
12904 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
12905 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
12906 install_element(BGP_FLOWSPECV4_NODE
,
12907 &no_neighbor_route_server_client_cmd
);
12908 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
12909 install_element(BGP_FLOWSPECV6_NODE
,
12910 &no_neighbor_route_server_client_cmd
);
12912 /* "neighbor addpath-tx-all-paths" commands.*/
12913 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
12914 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
12915 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12916 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12917 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12918 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12919 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12920 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12921 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12922 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12923 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12924 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12925 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12926 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12927 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12928 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12929 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12930 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12932 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
12933 install_element(BGP_NODE
,
12934 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12935 install_element(BGP_NODE
,
12936 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12937 install_element(BGP_IPV4_NODE
,
12938 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12939 install_element(BGP_IPV4_NODE
,
12940 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12941 install_element(BGP_IPV4M_NODE
,
12942 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12943 install_element(BGP_IPV4M_NODE
,
12944 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12945 install_element(BGP_IPV4L_NODE
,
12946 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12947 install_element(BGP_IPV4L_NODE
,
12948 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12949 install_element(BGP_IPV6_NODE
,
12950 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12951 install_element(BGP_IPV6_NODE
,
12952 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12953 install_element(BGP_IPV6M_NODE
,
12954 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12955 install_element(BGP_IPV6M_NODE
,
12956 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12957 install_element(BGP_IPV6L_NODE
,
12958 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12959 install_element(BGP_IPV6L_NODE
,
12960 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12961 install_element(BGP_VPNV4_NODE
,
12962 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12963 install_element(BGP_VPNV4_NODE
,
12964 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12965 install_element(BGP_VPNV6_NODE
,
12966 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12967 install_element(BGP_VPNV6_NODE
,
12968 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12970 /* "neighbor passive" commands. */
12971 install_element(BGP_NODE
, &neighbor_passive_cmd
);
12972 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
12975 /* "neighbor shutdown" commands. */
12976 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
12977 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
12978 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
12979 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
12981 /* "neighbor capability extended-nexthop" commands.*/
12982 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
12983 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
12985 /* "neighbor capability orf prefix-list" commands.*/
12986 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
12987 install_element(BGP_NODE
,
12988 &no_neighbor_capability_orf_prefix_hidden_cmd
);
12989 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
12990 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12991 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
12992 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12993 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
12994 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12995 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
12996 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12997 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
12998 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12999 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13000 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13002 /* "neighbor capability dynamic" commands.*/
13003 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13004 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13006 /* "neighbor dont-capability-negotiate" commands. */
13007 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13008 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13010 /* "neighbor ebgp-multihop" commands. */
13011 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13012 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13013 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13015 /* "neighbor disable-connected-check" commands. */
13016 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13017 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13019 /* "neighbor enforce-first-as" commands. */
13020 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13021 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13023 /* "neighbor description" commands. */
13024 install_element(BGP_NODE
, &neighbor_description_cmd
);
13025 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13027 /* "neighbor update-source" commands. "*/
13028 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13029 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13031 /* "neighbor default-originate" commands. */
13032 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13033 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13034 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13035 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13036 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13037 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13038 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13039 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13040 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13041 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13042 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13043 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13044 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13045 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13046 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13047 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13048 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13049 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13050 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13051 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13052 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13054 /* "neighbor port" commands. */
13055 install_element(BGP_NODE
, &neighbor_port_cmd
);
13056 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13058 /* "neighbor weight" commands. */
13059 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13060 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13062 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13063 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13064 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13065 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13066 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13067 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13068 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13069 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13070 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13071 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13072 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13073 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13074 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13075 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13076 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13077 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13079 /* "neighbor override-capability" commands. */
13080 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13081 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13083 /* "neighbor strict-capability-match" commands. */
13084 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13085 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13087 /* "neighbor timers" commands. */
13088 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13089 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13091 /* "neighbor timers connect" commands. */
13092 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13093 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13095 /* "neighbor advertisement-interval" commands. */
13096 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13097 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13099 /* "neighbor interface" commands. */
13100 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13101 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13103 /* "neighbor distribute" commands. */
13104 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13105 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13106 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13107 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13108 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13109 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13110 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13111 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13112 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13113 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13114 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13115 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13116 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13117 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13118 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13119 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13120 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13121 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13123 /* "neighbor prefix-list" commands. */
13124 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13125 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13126 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13127 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13128 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13129 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13130 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13131 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13132 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13133 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13134 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13135 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13136 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13137 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13138 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13139 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13140 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13141 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13142 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13143 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13144 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13145 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13147 /* "neighbor filter-list" commands. */
13148 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13149 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13150 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13151 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13152 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13153 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13154 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13155 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13156 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13157 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13158 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13159 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13160 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13161 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13162 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13163 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13164 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13165 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13166 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13167 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13168 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13169 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13171 /* "neighbor route-map" commands. */
13172 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13173 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13174 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13175 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13176 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13177 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13178 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13179 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13180 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13181 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13182 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13183 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13184 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13185 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13186 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13187 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13188 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13189 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13190 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13191 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13192 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13193 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13194 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13195 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13197 /* "neighbor unsuppress-map" commands. */
13198 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13199 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13200 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13201 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13202 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13203 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13204 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13205 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13206 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13207 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13208 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13209 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13210 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13211 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13212 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13213 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13214 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13215 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13217 /* "neighbor maximum-prefix" commands. */
13218 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13219 install_element(BGP_NODE
,
13220 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13221 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13222 install_element(BGP_NODE
,
13223 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13224 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13225 install_element(BGP_NODE
,
13226 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13227 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13228 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13229 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13230 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13231 install_element(BGP_IPV4_NODE
,
13232 &neighbor_maximum_prefix_threshold_warning_cmd
);
13233 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13234 install_element(BGP_IPV4_NODE
,
13235 &neighbor_maximum_prefix_threshold_restart_cmd
);
13236 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13237 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13238 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13239 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13240 install_element(BGP_IPV4M_NODE
,
13241 &neighbor_maximum_prefix_threshold_warning_cmd
);
13242 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13243 install_element(BGP_IPV4M_NODE
,
13244 &neighbor_maximum_prefix_threshold_restart_cmd
);
13245 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13246 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13247 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13248 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13249 install_element(BGP_IPV4L_NODE
,
13250 &neighbor_maximum_prefix_threshold_warning_cmd
);
13251 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13252 install_element(BGP_IPV4L_NODE
,
13253 &neighbor_maximum_prefix_threshold_restart_cmd
);
13254 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13255 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13256 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13257 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13258 install_element(BGP_IPV6_NODE
,
13259 &neighbor_maximum_prefix_threshold_warning_cmd
);
13260 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13261 install_element(BGP_IPV6_NODE
,
13262 &neighbor_maximum_prefix_threshold_restart_cmd
);
13263 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13264 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13265 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13266 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13267 install_element(BGP_IPV6M_NODE
,
13268 &neighbor_maximum_prefix_threshold_warning_cmd
);
13269 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13270 install_element(BGP_IPV6M_NODE
,
13271 &neighbor_maximum_prefix_threshold_restart_cmd
);
13272 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13273 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13274 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13275 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13276 install_element(BGP_IPV6L_NODE
,
13277 &neighbor_maximum_prefix_threshold_warning_cmd
);
13278 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13279 install_element(BGP_IPV6L_NODE
,
13280 &neighbor_maximum_prefix_threshold_restart_cmd
);
13281 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13282 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13283 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13284 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13285 install_element(BGP_VPNV4_NODE
,
13286 &neighbor_maximum_prefix_threshold_warning_cmd
);
13287 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13288 install_element(BGP_VPNV4_NODE
,
13289 &neighbor_maximum_prefix_threshold_restart_cmd
);
13290 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13291 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13292 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13293 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13294 install_element(BGP_VPNV6_NODE
,
13295 &neighbor_maximum_prefix_threshold_warning_cmd
);
13296 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13297 install_element(BGP_VPNV6_NODE
,
13298 &neighbor_maximum_prefix_threshold_restart_cmd
);
13299 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13301 /* "neighbor allowas-in" */
13302 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13303 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13304 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13305 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13306 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13307 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13308 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13309 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13310 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13311 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13312 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13313 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13314 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13315 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13316 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13317 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13318 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13319 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13320 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13321 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13323 /* address-family commands. */
13324 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13325 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13326 #ifdef KEEP_OLD_VPN_COMMANDS
13327 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13328 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13329 #endif /* KEEP_OLD_VPN_COMMANDS */
13331 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13333 /* "exit-address-family" command. */
13334 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13335 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13336 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13337 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13338 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13339 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13340 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13341 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13342 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13343 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13344 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13346 /* "clear ip bgp commands" */
13347 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13349 /* clear ip bgp prefix */
13350 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13351 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13352 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13354 /* "show [ip] bgp summary" commands. */
13355 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13356 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13357 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13358 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13359 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13360 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13362 /* "show [ip] bgp neighbors" commands. */
13363 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13365 /* "show [ip] bgp peer-group" commands. */
13366 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13368 /* "show [ip] bgp paths" commands. */
13369 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13371 /* "show [ip] bgp community" commands. */
13372 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13374 /* "show ip bgp large-community" commands. */
13375 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13376 /* "show [ip] bgp attribute-info" commands. */
13377 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13378 /* "show [ip] bgp route-leak" command */
13379 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13381 /* "redistribute" commands. */
13382 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13383 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13384 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13385 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13386 install_element(BGP_NODE
,
13387 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13388 install_element(BGP_NODE
,
13389 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13390 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13391 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13392 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13393 install_element(BGP_NODE
,
13394 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13395 install_element(BGP_NODE
,
13396 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13397 install_element(BGP_NODE
,
13398 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13399 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13400 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13401 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13402 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13403 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13404 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13405 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13406 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13407 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13408 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13409 install_element(BGP_IPV4_NODE
,
13410 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13411 install_element(BGP_IPV4_NODE
,
13412 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13413 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13414 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13415 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13416 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13417 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13418 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13420 /* import|export vpn [route-map WORD] */
13421 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13422 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13424 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13425 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13427 /* ttl_security commands */
13428 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13429 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13431 /* "show [ip] bgp memory" commands. */
13432 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13434 /* "show bgp martian next-hop" */
13435 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13437 /* "show [ip] bgp views" commands. */
13438 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13440 /* "show [ip] bgp vrfs" commands. */
13441 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13443 /* Community-list. */
13444 community_list_vty();
13446 /* vpn-policy commands */
13447 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13448 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13449 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13450 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13451 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13452 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13453 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13454 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13455 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13456 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13457 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13458 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13460 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13461 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13463 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13464 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13465 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13466 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13467 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13468 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13469 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13470 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13471 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13472 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13473 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13474 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13477 #include "memory.h"
13478 #include "bgp_regex.h"
13479 #include "bgp_clist.h"
13480 #include "bgp_ecommunity.h"
13482 /* VTY functions. */
13484 /* Direction value to string conversion. */
13485 static const char *community_direct_str(int direct
)
13488 case COMMUNITY_DENY
:
13490 case COMMUNITY_PERMIT
:
13497 /* Display error string. */
13498 static void community_list_perror(struct vty
*vty
, int ret
)
13501 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13502 vty_out(vty
, "%% Can't find community-list\n");
13504 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13505 vty_out(vty
, "%% Malformed community-list value\n");
13507 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13509 "%% Community name conflict, previously defined as standard community\n");
13511 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13513 "%% Community name conflict, previously defined as expanded community\n");
13518 /* "community-list" keyword help string. */
13519 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13521 /* ip community-list standard */
13522 DEFUN (ip_community_list_standard
,
13523 ip_community_list_standard_cmd
,
13524 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13527 "Community list number (standard)\n"
13528 "Add an standard community-list entry\n"
13529 "Community list name\n"
13530 "Specify community to reject\n"
13531 "Specify community to accept\n"
13534 char *cl_name_or_number
= NULL
;
13536 int style
= COMMUNITY_LIST_STANDARD
;
13539 argv_find(argv
, argc
, "(1-99)", &idx
);
13540 argv_find(argv
, argc
, "WORD", &idx
);
13541 cl_name_or_number
= argv
[idx
]->arg
;
13542 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13544 argv_find(argv
, argc
, "AA:NN", &idx
);
13545 char *str
= argv_concat(argv
, argc
, idx
);
13547 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13550 XFREE(MTYPE_TMP
, str
);
13553 /* Display error string. */
13554 community_list_perror(vty
, ret
);
13555 return CMD_WARNING_CONFIG_FAILED
;
13558 return CMD_SUCCESS
;
13561 DEFUN (no_ip_community_list_standard_all
,
13562 no_ip_community_list_standard_all_cmd
,
13563 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13567 "Community list number (standard)\n"
13568 "Add an standard community-list entry\n"
13569 "Community list name\n"
13570 "Specify community to reject\n"
13571 "Specify community to accept\n"
13574 char *cl_name_or_number
= NULL
;
13576 int style
= COMMUNITY_LIST_STANDARD
;
13579 argv_find(argv
, argc
, "(1-99)", &idx
);
13580 argv_find(argv
, argc
, "WORD", &idx
);
13581 cl_name_or_number
= argv
[idx
]->arg
;
13582 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13584 argv_find(argv
, argc
, "AA:NN", &idx
);
13585 char *str
= argv_concat(argv
, argc
, idx
);
13587 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13590 XFREE(MTYPE_TMP
, str
);
13593 community_list_perror(vty
, ret
);
13594 return CMD_WARNING_CONFIG_FAILED
;
13597 return CMD_SUCCESS
;
13600 /* ip community-list expanded */
13601 DEFUN (ip_community_list_expanded_all
,
13602 ip_community_list_expanded_all_cmd
,
13603 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13606 "Community list number (expanded)\n"
13607 "Add an expanded community-list entry\n"
13608 "Community list name\n"
13609 "Specify community to reject\n"
13610 "Specify community to accept\n"
13613 char *cl_name_or_number
= NULL
;
13615 int style
= COMMUNITY_LIST_EXPANDED
;
13618 argv_find(argv
, argc
, "(100-500)", &idx
);
13619 argv_find(argv
, argc
, "WORD", &idx
);
13620 cl_name_or_number
= argv
[idx
]->arg
;
13621 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13623 argv_find(argv
, argc
, "AA:NN", &idx
);
13624 char *str
= argv_concat(argv
, argc
, idx
);
13626 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13629 XFREE(MTYPE_TMP
, str
);
13632 /* Display error string. */
13633 community_list_perror(vty
, ret
);
13634 return CMD_WARNING_CONFIG_FAILED
;
13637 return CMD_SUCCESS
;
13640 DEFUN (no_ip_community_list_expanded_all
,
13641 no_ip_community_list_expanded_all_cmd
,
13642 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13646 "Community list number (expanded)\n"
13647 "Add an expanded community-list entry\n"
13648 "Community list name\n"
13649 "Specify community to reject\n"
13650 "Specify community to accept\n"
13653 char *cl_name_or_number
= NULL
;
13655 int style
= COMMUNITY_LIST_EXPANDED
;
13658 argv_find(argv
, argc
, "(100-500)", &idx
);
13659 argv_find(argv
, argc
, "WORD", &idx
);
13660 cl_name_or_number
= argv
[idx
]->arg
;
13661 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13663 argv_find(argv
, argc
, "AA:NN", &idx
);
13664 char *str
= argv_concat(argv
, argc
, idx
);
13666 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13669 XFREE(MTYPE_TMP
, str
);
13672 community_list_perror(vty
, ret
);
13673 return CMD_WARNING_CONFIG_FAILED
;
13676 return CMD_SUCCESS
;
13679 /* Return configuration string of community-list entry. */
13680 static const char *community_list_config_str(struct community_entry
*entry
)
13687 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13688 str
= community_str(entry
->u
.com
, false);
13689 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
13690 str
= lcommunity_str(entry
->u
.lcom
, false);
13692 str
= entry
->config
;
13697 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13699 struct community_entry
*entry
;
13701 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13702 if (entry
== list
->head
) {
13703 if (all_digit(list
->name
))
13704 vty_out(vty
, "Community %s list %s\n",
13705 entry
->style
== COMMUNITY_LIST_STANDARD
13707 : "(expanded) access",
13710 vty_out(vty
, "Named Community %s list %s\n",
13711 entry
->style
== COMMUNITY_LIST_STANDARD
13717 vty_out(vty
, " %s\n",
13718 community_direct_str(entry
->direct
));
13720 vty_out(vty
, " %s %s\n",
13721 community_direct_str(entry
->direct
),
13722 community_list_config_str(entry
));
13726 DEFUN (show_ip_community_list
,
13727 show_ip_community_list_cmd
,
13728 "show ip community-list",
13731 "List community-list\n")
13733 struct community_list
*list
;
13734 struct community_list_master
*cm
;
13736 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13738 return CMD_SUCCESS
;
13740 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13741 community_list_show(vty
, list
);
13743 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13744 community_list_show(vty
, list
);
13746 return CMD_SUCCESS
;
13749 DEFUN (show_ip_community_list_arg
,
13750 show_ip_community_list_arg_cmd
,
13751 "show ip community-list <(1-500)|WORD>",
13754 "List community-list\n"
13755 "Community-list number\n"
13756 "Community-list name\n")
13758 int idx_comm_list
= 3;
13759 struct community_list
*list
;
13761 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13762 COMMUNITY_LIST_MASTER
);
13764 vty_out(vty
, "%% Can't find community-list\n");
13765 return CMD_WARNING
;
13768 community_list_show(vty
, list
);
13770 return CMD_SUCCESS
;
13774 * Large Community code.
13776 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
13777 struct cmd_token
**argv
, int style
,
13778 int reject_all_digit_name
)
13786 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13789 /* All digit name check. */
13791 argv_find(argv
, argc
, "WORD", &idx
);
13792 argv_find(argv
, argc
, "(1-99)", &idx
);
13793 argv_find(argv
, argc
, "(100-500)", &idx
);
13794 cl_name
= argv
[idx
]->arg
;
13795 if (reject_all_digit_name
&& all_digit(cl_name
)) {
13796 vty_out(vty
, "%% Community name cannot have all digits\n");
13797 return CMD_WARNING_CONFIG_FAILED
;
13801 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
13802 argv_find(argv
, argc
, "LINE", &idx
);
13803 /* Concat community string argument. */
13805 str
= argv_concat(argv
, argc
, idx
);
13809 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
13811 /* Free temporary community list string allocated by
13814 XFREE(MTYPE_TMP
, str
);
13817 community_list_perror(vty
, ret
);
13818 return CMD_WARNING_CONFIG_FAILED
;
13820 return CMD_SUCCESS
;
13823 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
13824 struct cmd_token
**argv
, int style
)
13831 argv_find(argv
, argc
, "permit", &idx
);
13832 argv_find(argv
, argc
, "deny", &idx
);
13835 /* Check the list direct. */
13836 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
13837 direct
= COMMUNITY_PERMIT
;
13839 direct
= COMMUNITY_DENY
;
13842 argv_find(argv
, argc
, "LINE", &idx
);
13843 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
13844 /* Concat community string argument. */
13845 str
= argv_concat(argv
, argc
, idx
);
13849 argv_find(argv
, argc
, "(1-99)", &idx
);
13850 argv_find(argv
, argc
, "(100-500)", &idx
);
13851 argv_find(argv
, argc
, "WORD", &idx
);
13853 /* Unset community list. */
13854 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
13857 /* Free temporary community list string allocated by
13860 XFREE(MTYPE_TMP
, str
);
13863 community_list_perror(vty
, ret
);
13864 return CMD_WARNING_CONFIG_FAILED
;
13867 return CMD_SUCCESS
;
13870 /* "large-community-list" keyword help string. */
13871 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
13872 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
13874 DEFUN (ip_lcommunity_list_standard
,
13875 ip_lcommunity_list_standard_cmd
,
13876 "ip large-community-list (1-99) <deny|permit>",
13878 LCOMMUNITY_LIST_STR
13879 "Large Community list number (standard)\n"
13880 "Specify large community to reject\n"
13881 "Specify large community to accept\n")
13883 return lcommunity_list_set_vty(vty
, argc
, argv
,
13884 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13887 DEFUN (ip_lcommunity_list_standard1
,
13888 ip_lcommunity_list_standard1_cmd
,
13889 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
13891 LCOMMUNITY_LIST_STR
13892 "Large Community list number (standard)\n"
13893 "Specify large community to reject\n"
13894 "Specify large community to accept\n"
13895 LCOMMUNITY_VAL_STR
)
13897 return lcommunity_list_set_vty(vty
, argc
, argv
,
13898 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13901 DEFUN (ip_lcommunity_list_expanded
,
13902 ip_lcommunity_list_expanded_cmd
,
13903 "ip large-community-list (100-500) <deny|permit> LINE...",
13905 LCOMMUNITY_LIST_STR
13906 "Large Community list number (expanded)\n"
13907 "Specify large community to reject\n"
13908 "Specify large community to accept\n"
13909 "An ordered list as a regular-expression\n")
13911 return lcommunity_list_set_vty(vty
, argc
, argv
,
13912 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
13915 DEFUN (ip_lcommunity_list_name_standard
,
13916 ip_lcommunity_list_name_standard_cmd
,
13917 "ip large-community-list standard WORD <deny|permit>",
13919 LCOMMUNITY_LIST_STR
13920 "Specify standard large-community-list\n"
13921 "Large Community list name\n"
13922 "Specify large community to reject\n"
13923 "Specify large community to accept\n")
13925 return lcommunity_list_set_vty(vty
, argc
, argv
,
13926 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13929 DEFUN (ip_lcommunity_list_name_standard1
,
13930 ip_lcommunity_list_name_standard1_cmd
,
13931 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
13933 LCOMMUNITY_LIST_STR
13934 "Specify standard large-community-list\n"
13935 "Large Community list name\n"
13936 "Specify large community to reject\n"
13937 "Specify large community to accept\n"
13938 LCOMMUNITY_VAL_STR
)
13940 return lcommunity_list_set_vty(vty
, argc
, argv
,
13941 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13944 DEFUN (ip_lcommunity_list_name_expanded
,
13945 ip_lcommunity_list_name_expanded_cmd
,
13946 "ip large-community-list expanded WORD <deny|permit> LINE...",
13948 LCOMMUNITY_LIST_STR
13949 "Specify expanded large-community-list\n"
13950 "Large Community list name\n"
13951 "Specify large community to reject\n"
13952 "Specify large community to accept\n"
13953 "An ordered list as a regular-expression\n")
13955 return lcommunity_list_set_vty(vty
, argc
, argv
,
13956 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
13959 DEFUN (no_ip_lcommunity_list_standard_all
,
13960 no_ip_lcommunity_list_standard_all_cmd
,
13961 "no ip large-community-list <(1-99)|(100-500)|WORD>",
13964 LCOMMUNITY_LIST_STR
13965 "Large Community list number (standard)\n"
13966 "Large Community list number (expanded)\n"
13967 "Large Community list name\n")
13969 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13970 LARGE_COMMUNITY_LIST_STANDARD
);
13973 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
13974 no_ip_lcommunity_list_name_expanded_all_cmd
,
13975 "no ip large-community-list expanded WORD",
13978 LCOMMUNITY_LIST_STR
13979 "Specify expanded large-community-list\n"
13980 "Large Community list name\n")
13982 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13983 LARGE_COMMUNITY_LIST_EXPANDED
);
13986 DEFUN (no_ip_lcommunity_list_standard
,
13987 no_ip_lcommunity_list_standard_cmd
,
13988 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
13991 LCOMMUNITY_LIST_STR
13992 "Large Community list number (standard)\n"
13993 "Specify large community to reject\n"
13994 "Specify large community to accept\n"
13995 LCOMMUNITY_VAL_STR
)
13997 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13998 LARGE_COMMUNITY_LIST_STANDARD
);
14001 DEFUN (no_ip_lcommunity_list_expanded
,
14002 no_ip_lcommunity_list_expanded_cmd
,
14003 "no ip large-community-list (100-500) <deny|permit> LINE...",
14006 LCOMMUNITY_LIST_STR
14007 "Large Community list number (expanded)\n"
14008 "Specify large community to reject\n"
14009 "Specify large community to accept\n"
14010 "An ordered list as a regular-expression\n")
14012 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14013 LARGE_COMMUNITY_LIST_EXPANDED
);
14016 DEFUN (no_ip_lcommunity_list_name_standard
,
14017 no_ip_lcommunity_list_name_standard_cmd
,
14018 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14021 LCOMMUNITY_LIST_STR
14022 "Specify standard large-community-list\n"
14023 "Large Community list name\n"
14024 "Specify large community to reject\n"
14025 "Specify large community to accept\n"
14026 LCOMMUNITY_VAL_STR
)
14028 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14029 LARGE_COMMUNITY_LIST_STANDARD
);
14032 DEFUN (no_ip_lcommunity_list_name_expanded
,
14033 no_ip_lcommunity_list_name_expanded_cmd
,
14034 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14037 LCOMMUNITY_LIST_STR
14038 "Specify expanded large-community-list\n"
14039 "Large community list name\n"
14040 "Specify large community to reject\n"
14041 "Specify large community to accept\n"
14042 "An ordered list as a regular-expression\n")
14044 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14045 LARGE_COMMUNITY_LIST_EXPANDED
);
14048 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14050 struct community_entry
*entry
;
14052 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14053 if (entry
== list
->head
) {
14054 if (all_digit(list
->name
))
14055 vty_out(vty
, "Large community %s list %s\n",
14056 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14058 : "(expanded) access",
14062 "Named large community %s list %s\n",
14063 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14069 vty_out(vty
, " %s\n",
14070 community_direct_str(entry
->direct
));
14072 vty_out(vty
, " %s %s\n",
14073 community_direct_str(entry
->direct
),
14074 community_list_config_str(entry
));
14078 DEFUN (show_ip_lcommunity_list
,
14079 show_ip_lcommunity_list_cmd
,
14080 "show ip large-community-list",
14083 "List large-community list\n")
14085 struct community_list
*list
;
14086 struct community_list_master
*cm
;
14088 cm
= community_list_master_lookup(bgp_clist
,
14089 LARGE_COMMUNITY_LIST_MASTER
);
14091 return CMD_SUCCESS
;
14093 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14094 lcommunity_list_show(vty
, list
);
14096 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14097 lcommunity_list_show(vty
, list
);
14099 return CMD_SUCCESS
;
14102 DEFUN (show_ip_lcommunity_list_arg
,
14103 show_ip_lcommunity_list_arg_cmd
,
14104 "show ip large-community-list <(1-500)|WORD>",
14107 "List large-community list\n"
14108 "large-community-list number\n"
14109 "large-community-list name\n")
14111 struct community_list
*list
;
14113 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14114 LARGE_COMMUNITY_LIST_MASTER
);
14116 vty_out(vty
, "%% Can't find extcommunity-list\n");
14117 return CMD_WARNING
;
14120 lcommunity_list_show(vty
, list
);
14122 return CMD_SUCCESS
;
14125 /* "extcommunity-list" keyword help string. */
14126 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14127 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14129 DEFUN (ip_extcommunity_list_standard
,
14130 ip_extcommunity_list_standard_cmd
,
14131 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14133 EXTCOMMUNITY_LIST_STR
14134 "Extended Community list number (standard)\n"
14135 "Specify standard extcommunity-list\n"
14136 "Community list name\n"
14137 "Specify community to reject\n"
14138 "Specify community to accept\n"
14139 EXTCOMMUNITY_VAL_STR
)
14141 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14143 char *cl_number_or_name
= NULL
;
14146 argv_find(argv
, argc
, "(1-99)", &idx
);
14147 argv_find(argv
, argc
, "WORD", &idx
);
14148 cl_number_or_name
= argv
[idx
]->arg
;
14149 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14151 argv_find(argv
, argc
, "AA:NN", &idx
);
14152 char *str
= argv_concat(argv
, argc
, idx
);
14154 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14157 XFREE(MTYPE_TMP
, str
);
14160 community_list_perror(vty
, ret
);
14161 return CMD_WARNING_CONFIG_FAILED
;
14164 return CMD_SUCCESS
;
14167 DEFUN (ip_extcommunity_list_name_expanded
,
14168 ip_extcommunity_list_name_expanded_cmd
,
14169 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14171 EXTCOMMUNITY_LIST_STR
14172 "Extended Community list number (expanded)\n"
14173 "Specify expanded extcommunity-list\n"
14174 "Extended Community list name\n"
14175 "Specify community to reject\n"
14176 "Specify community to accept\n"
14177 "An ordered list as a regular-expression\n")
14179 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14181 char *cl_number_or_name
= NULL
;
14184 argv_find(argv
, argc
, "(100-500)", &idx
);
14185 argv_find(argv
, argc
, "WORD", &idx
);
14186 cl_number_or_name
= argv
[idx
]->arg
;
14187 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14189 argv_find(argv
, argc
, "LINE", &idx
);
14190 char *str
= argv_concat(argv
, argc
, idx
);
14192 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14195 XFREE(MTYPE_TMP
, str
);
14198 community_list_perror(vty
, ret
);
14199 return CMD_WARNING_CONFIG_FAILED
;
14202 return CMD_SUCCESS
;
14205 DEFUN (no_ip_extcommunity_list_standard_all
,
14206 no_ip_extcommunity_list_standard_all_cmd
,
14207 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14210 EXTCOMMUNITY_LIST_STR
14211 "Extended Community list number (standard)\n"
14212 "Specify standard extcommunity-list\n"
14213 "Community list name\n"
14214 "Specify community to reject\n"
14215 "Specify community to accept\n"
14216 EXTCOMMUNITY_VAL_STR
)
14218 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14220 char *cl_number_or_name
= NULL
;
14223 argv_find(argv
, argc
, "(1-99)", &idx
);
14224 argv_find(argv
, argc
, "WORD", &idx
);
14225 cl_number_or_name
= argv
[idx
]->arg
;
14226 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14228 argv_find(argv
, argc
, "AA:NN", &idx
);
14229 char *str
= argv_concat(argv
, argc
, idx
);
14231 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14234 XFREE(MTYPE_TMP
, str
);
14237 community_list_perror(vty
, ret
);
14238 return CMD_WARNING_CONFIG_FAILED
;
14241 return CMD_SUCCESS
;
14244 DEFUN (no_ip_extcommunity_list_expanded_all
,
14245 no_ip_extcommunity_list_expanded_all_cmd
,
14246 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14249 EXTCOMMUNITY_LIST_STR
14250 "Extended Community list number (expanded)\n"
14251 "Specify expanded extcommunity-list\n"
14252 "Extended Community list name\n"
14253 "Specify community to reject\n"
14254 "Specify community to accept\n"
14255 "An ordered list as a regular-expression\n")
14257 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14259 char *cl_number_or_name
= NULL
;
14262 argv_find(argv
, argc
, "(100-500)", &idx
);
14263 argv_find(argv
, argc
, "WORD", &idx
);
14264 cl_number_or_name
= argv
[idx
]->arg
;
14265 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14267 argv_find(argv
, argc
, "LINE", &idx
);
14268 char *str
= argv_concat(argv
, argc
, idx
);
14270 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14273 XFREE(MTYPE_TMP
, str
);
14276 community_list_perror(vty
, ret
);
14277 return CMD_WARNING_CONFIG_FAILED
;
14280 return CMD_SUCCESS
;
14283 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14285 struct community_entry
*entry
;
14287 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14288 if (entry
== list
->head
) {
14289 if (all_digit(list
->name
))
14290 vty_out(vty
, "Extended community %s list %s\n",
14291 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14293 : "(expanded) access",
14297 "Named extended community %s list %s\n",
14298 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14304 vty_out(vty
, " %s\n",
14305 community_direct_str(entry
->direct
));
14307 vty_out(vty
, " %s %s\n",
14308 community_direct_str(entry
->direct
),
14309 community_list_config_str(entry
));
14313 DEFUN (show_ip_extcommunity_list
,
14314 show_ip_extcommunity_list_cmd
,
14315 "show ip extcommunity-list",
14318 "List extended-community list\n")
14320 struct community_list
*list
;
14321 struct community_list_master
*cm
;
14323 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14325 return CMD_SUCCESS
;
14327 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14328 extcommunity_list_show(vty
, list
);
14330 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14331 extcommunity_list_show(vty
, list
);
14333 return CMD_SUCCESS
;
14336 DEFUN (show_ip_extcommunity_list_arg
,
14337 show_ip_extcommunity_list_arg_cmd
,
14338 "show ip extcommunity-list <(1-500)|WORD>",
14341 "List extended-community list\n"
14342 "Extcommunity-list number\n"
14343 "Extcommunity-list name\n")
14345 int idx_comm_list
= 3;
14346 struct community_list
*list
;
14348 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14349 EXTCOMMUNITY_LIST_MASTER
);
14351 vty_out(vty
, "%% Can't find extcommunity-list\n");
14352 return CMD_WARNING
;
14355 extcommunity_list_show(vty
, list
);
14357 return CMD_SUCCESS
;
14360 /* Display community-list and extcommunity-list configuration. */
14361 static int community_list_config_write(struct vty
*vty
)
14363 struct community_list
*list
;
14364 struct community_entry
*entry
;
14365 struct community_list_master
*cm
;
14368 /* Community-list. */
14369 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14371 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14372 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14373 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
14374 community_direct_str(entry
->direct
),
14375 community_list_config_str(entry
));
14378 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14379 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14380 vty_out(vty
, "ip community-list %s %s %s %s\n",
14381 entry
->style
== COMMUNITY_LIST_STANDARD
14384 list
->name
, community_direct_str(entry
->direct
),
14385 community_list_config_str(entry
));
14389 /* Extcommunity-list. */
14390 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14392 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14393 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14394 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
14395 list
->name
, community_direct_str(entry
->direct
),
14396 community_list_config_str(entry
));
14399 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14400 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14401 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
14402 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14405 list
->name
, community_direct_str(entry
->direct
),
14406 community_list_config_str(entry
));
14411 /* lcommunity-list. */
14412 cm
= community_list_master_lookup(bgp_clist
,
14413 LARGE_COMMUNITY_LIST_MASTER
);
14415 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14416 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14417 vty_out(vty
, "ip large-community-list %s %s %s\n",
14418 list
->name
, community_direct_str(entry
->direct
),
14419 community_list_config_str(entry
));
14422 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14423 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14424 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
14425 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
14428 list
->name
, community_direct_str(entry
->direct
),
14429 community_list_config_str(entry
));
14436 static struct cmd_node community_list_node
= {
14437 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
14440 static void community_list_vty(void)
14442 install_node(&community_list_node
, community_list_config_write
);
14444 /* Community-list. */
14445 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
14446 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
14447 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
14448 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
14449 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
14450 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
14452 /* Extcommunity-list. */
14453 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
14454 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
14455 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
14456 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
14457 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
14458 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
14460 /* Large Community List */
14461 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
14462 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
14463 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
14464 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
14465 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
14466 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
14467 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
14468 install_element(CONFIG_NODE
,
14469 &no_ip_lcommunity_list_name_expanded_all_cmd
);
14470 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
14471 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
14472 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
14473 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
14474 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
14475 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);