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
;
95 return BGP_IPV6M_NODE
;
97 case SAFI_LABELED_UNICAST
:
98 return BGP_IPV6L_NODE
;
101 return BGP_VPNV6_NODE
;
105 return BGP_IPV4_NODE
;
110 return BGP_EVPN_NODE
;
113 // We should never be here but to clarify the switch statement..
114 return BGP_IPV4_NODE
;
118 // Impossible to happen
119 return BGP_IPV4_NODE
;
122 /* Utility function to get address family from current node. */
123 afi_t
bgp_node_afi(struct vty
*vty
)
143 /* Utility function to get subsequent address family from current
145 safi_t
bgp_node_safi(struct vty
*vty
)
151 safi
= SAFI_MPLS_VPN
;
155 safi
= SAFI_MULTICAST
;
162 safi
= SAFI_LABELED_UNICAST
;
172 * Converts an AFI in string form to afi_t
174 * @param afi string, one of
177 * @return the corresponding afi_t
179 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
181 afi_t afi
= AFI_MAX
; /* unknown */
182 if (strmatch(afi_str
, "ipv4"))
184 else if (strmatch(afi_str
, "ipv6"))
189 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
193 if (argv_find(argv
, argc
, "ipv4", index
)) {
197 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
205 /* supports <unicast|multicast|vpn|labeled-unicast> */
206 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
208 safi_t safi
= SAFI_MAX
; /* unknown */
209 if (strmatch(safi_str
, "multicast"))
210 safi
= SAFI_MULTICAST
;
211 else if (strmatch(safi_str
, "unicast"))
213 else if (strmatch(safi_str
, "vpn"))
214 safi
= SAFI_MPLS_VPN
;
215 else if (strmatch(safi_str
, "labeled-unicast"))
216 safi
= SAFI_LABELED_UNICAST
;
220 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
224 if (argv_find(argv
, argc
, "unicast", index
)) {
227 *safi
= SAFI_UNICAST
;
228 } else if (argv_find(argv
, argc
, "multicast", index
)) {
231 *safi
= SAFI_MULTICAST
;
232 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
235 *safi
= SAFI_LABELED_UNICAST
;
236 } else if (argv_find(argv
, argc
, "vpn", index
)) {
239 *safi
= SAFI_MPLS_VPN
;
245 * bgp_vty_find_and_parse_afi_safi_bgp
247 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
248 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
249 * to appropriate values for the calling function. This is to allow the
250 * calling function to make decisions appropriate for the show command
251 * that is being parsed.
253 * The show commands are generally of the form:
254 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
255 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
257 * Since we use argv_find if the show command in particular doesn't have:
259 * [<view|vrf> VIEWVRFNAME]
260 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
261 * The command parsing should still be ok.
263 * vty -> The vty for the command so we can output some useful data in
264 * the event of a parse error in the vrf.
265 * argv -> The command tokens
266 * argc -> How many command tokens we have
267 * idx -> The current place in the command, generally should be 0 for this
269 * afi -> The parsed afi if it was included in the show command, returned here
270 * safi -> The parsed safi if it was included in the show command, returned here
271 * bgp -> Pointer to the bgp data structure we need to fill in.
273 * The function returns the correct location in the parse tree for the
276 * Returns 0 for failure to parse correctly, else the idx position of where
277 * it found the last token.
279 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
280 struct cmd_token
**argv
, int argc
,
281 int *idx
, afi_t
*afi
, safi_t
*safi
,
284 char *vrf_name
= NULL
;
290 if (argv_find(argv
, argc
, "ip", idx
))
293 if (argv_find(argv
, argc
, "view", idx
)
294 || argv_find(argv
, argc
, "vrf", idx
)) {
295 vrf_name
= argv
[*idx
+ 1]->arg
;
297 if (strmatch(vrf_name
, "all"))
300 *bgp
= bgp_lookup_by_name(vrf_name
);
303 "View/Vrf specified is unknown: %s\n",
310 *bgp
= bgp_get_default();
312 vty_out(vty
, "Unable to find default BGP instance\n");
318 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
319 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
325 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
327 struct interface
*ifp
= NULL
;
329 if (su
->sa
.sa_family
== AF_INET
)
330 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
331 else if (su
->sa
.sa_family
== AF_INET6
)
332 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
333 su
->sin6
.sin6_scope_id
,
342 /* Utility function for looking up peer from VTY. */
343 /* This is used only for configuration, so disallow if attempted on
344 * a dynamic neighbor.
346 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
348 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
357 ret
= str2sockunion(ip_str
, &su
);
359 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
361 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
364 "%% Malformed address or name: %s\n",
370 peer
= peer_lookup(bgp
, &su
);
373 "%% Specify remote-as or peer-group commands first\n");
376 if (peer_dynamic_neighbor(peer
)) {
378 "%% Operation not allowed on a dynamic neighbor\n");
385 /* Utility function for looking up peer or peer group. */
386 /* This is used only for configuration, so disallow if attempted on
387 * a dynamic neighbor.
389 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
391 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
394 struct peer
*peer
= NULL
;
395 struct peer_group
*group
= NULL
;
401 ret
= str2sockunion(peer_str
, &su
);
403 /* IP address, locate peer. */
404 peer
= peer_lookup(bgp
, &su
);
406 /* Not IP, could match either peer configured on interface or a
408 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
410 group
= peer_group_lookup(bgp
, peer_str
);
414 if (peer_dynamic_neighbor(peer
)) {
416 "%% Operation not allowed on a dynamic neighbor\n");
426 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
431 int bgp_vty_return(struct vty
*vty
, int ret
)
433 const char *str
= NULL
;
436 case BGP_ERR_INVALID_VALUE
:
437 str
= "Invalid value";
439 case BGP_ERR_INVALID_FLAG
:
440 str
= "Invalid flag";
442 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
443 str
= "Peer-group has been shutdown. Activate the peer-group first";
445 case BGP_ERR_PEER_FLAG_CONFLICT
:
446 str
= "Can't set override-capability and strict-capability-match at the same time";
448 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
449 str
= "Specify remote-as or peer-group remote AS first";
451 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
452 str
= "Cannot change the peer-group. Deconfigure first";
454 case BGP_ERR_PEER_GROUP_MISMATCH
:
455 str
= "Peer is not a member of this peer-group";
457 case BGP_ERR_PEER_FILTER_CONFLICT
:
458 str
= "Prefix/distribute list can not co-exist";
460 case BGP_ERR_NOT_INTERNAL_PEER
:
461 str
= "Invalid command. Not an internal neighbor";
463 case BGP_ERR_REMOVE_PRIVATE_AS
:
464 str
= "remove-private-AS cannot be configured for IBGP peers";
466 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
467 str
= "Local-AS allowed only for EBGP peers";
469 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
470 str
= "Cannot have local-as same as BGP AS number";
472 case BGP_ERR_TCPSIG_FAILED
:
473 str
= "Error while applying TCP-Sig to session(s)";
475 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
476 str
= "ebgp-multihop and ttl-security cannot be configured together";
478 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
479 str
= "ttl-security only allowed for EBGP peers";
481 case BGP_ERR_AS_OVERRIDE
:
482 str
= "as-override cannot be configured for IBGP peers";
484 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
485 str
= "Invalid limit for number of dynamic neighbors";
487 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
488 str
= "Dynamic neighbor listen range already exists";
490 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
491 str
= "Operation not allowed on a dynamic neighbor";
493 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
494 str
= "Operation not allowed on a directly connected neighbor";
496 case BGP_ERR_PEER_SAFI_CONFLICT
:
497 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
501 vty_out(vty
, "%% %s\n", str
);
502 return CMD_WARNING_CONFIG_FAILED
;
507 /* BGP clear sort. */
516 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
517 safi_t safi
, int error
)
520 case BGP_ERR_AF_UNCONFIGURED
:
522 "%%BGP: Enable %s address family for the neighbor %s\n",
523 afi_safi_print(afi
, safi
), peer
->host
);
525 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
527 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
535 /* `clear ip bgp' functions. */
536 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
537 enum clear_sort sort
, enum bgp_clear_type stype
,
542 struct listnode
*node
, *nnode
;
544 /* Clear all neighbors. */
546 * Pass along pointer to next node to peer_clear() when walking all
548 * on the BGP instance as that may get freed if it is a doppelganger
550 if (sort
== clear_all
) {
551 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
552 if (stype
== BGP_CLEAR_SOFT_NONE
)
553 ret
= peer_clear(peer
, &nnode
);
554 else if (peer
->afc
[afi
][safi
])
555 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
560 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
563 /* This is to apply read-only mode on this clear. */
564 if (stype
== BGP_CLEAR_SOFT_NONE
)
565 bgp
->update_delay_over
= 0;
570 /* Clear specified neighbors. */
571 if (sort
== clear_peer
) {
575 /* Make sockunion for lookup. */
576 ret
= str2sockunion(arg
, &su
);
578 peer
= peer_lookup_by_conf_if(bgp
, arg
);
580 peer
= peer_lookup_by_hostname(bgp
, arg
);
583 "Malformed address or name: %s\n",
589 peer
= peer_lookup(bgp
, &su
);
592 "%%BGP: Unknown neighbor - \"%s\"\n",
598 if (stype
== BGP_CLEAR_SOFT_NONE
)
599 ret
= peer_clear(peer
, NULL
);
601 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
604 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
609 /* Clear all peer-group members. */
610 if (sort
== clear_group
) {
611 struct peer_group
*group
;
613 group
= peer_group_lookup(bgp
, arg
);
615 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
619 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
620 if (stype
== BGP_CLEAR_SOFT_NONE
) {
621 peer_clear(peer
, NULL
);
625 if (!peer
->afc
[afi
][safi
])
628 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
631 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
636 if (sort
== clear_external
) {
637 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
638 if (peer
->sort
== BGP_PEER_IBGP
)
641 if (stype
== BGP_CLEAR_SOFT_NONE
)
642 ret
= peer_clear(peer
, &nnode
);
644 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
647 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
652 if (sort
== clear_as
) {
656 as
= strtoul(arg
, NULL
, 10);
658 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
663 if (stype
== BGP_CLEAR_SOFT_NONE
)
664 ret
= peer_clear(peer
, &nnode
);
666 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
669 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
673 "%%BGP: No peer is configured with AS %s\n",
681 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
682 safi_t safi
, enum clear_sort sort
,
683 enum bgp_clear_type stype
, const char *arg
)
687 /* BGP structure lookup. */
689 bgp
= bgp_lookup_by_name(name
);
691 vty_out(vty
, "Can't find BGP instance %s\n", name
);
695 bgp
= bgp_get_default();
697 vty_out(vty
, "No BGP process is configured\n");
702 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
705 /* clear soft inbound */
706 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
708 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
709 BGP_CLEAR_SOFT_IN
, NULL
);
710 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
711 BGP_CLEAR_SOFT_IN
, NULL
);
714 /* clear soft outbound */
715 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
717 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
718 BGP_CLEAR_SOFT_OUT
, NULL
);
719 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
720 BGP_CLEAR_SOFT_OUT
, NULL
);
724 #ifndef VTYSH_EXTRACT_PL
725 #include "bgpd/bgp_vty_clippy.c"
728 /* BGP global configuration. */
730 DEFUN (bgp_multiple_instance_func
,
731 bgp_multiple_instance_cmd
,
732 "bgp multiple-instance",
734 "Enable bgp multiple instance\n")
736 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
740 DEFUN (no_bgp_multiple_instance
,
741 no_bgp_multiple_instance_cmd
,
742 "no bgp multiple-instance",
745 "BGP multiple instance\n")
749 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
751 vty_out(vty
, "%% There are more than two BGP instances\n");
752 return CMD_WARNING_CONFIG_FAILED
;
757 DEFUN (bgp_config_type
,
759 "bgp config-type <cisco|zebra>",
761 "Configuration type\n"
766 if (argv_find(argv
, argc
, "cisco", &idx
))
767 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
769 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
774 DEFUN (no_bgp_config_type
,
775 no_bgp_config_type_cmd
,
776 "no bgp config-type [<cisco|zebra>]",
779 "Display configuration type\n"
783 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
788 DEFUN (no_synchronization
,
789 no_synchronization_cmd
,
790 "no synchronization",
792 "Perform IGP synchronization\n")
797 DEFUN (no_auto_summary
,
801 "Enable automatic network number summarization\n")
806 /* "router bgp" commands. */
807 DEFUN_NOSH (router_bgp
,
809 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
813 BGP_INSTANCE_HELP_STR
)
816 int idx_view_vrf
= 3;
821 const char *name
= NULL
;
822 enum bgp_instance_type inst_type
;
824 // "router bgp" without an ASN
826 // Pending: Make VRF option available for ASN less config
827 bgp
= bgp_get_default();
830 vty_out(vty
, "%% No BGP process is configured\n");
831 return CMD_WARNING_CONFIG_FAILED
;
834 if (listcount(bm
->bgp
) > 1) {
835 vty_out(vty
, "%% Please specify ASN and VRF\n");
836 return CMD_WARNING_CONFIG_FAILED
;
842 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
844 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
846 name
= argv
[idx_vrf
]->arg
;
848 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf"))
849 inst_type
= BGP_INSTANCE_TYPE_VRF
;
850 else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
851 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
854 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
856 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
858 "Please specify 'bgp multiple-instance' first\n");
859 return CMD_WARNING_CONFIG_FAILED
;
860 case BGP_ERR_AS_MISMATCH
:
861 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
862 return CMD_WARNING_CONFIG_FAILED
;
863 case BGP_ERR_INSTANCE_MISMATCH
:
865 "BGP instance name and AS number mismatch\n");
867 "BGP instance is already running; AS is %u\n",
869 return CMD_WARNING_CONFIG_FAILED
;
872 /* Pending: handle when user tries to change a view to vrf n vv.
876 /* unset the auto created flag as the user config is now present */
877 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
878 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
883 /* "no router bgp" commands. */
884 DEFUN (no_router_bgp
,
886 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
891 BGP_INSTANCE_HELP_STR
)
897 const char *name
= NULL
;
899 // "no router bgp" without an ASN
901 // Pending: Make VRF option available for ASN less config
902 bgp
= bgp_get_default();
905 vty_out(vty
, "%% No BGP process is configured\n");
906 return CMD_WARNING_CONFIG_FAILED
;
909 if (listcount(bm
->bgp
) > 1) {
910 vty_out(vty
, "%% Please specify ASN and VRF\n");
911 return CMD_WARNING_CONFIG_FAILED
;
915 vty_out(vty
, "%% Please unconfigure l3vni %u",
917 return CMD_WARNING_CONFIG_FAILED
;
920 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
923 name
= argv
[idx_vrf
]->arg
;
925 /* Lookup bgp structure. */
926 bgp
= bgp_lookup(as
, name
);
928 vty_out(vty
, "%% Can't find BGP instance\n");
929 return CMD_WARNING_CONFIG_FAILED
;
933 vty_out(vty
, "%% Please unconfigure l3vni %u",
935 return CMD_WARNING_CONFIG_FAILED
;
947 DEFPY (bgp_router_id
,
949 "bgp router-id A.B.C.D",
951 "Override configured router identifier\n"
952 "Manually configured router identifier\n")
954 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
955 bgp_router_id_static_set(bgp
, router_id
);
959 DEFPY (no_bgp_router_id
,
960 no_bgp_router_id_cmd
,
961 "no bgp router-id [A.B.C.D]",
964 "Override configured router identifier\n"
965 "Manually configured router identifier\n")
967 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
970 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
971 vty_out(vty
, "%% BGP router-id doesn't match\n");
972 return CMD_WARNING_CONFIG_FAILED
;
976 router_id
.s_addr
= 0;
977 bgp_router_id_static_set(bgp
, router_id
);
983 /* BGP Cluster ID. */
984 DEFUN (bgp_cluster_id
,
986 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
988 "Configure Route-Reflector Cluster-id\n"
989 "Route-Reflector Cluster-id in IP address format\n"
990 "Route-Reflector Cluster-id as 32 bit quantity\n")
992 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
995 struct in_addr cluster
;
997 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
999 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1000 return CMD_WARNING_CONFIG_FAILED
;
1003 bgp_cluster_id_set(bgp
, &cluster
);
1004 bgp_clear_star_soft_out(vty
, bgp
->name
);
1009 DEFUN (no_bgp_cluster_id
,
1010 no_bgp_cluster_id_cmd
,
1011 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1014 "Configure Route-Reflector Cluster-id\n"
1015 "Route-Reflector Cluster-id in IP address format\n"
1016 "Route-Reflector Cluster-id as 32 bit quantity\n")
1018 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1019 bgp_cluster_id_unset(bgp
);
1020 bgp_clear_star_soft_out(vty
, bgp
->name
);
1025 DEFUN (bgp_confederation_identifier
,
1026 bgp_confederation_identifier_cmd
,
1027 "bgp confederation identifier (1-4294967295)",
1028 "BGP specific commands\n"
1029 "AS confederation parameters\n"
1031 "Set routing domain confederation AS\n")
1033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1037 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1039 bgp_confederation_id_set(bgp
, as
);
1044 DEFUN (no_bgp_confederation_identifier
,
1045 no_bgp_confederation_identifier_cmd
,
1046 "no bgp confederation identifier [(1-4294967295)]",
1048 "BGP specific commands\n"
1049 "AS confederation parameters\n"
1051 "Set routing domain confederation AS\n")
1053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1054 bgp_confederation_id_unset(bgp
);
1059 DEFUN (bgp_confederation_peers
,
1060 bgp_confederation_peers_cmd
,
1061 "bgp confederation peers (1-4294967295)...",
1062 "BGP specific commands\n"
1063 "AS confederation parameters\n"
1064 "Peer ASs in BGP confederation\n"
1067 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1072 for (i
= idx_asn
; i
< argc
; i
++) {
1073 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1075 if (bgp
->as
== as
) {
1077 "%% Local member-AS not allowed in confed peer list\n");
1081 bgp_confederation_peers_add(bgp
, as
);
1086 DEFUN (no_bgp_confederation_peers
,
1087 no_bgp_confederation_peers_cmd
,
1088 "no bgp confederation peers (1-4294967295)...",
1090 "BGP specific commands\n"
1091 "AS confederation parameters\n"
1092 "Peer ASs in BGP confederation\n"
1095 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1100 for (i
= idx_asn
; i
< argc
; i
++) {
1101 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1103 bgp_confederation_peers_remove(bgp
, as
);
1109 * Central routine for maximum-paths configuration.
1110 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1111 * @set: 1 for setting values, 0 for removing the max-paths config.
1113 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1114 const char *mpaths
, u_int16_t options
,
1117 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1118 u_int16_t maxpaths
= 0;
1123 afi
= bgp_node_afi(vty
);
1124 safi
= bgp_node_safi(vty
);
1127 maxpaths
= strtol(mpaths
, NULL
, 10);
1128 if (maxpaths
> multipath_num
) {
1130 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1131 maxpaths
, multipath_num
);
1132 return CMD_WARNING_CONFIG_FAILED
;
1134 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1137 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1141 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1142 (set
== 1) ? "" : "un",
1143 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1144 maxpaths
, afi
, safi
);
1145 return CMD_WARNING_CONFIG_FAILED
;
1148 bgp_recalculate_all_bestpaths(bgp
);
1153 DEFUN (bgp_maxmed_admin
,
1154 bgp_maxmed_admin_cmd
,
1155 "bgp max-med administrative ",
1157 "Advertise routes with max-med\n"
1158 "Administratively applied, for an indefinite period\n")
1160 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1162 bgp
->v_maxmed_admin
= 1;
1163 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1165 bgp_maxmed_update(bgp
);
1170 DEFUN (bgp_maxmed_admin_medv
,
1171 bgp_maxmed_admin_medv_cmd
,
1172 "bgp max-med administrative (0-4294967295)",
1174 "Advertise routes with max-med\n"
1175 "Administratively applied, for an indefinite period\n"
1176 "Max MED value to be used\n")
1178 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1181 bgp
->v_maxmed_admin
= 1;
1182 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1184 bgp_maxmed_update(bgp
);
1189 DEFUN (no_bgp_maxmed_admin
,
1190 no_bgp_maxmed_admin_cmd
,
1191 "no bgp max-med administrative [(0-4294967295)]",
1194 "Advertise routes with max-med\n"
1195 "Administratively applied, for an indefinite period\n"
1196 "Max MED value to be used\n")
1198 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1199 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1200 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1201 bgp_maxmed_update(bgp
);
1206 DEFUN (bgp_maxmed_onstartup
,
1207 bgp_maxmed_onstartup_cmd
,
1208 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1210 "Advertise routes with max-med\n"
1211 "Effective on a startup\n"
1212 "Time (seconds) period for max-med\n"
1213 "Max MED value to be used\n")
1215 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1218 argv_find(argv
, argc
, "(5-86400)", &idx
);
1219 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1220 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1221 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1223 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1225 bgp_maxmed_update(bgp
);
1230 DEFUN (no_bgp_maxmed_onstartup
,
1231 no_bgp_maxmed_onstartup_cmd
,
1232 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1235 "Advertise routes with max-med\n"
1236 "Effective on a startup\n"
1237 "Time (seconds) period for max-med\n"
1238 "Max MED value to be used\n")
1240 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1242 /* Cancel max-med onstartup if its on */
1243 if (bgp
->t_maxmed_onstartup
) {
1244 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1245 bgp
->maxmed_onstartup_over
= 1;
1248 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1249 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1251 bgp_maxmed_update(bgp
);
1256 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1259 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1260 u_int16_t update_delay
;
1261 u_int16_t establish_wait
;
1263 update_delay
= strtoul(delay
, NULL
, 10);
1265 if (!wait
) /* update-delay <delay> */
1267 bgp
->v_update_delay
= update_delay
;
1268 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1272 /* update-delay <delay> <establish-wait> */
1273 establish_wait
= atoi(wait
);
1274 if (update_delay
< establish_wait
) {
1276 "%%Failed: update-delay less than the establish-wait!\n");
1277 return CMD_WARNING_CONFIG_FAILED
;
1280 bgp
->v_update_delay
= update_delay
;
1281 bgp
->v_establish_wait
= establish_wait
;
1286 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1288 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1290 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1291 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1296 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1298 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1299 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1300 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1301 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1307 /* Update-delay configuration */
1308 DEFUN (bgp_update_delay
,
1309 bgp_update_delay_cmd
,
1310 "update-delay (0-3600)",
1311 "Force initial delay for best-path and updates\n"
1315 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1318 DEFUN (bgp_update_delay_establish_wait
,
1319 bgp_update_delay_establish_wait_cmd
,
1320 "update-delay (0-3600) (1-3600)",
1321 "Force initial delay for best-path and updates\n"
1326 int idx_number_2
= 2;
1327 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1328 argv
[idx_number_2
]->arg
);
1331 /* Update-delay deconfiguration */
1332 DEFUN (no_bgp_update_delay
,
1333 no_bgp_update_delay_cmd
,
1334 "no update-delay [(0-3600) [(1-3600)]]",
1336 "Force initial delay for best-path and updates\n"
1340 return bgp_update_delay_deconfig_vty(vty
);
1344 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1347 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1350 uint32_t quanta
= strtoul(num
, NULL
, 10);
1351 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1352 memory_order_relaxed
);
1354 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1355 memory_order_relaxed
);
1361 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1364 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1367 uint32_t quanta
= strtoul(num
, NULL
, 10);
1368 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1369 memory_order_relaxed
);
1371 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1372 memory_order_relaxed
);
1378 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1381 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1382 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1383 vty_out(vty
, " write-quanta %d\n", quanta
);
1386 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1389 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1390 if (quanta
!= BGP_READ_PACKET_MAX
)
1391 vty_out(vty
, " read-quanta %d\n", quanta
);
1394 /* Packet quanta configuration */
1395 DEFUN (bgp_wpkt_quanta
,
1396 bgp_wpkt_quanta_cmd
,
1397 "write-quanta (1-10)",
1398 "How many packets to write to peer socket per run\n"
1399 "Number of packets\n")
1402 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1405 DEFUN (no_bgp_wpkt_quanta
,
1406 no_bgp_wpkt_quanta_cmd
,
1407 "no write-quanta (1-10)",
1409 "How many packets to write to peer socket per I/O cycle\n"
1410 "Number of packets\n")
1413 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1416 DEFUN (bgp_rpkt_quanta
,
1417 bgp_rpkt_quanta_cmd
,
1418 "read-quanta (1-10)",
1419 "How many packets to read from peer socket per I/O cycle\n"
1420 "Number of packets\n")
1423 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1426 DEFUN (no_bgp_rpkt_quanta
,
1427 no_bgp_rpkt_quanta_cmd
,
1428 "no read-quanta (1-10)",
1430 "How many packets to read from peer socket per I/O cycle\n"
1431 "Number of packets\n")
1434 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1437 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1439 if (!bgp
->heuristic_coalesce
)
1440 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1444 DEFUN (bgp_coalesce_time
,
1445 bgp_coalesce_time_cmd
,
1446 "coalesce-time (0-4294967295)",
1447 "Subgroup coalesce timer\n"
1448 "Subgroup coalesce timer value (in ms)\n")
1450 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1453 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1454 bgp
->heuristic_coalesce
= false;
1455 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1459 DEFUN (no_bgp_coalesce_time
,
1460 no_bgp_coalesce_time_cmd
,
1461 "no coalesce-time (0-4294967295)",
1463 "Subgroup coalesce timer\n"
1464 "Subgroup coalesce timer value (in ms)\n")
1466 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1468 bgp
->heuristic_coalesce
= true;
1469 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1473 /* Maximum-paths configuration */
1474 DEFUN (bgp_maxpaths
,
1476 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1477 "Forward packets over multiple paths\n"
1478 "Number of paths\n")
1481 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1482 argv
[idx_number
]->arg
, 0, 1);
1485 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1486 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1487 "Forward packets over multiple paths\n"
1488 "Number of paths\n")
1490 DEFUN (bgp_maxpaths_ibgp
,
1491 bgp_maxpaths_ibgp_cmd
,
1492 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1493 "Forward packets over multiple paths\n"
1495 "Number of paths\n")
1498 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1499 argv
[idx_number
]->arg
, 0, 1);
1502 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1503 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1504 "Forward packets over multiple paths\n"
1506 "Number of paths\n")
1508 DEFUN (bgp_maxpaths_ibgp_cluster
,
1509 bgp_maxpaths_ibgp_cluster_cmd
,
1510 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1511 "Forward packets over multiple paths\n"
1514 "Match the cluster length\n")
1517 return bgp_maxpaths_config_vty(
1518 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1519 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1522 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1523 "maximum-paths ibgp " CMD_RANGE_STR(
1524 1, MULTIPATH_NUM
) " equal-cluster-length",
1525 "Forward packets over multiple paths\n"
1528 "Match the cluster length\n")
1530 DEFUN (no_bgp_maxpaths
,
1531 no_bgp_maxpaths_cmd
,
1532 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1534 "Forward packets over multiple paths\n"
1535 "Number of paths\n")
1537 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1540 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1541 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1542 "Forward packets over multiple paths\n"
1543 "Number of paths\n")
1545 DEFUN (no_bgp_maxpaths_ibgp
,
1546 no_bgp_maxpaths_ibgp_cmd
,
1547 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1549 "Forward packets over multiple paths\n"
1552 "Match the cluster length\n")
1554 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1557 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1558 "no maximum-paths ibgp [" CMD_RANGE_STR(
1559 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1561 "Forward packets over multiple paths\n"
1564 "Match the cluster length\n")
1566 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1569 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1570 vty_out(vty
, " maximum-paths %d\n",
1571 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1574 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1575 vty_out(vty
, " maximum-paths ibgp %d",
1576 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1577 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1578 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1579 vty_out(vty
, " equal-cluster-length");
1588 "timers bgp (0-65535) (0-65535)",
1589 "Adjust routing timers\n"
1591 "Keepalive interval\n"
1594 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1596 int idx_number_2
= 3;
1597 unsigned long keepalive
= 0;
1598 unsigned long holdtime
= 0;
1600 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1601 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1603 /* Holdtime value check. */
1604 if (holdtime
< 3 && holdtime
!= 0) {
1606 "%% hold time value must be either 0 or greater than 3\n");
1607 return CMD_WARNING_CONFIG_FAILED
;
1610 bgp_timers_set(bgp
, keepalive
, holdtime
);
1615 DEFUN (no_bgp_timers
,
1617 "no timers bgp [(0-65535) (0-65535)]",
1619 "Adjust routing timers\n"
1621 "Keepalive interval\n"
1624 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1625 bgp_timers_unset(bgp
);
1631 DEFUN (bgp_client_to_client_reflection
,
1632 bgp_client_to_client_reflection_cmd
,
1633 "bgp client-to-client reflection",
1634 "BGP specific commands\n"
1635 "Configure client to client route reflection\n"
1636 "reflection of routes allowed\n")
1638 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1639 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1640 bgp_clear_star_soft_out(vty
, bgp
->name
);
1645 DEFUN (no_bgp_client_to_client_reflection
,
1646 no_bgp_client_to_client_reflection_cmd
,
1647 "no bgp client-to-client reflection",
1649 "BGP specific commands\n"
1650 "Configure client to client route reflection\n"
1651 "reflection of routes allowed\n")
1653 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1654 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1655 bgp_clear_star_soft_out(vty
, bgp
->name
);
1660 /* "bgp always-compare-med" configuration. */
1661 DEFUN (bgp_always_compare_med
,
1662 bgp_always_compare_med_cmd
,
1663 "bgp always-compare-med",
1664 "BGP specific commands\n"
1665 "Allow comparing MED from different neighbors\n")
1667 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1668 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1669 bgp_recalculate_all_bestpaths(bgp
);
1674 DEFUN (no_bgp_always_compare_med
,
1675 no_bgp_always_compare_med_cmd
,
1676 "no bgp always-compare-med",
1678 "BGP specific commands\n"
1679 "Allow comparing MED from different neighbors\n")
1681 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1682 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1683 bgp_recalculate_all_bestpaths(bgp
);
1688 /* "bgp deterministic-med" configuration. */
1689 DEFUN (bgp_deterministic_med
,
1690 bgp_deterministic_med_cmd
,
1691 "bgp deterministic-med",
1692 "BGP specific commands\n"
1693 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1695 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1697 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1698 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1699 bgp_recalculate_all_bestpaths(bgp
);
1705 DEFUN (no_bgp_deterministic_med
,
1706 no_bgp_deterministic_med_cmd
,
1707 "no bgp deterministic-med",
1709 "BGP specific commands\n"
1710 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1712 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1713 int bestpath_per_as_used
;
1717 struct listnode
*node
, *nnode
;
1719 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1720 bestpath_per_as_used
= 0;
1722 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1723 FOREACH_AFI_SAFI (afi
, safi
)
1725 peer
->af_flags
[afi
][safi
],
1726 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1727 bestpath_per_as_used
= 1;
1731 if (bestpath_per_as_used
)
1735 if (bestpath_per_as_used
) {
1737 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1738 return CMD_WARNING_CONFIG_FAILED
;
1740 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1741 bgp_recalculate_all_bestpaths(bgp
);
1748 /* "bgp graceful-restart" configuration. */
1749 DEFUN (bgp_graceful_restart
,
1750 bgp_graceful_restart_cmd
,
1751 "bgp graceful-restart",
1752 "BGP specific commands\n"
1753 "Graceful restart capability parameters\n")
1755 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1756 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1760 DEFUN (no_bgp_graceful_restart
,
1761 no_bgp_graceful_restart_cmd
,
1762 "no bgp graceful-restart",
1764 "BGP specific commands\n"
1765 "Graceful restart capability parameters\n")
1767 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1768 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1772 DEFUN (bgp_graceful_restart_stalepath_time
,
1773 bgp_graceful_restart_stalepath_time_cmd
,
1774 "bgp graceful-restart stalepath-time (1-3600)",
1775 "BGP specific commands\n"
1776 "Graceful restart capability parameters\n"
1777 "Set the max time to hold onto restarting peer's stale paths\n"
1778 "Delay value (seconds)\n")
1780 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1782 u_int32_t stalepath
;
1784 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1785 bgp
->stalepath_time
= stalepath
;
1789 DEFUN (bgp_graceful_restart_restart_time
,
1790 bgp_graceful_restart_restart_time_cmd
,
1791 "bgp graceful-restart restart-time (1-3600)",
1792 "BGP specific commands\n"
1793 "Graceful restart capability parameters\n"
1794 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1795 "Delay value (seconds)\n")
1797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1801 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1802 bgp
->restart_time
= restart
;
1806 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1807 no_bgp_graceful_restart_stalepath_time_cmd
,
1808 "no bgp graceful-restart stalepath-time [(1-3600)]",
1810 "BGP specific commands\n"
1811 "Graceful restart capability parameters\n"
1812 "Set the max time to hold onto restarting peer's stale paths\n"
1813 "Delay value (seconds)\n")
1815 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1817 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1821 DEFUN (no_bgp_graceful_restart_restart_time
,
1822 no_bgp_graceful_restart_restart_time_cmd
,
1823 "no bgp graceful-restart restart-time [(1-3600)]",
1825 "BGP specific commands\n"
1826 "Graceful restart capability parameters\n"
1827 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1828 "Delay value (seconds)\n")
1830 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1832 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1836 DEFUN (bgp_graceful_restart_preserve_fw
,
1837 bgp_graceful_restart_preserve_fw_cmd
,
1838 "bgp graceful-restart preserve-fw-state",
1839 "BGP specific commands\n"
1840 "Graceful restart capability parameters\n"
1841 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1843 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1844 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1848 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1849 no_bgp_graceful_restart_preserve_fw_cmd
,
1850 "no bgp graceful-restart preserve-fw-state",
1852 "BGP specific commands\n"
1853 "Graceful restart capability parameters\n"
1854 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1857 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1861 static void bgp_redistribute_redo(struct bgp
*bgp
)
1865 struct list
*red_list
;
1866 struct listnode
*node
;
1867 struct bgp_redist
*red
;
1869 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1870 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1872 red_list
= bgp
->redist
[afi
][i
];
1876 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1877 bgp_redistribute_resend(bgp
, afi
, i
,
1884 /* "bgp graceful-shutdown" configuration */
1885 DEFUN (bgp_graceful_shutdown
,
1886 bgp_graceful_shutdown_cmd
,
1887 "bgp graceful-shutdown",
1889 "Graceful shutdown parameters\n")
1891 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1893 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1894 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1895 bgp_static_redo_import_check(bgp
);
1896 bgp_redistribute_redo(bgp
);
1897 bgp_clear_star_soft_out(vty
, bgp
->name
);
1898 bgp_clear_star_soft_in(vty
, bgp
->name
);
1904 DEFUN (no_bgp_graceful_shutdown
,
1905 no_bgp_graceful_shutdown_cmd
,
1906 "no bgp graceful-shutdown",
1909 "Graceful shutdown parameters\n")
1911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1913 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1914 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1915 bgp_static_redo_import_check(bgp
);
1916 bgp_redistribute_redo(bgp
);
1917 bgp_clear_star_soft_out(vty
, bgp
->name
);
1918 bgp_clear_star_soft_in(vty
, bgp
->name
);
1924 /* "bgp fast-external-failover" configuration. */
1925 DEFUN (bgp_fast_external_failover
,
1926 bgp_fast_external_failover_cmd
,
1927 "bgp fast-external-failover",
1929 "Immediately reset session if a link to a directly connected external peer goes down\n")
1931 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1932 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1936 DEFUN (no_bgp_fast_external_failover
,
1937 no_bgp_fast_external_failover_cmd
,
1938 "no bgp fast-external-failover",
1941 "Immediately reset session if a link to a directly connected external peer goes down\n")
1943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1944 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1948 /* "bgp enforce-first-as" configuration. */
1949 DEFUN (bgp_enforce_first_as
,
1950 bgp_enforce_first_as_cmd
,
1951 "bgp enforce-first-as",
1953 "Enforce the first AS for EBGP routes\n")
1955 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1956 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1957 bgp_clear_star_soft_in(vty
, bgp
->name
);
1962 DEFUN (no_bgp_enforce_first_as
,
1963 no_bgp_enforce_first_as_cmd
,
1964 "no bgp enforce-first-as",
1967 "Enforce the first AS for EBGP routes\n")
1969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1970 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1971 bgp_clear_star_soft_in(vty
, bgp
->name
);
1976 /* "bgp bestpath compare-routerid" configuration. */
1977 DEFUN (bgp_bestpath_compare_router_id
,
1978 bgp_bestpath_compare_router_id_cmd
,
1979 "bgp bestpath compare-routerid",
1980 "BGP specific commands\n"
1981 "Change the default bestpath selection\n"
1982 "Compare router-id for identical EBGP paths\n")
1984 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1985 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
1986 bgp_recalculate_all_bestpaths(bgp
);
1991 DEFUN (no_bgp_bestpath_compare_router_id
,
1992 no_bgp_bestpath_compare_router_id_cmd
,
1993 "no bgp bestpath compare-routerid",
1995 "BGP specific commands\n"
1996 "Change the default bestpath selection\n"
1997 "Compare router-id for identical EBGP paths\n")
1999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2000 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2001 bgp_recalculate_all_bestpaths(bgp
);
2006 /* "bgp bestpath as-path ignore" configuration. */
2007 DEFUN (bgp_bestpath_aspath_ignore
,
2008 bgp_bestpath_aspath_ignore_cmd
,
2009 "bgp bestpath as-path ignore",
2010 "BGP specific commands\n"
2011 "Change the default bestpath selection\n"
2012 "AS-path attribute\n"
2013 "Ignore as-path length in selecting a route\n")
2015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2016 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2017 bgp_recalculate_all_bestpaths(bgp
);
2022 DEFUN (no_bgp_bestpath_aspath_ignore
,
2023 no_bgp_bestpath_aspath_ignore_cmd
,
2024 "no bgp bestpath as-path ignore",
2026 "BGP specific commands\n"
2027 "Change the default bestpath selection\n"
2028 "AS-path attribute\n"
2029 "Ignore as-path length in selecting a route\n")
2031 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2032 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2033 bgp_recalculate_all_bestpaths(bgp
);
2038 /* "bgp bestpath as-path confed" configuration. */
2039 DEFUN (bgp_bestpath_aspath_confed
,
2040 bgp_bestpath_aspath_confed_cmd
,
2041 "bgp bestpath as-path confed",
2042 "BGP specific commands\n"
2043 "Change the default bestpath selection\n"
2044 "AS-path attribute\n"
2045 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2047 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2048 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2049 bgp_recalculate_all_bestpaths(bgp
);
2054 DEFUN (no_bgp_bestpath_aspath_confed
,
2055 no_bgp_bestpath_aspath_confed_cmd
,
2056 "no bgp bestpath as-path confed",
2058 "BGP specific commands\n"
2059 "Change the default bestpath selection\n"
2060 "AS-path attribute\n"
2061 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2064 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2065 bgp_recalculate_all_bestpaths(bgp
);
2070 /* "bgp bestpath as-path multipath-relax" configuration. */
2071 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2072 bgp_bestpath_aspath_multipath_relax_cmd
,
2073 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2074 "BGP specific commands\n"
2075 "Change the default bestpath selection\n"
2076 "AS-path attribute\n"
2077 "Allow load sharing across routes that have different AS paths (but same length)\n"
2078 "Generate an AS_SET\n"
2079 "Do not generate an AS_SET\n")
2081 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2083 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2085 /* no-as-set is now the default behavior so we can silently
2087 if (argv_find(argv
, argc
, "as-set", &idx
))
2088 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2090 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2092 bgp_recalculate_all_bestpaths(bgp
);
2097 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2098 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2099 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2101 "BGP specific commands\n"
2102 "Change the default bestpath selection\n"
2103 "AS-path attribute\n"
2104 "Allow load sharing across routes that have different AS paths (but same length)\n"
2105 "Generate an AS_SET\n"
2106 "Do not generate an AS_SET\n")
2108 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2109 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2110 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2111 bgp_recalculate_all_bestpaths(bgp
);
2116 /* "bgp log-neighbor-changes" configuration. */
2117 DEFUN (bgp_log_neighbor_changes
,
2118 bgp_log_neighbor_changes_cmd
,
2119 "bgp log-neighbor-changes",
2120 "BGP specific commands\n"
2121 "Log neighbor up/down and reset reason\n")
2123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2124 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2128 DEFUN (no_bgp_log_neighbor_changes
,
2129 no_bgp_log_neighbor_changes_cmd
,
2130 "no bgp log-neighbor-changes",
2132 "BGP specific commands\n"
2133 "Log neighbor up/down and reset reason\n")
2135 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2136 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2140 /* "bgp bestpath med" configuration. */
2141 DEFUN (bgp_bestpath_med
,
2142 bgp_bestpath_med_cmd
,
2143 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2144 "BGP specific commands\n"
2145 "Change the default bestpath selection\n"
2147 "Compare MED among confederation paths\n"
2148 "Treat missing MED as the least preferred one\n"
2149 "Treat missing MED as the least preferred one\n"
2150 "Compare MED among confederation paths\n")
2152 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2155 if (argv_find(argv
, argc
, "confed", &idx
))
2156 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2158 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2159 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2161 bgp_recalculate_all_bestpaths(bgp
);
2166 DEFUN (no_bgp_bestpath_med
,
2167 no_bgp_bestpath_med_cmd
,
2168 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2170 "BGP specific commands\n"
2171 "Change the default bestpath selection\n"
2173 "Compare MED among confederation paths\n"
2174 "Treat missing MED as the least preferred one\n"
2175 "Treat missing MED as the least preferred one\n"
2176 "Compare MED among confederation paths\n")
2178 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2181 if (argv_find(argv
, argc
, "confed", &idx
))
2182 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2184 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2185 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2187 bgp_recalculate_all_bestpaths(bgp
);
2192 /* "no bgp default ipv4-unicast". */
2193 DEFUN (no_bgp_default_ipv4_unicast
,
2194 no_bgp_default_ipv4_unicast_cmd
,
2195 "no bgp default ipv4-unicast",
2197 "BGP specific commands\n"
2198 "Configure BGP defaults\n"
2199 "Activate ipv4-unicast for a peer by default\n")
2201 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2202 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2206 DEFUN (bgp_default_ipv4_unicast
,
2207 bgp_default_ipv4_unicast_cmd
,
2208 "bgp default ipv4-unicast",
2209 "BGP specific commands\n"
2210 "Configure BGP defaults\n"
2211 "Activate ipv4-unicast for a peer by default\n")
2213 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2214 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2218 /* Display hostname in certain command outputs */
2219 DEFUN (bgp_default_show_hostname
,
2220 bgp_default_show_hostname_cmd
,
2221 "bgp default show-hostname",
2222 "BGP specific commands\n"
2223 "Configure BGP defaults\n"
2224 "Show hostname in certain command ouputs\n")
2226 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2227 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2231 DEFUN (no_bgp_default_show_hostname
,
2232 no_bgp_default_show_hostname_cmd
,
2233 "no bgp default show-hostname",
2235 "BGP specific commands\n"
2236 "Configure BGP defaults\n"
2237 "Show hostname in certain command ouputs\n")
2239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2240 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2244 /* "bgp network import-check" configuration. */
2245 DEFUN (bgp_network_import_check
,
2246 bgp_network_import_check_cmd
,
2247 "bgp network import-check",
2248 "BGP specific commands\n"
2249 "BGP network command\n"
2250 "Check BGP network route exists in IGP\n")
2252 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2253 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2254 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2255 bgp_static_redo_import_check(bgp
);
2261 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2262 "bgp network import-check exact",
2263 "BGP specific commands\n"
2264 "BGP network command\n"
2265 "Check BGP network route exists in IGP\n"
2266 "Match route precisely\n")
2268 DEFUN (no_bgp_network_import_check
,
2269 no_bgp_network_import_check_cmd
,
2270 "no bgp network import-check",
2272 "BGP specific commands\n"
2273 "BGP network command\n"
2274 "Check BGP network route exists in IGP\n")
2276 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2277 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2278 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2279 bgp_static_redo_import_check(bgp
);
2285 DEFUN (bgp_default_local_preference
,
2286 bgp_default_local_preference_cmd
,
2287 "bgp default local-preference (0-4294967295)",
2288 "BGP specific commands\n"
2289 "Configure BGP defaults\n"
2290 "local preference (higher=more preferred)\n"
2291 "Configure default local preference value\n")
2293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2295 u_int32_t local_pref
;
2297 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2299 bgp_default_local_preference_set(bgp
, local_pref
);
2300 bgp_clear_star_soft_in(vty
, bgp
->name
);
2305 DEFUN (no_bgp_default_local_preference
,
2306 no_bgp_default_local_preference_cmd
,
2307 "no bgp default local-preference [(0-4294967295)]",
2309 "BGP specific commands\n"
2310 "Configure BGP defaults\n"
2311 "local preference (higher=more preferred)\n"
2312 "Configure default local preference value\n")
2314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2315 bgp_default_local_preference_unset(bgp
);
2316 bgp_clear_star_soft_in(vty
, bgp
->name
);
2322 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2323 bgp_default_subgroup_pkt_queue_max_cmd
,
2324 "bgp default subgroup-pkt-queue-max (20-100)",
2325 "BGP specific commands\n"
2326 "Configure BGP defaults\n"
2327 "subgroup-pkt-queue-max\n"
2328 "Configure subgroup packet queue max\n")
2330 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2334 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2336 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2341 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2342 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2343 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2345 "BGP specific commands\n"
2346 "Configure BGP defaults\n"
2347 "subgroup-pkt-queue-max\n"
2348 "Configure subgroup packet queue max\n")
2350 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2351 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2356 DEFUN (bgp_rr_allow_outbound_policy
,
2357 bgp_rr_allow_outbound_policy_cmd
,
2358 "bgp route-reflector allow-outbound-policy",
2359 "BGP specific commands\n"
2360 "Allow modifications made by out route-map\n"
2361 "on ibgp neighbors\n")
2363 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2365 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2366 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2367 update_group_announce_rrclients(bgp
);
2368 bgp_clear_star_soft_out(vty
, bgp
->name
);
2374 DEFUN (no_bgp_rr_allow_outbound_policy
,
2375 no_bgp_rr_allow_outbound_policy_cmd
,
2376 "no bgp route-reflector allow-outbound-policy",
2378 "BGP specific commands\n"
2379 "Allow modifications made by out route-map\n"
2380 "on ibgp neighbors\n")
2382 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2384 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2385 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2386 update_group_announce_rrclients(bgp
);
2387 bgp_clear_star_soft_out(vty
, bgp
->name
);
2393 DEFUN (bgp_listen_limit
,
2394 bgp_listen_limit_cmd
,
2395 "bgp listen limit (1-5000)",
2396 "BGP specific commands\n"
2397 "Configure BGP defaults\n"
2398 "maximum number of BGP Dynamic Neighbors that can be created\n"
2399 "Configure Dynamic Neighbors listen limit value\n")
2401 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2405 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2407 bgp_listen_limit_set(bgp
, listen_limit
);
2412 DEFUN (no_bgp_listen_limit
,
2413 no_bgp_listen_limit_cmd
,
2414 "no bgp listen limit [(1-5000)]",
2415 "BGP specific commands\n"
2416 "Configure BGP defaults\n"
2417 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2418 "Configure Dynamic Neighbors listen limit value to default\n"
2419 "Configure Dynamic Neighbors listen limit value\n")
2421 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2422 bgp_listen_limit_unset(bgp
);
2428 * Check if this listen range is already configured. Check for exact
2429 * match or overlap based on input.
2431 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2432 struct prefix
*range
, int exact
)
2434 struct listnode
*node
, *nnode
;
2435 struct listnode
*node1
, *nnode1
;
2436 struct peer_group
*group
;
2441 afi
= family2afi(range
->family
);
2442 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2443 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2446 match
= prefix_same(range
, lr
);
2448 match
= (prefix_match(range
, lr
)
2449 || prefix_match(lr
, range
));
2458 DEFUN (bgp_listen_range
,
2459 bgp_listen_range_cmd
,
2460 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2461 "BGP specific commands\n"
2462 "Configure BGP dynamic neighbors listen range\n"
2463 "Configure BGP dynamic neighbors listen range\n"
2465 "Member of the peer-group\n"
2466 "Peer-group name\n")
2468 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2469 struct prefix range
;
2470 struct peer_group
*group
, *existing_group
;
2475 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2476 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2477 char *prefix
= argv
[idx
]->arg
;
2478 argv_find(argv
, argc
, "WORD", &idx
);
2479 char *peergroup
= argv
[idx
]->arg
;
2481 /* Convert IP prefix string to struct prefix. */
2482 ret
= str2prefix(prefix
, &range
);
2484 vty_out(vty
, "%% Malformed listen range\n");
2485 return CMD_WARNING_CONFIG_FAILED
;
2488 afi
= family2afi(range
.family
);
2490 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2492 "%% Malformed listen range (link-local address)\n");
2493 return CMD_WARNING_CONFIG_FAILED
;
2498 /* Check if same listen range is already configured. */
2499 existing_group
= listen_range_exists(bgp
, &range
, 1);
2500 if (existing_group
) {
2501 if (strcmp(existing_group
->name
, peergroup
) == 0)
2505 "%% Same listen range is attached to peer-group %s\n",
2506 existing_group
->name
);
2507 return CMD_WARNING_CONFIG_FAILED
;
2511 /* Check if an overlapping listen range exists. */
2512 if (listen_range_exists(bgp
, &range
, 0)) {
2514 "%% Listen range overlaps with existing listen range\n");
2515 return CMD_WARNING_CONFIG_FAILED
;
2518 group
= peer_group_lookup(bgp
, peergroup
);
2520 vty_out(vty
, "%% Configure the peer-group first\n");
2521 return CMD_WARNING_CONFIG_FAILED
;
2524 ret
= peer_group_listen_range_add(group
, &range
);
2525 return bgp_vty_return(vty
, ret
);
2528 DEFUN (no_bgp_listen_range
,
2529 no_bgp_listen_range_cmd
,
2530 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2532 "BGP specific commands\n"
2533 "Unconfigure BGP dynamic neighbors listen range\n"
2534 "Unconfigure BGP dynamic neighbors listen range\n"
2536 "Member of the peer-group\n"
2537 "Peer-group name\n")
2539 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2540 struct prefix range
;
2541 struct peer_group
*group
;
2546 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2547 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2548 char *prefix
= argv
[idx
]->arg
;
2549 argv_find(argv
, argc
, "WORD", &idx
);
2550 char *peergroup
= argv
[idx
]->arg
;
2552 /* Convert IP prefix string to struct prefix. */
2553 ret
= str2prefix(prefix
, &range
);
2555 vty_out(vty
, "%% Malformed listen range\n");
2556 return CMD_WARNING_CONFIG_FAILED
;
2559 afi
= family2afi(range
.family
);
2561 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2563 "%% Malformed listen range (link-local address)\n");
2564 return CMD_WARNING_CONFIG_FAILED
;
2569 group
= peer_group_lookup(bgp
, peergroup
);
2571 vty_out(vty
, "%% Peer-group does not exist\n");
2572 return CMD_WARNING_CONFIG_FAILED
;
2575 ret
= peer_group_listen_range_del(group
, &range
);
2576 return bgp_vty_return(vty
, ret
);
2579 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2581 struct peer_group
*group
;
2582 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2583 struct prefix
*range
;
2585 char buf
[PREFIX2STR_BUFFER
];
2587 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2588 vty_out(vty
, " bgp listen limit %d\n",
2589 bgp
->dynamic_neighbors_limit
);
2591 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2592 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2593 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2595 prefix2str(range
, buf
, sizeof(buf
));
2597 " bgp listen range %s peer-group %s\n",
2605 DEFUN (bgp_disable_connected_route_check
,
2606 bgp_disable_connected_route_check_cmd
,
2607 "bgp disable-ebgp-connected-route-check",
2608 "BGP specific commands\n"
2609 "Disable checking if nexthop is connected on ebgp sessions\n")
2611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2612 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2613 bgp_clear_star_soft_in(vty
, bgp
->name
);
2618 DEFUN (no_bgp_disable_connected_route_check
,
2619 no_bgp_disable_connected_route_check_cmd
,
2620 "no bgp disable-ebgp-connected-route-check",
2622 "BGP specific commands\n"
2623 "Disable checking if nexthop is connected on ebgp sessions\n")
2625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2626 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2627 bgp_clear_star_soft_in(vty
, bgp
->name
);
2633 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2634 const char *as_str
, afi_t afi
, safi_t safi
)
2636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2639 int as_type
= AS_SPECIFIED
;
2642 if (as_str
[0] == 'i') {
2644 as_type
= AS_INTERNAL
;
2645 } else if (as_str
[0] == 'e') {
2647 as_type
= AS_EXTERNAL
;
2649 /* Get AS number. */
2650 as
= strtoul(as_str
, NULL
, 10);
2653 /* If peer is peer group, call proper function. */
2654 ret
= str2sockunion(peer_str
, &su
);
2656 /* Check for peer by interface */
2657 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2660 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2663 "%% Create the peer-group or interface first\n");
2664 return CMD_WARNING_CONFIG_FAILED
;
2669 if (peer_address_self_check(bgp
, &su
)) {
2671 "%% Can not configure the local system as neighbor\n");
2672 return CMD_WARNING_CONFIG_FAILED
;
2674 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2677 /* This peer belongs to peer group. */
2679 case BGP_ERR_PEER_GROUP_MEMBER
:
2681 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2683 return CMD_WARNING_CONFIG_FAILED
;
2684 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2686 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2688 return CMD_WARNING_CONFIG_FAILED
;
2690 return bgp_vty_return(vty
, ret
);
2693 DEFUN (bgp_default_shutdown
,
2694 bgp_default_shutdown_cmd
,
2695 "[no] bgp default shutdown",
2698 "Configure BGP defaults\n"
2699 "Apply administrative shutdown to newly configured peers\n")
2701 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2702 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2706 DEFUN (neighbor_remote_as
,
2707 neighbor_remote_as_cmd
,
2708 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2711 "Specify a BGP neighbor\n"
2713 "Internal BGP peer\n"
2714 "External BGP peer\n")
2717 int idx_remote_as
= 3;
2718 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2719 argv
[idx_remote_as
]->arg
, AFI_IP
,
2723 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2724 afi_t afi
, safi_t safi
, int v6only
,
2725 const char *peer_group_name
,
2728 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2730 int as_type
= AS_UNSPECIFIED
;
2732 struct peer_group
*group
;
2736 group
= peer_group_lookup(bgp
, conf_if
);
2739 vty_out(vty
, "%% Name conflict with peer-group \n");
2740 return CMD_WARNING_CONFIG_FAILED
;
2744 if (as_str
[0] == 'i') {
2745 as_type
= AS_INTERNAL
;
2746 } else if (as_str
[0] == 'e') {
2747 as_type
= AS_EXTERNAL
;
2749 /* Get AS number. */
2750 as
= strtoul(as_str
, NULL
, 10);
2751 as_type
= AS_SPECIFIED
;
2755 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2758 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2761 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2762 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2763 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2764 as_type
, 0, 0, NULL
);
2766 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2767 as_type
, afi
, safi
, NULL
);
2770 vty_out(vty
, "%% BGP failed to create peer\n");
2771 return CMD_WARNING_CONFIG_FAILED
;
2775 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2777 /* Request zebra to initiate IPv6 RAs on this interface. We do
2779 * any unnumbered peer in order to not worry about run-time
2781 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2783 * gets deleted later etc.)
2786 bgp_zebra_initiate_radv(bgp
, peer
);
2789 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2790 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2792 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2794 UNSET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2796 /* v6only flag changed. Reset bgp seesion */
2797 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2798 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2799 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2800 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2802 bgp_session_reset(peer
);
2805 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
2806 peer_flag_set(peer
, PEER_FLAG_CAPABILITY_ENHE
);
2808 if (peer_group_name
) {
2809 group
= peer_group_lookup(bgp
, peer_group_name
);
2811 vty_out(vty
, "%% Configure the peer-group first\n");
2812 return CMD_WARNING_CONFIG_FAILED
;
2815 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2818 return bgp_vty_return(vty
, ret
);
2821 DEFUN (neighbor_interface_config
,
2822 neighbor_interface_config_cmd
,
2823 "neighbor WORD interface [peer-group WORD]",
2825 "Interface name or neighbor tag\n"
2826 "Enable BGP on interface\n"
2827 "Member of the peer-group\n"
2828 "Peer-group name\n")
2831 int idx_peer_group_word
= 4;
2833 if (argc
> idx_peer_group_word
)
2834 return peer_conf_interface_get(
2835 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2836 argv
[idx_peer_group_word
]->arg
, NULL
);
2838 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2839 SAFI_UNICAST
, 0, NULL
, NULL
);
2842 DEFUN (neighbor_interface_config_v6only
,
2843 neighbor_interface_config_v6only_cmd
,
2844 "neighbor WORD interface v6only [peer-group WORD]",
2846 "Interface name or neighbor tag\n"
2847 "Enable BGP on interface\n"
2848 "Enable BGP with v6 link-local only\n"
2849 "Member of the peer-group\n"
2850 "Peer-group name\n")
2853 int idx_peer_group_word
= 5;
2855 if (argc
> idx_peer_group_word
)
2856 return peer_conf_interface_get(
2857 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2858 argv
[idx_peer_group_word
]->arg
, NULL
);
2860 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2861 SAFI_UNICAST
, 1, NULL
, NULL
);
2865 DEFUN (neighbor_interface_config_remote_as
,
2866 neighbor_interface_config_remote_as_cmd
,
2867 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2869 "Interface name or neighbor tag\n"
2870 "Enable BGP on interface\n"
2871 "Specify a BGP neighbor\n"
2873 "Internal BGP peer\n"
2874 "External BGP peer\n")
2877 int idx_remote_as
= 4;
2878 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2879 SAFI_UNICAST
, 0, NULL
,
2880 argv
[idx_remote_as
]->arg
);
2883 DEFUN (neighbor_interface_v6only_config_remote_as
,
2884 neighbor_interface_v6only_config_remote_as_cmd
,
2885 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2887 "Interface name or neighbor tag\n"
2888 "Enable BGP with v6 link-local only\n"
2889 "Enable BGP on interface\n"
2890 "Specify a BGP neighbor\n"
2892 "Internal BGP peer\n"
2893 "External BGP peer\n")
2896 int idx_remote_as
= 5;
2897 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2898 SAFI_UNICAST
, 1, NULL
,
2899 argv
[idx_remote_as
]->arg
);
2902 DEFUN (neighbor_peer_group
,
2903 neighbor_peer_group_cmd
,
2904 "neighbor WORD peer-group",
2906 "Interface name or neighbor tag\n"
2907 "Configure peer-group\n")
2909 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2912 struct peer_group
*group
;
2914 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2916 vty_out(vty
, "%% Name conflict with interface: \n");
2917 return CMD_WARNING_CONFIG_FAILED
;
2920 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2922 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2923 return CMD_WARNING_CONFIG_FAILED
;
2931 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
2935 "Specify a BGP neighbor\n"
2937 "Internal BGP peer\n"
2938 "External BGP peer\n")
2940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2944 struct peer_group
*group
;
2948 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
2950 /* look up for neighbor by interface name config. */
2951 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
2953 /* Request zebra to terminate IPv6 RAs on this
2956 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
2961 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
2963 peer_group_delete(group
);
2965 vty_out(vty
, "%% Create the peer-group first\n");
2966 return CMD_WARNING_CONFIG_FAILED
;
2969 peer
= peer_lookup(bgp
, &su
);
2971 if (peer_dynamic_neighbor(peer
)) {
2973 "%% Operation not allowed on a dynamic neighbor\n");
2974 return CMD_WARNING_CONFIG_FAILED
;
2977 other
= peer
->doppelganger
;
2979 if (other
&& other
->status
!= Deleted
)
2987 DEFUN (no_neighbor_interface_config
,
2988 no_neighbor_interface_config_cmd
,
2989 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
2993 "Configure BGP on interface\n"
2994 "Enable BGP with v6 link-local only\n"
2995 "Member of the peer-group\n"
2997 "Specify a BGP neighbor\n"
2999 "Internal BGP peer\n"
3000 "External BGP peer\n")
3002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3006 /* look up for neighbor by interface name config. */
3007 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3009 /* Request zebra to terminate IPv6 RAs on this interface. */
3011 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3014 vty_out(vty
, "%% Create the bgp interface first\n");
3015 return CMD_WARNING_CONFIG_FAILED
;
3020 DEFUN (no_neighbor_peer_group
,
3021 no_neighbor_peer_group_cmd
,
3022 "no neighbor WORD peer-group",
3026 "Configure peer-group\n")
3028 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3030 struct peer_group
*group
;
3032 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3034 peer_group_delete(group
);
3036 vty_out(vty
, "%% Create the peer-group first\n");
3037 return CMD_WARNING_CONFIG_FAILED
;
3042 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3043 no_neighbor_interface_peer_group_remote_as_cmd
,
3044 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3047 "Interface name or neighbor tag\n"
3048 "Specify a BGP neighbor\n"
3050 "Internal BGP peer\n"
3051 "External BGP peer\n")
3053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3055 struct peer_group
*group
;
3058 /* look up for neighbor by interface name config. */
3059 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3061 peer_as_change(peer
, 0, AS_SPECIFIED
);
3065 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3067 peer_group_remote_as_delete(group
);
3069 vty_out(vty
, "%% Create the peer-group or interface first\n");
3070 return CMD_WARNING_CONFIG_FAILED
;
3075 DEFUN (neighbor_local_as
,
3076 neighbor_local_as_cmd
,
3077 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3080 "Specify a local-as number\n"
3081 "AS number used as local AS\n")
3089 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3091 return CMD_WARNING_CONFIG_FAILED
;
3093 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3094 ret
= peer_local_as_set(peer
, as
, 0, 0);
3095 return bgp_vty_return(vty
, ret
);
3098 DEFUN (neighbor_local_as_no_prepend
,
3099 neighbor_local_as_no_prepend_cmd
,
3100 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3103 "Specify a local-as number\n"
3104 "AS number used as local AS\n"
3105 "Do not prepend local-as to updates from ebgp peers\n")
3113 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3115 return CMD_WARNING_CONFIG_FAILED
;
3117 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3118 ret
= peer_local_as_set(peer
, as
, 1, 0);
3119 return bgp_vty_return(vty
, ret
);
3122 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3123 neighbor_local_as_no_prepend_replace_as_cmd
,
3124 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3127 "Specify a local-as number\n"
3128 "AS number used as local AS\n"
3129 "Do not prepend local-as to updates from ebgp peers\n"
3130 "Do not prepend local-as to updates from ibgp peers\n")
3138 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3140 return CMD_WARNING_CONFIG_FAILED
;
3142 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3143 ret
= peer_local_as_set(peer
, as
, 1, 1);
3144 return bgp_vty_return(vty
, ret
);
3147 DEFUN (no_neighbor_local_as
,
3148 no_neighbor_local_as_cmd
,
3149 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3153 "Specify a local-as number\n"
3154 "AS number used as local AS\n"
3155 "Do not prepend local-as to updates from ebgp peers\n"
3156 "Do not prepend local-as to updates from ibgp peers\n")
3162 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3164 return CMD_WARNING_CONFIG_FAILED
;
3166 ret
= peer_local_as_unset(peer
);
3167 return bgp_vty_return(vty
, ret
);
3171 DEFUN (neighbor_solo
,
3173 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3176 "Solo peer - part of its own update group\n")
3182 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3184 return CMD_WARNING_CONFIG_FAILED
;
3186 ret
= update_group_adjust_soloness(peer
, 1);
3187 return bgp_vty_return(vty
, ret
);
3190 DEFUN (no_neighbor_solo
,
3191 no_neighbor_solo_cmd
,
3192 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3196 "Solo peer - part of its own update group\n")
3202 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3204 return CMD_WARNING_CONFIG_FAILED
;
3206 ret
= update_group_adjust_soloness(peer
, 0);
3207 return bgp_vty_return(vty
, ret
);
3210 DEFUN (neighbor_password
,
3211 neighbor_password_cmd
,
3212 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3223 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3225 return CMD_WARNING_CONFIG_FAILED
;
3227 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3228 return bgp_vty_return(vty
, ret
);
3231 DEFUN (no_neighbor_password
,
3232 no_neighbor_password_cmd
,
3233 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3244 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3246 return CMD_WARNING_CONFIG_FAILED
;
3248 ret
= peer_password_unset(peer
);
3249 return bgp_vty_return(vty
, ret
);
3252 DEFUN (neighbor_activate
,
3253 neighbor_activate_cmd
,
3254 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3257 "Enable the Address Family for this Neighbor\n")
3263 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3265 return CMD_WARNING_CONFIG_FAILED
;
3267 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3268 return bgp_vty_return(vty
, ret
);
3271 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3272 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3273 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3274 "Enable the Address Family for this Neighbor\n")
3276 DEFUN (no_neighbor_activate
,
3277 no_neighbor_activate_cmd
,
3278 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3282 "Enable the Address Family for this Neighbor\n")
3289 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3291 return CMD_WARNING_CONFIG_FAILED
;
3293 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3294 return bgp_vty_return(vty
, ret
);
3297 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3298 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3299 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3300 "Enable the Address Family for this Neighbor\n")
3302 DEFUN (neighbor_set_peer_group
,
3303 neighbor_set_peer_group_cmd
,
3304 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3307 "Member of the peer-group\n"
3308 "Peer-group name\n")
3310 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3317 struct peer_group
*group
;
3321 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3323 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3325 vty_out(vty
, "%% Malformed address or name: %s\n",
3326 argv
[idx_peer
]->arg
);
3327 return CMD_WARNING_CONFIG_FAILED
;
3330 if (peer_address_self_check(bgp
, &su
)) {
3332 "%% Can not configure the local system as neighbor\n");
3333 return CMD_WARNING_CONFIG_FAILED
;
3336 /* Disallow for dynamic neighbor. */
3337 peer
= peer_lookup(bgp
, &su
);
3338 if (peer
&& peer_dynamic_neighbor(peer
)) {
3340 "%% Operation not allowed on a dynamic neighbor\n");
3341 return CMD_WARNING_CONFIG_FAILED
;
3345 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3347 vty_out(vty
, "%% Configure the peer-group first\n");
3348 return CMD_WARNING_CONFIG_FAILED
;
3351 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3353 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3355 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3357 return CMD_WARNING_CONFIG_FAILED
;
3360 return bgp_vty_return(vty
, ret
);
3363 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3364 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3365 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3366 "Member of the peer-group\n"
3367 "Peer-group name\n")
3369 DEFUN (no_neighbor_set_peer_group
,
3370 no_neighbor_set_peer_group_cmd
,
3371 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3375 "Member of the peer-group\n"
3376 "Peer-group name\n")
3378 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3383 struct peer_group
*group
;
3385 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3387 return CMD_WARNING_CONFIG_FAILED
;
3389 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3391 vty_out(vty
, "%% Configure the peer-group first\n");
3392 return CMD_WARNING_CONFIG_FAILED
;
3395 ret
= peer_delete(peer
);
3397 return bgp_vty_return(vty
, ret
);
3400 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3401 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3402 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3403 "Member of the peer-group\n"
3404 "Peer-group name\n")
3406 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3407 u_int16_t flag
, int set
)
3412 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3414 return CMD_WARNING_CONFIG_FAILED
;
3417 * If 'neighbor <interface>', then this is for directly connected peers,
3418 * we should not accept disable-connected-check.
3420 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3422 "%s is directly connected peer, cannot accept disable-"
3423 "connected-check\n",
3425 return CMD_WARNING_CONFIG_FAILED
;
3428 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3429 peer_tx_shutdown_message_unset(peer
);
3432 ret
= peer_flag_set(peer
, flag
);
3434 ret
= peer_flag_unset(peer
, flag
);
3436 return bgp_vty_return(vty
, ret
);
3439 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
,
3442 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3445 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3448 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3451 /* neighbor passive. */
3452 DEFUN (neighbor_passive
,
3453 neighbor_passive_cmd
,
3454 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3457 "Don't send open messages to this neighbor\n")
3460 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3463 DEFUN (no_neighbor_passive
,
3464 no_neighbor_passive_cmd
,
3465 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3469 "Don't send open messages to this neighbor\n")
3472 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3475 /* neighbor shutdown. */
3476 DEFUN (neighbor_shutdown_msg
,
3477 neighbor_shutdown_msg_cmd
,
3478 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3481 "Administratively shut down this neighbor\n"
3482 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3483 "Shutdown message\n")
3489 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3493 return CMD_WARNING_CONFIG_FAILED
;
3494 message
= argv_concat(argv
, argc
, 4);
3495 peer_tx_shutdown_message_set(peer
, message
);
3496 XFREE(MTYPE_TMP
, message
);
3499 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3502 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3503 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3504 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3505 "Administratively shut down this neighbor\n")
3507 DEFUN (no_neighbor_shutdown_msg
,
3508 no_neighbor_shutdown_msg_cmd
,
3509 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3513 "Administratively shut down this neighbor\n"
3514 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3515 "Shutdown message\n")
3519 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3520 PEER_FLAG_SHUTDOWN
);
3523 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3524 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3525 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3526 "Administratively shut down this neighbor\n")
3528 /* neighbor capability dynamic. */
3529 DEFUN (neighbor_capability_dynamic
,
3530 neighbor_capability_dynamic_cmd
,
3531 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3534 "Advertise capability to the peer\n"
3535 "Advertise dynamic capability to this neighbor\n")
3538 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3539 PEER_FLAG_DYNAMIC_CAPABILITY
);
3542 DEFUN (no_neighbor_capability_dynamic
,
3543 no_neighbor_capability_dynamic_cmd
,
3544 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3548 "Advertise capability to the peer\n"
3549 "Advertise dynamic capability to this neighbor\n")
3552 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3553 PEER_FLAG_DYNAMIC_CAPABILITY
);
3556 /* neighbor dont-capability-negotiate */
3557 DEFUN (neighbor_dont_capability_negotiate
,
3558 neighbor_dont_capability_negotiate_cmd
,
3559 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3562 "Do not perform capability negotiation\n")
3565 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3566 PEER_FLAG_DONT_CAPABILITY
);
3569 DEFUN (no_neighbor_dont_capability_negotiate
,
3570 no_neighbor_dont_capability_negotiate_cmd
,
3571 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3575 "Do not perform capability negotiation\n")
3578 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3579 PEER_FLAG_DONT_CAPABILITY
);
3582 /* neighbor capability extended next hop encoding */
3583 DEFUN (neighbor_capability_enhe
,
3584 neighbor_capability_enhe_cmd
,
3585 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3588 "Advertise capability to the peer\n"
3589 "Advertise extended next-hop capability to the peer\n")
3592 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3593 PEER_FLAG_CAPABILITY_ENHE
);
3596 DEFUN (no_neighbor_capability_enhe
,
3597 no_neighbor_capability_enhe_cmd
,
3598 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3602 "Advertise capability to the peer\n"
3603 "Advertise extended next-hop capability to the peer\n")
3606 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3607 PEER_FLAG_CAPABILITY_ENHE
);
3610 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3611 afi_t afi
, safi_t safi
, u_int32_t flag
,
3617 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3619 return CMD_WARNING_CONFIG_FAILED
;
3622 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3624 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3626 return bgp_vty_return(vty
, ret
);
3629 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3630 afi_t afi
, safi_t safi
, u_int32_t flag
)
3632 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3635 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3636 afi_t afi
, safi_t safi
, u_int32_t flag
)
3638 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3641 /* neighbor capability orf prefix-list. */
3642 DEFUN (neighbor_capability_orf_prefix
,
3643 neighbor_capability_orf_prefix_cmd
,
3644 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3647 "Advertise capability to the peer\n"
3648 "Advertise ORF capability to the peer\n"
3649 "Advertise prefixlist ORF capability to this neighbor\n"
3650 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3651 "Capability to RECEIVE the ORF from this neighbor\n"
3652 "Capability to SEND the ORF to this neighbor\n")
3655 int idx_send_recv
= 5;
3658 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3659 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3660 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3661 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3662 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3663 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3665 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3666 return CMD_WARNING_CONFIG_FAILED
;
3669 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3670 bgp_node_safi(vty
), flag
);
3674 neighbor_capability_orf_prefix
,
3675 neighbor_capability_orf_prefix_hidden_cmd
,
3676 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3677 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3678 "Advertise capability to the peer\n"
3679 "Advertise ORF capability to the peer\n"
3680 "Advertise prefixlist ORF capability to this neighbor\n"
3681 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3682 "Capability to RECEIVE the ORF from this neighbor\n"
3683 "Capability to SEND the ORF to this neighbor\n")
3685 DEFUN (no_neighbor_capability_orf_prefix
,
3686 no_neighbor_capability_orf_prefix_cmd
,
3687 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3691 "Advertise capability to the peer\n"
3692 "Advertise ORF capability to the peer\n"
3693 "Advertise prefixlist ORF capability to this neighbor\n"
3694 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3695 "Capability to RECEIVE the ORF from this neighbor\n"
3696 "Capability to SEND the ORF to this neighbor\n")
3699 int idx_send_recv
= 6;
3702 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3703 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3704 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3705 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3706 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3707 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3709 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3710 return CMD_WARNING_CONFIG_FAILED
;
3713 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3714 bgp_node_afi(vty
), bgp_node_safi(vty
),
3719 no_neighbor_capability_orf_prefix
,
3720 no_neighbor_capability_orf_prefix_hidden_cmd
,
3721 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3722 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3723 "Advertise capability to the peer\n"
3724 "Advertise ORF capability to the peer\n"
3725 "Advertise prefixlist ORF capability to this neighbor\n"
3726 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3727 "Capability to RECEIVE the ORF from this neighbor\n"
3728 "Capability to SEND the ORF to this neighbor\n")
3730 /* neighbor next-hop-self. */
3731 DEFUN (neighbor_nexthop_self
,
3732 neighbor_nexthop_self_cmd
,
3733 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3736 "Disable the next hop calculation for this neighbor\n")
3739 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3740 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3743 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3744 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3745 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3746 "Disable the next hop calculation for this neighbor\n")
3748 /* neighbor next-hop-self. */
3749 DEFUN (neighbor_nexthop_self_force
,
3750 neighbor_nexthop_self_force_cmd
,
3751 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3754 "Disable the next hop calculation for this neighbor\n"
3755 "Set the next hop to self for reflected routes\n")
3758 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3760 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3763 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3764 neighbor_nexthop_self_force_hidden_cmd
,
3765 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3766 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3767 "Disable the next hop calculation for this neighbor\n"
3768 "Set the next hop to self for reflected routes\n")
3770 DEFUN (no_neighbor_nexthop_self
,
3771 no_neighbor_nexthop_self_cmd
,
3772 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3776 "Disable the next hop calculation for this neighbor\n")
3779 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3780 bgp_node_afi(vty
), bgp_node_safi(vty
),
3781 PEER_FLAG_NEXTHOP_SELF
);
3784 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3785 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3786 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3787 "Disable the next hop calculation for this neighbor\n")
3789 DEFUN (no_neighbor_nexthop_self_force
,
3790 no_neighbor_nexthop_self_force_cmd
,
3791 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3795 "Disable the next hop calculation for this neighbor\n"
3796 "Set the next hop to self for reflected routes\n")
3799 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3800 bgp_node_afi(vty
), bgp_node_safi(vty
),
3801 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3804 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3805 no_neighbor_nexthop_self_force_hidden_cmd
,
3806 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3807 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3808 "Disable the next hop calculation for this neighbor\n"
3809 "Set the next hop to self for reflected routes\n")
3811 /* neighbor as-override */
3812 DEFUN (neighbor_as_override
,
3813 neighbor_as_override_cmd
,
3814 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3817 "Override ASNs in outbound updates if aspath equals remote-as\n")
3820 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3821 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3824 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3825 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3826 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3827 "Override ASNs in outbound updates if aspath equals remote-as\n")
3829 DEFUN (no_neighbor_as_override
,
3830 no_neighbor_as_override_cmd
,
3831 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3835 "Override ASNs in outbound updates if aspath equals remote-as\n")
3838 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3839 bgp_node_afi(vty
), bgp_node_safi(vty
),
3840 PEER_FLAG_AS_OVERRIDE
);
3843 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3844 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3845 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3846 "Override ASNs in outbound updates if aspath equals remote-as\n")
3848 /* neighbor remove-private-AS. */
3849 DEFUN (neighbor_remove_private_as
,
3850 neighbor_remove_private_as_cmd
,
3851 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3854 "Remove private ASNs in outbound updates\n")
3857 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3859 PEER_FLAG_REMOVE_PRIVATE_AS
);
3862 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3863 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3864 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3865 "Remove private ASNs in outbound updates\n")
3867 DEFUN (neighbor_remove_private_as_all
,
3868 neighbor_remove_private_as_all_cmd
,
3869 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3872 "Remove private ASNs in outbound updates\n"
3873 "Apply to all AS numbers\n")
3876 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3878 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3881 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3882 neighbor_remove_private_as_all_hidden_cmd
,
3883 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3884 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3885 "Remove private ASNs in outbound updates\n"
3886 "Apply to all AS numbers")
3888 DEFUN (neighbor_remove_private_as_replace_as
,
3889 neighbor_remove_private_as_replace_as_cmd
,
3890 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3893 "Remove private ASNs in outbound updates\n"
3894 "Replace private ASNs with our ASN in outbound updates\n")
3897 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3899 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3902 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3903 neighbor_remove_private_as_replace_as_hidden_cmd
,
3904 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3905 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3906 "Remove private ASNs in outbound updates\n"
3907 "Replace private ASNs with our ASN in outbound updates\n")
3909 DEFUN (neighbor_remove_private_as_all_replace_as
,
3910 neighbor_remove_private_as_all_replace_as_cmd
,
3911 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3914 "Remove private ASNs in outbound updates\n"
3915 "Apply to all AS numbers\n"
3916 "Replace private ASNs with our ASN in outbound updates\n")
3919 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3921 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3925 neighbor_remove_private_as_all_replace_as
,
3926 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3927 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3928 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3929 "Remove private ASNs in outbound updates\n"
3930 "Apply to all AS numbers\n"
3931 "Replace private ASNs with our ASN in outbound updates\n")
3933 DEFUN (no_neighbor_remove_private_as
,
3934 no_neighbor_remove_private_as_cmd
,
3935 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3939 "Remove private ASNs in outbound updates\n")
3942 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3943 bgp_node_afi(vty
), bgp_node_safi(vty
),
3944 PEER_FLAG_REMOVE_PRIVATE_AS
);
3947 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
3948 no_neighbor_remove_private_as_hidden_cmd
,
3949 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3950 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3951 "Remove private ASNs in outbound updates\n")
3953 DEFUN (no_neighbor_remove_private_as_all
,
3954 no_neighbor_remove_private_as_all_cmd
,
3955 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3959 "Remove private ASNs in outbound updates\n"
3960 "Apply to all AS numbers\n")
3963 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3964 bgp_node_afi(vty
), bgp_node_safi(vty
),
3965 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3968 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
3969 no_neighbor_remove_private_as_all_hidden_cmd
,
3970 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3971 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3972 "Remove private ASNs in outbound updates\n"
3973 "Apply to all AS numbers\n")
3975 DEFUN (no_neighbor_remove_private_as_replace_as
,
3976 no_neighbor_remove_private_as_replace_as_cmd
,
3977 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3981 "Remove private ASNs in outbound updates\n"
3982 "Replace private ASNs with our ASN in outbound updates\n")
3985 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3986 bgp_node_afi(vty
), bgp_node_safi(vty
),
3987 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3990 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
3991 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
3992 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3993 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3994 "Remove private ASNs in outbound updates\n"
3995 "Replace private ASNs with our ASN in outbound updates\n")
3997 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
3998 no_neighbor_remove_private_as_all_replace_as_cmd
,
3999 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4003 "Remove private ASNs in outbound updates\n"
4004 "Apply to all AS numbers\n"
4005 "Replace private ASNs with our ASN in outbound updates\n")
4008 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4009 bgp_node_afi(vty
), bgp_node_safi(vty
),
4010 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4014 no_neighbor_remove_private_as_all_replace_as
,
4015 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4016 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4017 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4018 "Remove private ASNs in outbound updates\n"
4019 "Apply to all AS numbers\n"
4020 "Replace private ASNs with our ASN in outbound updates\n")
4023 /* neighbor send-community. */
4024 DEFUN (neighbor_send_community
,
4025 neighbor_send_community_cmd
,
4026 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4029 "Send Community attribute to this neighbor\n")
4032 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4034 PEER_FLAG_SEND_COMMUNITY
);
4037 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4038 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4039 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4040 "Send Community attribute to this neighbor\n")
4042 DEFUN (no_neighbor_send_community
,
4043 no_neighbor_send_community_cmd
,
4044 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4048 "Send Community attribute to this neighbor\n")
4051 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4052 bgp_node_afi(vty
), bgp_node_safi(vty
),
4053 PEER_FLAG_SEND_COMMUNITY
);
4056 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4057 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4058 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4059 "Send Community attribute to this neighbor\n")
4061 /* neighbor send-community extended. */
4062 DEFUN (neighbor_send_community_type
,
4063 neighbor_send_community_type_cmd
,
4064 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4067 "Send Community attribute to this neighbor\n"
4068 "Send Standard and Extended Community attributes\n"
4069 "Send Standard, Large and Extended Community attributes\n"
4070 "Send Extended Community attributes\n"
4071 "Send Standard Community attributes\n"
4072 "Send Large Community attributes\n")
4077 char *peer
= argv
[1]->arg
;
4079 if (argv_find(argv
, argc
, "standard", &idx
))
4080 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4081 else if (argv_find(argv
, argc
, "extended", &idx
))
4082 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4083 else if (argv_find(argv
, argc
, "large", &idx
))
4084 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4085 else if (argv_find(argv
, argc
, "both", &idx
)) {
4086 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4087 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4089 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4090 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4091 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4094 return peer_af_flag_set_vty(vty
, peer
, bgp_node_afi(vty
),
4095 bgp_node_safi(vty
), flag
);
4099 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4100 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4101 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4102 "Send Community attribute to this neighbor\n"
4103 "Send Standard and Extended Community attributes\n"
4104 "Send Standard, Large and Extended Community attributes\n"
4105 "Send Extended Community attributes\n"
4106 "Send Standard Community attributes\n"
4107 "Send Large Community attributes\n")
4109 DEFUN (no_neighbor_send_community_type
,
4110 no_neighbor_send_community_type_cmd
,
4111 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4115 "Send Community attribute to this neighbor\n"
4116 "Send Standard and Extended Community attributes\n"
4117 "Send Standard, Large and Extended Community attributes\n"
4118 "Send Extended Community attributes\n"
4119 "Send Standard Community attributes\n"
4120 "Send Large Community attributes\n")
4124 const char *type
= argv
[argc
- 1]->text
;
4126 if (strmatch(type
, "standard"))
4127 return peer_af_flag_unset_vty(
4128 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4129 bgp_node_safi(vty
), PEER_FLAG_SEND_COMMUNITY
);
4130 if (strmatch(type
, "extended"))
4131 return peer_af_flag_unset_vty(
4132 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4133 bgp_node_safi(vty
), PEER_FLAG_SEND_EXT_COMMUNITY
);
4134 if (strmatch(type
, "large"))
4135 return peer_af_flag_unset_vty(
4136 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4137 bgp_node_safi(vty
), PEER_FLAG_SEND_LARGE_COMMUNITY
);
4138 if (strmatch(type
, "both"))
4139 return peer_af_flag_unset_vty(
4140 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4142 PEER_FLAG_SEND_COMMUNITY
4143 | PEER_FLAG_SEND_EXT_COMMUNITY
);
4145 /* if (strmatch (type, "all")) */
4146 return peer_af_flag_unset_vty(
4147 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4148 (PEER_FLAG_SEND_COMMUNITY
| PEER_FLAG_SEND_EXT_COMMUNITY
4149 | PEER_FLAG_SEND_LARGE_COMMUNITY
));
4153 no_neighbor_send_community_type
,
4154 no_neighbor_send_community_type_hidden_cmd
,
4155 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4156 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4157 "Send Community attribute to this neighbor\n"
4158 "Send Standard and Extended Community attributes\n"
4159 "Send Standard, Large and Extended Community attributes\n"
4160 "Send Extended Community attributes\n"
4161 "Send Standard Community attributes\n"
4162 "Send Large Community attributes\n")
4164 /* neighbor soft-reconfig. */
4165 DEFUN (neighbor_soft_reconfiguration
,
4166 neighbor_soft_reconfiguration_cmd
,
4167 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4170 "Per neighbor soft reconfiguration\n"
4171 "Allow inbound soft reconfiguration for this neighbor\n")
4174 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4176 PEER_FLAG_SOFT_RECONFIG
);
4179 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4180 neighbor_soft_reconfiguration_hidden_cmd
,
4181 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4182 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4183 "Per neighbor soft reconfiguration\n"
4184 "Allow inbound soft reconfiguration for this neighbor\n")
4186 DEFUN (no_neighbor_soft_reconfiguration
,
4187 no_neighbor_soft_reconfiguration_cmd
,
4188 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4192 "Per neighbor soft reconfiguration\n"
4193 "Allow inbound soft reconfiguration for this neighbor\n")
4196 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4197 bgp_node_afi(vty
), bgp_node_safi(vty
),
4198 PEER_FLAG_SOFT_RECONFIG
);
4201 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4202 no_neighbor_soft_reconfiguration_hidden_cmd
,
4203 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4204 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4205 "Per neighbor soft reconfiguration\n"
4206 "Allow inbound soft reconfiguration for this neighbor\n")
4208 DEFUN (neighbor_route_reflector_client
,
4209 neighbor_route_reflector_client_cmd
,
4210 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4213 "Configure a neighbor as Route Reflector client\n")
4219 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4221 return CMD_WARNING_CONFIG_FAILED
;
4223 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4225 PEER_FLAG_REFLECTOR_CLIENT
);
4228 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4229 neighbor_route_reflector_client_hidden_cmd
,
4230 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4231 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4232 "Configure a neighbor as Route Reflector client\n")
4234 DEFUN (no_neighbor_route_reflector_client
,
4235 no_neighbor_route_reflector_client_cmd
,
4236 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4240 "Configure a neighbor as Route Reflector client\n")
4243 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4244 bgp_node_afi(vty
), bgp_node_safi(vty
),
4245 PEER_FLAG_REFLECTOR_CLIENT
);
4248 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4249 no_neighbor_route_reflector_client_hidden_cmd
,
4250 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4251 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4252 "Configure a neighbor as Route Reflector client\n")
4254 /* neighbor route-server-client. */
4255 DEFUN (neighbor_route_server_client
,
4256 neighbor_route_server_client_cmd
,
4257 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4260 "Configure a neighbor as Route Server client\n")
4265 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4267 return CMD_WARNING_CONFIG_FAILED
;
4268 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4270 PEER_FLAG_RSERVER_CLIENT
);
4273 ALIAS_HIDDEN(neighbor_route_server_client
,
4274 neighbor_route_server_client_hidden_cmd
,
4275 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4276 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4277 "Configure a neighbor as Route Server client\n")
4279 DEFUN (no_neighbor_route_server_client
,
4280 no_neighbor_route_server_client_cmd
,
4281 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4285 "Configure a neighbor as Route Server client\n")
4288 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4289 bgp_node_afi(vty
), bgp_node_safi(vty
),
4290 PEER_FLAG_RSERVER_CLIENT
);
4293 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4294 no_neighbor_route_server_client_hidden_cmd
,
4295 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4296 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4297 "Configure a neighbor as Route Server client\n")
4299 DEFUN (neighbor_nexthop_local_unchanged
,
4300 neighbor_nexthop_local_unchanged_cmd
,
4301 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4304 "Configure treatment of outgoing link-local nexthop attribute\n"
4305 "Leave link-local nexthop unchanged for this peer\n")
4308 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4310 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4313 DEFUN (no_neighbor_nexthop_local_unchanged
,
4314 no_neighbor_nexthop_local_unchanged_cmd
,
4315 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4319 "Configure treatment of outgoing link-local-nexthop attribute\n"
4320 "Leave link-local nexthop unchanged for this peer\n")
4323 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4324 bgp_node_afi(vty
), bgp_node_safi(vty
),
4325 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4328 DEFUN (neighbor_attr_unchanged
,
4329 neighbor_attr_unchanged_cmd
,
4330 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4333 "BGP attribute is propagated unchanged to this neighbor\n"
4334 "As-path attribute\n"
4335 "Nexthop attribute\n"
4339 char *peer_str
= argv
[1]->arg
;
4341 u_int16_t flags
= 0;
4342 afi_t afi
= bgp_node_afi(vty
);
4343 safi_t safi
= bgp_node_safi(vty
);
4345 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4347 return CMD_WARNING_CONFIG_FAILED
;
4349 if (argv_find(argv
, argc
, "as-path", &idx
))
4350 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4352 if (argv_find(argv
, argc
, "next-hop", &idx
))
4353 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4355 if (argv_find(argv
, argc
, "med", &idx
))
4356 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4358 /* no flags means all of them! */
4360 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4361 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4362 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4364 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4365 && peer_af_flag_check(peer
, afi
, safi
,
4366 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4367 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4368 PEER_FLAG_AS_PATH_UNCHANGED
);
4371 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4372 && peer_af_flag_check(peer
, afi
, safi
,
4373 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4374 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4375 PEER_FLAG_NEXTHOP_UNCHANGED
);
4378 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4379 && peer_af_flag_check(peer
, afi
, safi
,
4380 PEER_FLAG_MED_UNCHANGED
)) {
4381 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4382 PEER_FLAG_MED_UNCHANGED
);
4386 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4390 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4391 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4392 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4393 "BGP attribute is propagated unchanged to this neighbor\n"
4394 "As-path attribute\n"
4395 "Nexthop attribute\n"
4398 DEFUN (no_neighbor_attr_unchanged
,
4399 no_neighbor_attr_unchanged_cmd
,
4400 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4404 "BGP attribute is propagated unchanged to this neighbor\n"
4405 "As-path attribute\n"
4406 "Nexthop attribute\n"
4410 char *peer
= argv
[2]->arg
;
4411 u_int16_t flags
= 0;
4413 if (argv_find(argv
, argc
, "as-path", &idx
))
4414 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4416 if (argv_find(argv
, argc
, "next-hop", &idx
))
4417 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4419 if (argv_find(argv
, argc
, "med", &idx
))
4420 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4422 if (!flags
) // no flags means all of them!
4424 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4425 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4426 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4429 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4430 bgp_node_safi(vty
), flags
);
4434 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4435 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4436 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4437 "BGP attribute is propagated unchanged to this neighbor\n"
4438 "As-path attribute\n"
4439 "Nexthop attribute\n"
4442 /* EBGP multihop configuration. */
4443 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4444 const char *ttl_str
)
4449 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4451 return CMD_WARNING_CONFIG_FAILED
;
4454 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4459 ttl
= strtoul(ttl_str
, NULL
, 10);
4461 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4464 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4468 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4470 return CMD_WARNING_CONFIG_FAILED
;
4472 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4475 /* neighbor ebgp-multihop. */
4476 DEFUN (neighbor_ebgp_multihop
,
4477 neighbor_ebgp_multihop_cmd
,
4478 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4481 "Allow EBGP neighbors not on directly connected networks\n")
4484 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4487 DEFUN (neighbor_ebgp_multihop_ttl
,
4488 neighbor_ebgp_multihop_ttl_cmd
,
4489 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4492 "Allow EBGP neighbors not on directly connected networks\n"
4493 "maximum hop count\n")
4497 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4498 argv
[idx_number
]->arg
);
4501 DEFUN (no_neighbor_ebgp_multihop
,
4502 no_neighbor_ebgp_multihop_cmd
,
4503 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4507 "Allow EBGP neighbors not on directly connected networks\n"
4508 "maximum hop count\n")
4511 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4515 /* disable-connected-check */
4516 DEFUN (neighbor_disable_connected_check
,
4517 neighbor_disable_connected_check_cmd
,
4518 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4521 "one-hop away EBGP peer using loopback address\n"
4522 "Enforce EBGP neighbors perform multihop\n")
4525 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4526 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4529 DEFUN (no_neighbor_disable_connected_check
,
4530 no_neighbor_disable_connected_check_cmd
,
4531 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4535 "one-hop away EBGP peer using loopback address\n"
4536 "Enforce EBGP neighbors perform multihop\n")
4539 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4540 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4543 DEFUN (neighbor_description
,
4544 neighbor_description_cmd
,
4545 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4548 "Neighbor specific description\n"
4549 "Up to 80 characters describing this neighbor\n")
4556 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4558 return CMD_WARNING_CONFIG_FAILED
;
4560 str
= argv_concat(argv
, argc
, idx_line
);
4562 peer_description_set(peer
, str
);
4564 XFREE(MTYPE_TMP
, str
);
4569 DEFUN (no_neighbor_description
,
4570 no_neighbor_description_cmd
,
4571 "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]",
4575 "Neighbor specific description\n"
4576 "Up to 80 characters describing this neighbor\n")
4581 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4583 return CMD_WARNING_CONFIG_FAILED
;
4585 peer_description_unset(peer
);
4591 /* Neighbor update-source. */
4592 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4593 const char *source_str
)
4598 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4600 return CMD_WARNING_CONFIG_FAILED
;
4607 int ret
= str2sockunion(source_str
, &su
);
4610 peer_update_source_addr_set(peer
, &su
);
4612 if (str2prefix(source_str
, &p
)) {
4614 "%% Invalid update-source, remove prefix length \n");
4615 return CMD_WARNING_CONFIG_FAILED
;
4617 peer_update_source_if_set(peer
, source_str
);
4620 peer_update_source_unset(peer
);
4625 #define BGP_UPDATE_SOURCE_HELP_STR \
4628 "Interface name (requires zebra to be running)\n"
4630 DEFUN (neighbor_update_source
,
4631 neighbor_update_source_cmd
,
4632 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4635 "Source of routing updates\n"
4636 BGP_UPDATE_SOURCE_HELP_STR
)
4640 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4641 argv
[idx_peer_2
]->arg
);
4644 DEFUN (no_neighbor_update_source
,
4645 no_neighbor_update_source_cmd
,
4646 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4650 "Source of routing updates\n"
4651 BGP_UPDATE_SOURCE_HELP_STR
)
4654 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4657 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4658 afi_t afi
, safi_t safi
,
4659 const char *rmap
, int set
)
4664 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4666 return CMD_WARNING_CONFIG_FAILED
;
4669 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4671 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4673 return bgp_vty_return(vty
, ret
);
4676 /* neighbor default-originate. */
4677 DEFUN (neighbor_default_originate
,
4678 neighbor_default_originate_cmd
,
4679 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4682 "Originate default route to this neighbor\n")
4685 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4687 bgp_node_safi(vty
), NULL
, 1);
4690 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4691 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4692 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4693 "Originate default route to this neighbor\n")
4695 DEFUN (neighbor_default_originate_rmap
,
4696 neighbor_default_originate_rmap_cmd
,
4697 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4700 "Originate default route to this neighbor\n"
4701 "Route-map to specify criteria to originate default\n"
4706 return peer_default_originate_set_vty(
4707 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4708 argv
[idx_word
]->arg
, 1);
4712 neighbor_default_originate_rmap
,
4713 neighbor_default_originate_rmap_hidden_cmd
,
4714 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4715 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4716 "Originate default route to this neighbor\n"
4717 "Route-map to specify criteria to originate default\n"
4720 DEFUN (no_neighbor_default_originate
,
4721 no_neighbor_default_originate_cmd
,
4722 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4726 "Originate default route to this neighbor\n"
4727 "Route-map to specify criteria to originate default\n"
4731 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4733 bgp_node_safi(vty
), NULL
, 0);
4737 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4738 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4739 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4740 "Originate default route to this neighbor\n"
4741 "Route-map to specify criteria to originate default\n"
4745 /* Set neighbor's BGP port. */
4746 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4747 const char *port_str
)
4753 peer
= peer_lookup_vty(vty
, ip_str
);
4755 return CMD_WARNING_CONFIG_FAILED
;
4758 sp
= getservbyname("bgp", "tcp");
4759 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4761 port
= strtoul(port_str
, NULL
, 10);
4764 peer_port_set(peer
, port
);
4769 /* Set specified peer's BGP port. */
4770 DEFUN (neighbor_port
,
4772 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4775 "Neighbor's BGP port\n"
4776 "TCP port number\n")
4780 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4781 argv
[idx_number
]->arg
);
4784 DEFUN (no_neighbor_port
,
4785 no_neighbor_port_cmd
,
4786 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4790 "Neighbor's BGP port\n"
4791 "TCP port number\n")
4794 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4798 /* neighbor weight. */
4799 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4800 safi_t safi
, const char *weight_str
)
4804 unsigned long weight
;
4806 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4808 return CMD_WARNING_CONFIG_FAILED
;
4810 weight
= strtoul(weight_str
, NULL
, 10);
4812 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4813 return bgp_vty_return(vty
, ret
);
4816 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4822 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4824 return CMD_WARNING_CONFIG_FAILED
;
4826 ret
= peer_weight_unset(peer
, afi
, safi
);
4827 return bgp_vty_return(vty
, ret
);
4830 DEFUN (neighbor_weight
,
4831 neighbor_weight_cmd
,
4832 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4835 "Set default weight for routes from this neighbor\n"
4840 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4841 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4844 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4845 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4846 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4847 "Set default weight for routes from this neighbor\n"
4850 DEFUN (no_neighbor_weight
,
4851 no_neighbor_weight_cmd
,
4852 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4856 "Set default weight for routes from this neighbor\n"
4860 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4861 bgp_node_afi(vty
), bgp_node_safi(vty
));
4864 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4865 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4866 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4867 "Set default weight for routes from this neighbor\n"
4871 /* Override capability negotiation. */
4872 DEFUN (neighbor_override_capability
,
4873 neighbor_override_capability_cmd
,
4874 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4877 "Override capability negotiation result\n")
4880 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4881 PEER_FLAG_OVERRIDE_CAPABILITY
);
4884 DEFUN (no_neighbor_override_capability
,
4885 no_neighbor_override_capability_cmd
,
4886 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4890 "Override capability negotiation result\n")
4893 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4894 PEER_FLAG_OVERRIDE_CAPABILITY
);
4897 DEFUN (neighbor_strict_capability
,
4898 neighbor_strict_capability_cmd
,
4899 "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4902 "Strict capability negotiation match\n")
4905 return peer_flag_set_vty(vty
, argv
[idx_ip
]->arg
,
4906 PEER_FLAG_STRICT_CAP_MATCH
);
4909 DEFUN (no_neighbor_strict_capability
,
4910 no_neighbor_strict_capability_cmd
,
4911 "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4915 "Strict capability negotiation match\n")
4918 return peer_flag_unset_vty(vty
, argv
[idx_ip
]->arg
,
4919 PEER_FLAG_STRICT_CAP_MATCH
);
4922 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
4923 const char *keep_str
, const char *hold_str
)
4927 u_int32_t keepalive
;
4930 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4932 return CMD_WARNING_CONFIG_FAILED
;
4934 keepalive
= strtoul(keep_str
, NULL
, 10);
4935 holdtime
= strtoul(hold_str
, NULL
, 10);
4937 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
4939 return bgp_vty_return(vty
, ret
);
4942 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
4947 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4949 return CMD_WARNING_CONFIG_FAILED
;
4951 ret
= peer_timers_unset(peer
);
4953 return bgp_vty_return(vty
, ret
);
4956 DEFUN (neighbor_timers
,
4957 neighbor_timers_cmd
,
4958 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
4961 "BGP per neighbor timers\n"
4962 "Keepalive interval\n"
4967 int idx_number_2
= 4;
4968 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
4969 argv
[idx_number
]->arg
,
4970 argv
[idx_number_2
]->arg
);
4973 DEFUN (no_neighbor_timers
,
4974 no_neighbor_timers_cmd
,
4975 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
4979 "BGP per neighbor timers\n"
4980 "Keepalive interval\n"
4984 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
4988 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
4989 const char *time_str
)
4995 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4997 return CMD_WARNING_CONFIG_FAILED
;
4999 connect
= strtoul(time_str
, NULL
, 10);
5001 ret
= peer_timers_connect_set(peer
, connect
);
5003 return bgp_vty_return(vty
, ret
);
5006 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5011 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5013 return CMD_WARNING_CONFIG_FAILED
;
5015 ret
= peer_timers_connect_unset(peer
);
5017 return bgp_vty_return(vty
, ret
);
5020 DEFUN (neighbor_timers_connect
,
5021 neighbor_timers_connect_cmd
,
5022 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5025 "BGP per neighbor timers\n"
5026 "BGP connect timer\n"
5031 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5032 argv
[idx_number
]->arg
);
5035 DEFUN (no_neighbor_timers_connect
,
5036 no_neighbor_timers_connect_cmd
,
5037 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5041 "BGP per neighbor timers\n"
5042 "BGP connect timer\n"
5046 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5050 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5051 const char *time_str
, int set
)
5055 u_int32_t routeadv
= 0;
5057 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5059 return CMD_WARNING_CONFIG_FAILED
;
5062 routeadv
= strtoul(time_str
, NULL
, 10);
5065 ret
= peer_advertise_interval_set(peer
, routeadv
);
5067 ret
= peer_advertise_interval_unset(peer
);
5069 return bgp_vty_return(vty
, ret
);
5072 DEFUN (neighbor_advertise_interval
,
5073 neighbor_advertise_interval_cmd
,
5074 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5077 "Minimum interval between sending BGP routing updates\n"
5078 "time in seconds\n")
5082 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5083 argv
[idx_number
]->arg
, 1);
5086 DEFUN (no_neighbor_advertise_interval
,
5087 no_neighbor_advertise_interval_cmd
,
5088 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5092 "Minimum interval between sending BGP routing updates\n"
5093 "time in seconds\n")
5096 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5100 /* Time to wait before processing route-map updates */
5101 DEFUN (bgp_set_route_map_delay_timer
,
5102 bgp_set_route_map_delay_timer_cmd
,
5103 "bgp route-map delay-timer (0-600)",
5105 "BGP route-map delay timer\n"
5106 "Time in secs to wait before processing route-map changes\n"
5107 "0 disables the timer, no route updates happen when route-maps change\n")
5110 u_int32_t rmap_delay_timer
;
5112 if (argv
[idx_number
]->arg
) {
5113 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5114 bm
->rmap_update_timer
= rmap_delay_timer
;
5116 /* if the dynamic update handling is being disabled, and a timer
5118 * running, stop the timer and act as if the timer has already
5121 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5122 BGP_TIMER_OFF(bm
->t_rmap_update
);
5123 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5128 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5129 return CMD_WARNING_CONFIG_FAILED
;
5133 DEFUN (no_bgp_set_route_map_delay_timer
,
5134 no_bgp_set_route_map_delay_timer_cmd
,
5135 "no bgp route-map delay-timer [(0-600)]",
5138 "Default BGP route-map delay timer\n"
5139 "Reset to default time to wait for processing route-map changes\n"
5140 "0 disables the timer, no route updates happen when route-maps change\n")
5143 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5149 /* neighbor interface */
5150 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5155 peer
= peer_lookup_vty(vty
, ip_str
);
5156 if (!peer
|| peer
->conf_if
) {
5157 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5158 return CMD_WARNING_CONFIG_FAILED
;
5162 peer_interface_set(peer
, str
);
5164 peer_interface_unset(peer
);
5169 DEFUN (neighbor_interface
,
5170 neighbor_interface_cmd
,
5171 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5179 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5182 DEFUN (no_neighbor_interface
,
5183 no_neighbor_interface_cmd
,
5184 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5192 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5195 DEFUN (neighbor_distribute_list
,
5196 neighbor_distribute_list_cmd
,
5197 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5200 "Filter updates to/from this neighbor\n"
5201 "IP access-list number\n"
5202 "IP access-list number (expanded range)\n"
5203 "IP Access-list name\n"
5204 "Filter incoming updates\n"
5205 "Filter outgoing updates\n")
5212 const char *pstr
= argv
[idx_peer
]->arg
;
5213 const char *acl
= argv
[idx_acl
]->arg
;
5214 const char *inout
= argv
[argc
- 1]->text
;
5216 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5218 return CMD_WARNING_CONFIG_FAILED
;
5220 /* Check filter direction. */
5221 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5222 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5225 return bgp_vty_return(vty
, ret
);
5229 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5230 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5231 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5232 "Filter updates to/from this neighbor\n"
5233 "IP access-list number\n"
5234 "IP access-list number (expanded range)\n"
5235 "IP Access-list name\n"
5236 "Filter incoming updates\n"
5237 "Filter outgoing updates\n")
5239 DEFUN (no_neighbor_distribute_list
,
5240 no_neighbor_distribute_list_cmd
,
5241 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5245 "Filter updates to/from this neighbor\n"
5246 "IP access-list number\n"
5247 "IP access-list number (expanded range)\n"
5248 "IP Access-list name\n"
5249 "Filter incoming updates\n"
5250 "Filter outgoing updates\n")
5256 const char *pstr
= argv
[idx_peer
]->arg
;
5257 const char *inout
= argv
[argc
- 1]->text
;
5259 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5261 return CMD_WARNING_CONFIG_FAILED
;
5263 /* Check filter direction. */
5264 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5265 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5268 return bgp_vty_return(vty
, ret
);
5272 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5273 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5274 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5275 "Filter updates to/from this neighbor\n"
5276 "IP access-list number\n"
5277 "IP access-list number (expanded range)\n"
5278 "IP Access-list name\n"
5279 "Filter incoming updates\n"
5280 "Filter outgoing updates\n")
5282 /* Set prefix list to the peer. */
5283 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5284 afi_t afi
, safi_t safi
,
5285 const char *name_str
,
5286 const char *direct_str
)
5290 int direct
= FILTER_IN
;
5292 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5294 return CMD_WARNING_CONFIG_FAILED
;
5296 /* Check filter direction. */
5297 if (strncmp(direct_str
, "i", 1) == 0)
5299 else if (strncmp(direct_str
, "o", 1) == 0)
5300 direct
= FILTER_OUT
;
5302 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5304 return bgp_vty_return(vty
, ret
);
5307 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5308 afi_t afi
, safi_t safi
,
5309 const char *direct_str
)
5313 int direct
= FILTER_IN
;
5315 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5317 return CMD_WARNING_CONFIG_FAILED
;
5319 /* Check filter direction. */
5320 if (strncmp(direct_str
, "i", 1) == 0)
5322 else if (strncmp(direct_str
, "o", 1) == 0)
5323 direct
= FILTER_OUT
;
5325 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5327 return bgp_vty_return(vty
, ret
);
5330 DEFUN (neighbor_prefix_list
,
5331 neighbor_prefix_list_cmd
,
5332 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5335 "Filter updates to/from this neighbor\n"
5336 "Name of a prefix list\n"
5337 "Filter incoming updates\n"
5338 "Filter outgoing updates\n")
5343 return peer_prefix_list_set_vty(
5344 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5345 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5348 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5349 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5350 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5351 "Filter updates to/from this neighbor\n"
5352 "Name of a prefix list\n"
5353 "Filter incoming updates\n"
5354 "Filter outgoing updates\n")
5356 DEFUN (no_neighbor_prefix_list
,
5357 no_neighbor_prefix_list_cmd
,
5358 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5362 "Filter updates to/from this neighbor\n"
5363 "Name of a prefix list\n"
5364 "Filter incoming updates\n"
5365 "Filter outgoing updates\n")
5369 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5370 bgp_node_afi(vty
), bgp_node_safi(vty
),
5371 argv
[idx_in_out
]->arg
);
5374 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5375 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5376 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5377 "Filter updates to/from this neighbor\n"
5378 "Name of a prefix list\n"
5379 "Filter incoming updates\n"
5380 "Filter outgoing updates\n")
5382 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5383 safi_t safi
, const char *name_str
,
5384 const char *direct_str
)
5388 int direct
= FILTER_IN
;
5390 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5392 return CMD_WARNING_CONFIG_FAILED
;
5394 /* Check filter direction. */
5395 if (strncmp(direct_str
, "i", 1) == 0)
5397 else if (strncmp(direct_str
, "o", 1) == 0)
5398 direct
= FILTER_OUT
;
5400 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5402 return bgp_vty_return(vty
, ret
);
5405 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5406 safi_t safi
, const char *direct_str
)
5410 int direct
= FILTER_IN
;
5412 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5414 return CMD_WARNING_CONFIG_FAILED
;
5416 /* Check filter direction. */
5417 if (strncmp(direct_str
, "i", 1) == 0)
5419 else if (strncmp(direct_str
, "o", 1) == 0)
5420 direct
= FILTER_OUT
;
5422 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5424 return bgp_vty_return(vty
, ret
);
5427 DEFUN (neighbor_filter_list
,
5428 neighbor_filter_list_cmd
,
5429 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5432 "Establish BGP filters\n"
5433 "AS path access-list name\n"
5434 "Filter incoming routes\n"
5435 "Filter outgoing routes\n")
5440 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5441 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5442 argv
[idx_in_out
]->arg
);
5445 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5446 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5447 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5448 "Establish BGP filters\n"
5449 "AS path access-list name\n"
5450 "Filter incoming routes\n"
5451 "Filter outgoing routes\n")
5453 DEFUN (no_neighbor_filter_list
,
5454 no_neighbor_filter_list_cmd
,
5455 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5459 "Establish BGP filters\n"
5460 "AS path access-list name\n"
5461 "Filter incoming routes\n"
5462 "Filter outgoing routes\n")
5466 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5467 bgp_node_afi(vty
), bgp_node_safi(vty
),
5468 argv
[idx_in_out
]->arg
);
5471 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5472 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5473 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5474 "Establish BGP filters\n"
5475 "AS path access-list name\n"
5476 "Filter incoming routes\n"
5477 "Filter outgoing routes\n")
5479 /* Set route-map to the peer. */
5480 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5481 afi_t afi
, safi_t safi
, const char *name_str
,
5482 const char *direct_str
)
5486 int direct
= RMAP_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
, "in", 2) == 0)
5495 else if (strncmp(direct_str
, "o", 1) == 0)
5498 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5500 return bgp_vty_return(vty
, ret
);
5503 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5504 afi_t afi
, safi_t safi
,
5505 const char *direct_str
)
5509 int direct
= RMAP_IN
;
5511 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5513 return CMD_WARNING_CONFIG_FAILED
;
5515 /* Check filter direction. */
5516 if (strncmp(direct_str
, "in", 2) == 0)
5518 else if (strncmp(direct_str
, "o", 1) == 0)
5521 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5523 return bgp_vty_return(vty
, ret
);
5526 DEFUN (neighbor_route_map
,
5527 neighbor_route_map_cmd
,
5528 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5531 "Apply route map to neighbor\n"
5532 "Name of route map\n"
5533 "Apply map to incoming routes\n"
5534 "Apply map to outbound routes\n")
5539 return peer_route_map_set_vty(
5540 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5541 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5544 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5545 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5546 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5547 "Apply route map to neighbor\n"
5548 "Name of route map\n"
5549 "Apply map to incoming routes\n"
5550 "Apply map to outbound routes\n")
5552 DEFUN (no_neighbor_route_map
,
5553 no_neighbor_route_map_cmd
,
5554 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5558 "Apply route map to neighbor\n"
5559 "Name of route map\n"
5560 "Apply map to incoming routes\n"
5561 "Apply map to outbound routes\n")
5565 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5566 bgp_node_afi(vty
), bgp_node_safi(vty
),
5567 argv
[idx_in_out
]->arg
);
5570 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5571 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5572 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5573 "Apply route map to neighbor\n"
5574 "Name of route map\n"
5575 "Apply map to incoming routes\n"
5576 "Apply map to outbound routes\n")
5578 /* Set unsuppress-map to the peer. */
5579 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5580 afi_t afi
, safi_t safi
,
5581 const char *name_str
)
5586 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5588 return CMD_WARNING_CONFIG_FAILED
;
5590 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5592 return bgp_vty_return(vty
, ret
);
5595 /* Unset route-map from the peer. */
5596 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5597 afi_t afi
, safi_t safi
)
5602 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5604 return CMD_WARNING_CONFIG_FAILED
;
5606 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5608 return bgp_vty_return(vty
, ret
);
5611 DEFUN (neighbor_unsuppress_map
,
5612 neighbor_unsuppress_map_cmd
,
5613 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5616 "Route-map to selectively unsuppress suppressed routes\n"
5617 "Name of route map\n")
5621 return peer_unsuppress_map_set_vty(
5622 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5623 argv
[idx_word
]->arg
);
5626 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5627 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5628 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5629 "Route-map to selectively unsuppress suppressed routes\n"
5630 "Name of route map\n")
5632 DEFUN (no_neighbor_unsuppress_map
,
5633 no_neighbor_unsuppress_map_cmd
,
5634 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5638 "Route-map to selectively unsuppress suppressed routes\n"
5639 "Name of route map\n")
5642 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5644 bgp_node_safi(vty
));
5647 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5648 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5649 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5650 "Route-map to selectively unsuppress suppressed routes\n"
5651 "Name of route map\n")
5653 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5654 afi_t afi
, safi_t safi
,
5655 const char *num_str
,
5656 const char *threshold_str
, int warning
,
5657 const char *restart_str
)
5665 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5667 return CMD_WARNING_CONFIG_FAILED
;
5669 max
= strtoul(num_str
, NULL
, 10);
5671 threshold
= atoi(threshold_str
);
5673 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5676 restart
= atoi(restart_str
);
5680 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5683 return bgp_vty_return(vty
, ret
);
5686 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5687 afi_t afi
, safi_t safi
)
5692 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5694 return CMD_WARNING_CONFIG_FAILED
;
5696 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5698 return bgp_vty_return(vty
, ret
);
5701 /* Maximum number of prefix configuration. prefix count is different
5702 for each peer configuration. So this configuration can be set for
5703 each peer configuration. */
5704 DEFUN (neighbor_maximum_prefix
,
5705 neighbor_maximum_prefix_cmd
,
5706 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5709 "Maximum number of prefix accept from this peer\n"
5710 "maximum no. of prefix limit\n")
5714 return peer_maximum_prefix_set_vty(
5715 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5716 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5719 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5720 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5721 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5722 "Maximum number of prefix accept from this peer\n"
5723 "maximum no. of prefix limit\n")
5725 DEFUN (neighbor_maximum_prefix_threshold
,
5726 neighbor_maximum_prefix_threshold_cmd
,
5727 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5730 "Maximum number of prefix accept from this peer\n"
5731 "maximum no. of prefix limit\n"
5732 "Threshold value (%) at which to generate a warning msg\n")
5736 int idx_number_2
= 4;
5737 return peer_maximum_prefix_set_vty(
5738 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5739 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5743 neighbor_maximum_prefix_threshold
,
5744 neighbor_maximum_prefix_threshold_hidden_cmd
,
5745 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5746 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5747 "Maximum number of prefix accept from this peer\n"
5748 "maximum no. of prefix limit\n"
5749 "Threshold value (%) at which to generate a warning msg\n")
5751 DEFUN (neighbor_maximum_prefix_warning
,
5752 neighbor_maximum_prefix_warning_cmd
,
5753 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5756 "Maximum number of prefix accept from this peer\n"
5757 "maximum no. of prefix limit\n"
5758 "Only give warning message when limit is exceeded\n")
5762 return peer_maximum_prefix_set_vty(
5763 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5764 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5768 neighbor_maximum_prefix_warning
,
5769 neighbor_maximum_prefix_warning_hidden_cmd
,
5770 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5771 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5772 "Maximum number of prefix accept from this peer\n"
5773 "maximum no. of prefix limit\n"
5774 "Only give warning message when limit is exceeded\n")
5776 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5777 neighbor_maximum_prefix_threshold_warning_cmd
,
5778 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5781 "Maximum number of prefix accept from this peer\n"
5782 "maximum no. of prefix limit\n"
5783 "Threshold value (%) at which to generate a warning msg\n"
5784 "Only give warning message when limit is exceeded\n")
5788 int idx_number_2
= 4;
5789 return peer_maximum_prefix_set_vty(
5790 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5791 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5795 neighbor_maximum_prefix_threshold_warning
,
5796 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5797 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5798 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5799 "Maximum number of prefix accept from this peer\n"
5800 "maximum no. of prefix limit\n"
5801 "Threshold value (%) at which to generate a warning msg\n"
5802 "Only give warning message when limit is exceeded\n")
5804 DEFUN (neighbor_maximum_prefix_restart
,
5805 neighbor_maximum_prefix_restart_cmd
,
5806 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5809 "Maximum number of prefix accept from this peer\n"
5810 "maximum no. of prefix limit\n"
5811 "Restart bgp connection after limit is exceeded\n"
5812 "Restart interval in minutes\n")
5816 int idx_number_2
= 5;
5817 return peer_maximum_prefix_set_vty(
5818 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5819 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5823 neighbor_maximum_prefix_restart
,
5824 neighbor_maximum_prefix_restart_hidden_cmd
,
5825 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5826 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5827 "Maximum number of prefix accept from this peer\n"
5828 "maximum no. of prefix limit\n"
5829 "Restart bgp connection after limit is exceeded\n"
5830 "Restart interval in minutes\n")
5832 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5833 neighbor_maximum_prefix_threshold_restart_cmd
,
5834 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5837 "Maximum number of prefixes to accept from this peer\n"
5838 "maximum no. of prefix limit\n"
5839 "Threshold value (%) at which to generate a warning msg\n"
5840 "Restart bgp connection after limit is exceeded\n"
5841 "Restart interval in minutes\n")
5845 int idx_number_2
= 4;
5846 int idx_number_3
= 6;
5847 return peer_maximum_prefix_set_vty(
5848 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5849 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5850 argv
[idx_number_3
]->arg
);
5854 neighbor_maximum_prefix_threshold_restart
,
5855 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5856 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5857 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5858 "Maximum number of prefixes to accept from this peer\n"
5859 "maximum no. of prefix limit\n"
5860 "Threshold value (%) at which to generate a warning msg\n"
5861 "Restart bgp connection after limit is exceeded\n"
5862 "Restart interval in minutes\n")
5864 DEFUN (no_neighbor_maximum_prefix
,
5865 no_neighbor_maximum_prefix_cmd
,
5866 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5870 "Maximum number of prefixes to accept from this peer\n"
5871 "maximum no. of prefix limit\n"
5872 "Threshold value (%) at which to generate a warning msg\n"
5873 "Restart bgp connection after limit is exceeded\n"
5874 "Restart interval in minutes\n"
5875 "Only give warning message when limit is exceeded\n")
5878 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5880 bgp_node_safi(vty
));
5884 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5885 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5886 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5887 "Maximum number of prefixes to accept from this peer\n"
5888 "maximum no. of prefix limit\n"
5889 "Threshold value (%) at which to generate a warning msg\n"
5890 "Restart bgp connection after limit is exceeded\n"
5891 "Restart interval in minutes\n"
5892 "Only give warning message when limit is exceeded\n")
5895 /* "neighbor allowas-in" */
5896 DEFUN (neighbor_allowas_in
,
5897 neighbor_allowas_in_cmd
,
5898 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5901 "Accept as-path with my AS present in it\n"
5902 "Number of occurances of AS number\n"
5903 "Only accept my AS in the as-path if the route was originated in my AS\n")
5906 int idx_number_origin
= 3;
5912 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5914 return CMD_WARNING_CONFIG_FAILED
;
5916 if (argc
<= idx_number_origin
)
5919 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
5922 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
5925 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5928 return bgp_vty_return(vty
, ret
);
5932 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
5933 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5934 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5935 "Accept as-path with my AS present in it\n"
5936 "Number of occurances of AS number\n"
5937 "Only accept my AS in the as-path if the route was originated in my AS\n")
5939 DEFUN (no_neighbor_allowas_in
,
5940 no_neighbor_allowas_in_cmd
,
5941 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5945 "allow local ASN appears in aspath attribute\n"
5946 "Number of occurances of AS number\n"
5947 "Only accept my AS in the as-path if the route was originated in my AS\n")
5953 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5955 return CMD_WARNING_CONFIG_FAILED
;
5957 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
5958 bgp_node_safi(vty
));
5960 return bgp_vty_return(vty
, ret
);
5964 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
5965 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5966 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5967 "allow local ASN appears in aspath attribute\n"
5968 "Number of occurances of AS number\n"
5969 "Only accept my AS in the as-path if the route was originated in my AS\n")
5971 DEFUN (neighbor_ttl_security
,
5972 neighbor_ttl_security_cmd
,
5973 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
5976 "BGP ttl-security parameters\n"
5977 "Specify the maximum number of hops to the BGP peer\n"
5978 "Number of hops to BGP peer\n")
5985 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5987 return CMD_WARNING_CONFIG_FAILED
;
5989 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5992 * If 'neighbor swpX', then this is for directly connected peers,
5993 * we should not accept a ttl-security hops value greater than 1.
5995 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
5997 "%s is directly connected peer, hops cannot exceed 1\n",
5998 argv
[idx_peer
]->arg
);
5999 return CMD_WARNING_CONFIG_FAILED
;
6002 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6005 DEFUN (no_neighbor_ttl_security
,
6006 no_neighbor_ttl_security_cmd
,
6007 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6011 "BGP ttl-security parameters\n"
6012 "Specify the maximum number of hops to the BGP peer\n"
6013 "Number of hops to BGP peer\n")
6018 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6020 return CMD_WARNING_CONFIG_FAILED
;
6022 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6025 DEFUN (neighbor_addpath_tx_all_paths
,
6026 neighbor_addpath_tx_all_paths_cmd
,
6027 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6030 "Use addpath to advertise all paths to a neighbor\n")
6035 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6037 return CMD_WARNING_CONFIG_FAILED
;
6039 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6041 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6044 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6045 neighbor_addpath_tx_all_paths_hidden_cmd
,
6046 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6047 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6048 "Use addpath to advertise all paths to a neighbor\n")
6050 DEFUN (no_neighbor_addpath_tx_all_paths
,
6051 no_neighbor_addpath_tx_all_paths_cmd
,
6052 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6056 "Use addpath to advertise all paths to a neighbor\n")
6059 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6060 bgp_node_afi(vty
), bgp_node_safi(vty
),
6061 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6064 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6065 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6066 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6067 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6068 "Use addpath to advertise all paths to a neighbor\n")
6070 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6071 neighbor_addpath_tx_bestpath_per_as_cmd
,
6072 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6075 "Use addpath to advertise the bestpath per each neighboring AS\n")
6080 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6082 return CMD_WARNING_CONFIG_FAILED
;
6084 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6086 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6089 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6090 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6091 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6092 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6093 "Use addpath to advertise the bestpath per each neighboring AS\n")
6095 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6096 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6097 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6101 "Use addpath to advertise the bestpath per each neighboring AS\n")
6104 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6105 bgp_node_afi(vty
), bgp_node_safi(vty
),
6106 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6109 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6110 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6111 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6112 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6113 "Use addpath to advertise the bestpath per each neighboring AS\n")
6115 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6116 struct ecommunity
**list
)
6118 struct ecommunity
*ecom
= NULL
;
6119 struct ecommunity
*ecomadd
;
6121 for (; argc
; --argc
, ++argv
) {
6123 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6124 ECOMMUNITY_ROUTE_TARGET
, 0);
6126 vty_out(vty
, "Malformed community-list value\n");
6128 ecommunity_free(&ecom
);
6129 return CMD_WARNING_CONFIG_FAILED
;
6133 ecommunity_merge(ecom
, ecomadd
);
6134 ecommunity_free(&ecomadd
);
6141 ecommunity_free(&*list
);
6148 static int vpn_policy_getafi(struct vty
*vty
, int *doafi
)
6150 switch (vty
->node
) {
6159 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6160 return CMD_WARNING_CONFIG_FAILED
;
6165 DEFPY (af_rd_vpn_export
,
6166 af_rd_vpn_export_cmd
,
6167 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6169 "Specify route distinguisher\n"
6170 "Between current address-family and vpn\n"
6171 "For routes leaked from current address-family to vpn\n"
6172 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6174 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6175 struct prefix_rd prd
;
6177 int doafi
[AFI_MAX
] = {0};
6182 if (argv_find(argv
, argc
, "no", &idx
))
6186 ret
= str2prefix_rd(rd_str
, &prd
);
6188 vty_out(vty
, "%% Malformed rd\n");
6189 return CMD_WARNING_CONFIG_FAILED
;
6193 ret
= vpn_policy_getafi(vty
, doafi
);
6194 if (ret
!= CMD_SUCCESS
)
6198 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6202 /* pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6204 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6205 bgp_get_default(), bgp
);
6208 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6209 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6210 BGP_VPN_POLICY_TOVPN_RD_SET
);
6212 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6213 BGP_VPN_POLICY_TOVPN_RD_SET
);
6216 /* post-change: re-export vpn routes */
6217 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6218 bgp_get_default(), bgp
);
6224 ALIAS (af_rd_vpn_export
,
6225 af_no_rd_vpn_export_cmd
,
6228 "Specify route distinguisher\n"
6229 "Between current address-family and vpn\n"
6230 "For routes leaked from current address-family to vpn\n")
6232 DEFPY (af_label_vpn_export
,
6233 af_label_vpn_export_cmd
,
6234 "[no] label vpn export (0-1048575)$label_val",
6236 "label value for VRF\n"
6237 "Between current address-family and vpn\n"
6238 "For routes leaked from current address-family to vpn\n"
6239 "Label Value <0-1048575>\n")
6241 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6242 mpls_label_t label
= MPLS_LABEL_NONE
;
6243 int doafi
[AFI_MAX
] = {0};
6249 if (argv_find(argv
, argc
, "no", &idx
))
6253 label
= label_val
; /* rely on parser to force unsigned */
6255 ret
= vpn_policy_getafi(vty
, doafi
);
6256 if (ret
!= CMD_SUCCESS
)
6259 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6264 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6266 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6267 bgp_get_default(), bgp
);
6269 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6271 /* post-change: re-export vpn routes */
6272 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6273 bgp_get_default(), bgp
);
6279 ALIAS (af_label_vpn_export
,
6280 af_no_label_vpn_export_cmd
,
6281 "no label vpn export",
6283 "label value for VRF\n"
6284 "Between current address-family and vpn\n"
6285 "For routes leaked from current address-family to vpn\n")
6287 DEFPY (af_nexthop_vpn_export
,
6288 af_nexthop_vpn_export_cmd
,
6289 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6291 "Specify next hop to use for VRF advertised prefixes\n"
6292 "Between current address-family and vpn\n"
6293 "For routes leaked from current address-family to vpn\n"
6297 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6298 int doafi
[AFI_MAX
] = {0};
6305 if (argv_find(argv
, argc
, "no", &idx
))
6309 if (!sockunion2hostprefix(nexthop_str
, &p
))
6310 return CMD_WARNING_CONFIG_FAILED
;
6313 ret
= vpn_policy_getafi(vty
, doafi
);
6314 if (ret
!= CMD_SUCCESS
)
6317 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6322 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6324 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6325 bgp_get_default(), bgp
);
6328 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6329 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6330 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6332 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6333 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6336 /* post-change: re-export vpn routes */
6337 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6338 bgp_get_default(), bgp
);
6344 ALIAS (af_nexthop_vpn_export
,
6345 af_no_nexthop_vpn_export_cmd
,
6346 "no nexthop vpn export",
6348 "Specify next hop to use for VRF advertised prefixes\n"
6349 "Between current address-family and vpn\n"
6350 "For routes leaked from current address-family to vpn\n")
6352 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6354 if (!strcmp(dstr
, "import")) {
6355 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6356 } else if (!strcmp(dstr
, "export")) {
6357 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6358 } else if (!strcmp(dstr
, "both")) {
6359 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6360 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6362 vty_out(vty
, "%% direction parse error\n");
6363 return CMD_WARNING_CONFIG_FAILED
;
6368 DEFPY (af_rt_vpn_imexport
,
6369 af_rt_vpn_imexport_cmd
,
6370 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6372 "Specify route target list\n"
6373 "Specify route target list\n"
6374 "Between current address-family and vpn\n"
6375 "For routes leaked from vpn to current address-family: match any\n"
6376 "For routes leaked from current address-family to vpn: set\n"
6377 "both import: match any and export: set\n"
6378 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6382 struct ecommunity
*ecom
= NULL
;
6383 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6384 int doafi
[AFI_MAX
] = {0};
6385 vpn_policy_direction_t dir
;
6390 if (argv_find(argv
, argc
, "no", &idx
))
6393 ret
= vpn_policy_getafi(vty
, doafi
);
6394 if (ret
!= CMD_SUCCESS
)
6397 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6398 if (ret
!= CMD_SUCCESS
)
6402 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6403 vty_out(vty
, "%% Missing RTLIST\n");
6404 return CMD_WARNING_CONFIG_FAILED
;
6406 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6407 if (ret
!= CMD_SUCCESS
) {
6412 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6415 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6419 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6422 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6424 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6425 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6426 ecommunity_dup(ecom
);
6428 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6430 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6431 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6434 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6437 ecommunity_free(&ecom
);
6442 ALIAS (af_rt_vpn_imexport
,
6443 af_no_rt_vpn_imexport_cmd
,
6444 "no <rt|route-target> vpn <import|export|both>$direction_str",
6446 "Specify route target list\n"
6447 "Specify route target list\n"
6448 "Between current address-family and vpn\n"
6449 "For routes leaked from vpn to current address-family\n"
6450 "For routes leaked from current address-family to vpn\n"
6451 "both import and export\n")
6453 DEFPY (af_route_map_vpn_imexport
,
6454 af_route_map_vpn_imexport_cmd
,
6455 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6456 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6458 "Specify route map\n"
6459 "Between current address-family and vpn\n"
6460 "For routes leaked from vpn to current address-family\n"
6461 "For routes leaked from current address-family to vpn\n"
6462 "name of route-map\n")
6464 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6466 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6467 int doafi
[AFI_MAX
] = {0};
6468 vpn_policy_direction_t dir
;
6473 if (argv_find(argv
, argc
, "no", &idx
))
6476 ret
= vpn_policy_getafi(vty
, doafi
);
6477 if (ret
!= CMD_SUCCESS
)
6480 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6481 if (ret
!= CMD_SUCCESS
)
6484 for (afi
= 0; afi
< AFI_MAX
; ++afi
) {
6487 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6491 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6494 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6495 XFREE(MTYPE_ROUTE_MAP_NAME
,
6496 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6497 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6498 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6499 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6500 route_map_lookup_by_name(rmap_str
);
6502 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6503 XFREE(MTYPE_ROUTE_MAP_NAME
,
6504 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6505 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6506 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6509 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6516 ALIAS (af_route_map_vpn_imexport
,
6517 af_no_route_map_vpn_imexport_cmd
,
6518 "no route-map vpn <import|export>$direction_str",
6520 "Specify route map\n"
6521 "Between current address-family and vpn\n"
6522 "For routes leaked from vpn to current address-family\n"
6523 "For routes leaked from current address-family to vpn\n")
6525 /* This command is valid only in a bgp vrf instance or the default instance */
6526 DEFPY (bgp_imexport_vpn
,
6527 bgp_imexport_vpn_cmd
,
6528 "[no] <import|export>$direction_str vpn",
6529 "Export routes to another routing protocol\n"
6530 "to VPN RIB per vpn-policy")
6532 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6539 vpn_policy_direction_t dir
;
6541 if (argv_find(argv
, argc
, "no", &idx
))
6544 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6545 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6547 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6548 return CMD_WARNING_CONFIG_FAILED
;
6551 afi
= bgp_node_afi(vty
);
6552 safi
= bgp_node_safi(vty
);
6553 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6554 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6555 return CMD_WARNING_CONFIG_FAILED
;
6558 if (!strcmp(direction_str
, "import")) {
6559 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6560 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6561 } else if (!strcmp(direction_str
, "export")) {
6562 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6563 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6565 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6566 return CMD_WARNING_CONFIG_FAILED
;
6569 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6572 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6573 if (!previous_state
) {
6574 /* trigger export current vrf */
6575 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6578 if (previous_state
) {
6579 /* trigger un-export current vrf */
6580 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6582 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6588 DEFUN_NOSH (address_family_ipv4_safi
,
6589 address_family_ipv4_safi_cmd
,
6590 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]",
6591 "Enter Address Family command mode\n"
6593 BGP_SAFI_WITH_LABEL_HELP_STR
)
6597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6598 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6599 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6600 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6601 && safi
!= SAFI_EVPN
) {
6603 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6604 return CMD_WARNING_CONFIG_FAILED
;
6606 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6608 vty
->node
= BGP_IPV4_NODE
;
6613 DEFUN_NOSH (address_family_ipv6_safi
,
6614 address_family_ipv6_safi_cmd
,
6615 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]",
6616 "Enter Address Family command mode\n"
6618 BGP_SAFI_WITH_LABEL_HELP_STR
)
6621 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6622 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6623 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6624 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6625 && safi
!= SAFI_EVPN
) {
6627 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6628 return CMD_WARNING_CONFIG_FAILED
;
6630 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6632 vty
->node
= BGP_IPV6_NODE
;
6637 #ifdef KEEP_OLD_VPN_COMMANDS
6638 DEFUN_NOSH (address_family_vpnv4
,
6639 address_family_vpnv4_cmd
,
6640 "address-family vpnv4 [unicast]",
6641 "Enter Address Family command mode\n"
6643 "Address Family modifier\n")
6645 vty
->node
= BGP_VPNV4_NODE
;
6649 DEFUN_NOSH (address_family_vpnv6
,
6650 address_family_vpnv6_cmd
,
6651 "address-family vpnv6 [unicast]",
6652 "Enter Address Family command mode\n"
6654 "Address Family modifier\n")
6656 vty
->node
= BGP_VPNV6_NODE
;
6661 DEFUN_NOSH (address_family_evpn
,
6662 address_family_evpn_cmd
,
6663 "address-family l2vpn evpn",
6664 "Enter Address Family command mode\n"
6666 "Address Family modifier\n")
6668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6669 vty
->node
= BGP_EVPN_NODE
;
6673 DEFUN_NOSH (exit_address_family
,
6674 exit_address_family_cmd
,
6675 "exit-address-family",
6676 "Exit from Address Family configuration mode\n")
6678 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
6679 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
6680 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
6681 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
6682 || vty
->node
== BGP_EVPN_NODE
)
6683 vty
->node
= BGP_NODE
;
6687 /* Recalculate bestpath and re-advertise a prefix */
6688 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
6689 const char *ip_str
, afi_t afi
, safi_t safi
,
6690 struct prefix_rd
*prd
)
6693 struct prefix match
;
6694 struct bgp_node
*rn
;
6695 struct bgp_node
*rm
;
6697 struct bgp_table
*table
;
6698 struct bgp_table
*rib
;
6700 /* BGP structure lookup. */
6702 bgp
= bgp_lookup_by_name(view_name
);
6704 vty_out(vty
, "%% Can't find BGP instance %s\n",
6709 bgp
= bgp_get_default();
6711 vty_out(vty
, "%% No BGP process is configured\n");
6716 /* Check IP address argument. */
6717 ret
= str2prefix(ip_str
, &match
);
6719 vty_out(vty
, "%% address is malformed\n");
6723 match
.family
= afi2family(afi
);
6724 rib
= bgp
->rib
[afi
][safi
];
6726 if (safi
== SAFI_MPLS_VPN
) {
6727 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
6728 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
6731 if ((table
= rn
->info
) != NULL
) {
6732 if ((rm
= bgp_node_match(table
, &match
))
6735 == match
.prefixlen
) {
6737 BGP_NODE_USER_CLEAR
);
6738 bgp_process(bgp
, rm
, afi
, safi
);
6740 bgp_unlock_node(rm
);
6745 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
6746 if (rn
->p
.prefixlen
== match
.prefixlen
) {
6747 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
6748 bgp_process(bgp
, rn
, afi
, safi
);
6750 bgp_unlock_node(rn
);
6757 /* one clear bgp command to rule them all */
6758 DEFUN (clear_ip_bgp_all
,
6759 clear_ip_bgp_all_cmd
,
6760 "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>]",
6764 BGP_INSTANCE_HELP_STR
6766 BGP_SAFI_WITH_LABEL_HELP_STR
6768 "BGP neighbor address to clear\n"
6769 "BGP IPv6 neighbor to clear\n"
6770 "BGP neighbor on interface to clear\n"
6771 "Clear peers with the AS number\n"
6772 "Clear all external peers\n"
6773 "Clear all members of peer-group\n"
6774 "BGP peer-group name\n"
6779 "Push out prefix-list ORF and do inbound soft reconfig\n"
6784 afi_t afi
= AFI_IP6
;
6785 safi_t safi
= SAFI_UNICAST
;
6786 enum clear_sort clr_sort
= clear_peer
;
6787 enum bgp_clear_type clr_type
;
6788 char *clr_arg
= NULL
;
6792 /* clear [ip] bgp */
6793 if (argv_find(argv
, argc
, "ip", &idx
))
6796 /* [<view|vrf> VIEWVRFNAME] */
6797 if (argv_find(argv
, argc
, "view", &idx
)
6798 || argv_find(argv
, argc
, "vrf", &idx
)) {
6799 vrf
= argv
[idx
+ 1]->arg
;
6803 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
6804 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
6805 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
6807 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
6808 if (argv_find(argv
, argc
, "*", &idx
)) {
6809 clr_sort
= clear_all
;
6810 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6811 clr_sort
= clear_peer
;
6812 clr_arg
= argv
[idx
]->arg
;
6813 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
6814 clr_sort
= clear_peer
;
6815 clr_arg
= argv
[idx
]->arg
;
6816 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
6817 clr_sort
= clear_group
;
6819 clr_arg
= argv
[idx
]->arg
;
6820 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
6821 clr_sort
= clear_peer
;
6822 clr_arg
= argv
[idx
]->arg
;
6823 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
6824 clr_sort
= clear_as
;
6825 clr_arg
= argv
[idx
]->arg
;
6826 } else if (argv_find(argv
, argc
, "external", &idx
)) {
6827 clr_sort
= clear_external
;
6830 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
6831 if (argv_find(argv
, argc
, "soft", &idx
)) {
6832 if (argv_find(argv
, argc
, "in", &idx
)
6833 || argv_find(argv
, argc
, "out", &idx
))
6834 clr_type
= strmatch(argv
[idx
]->text
, "in")
6836 : BGP_CLEAR_SOFT_OUT
;
6838 clr_type
= BGP_CLEAR_SOFT_BOTH
;
6839 } else if (argv_find(argv
, argc
, "in", &idx
)) {
6840 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
6841 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
6842 : BGP_CLEAR_SOFT_IN
;
6843 } else if (argv_find(argv
, argc
, "out", &idx
)) {
6844 clr_type
= BGP_CLEAR_SOFT_OUT
;
6846 clr_type
= BGP_CLEAR_SOFT_NONE
;
6848 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
6851 DEFUN (clear_ip_bgp_prefix
,
6852 clear_ip_bgp_prefix_cmd
,
6853 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
6857 BGP_INSTANCE_HELP_STR
6858 "Clear bestpath and re-advertise\n"
6862 char *prefix
= NULL
;
6866 /* [<view|vrf> VIEWVRFNAME] */
6867 if (argv_find(argv
, argc
, "VIEWVRFNAME", &idx
))
6868 vrf
= argv
[idx
]->arg
;
6870 prefix
= argv
[argc
- 1]->arg
;
6872 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
6875 DEFUN (clear_bgp_ipv6_safi_prefix
,
6876 clear_bgp_ipv6_safi_prefix_cmd
,
6877 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
6883 "Clear bestpath and re-advertise\n"
6887 int idx_ipv6_prefix
= 0;
6888 safi_t safi
= SAFI_UNICAST
;
6889 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
6890 argv
[idx_ipv6_prefix
]->arg
: NULL
;
6892 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
6893 return bgp_clear_prefix(
6894 vty
, NULL
, prefix
, AFI_IP6
,
6898 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
6899 clear_bgp_instance_ipv6_safi_prefix_cmd
,
6900 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
6904 BGP_INSTANCE_HELP_STR
6907 "Clear bestpath and re-advertise\n"
6912 int idx_ipv6_prefix
= 0;
6913 safi_t safi
= SAFI_UNICAST
;
6914 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
6915 argv
[idx_ipv6_prefix
]->arg
: NULL
;
6916 /* [<view|vrf> VIEWVRFNAME] */
6917 char *vrfview
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx_word
) ?
6918 argv
[idx_word
]->arg
: NULL
;
6920 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
6922 return bgp_clear_prefix(
6923 vty
, vrfview
, prefix
,
6924 AFI_IP6
, safi
, NULL
);
6927 DEFUN (show_bgp_views
,
6929 "show [ip] bgp views",
6933 "Show the defined BGP views\n")
6935 struct list
*inst
= bm
->bgp
;
6936 struct listnode
*node
;
6939 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
6940 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
6944 vty_out(vty
, "Defined BGP views:\n");
6945 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
6947 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
6949 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
6956 DEFUN (show_bgp_vrfs
,
6958 "show [ip] bgp vrfs [json]",
6965 char buf
[ETHER_ADDR_STRLEN
];
6966 struct list
*inst
= bm
->bgp
;
6967 struct listnode
*node
;
6969 u_char uj
= use_json(argc
, argv
);
6970 json_object
*json
= NULL
;
6971 json_object
*json_vrfs
= NULL
;
6974 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
6975 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
6980 json
= json_object_new_object();
6981 json_vrfs
= json_object_new_object();
6984 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
6985 const char *name
, *type
;
6987 struct listnode
*node
, *nnode
;
6988 int peers_cfg
, peers_estb
;
6989 json_object
*json_vrf
= NULL
;
6992 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
6996 if (!uj
&& count
== 1)
6998 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
6999 "Type", "Id", "routerId", "#PeersVfg",
7000 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7002 peers_cfg
= peers_estb
= 0;
7004 json_vrf
= json_object_new_object();
7007 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7008 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7011 if (peer
->status
== Established
)
7015 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7025 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7027 : (int64_t)bgp
->vrf_id
;
7028 json_object_string_add(json_vrf
, "type", type
);
7029 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7030 json_object_string_add(json_vrf
, "routerId",
7031 inet_ntoa(bgp
->router_id
));
7032 json_object_int_add(json_vrf
, "numConfiguredPeers",
7034 json_object_int_add(json_vrf
, "numEstablishedPeers",
7037 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7038 json_object_string_add(
7040 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7041 json_object_object_add(json_vrfs
, name
, json_vrf
);
7044 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7046 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7048 inet_ntoa(bgp
->router_id
), peers_cfg
,
7049 peers_estb
, name
, bgp
->l3vni
,
7050 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7054 json_object_object_add(json
, "vrfs", json_vrfs
);
7056 json_object_int_add(json
, "totalVrfs", count
);
7058 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7059 json
, JSON_C_TO_STRING_PRETTY
));
7060 json_object_free(json
);
7064 "\nTotal number of VRFs (including default): %d\n",
7071 static void show_address_entry(struct hash_backet
*backet
, void *args
)
7073 struct vty
*vty
= (struct vty
*)args
;
7074 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
7076 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
7080 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7082 struct vty
*vty
= (struct vty
*)args
;
7083 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7085 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7089 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7091 vty_out(vty
, "self nexthop database:\n");
7092 hash_iterate(bgp
->address_hash
,
7093 (void (*)(struct hash_backet
*, void *))show_address_entry
,
7096 vty_out(vty
, "Tunnel-ip database:\n");
7097 hash_iterate(bgp
->tip_hash
,
7098 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7102 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7103 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7104 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7105 "martian next-hops\n"
7106 "martian next-hop database\n")
7108 struct bgp
*bgp
= NULL
;
7111 if (argv_find(argv
, argc
, "view", &idx
)
7112 || argv_find(argv
, argc
, "vrf", &idx
))
7113 bgp
= bgp_lookup_by_name(argv
[idx
+ 1]->arg
);
7115 bgp
= bgp_get_default();
7118 vty_out(vty
, "%% No BGP process is configured\n");
7121 bgp_show_martian_nexthops(vty
, bgp
);
7126 DEFUN (show_bgp_memory
,
7127 show_bgp_memory_cmd
,
7128 "show [ip] bgp memory",
7132 "Global BGP memory statistics\n")
7134 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7135 unsigned long count
;
7137 /* RIB related usage stats */
7138 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7139 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7140 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7141 count
* sizeof(struct bgp_node
)));
7143 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7144 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7145 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7146 count
* sizeof(struct bgp_info
)));
7147 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7148 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7150 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7151 count
* sizeof(struct bgp_info_extra
)));
7153 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7154 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7155 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7156 count
* sizeof(struct bgp_static
)));
7158 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7159 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7160 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7161 count
* sizeof(struct bpacket
)));
7164 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7165 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7166 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7167 count
* sizeof(struct bgp_adj_in
)));
7168 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7169 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7170 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7171 count
* sizeof(struct bgp_adj_out
)));
7173 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7174 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7176 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7177 count
* sizeof(struct bgp_nexthop_cache
)));
7179 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7180 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7182 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7183 count
* sizeof(struct bgp_damp_info
)));
7186 count
= attr_count();
7187 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7188 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7189 count
* sizeof(struct attr
)));
7191 if ((count
= attr_unknown_count()))
7192 vty_out(vty
, "%ld unknown attributes\n", count
);
7194 /* AS_PATH attributes */
7195 count
= aspath_count();
7196 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7197 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7198 count
* sizeof(struct aspath
)));
7200 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7201 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7202 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7203 count
* sizeof(struct assegment
)));
7205 /* Other attributes */
7206 if ((count
= community_count()))
7207 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7208 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7209 count
* sizeof(struct community
)));
7210 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7211 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7212 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7213 count
* sizeof(struct ecommunity
)));
7214 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7216 "%ld BGP large-community entries, using %s of memory\n",
7217 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7218 count
* sizeof(struct lcommunity
)));
7220 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7221 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7222 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7223 count
* sizeof(struct cluster_list
)));
7225 /* Peer related usage */
7226 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7227 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7228 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7229 count
* sizeof(struct peer
)));
7231 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7232 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7233 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7234 count
* sizeof(struct peer_group
)));
7237 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7238 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7239 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7240 count
* sizeof(struct hash
)));
7241 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7242 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7243 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7244 count
* sizeof(struct hash_backet
)));
7245 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7246 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7247 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7248 count
* sizeof(regex_t
)));
7252 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7254 json_object
*bestpath
= json_object_new_object();
7256 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7257 json_object_string_add(bestpath
, "asPath", "ignore");
7259 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7260 json_object_string_add(bestpath
, "asPath", "confed");
7262 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7263 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7264 json_object_string_add(bestpath
, "multiPathRelax",
7267 json_object_string_add(bestpath
, "multiPathRelax",
7270 json_object_string_add(bestpath
, "multiPathRelax", "false");
7272 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7273 json_object_string_add(bestpath
, "compareRouterId", "true");
7274 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7275 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7276 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7277 json_object_string_add(bestpath
, "med", "confed");
7278 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7279 json_object_string_add(bestpath
, "med",
7280 "missing-as-worst");
7282 json_object_string_add(bestpath
, "med", "true");
7285 json_object_object_add(json
, "bestPath", bestpath
);
7288 /* Show BGP peer's summary information. */
7289 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7290 u_char use_json
, json_object
*json
)
7293 struct listnode
*node
, *nnode
;
7294 unsigned int count
= 0, dn_count
= 0;
7295 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7296 char neighbor_buf
[VTY_BUFSIZ
];
7297 int neighbor_col_default_width
= 16;
7299 int max_neighbor_width
= 0;
7301 json_object
*json_peer
= NULL
;
7302 json_object
*json_peers
= NULL
;
7304 /* labeled-unicast routes are installed in the unicast table so in order
7306 * display the correct PfxRcd value we must look at SAFI_UNICAST
7308 if (safi
== SAFI_LABELED_UNICAST
)
7309 pfx_rcd_safi
= SAFI_UNICAST
;
7311 pfx_rcd_safi
= safi
;
7315 json
= json_object_new_object();
7317 json_peers
= json_object_new_object();
7319 /* Loop over all neighbors that will be displayed to determine
7321 * characters are needed for the Neighbor column
7323 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7324 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7327 if (peer
->afc
[afi
][safi
]) {
7328 memset(dn_flag
, '\0', sizeof(dn_flag
));
7329 if (peer_dynamic_neighbor(peer
))
7333 && bgp_flag_check(bgp
,
7334 BGP_FLAG_SHOW_HOSTNAME
))
7335 sprintf(neighbor_buf
, "%s%s(%s) ",
7336 dn_flag
, peer
->hostname
,
7339 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7342 len
= strlen(neighbor_buf
);
7344 if (len
> max_neighbor_width
)
7345 max_neighbor_width
= len
;
7349 /* Originally we displayed the Neighbor column as 16
7350 * characters wide so make that the default
7352 if (max_neighbor_width
< neighbor_col_default_width
)
7353 max_neighbor_width
= neighbor_col_default_width
;
7356 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7357 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7360 if (!peer
->afc
[afi
][safi
])
7365 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7368 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7370 : (int64_t)bgp
->vrf_id
;
7372 /* Usage summary and header */
7374 json_object_string_add(
7376 inet_ntoa(bgp
->router_id
));
7377 json_object_int_add(json
, "as", bgp
->as
);
7378 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7379 json_object_string_add(
7382 == BGP_INSTANCE_TYPE_DEFAULT
)
7387 "BGP router identifier %s, local AS number %u vrf-id %d",
7388 inet_ntoa(bgp
->router_id
), bgp
->as
,
7389 bgp
->vrf_id
== VRF_UNKNOWN
7391 : (int)bgp
->vrf_id
);
7395 if (bgp_update_delay_configured(bgp
)) {
7397 json_object_int_add(
7398 json
, "updateDelayLimit",
7399 bgp
->v_update_delay
);
7401 if (bgp
->v_update_delay
7402 != bgp
->v_establish_wait
)
7403 json_object_int_add(
7405 "updateDelayEstablishWait",
7406 bgp
->v_establish_wait
);
7408 if (bgp_update_delay_active(bgp
)) {
7409 json_object_string_add(
7411 "updateDelayFirstNeighbor",
7412 bgp
->update_delay_begin_time
);
7413 json_object_boolean_true_add(
7415 "updateDelayInProgress");
7417 if (bgp
->update_delay_over
) {
7418 json_object_string_add(
7420 "updateDelayFirstNeighbor",
7421 bgp
->update_delay_begin_time
);
7422 json_object_string_add(
7424 "updateDelayBestpathResumed",
7425 bgp
->update_delay_end_time
);
7426 json_object_string_add(
7428 "updateDelayZebraUpdateResume",
7429 bgp
->update_delay_zebra_resume_time
);
7430 json_object_string_add(
7432 "updateDelayPeerUpdateResume",
7433 bgp
->update_delay_peers_resume_time
);
7438 "Read-only mode update-delay limit: %d seconds\n",
7439 bgp
->v_update_delay
);
7440 if (bgp
->v_update_delay
7441 != bgp
->v_establish_wait
)
7443 " Establish wait: %d seconds\n",
7444 bgp
->v_establish_wait
);
7446 if (bgp_update_delay_active(bgp
)) {
7448 " First neighbor established: %s\n",
7449 bgp
->update_delay_begin_time
);
7451 " Delay in progress\n");
7453 if (bgp
->update_delay_over
) {
7455 " First neighbor established: %s\n",
7456 bgp
->update_delay_begin_time
);
7458 " Best-paths resumed: %s\n",
7459 bgp
->update_delay_end_time
);
7461 " zebra update resumed: %s\n",
7462 bgp
->update_delay_zebra_resume_time
);
7464 " peers update resumed: %s\n",
7465 bgp
->update_delay_peers_resume_time
);
7472 if (bgp_maxmed_onstartup_configured(bgp
)
7473 && bgp
->maxmed_active
)
7474 json_object_boolean_true_add(
7475 json
, "maxMedOnStartup");
7476 if (bgp
->v_maxmed_admin
)
7477 json_object_boolean_true_add(
7478 json
, "maxMedAdministrative");
7480 json_object_int_add(
7481 json
, "tableVersion",
7482 bgp_table_version(bgp
->rib
[afi
][safi
]));
7484 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7485 json_object_int_add(json
, "ribCount", ents
);
7486 json_object_int_add(
7488 ents
* sizeof(struct bgp_node
));
7490 ents
= listcount(bgp
->peer
);
7491 json_object_int_add(json
, "peerCount", ents
);
7492 json_object_int_add(json
, "peerMemory",
7493 ents
* sizeof(struct peer
));
7495 if ((ents
= listcount(bgp
->group
))) {
7496 json_object_int_add(
7497 json
, "peerGroupCount", ents
);
7498 json_object_int_add(
7499 json
, "peerGroupMemory",
7500 ents
* sizeof(struct
7504 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7505 BGP_CONFIG_DAMPENING
))
7506 json_object_boolean_true_add(
7507 json
, "dampeningEnabled");
7509 if (bgp_maxmed_onstartup_configured(bgp
)
7510 && bgp
->maxmed_active
)
7512 "Max-med on-startup active\n");
7513 if (bgp
->v_maxmed_admin
)
7515 "Max-med administrative active\n");
7517 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7518 bgp_table_version(bgp
->rib
[afi
][safi
]));
7520 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7522 "RIB entries %ld, using %s of memory\n",
7524 mtype_memstr(memstrbuf
,
7526 ents
* sizeof(struct
7529 /* Peer related usage */
7530 ents
= listcount(bgp
->peer
);
7531 vty_out(vty
, "Peers %ld, using %s of memory\n",
7534 memstrbuf
, sizeof(memstrbuf
),
7535 ents
* sizeof(struct peer
)));
7537 if ((ents
= listcount(bgp
->group
)))
7539 "Peer groups %ld, using %s of memory\n",
7544 ents
* sizeof(struct
7547 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7548 BGP_CONFIG_DAMPENING
))
7549 vty_out(vty
, "Dampening enabled.\n");
7552 /* Subtract 8 here because 'Neighbor' is
7554 vty_out(vty
, "Neighbor");
7555 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7558 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7565 json_peer
= json_object_new_object();
7567 if (peer_dynamic_neighbor(peer
))
7568 json_object_boolean_true_add(json_peer
,
7572 json_object_string_add(json_peer
, "hostname",
7575 if (peer
->domainname
)
7576 json_object_string_add(json_peer
, "domainname",
7579 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7580 json_object_int_add(json_peer
, "version", 4);
7581 json_object_int_add(json_peer
, "msgRcvd",
7582 PEER_TOTAL_RX(peer
));
7583 json_object_int_add(json_peer
, "msgSent",
7584 PEER_TOTAL_TX(peer
));
7586 json_object_int_add(json_peer
, "tableVersion",
7587 peer
->version
[afi
][safi
]);
7588 json_object_int_add(json_peer
, "outq",
7590 json_object_int_add(json_peer
, "inq", 0);
7591 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7592 use_json
, json_peer
);
7593 json_object_int_add(json_peer
, "prefixReceivedCount",
7594 peer
->pcount
[afi
][pfx_rcd_safi
]);
7596 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7597 json_object_string_add(json_peer
, "state",
7599 else if (CHECK_FLAG(peer
->sflags
,
7600 PEER_STATUS_PREFIX_OVERFLOW
))
7601 json_object_string_add(json_peer
, "state",
7604 json_object_string_add(
7606 lookup_msg(bgp_status_msg
, peer
->status
,
7610 json_object_string_add(json_peer
, "idType",
7612 else if (peer
->su
.sa
.sa_family
== AF_INET
)
7613 json_object_string_add(json_peer
, "idType",
7615 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
7616 json_object_string_add(json_peer
, "idType",
7619 json_object_object_add(json_peers
, peer
->host
,
7622 memset(dn_flag
, '\0', sizeof(dn_flag
));
7623 if (peer_dynamic_neighbor(peer
)) {
7629 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7630 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7631 peer
->hostname
, peer
->host
);
7633 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7635 /* pad the neighbor column with spaces */
7636 if (len
< max_neighbor_width
)
7637 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7640 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
7641 peer
->as
, PEER_TOTAL_RX(peer
),
7642 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
7643 0, peer
->obuf
->count
,
7644 peer_uptime(peer
->uptime
, timebuf
,
7645 BGP_UPTIME_LEN
, 0, NULL
));
7647 if (peer
->status
== Established
)
7648 if (peer
->afc_recv
[afi
][pfx_rcd_safi
])
7649 vty_out(vty
, " %12ld",
7653 vty_out(vty
, " NoNeg");
7655 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7656 vty_out(vty
, " Idle (Admin)");
7657 else if (CHECK_FLAG(
7659 PEER_STATUS_PREFIX_OVERFLOW
))
7660 vty_out(vty
, " Idle (PfxCt)");
7662 vty_out(vty
, " %12s",
7663 lookup_msg(bgp_status_msg
,
7664 peer
->status
, NULL
));
7671 json_object_object_add(json
, "peers", json_peers
);
7673 json_object_int_add(json
, "totalPeers", count
);
7674 json_object_int_add(json
, "dynamicPeers", dn_count
);
7676 bgp_show_bestpath_json(bgp
, json
);
7678 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7679 json
, JSON_C_TO_STRING_PRETTY
));
7680 json_object_free(json
);
7683 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
7687 "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n",
7688 afi_safi_print(afi
, safi
));
7690 vty_out(vty
, "No %s neighbor is configured\n",
7691 afi_safi_print(afi
, safi
));
7694 if (dn_count
&& !use_json
) {
7695 vty_out(vty
, "* - dynamic neighbor\n");
7696 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
7697 dn_count
, bgp
->dynamic_neighbors_limit
);
7704 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
7705 int safi
, u_char use_json
,
7709 int afi_wildcard
= (afi
== AFI_MAX
);
7710 int safi_wildcard
= (safi
== SAFI_MAX
);
7711 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
7712 bool json_output
= false;
7714 if (use_json
&& is_wildcard
)
7715 vty_out(vty
, "{\n");
7717 afi
= 1; /* AFI_IP */
7718 while (afi
< AFI_MAX
) {
7720 safi
= 1; /* SAFI_UNICAST */
7721 while (safi
< SAFI_MAX
) {
7722 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
7726 * So limit output to those afi/safi
7728 * actualy have something interesting in
7732 json
= json_object_new_object();
7735 vty_out(vty
, ",\n");
7739 vty_out(vty
, "\"%s\":",
7743 vty_out(vty
, "\n%s Summary:\n",
7748 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
7760 if (use_json
&& is_wildcard
)
7761 vty_out(vty
, "}\n");
7762 else if (use_json
&& !json_output
)
7763 vty_out(vty
, "{}\n");
7766 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
7767 safi_t safi
, u_char use_json
)
7769 struct listnode
*node
, *nnode
;
7771 json_object
*json
= NULL
;
7775 vty_out(vty
, "{\n");
7777 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
7779 json
= json_object_new_object();
7782 vty_out(vty
, ",\n");
7786 vty_out(vty
, "\"%s\":",
7787 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7791 vty_out(vty
, "\nInstance %s:\n",
7792 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7796 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
7800 vty_out(vty
, "}\n");
7803 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
7804 safi_t safi
, u_char use_json
)
7809 if (strmatch(name
, "all")) {
7810 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
7814 bgp
= bgp_lookup_by_name(name
);
7818 vty_out(vty
, "{}\n");
7821 "%% No such BGP instance exist\n");
7825 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
7831 bgp
= bgp_get_default();
7834 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
7839 /* `show [ip] bgp summary' commands. */
7840 DEFUN (show_ip_bgp_summary
,
7841 show_ip_bgp_summary_cmd
,
7842 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
7846 BGP_INSTANCE_HELP_STR
7848 BGP_SAFI_WITH_LABEL_HELP_STR
7849 "Summary of BGP neighbor status\n"
7853 afi_t afi
= AFI_MAX
;
7854 safi_t safi
= SAFI_MAX
;
7859 if (argv_find(argv
, argc
, "ip", &idx
))
7861 /* [<view|vrf> VIEWVRFNAME] */
7862 if (argv_find(argv
, argc
, "view", &idx
)
7863 || argv_find(argv
, argc
, "vrf", &idx
))
7864 vrf
= argv
[++idx
]->arg
;
7865 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7866 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
7867 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7870 int uj
= use_json(argc
, argv
);
7872 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
7875 const char *afi_safi_print(afi_t afi
, safi_t safi
)
7877 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
7878 return "IPv4 Unicast";
7879 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
7880 return "IPv4 Multicast";
7881 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
7882 return "IPv4 Labeled Unicast";
7883 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7885 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
7886 return "IPv4 Encap";
7887 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
7888 return "IPv6 Unicast";
7889 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
7890 return "IPv6 Multicast";
7891 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
7892 return "IPv6 Labeled Unicast";
7893 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
7895 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
7896 return "IPv6 Encap";
7897 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
7898 return "L2VPN EVPN";
7904 * Please note that we have intentionally camelCased
7905 * the return strings here. So if you want
7906 * to use this function, please ensure you
7907 * are doing this within json output
7909 const char *afi_safi_json(afi_t afi
, safi_t safi
)
7911 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
7912 return "ipv4Unicast";
7913 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
7914 return "ipv4Multicast";
7915 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
7916 return "ipv4LabeledUnicast";
7917 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7919 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
7921 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
7922 return "ipv6Unicast";
7923 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
7924 return "ipv6Multicast";
7925 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
7926 return "ipv6LabeledUnicast";
7927 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
7929 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
7931 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
7937 /* Show BGP peer's information. */
7938 enum show_type
{ show_all
, show_peer
};
7940 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
7941 afi_t afi
, safi_t safi
,
7942 u_int16_t adv_smcap
, u_int16_t adv_rmcap
,
7943 u_int16_t rcv_smcap
, u_int16_t rcv_rmcap
,
7944 u_char use_json
, json_object
*json_pref
)
7947 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
7948 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
7950 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
7951 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7952 json_object_string_add(json_pref
, "sendMode",
7953 "advertisedAndReceived");
7954 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
7955 json_object_string_add(json_pref
, "sendMode",
7957 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7958 json_object_string_add(json_pref
, "sendMode",
7961 vty_out(vty
, " Send-mode: ");
7962 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
7963 vty_out(vty
, "advertised");
7964 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7965 vty_out(vty
, "%sreceived",
7966 CHECK_FLAG(p
->af_cap
[afi
][safi
],
7975 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
7976 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
7978 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
7979 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7980 json_object_string_add(json_pref
, "recvMode",
7981 "advertisedAndReceived");
7982 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
7983 json_object_string_add(json_pref
, "recvMode",
7985 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7986 json_object_string_add(json_pref
, "recvMode",
7989 vty_out(vty
, " Receive-mode: ");
7990 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
7991 vty_out(vty
, "advertised");
7992 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7993 vty_out(vty
, "%sreceived",
7994 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8003 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8004 safi_t safi
, u_char use_json
,
8005 json_object
*json_neigh
)
8007 struct bgp_filter
*filter
;
8008 struct peer_af
*paf
;
8009 char orf_pfx_name
[BUFSIZ
];
8011 json_object
*json_af
= NULL
;
8012 json_object
*json_prefA
= NULL
;
8013 json_object
*json_prefB
= NULL
;
8014 json_object
*json_addr
= NULL
;
8017 json_addr
= json_object_new_object();
8018 json_af
= json_object_new_object();
8019 filter
= &p
->filter
[afi
][safi
];
8021 if (peer_group_active(p
))
8022 json_object_string_add(json_addr
, "peerGroupMember",
8025 paf
= peer_af_find(p
, afi
, safi
);
8026 if (paf
&& PAF_SUBGRP(paf
)) {
8027 json_object_int_add(json_addr
, "updateGroupId",
8028 PAF_UPDGRP(paf
)->id
);
8029 json_object_int_add(json_addr
, "subGroupId",
8030 PAF_SUBGRP(paf
)->id
);
8031 json_object_int_add(json_addr
, "packetQueueLength",
8032 bpacket_queue_virtual_length(paf
));
8035 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8036 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8037 PEER_CAP_ORF_PREFIX_SM_RCV
)
8038 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8039 PEER_CAP_ORF_PREFIX_RM_ADV
)
8040 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8041 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8042 json_object_int_add(json_af
, "orfType",
8044 json_prefA
= json_object_new_object();
8045 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8046 PEER_CAP_ORF_PREFIX_SM_ADV
,
8047 PEER_CAP_ORF_PREFIX_RM_ADV
,
8048 PEER_CAP_ORF_PREFIX_SM_RCV
,
8049 PEER_CAP_ORF_PREFIX_RM_RCV
,
8050 use_json
, json_prefA
);
8051 json_object_object_add(json_af
, "orfPrefixList",
8055 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8056 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8057 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8058 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8059 PEER_CAP_ORF_PREFIX_RM_ADV
)
8060 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8061 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8062 json_object_int_add(json_af
, "orfOldType",
8063 ORF_TYPE_PREFIX_OLD
);
8064 json_prefB
= json_object_new_object();
8065 bgp_show_peer_afi_orf_cap(
8066 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8067 PEER_CAP_ORF_PREFIX_RM_ADV
,
8068 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8069 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8071 json_object_object_add(json_af
, "orfOldPrefixList",
8075 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8076 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8077 PEER_CAP_ORF_PREFIX_SM_RCV
)
8078 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8079 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8080 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8081 PEER_CAP_ORF_PREFIX_RM_ADV
)
8082 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8083 PEER_CAP_ORF_PREFIX_RM_RCV
)
8084 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8085 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8086 json_object_object_add(json_addr
, "afDependentCap",
8089 json_object_free(json_af
);
8091 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8092 orf_pfx_count
= prefix_bgp_show_prefix_list(
8093 NULL
, afi
, orf_pfx_name
, use_json
);
8095 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8096 PEER_STATUS_ORF_PREFIX_SEND
)
8098 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8099 PEER_STATUS_ORF_PREFIX_SEND
))
8100 json_object_boolean_true_add(json_neigh
,
8103 json_object_int_add(json_addr
, "orfRecvCounter",
8106 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8107 PEER_STATUS_ORF_WAIT_REFRESH
))
8108 json_object_string_add(
8109 json_addr
, "orfFirstUpdate",
8110 "deferredUntilORFOrRouteRefreshRecvd");
8112 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8113 PEER_FLAG_REFLECTOR_CLIENT
))
8114 json_object_boolean_true_add(json_addr
,
8115 "routeReflectorClient");
8116 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8117 PEER_FLAG_RSERVER_CLIENT
))
8118 json_object_boolean_true_add(json_addr
,
8119 "routeServerClient");
8120 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8121 json_object_boolean_true_add(json_addr
,
8122 "inboundSoftConfigPermit");
8124 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8125 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8126 json_object_boolean_true_add(
8128 "privateAsNumsAllReplacedInUpdatesToNbr");
8129 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8130 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8131 json_object_boolean_true_add(
8133 "privateAsNumsReplacedInUpdatesToNbr");
8134 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8135 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8136 json_object_boolean_true_add(
8138 "privateAsNumsAllRemovedInUpdatesToNbr");
8139 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8140 PEER_FLAG_REMOVE_PRIVATE_AS
))
8141 json_object_boolean_true_add(
8143 "privateAsNumsRemovedInUpdatesToNbr");
8145 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8146 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8147 json_object_boolean_true_add(json_addr
,
8148 "addpathTxAllPaths");
8150 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8151 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8152 json_object_boolean_true_add(json_addr
,
8153 "addpathTxBestpathPerAS");
8155 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8156 json_object_string_add(json_addr
,
8157 "overrideASNsInOutboundUpdates",
8158 "ifAspathEqualRemoteAs");
8160 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8161 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8162 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8163 json_object_boolean_true_add(json_addr
,
8164 "routerAlwaysNextHop");
8165 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8166 PEER_FLAG_AS_PATH_UNCHANGED
))
8167 json_object_boolean_true_add(
8168 json_addr
, "unchangedAsPathPropogatedToNbr");
8169 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8170 PEER_FLAG_NEXTHOP_UNCHANGED
))
8171 json_object_boolean_true_add(
8172 json_addr
, "unchangedNextHopPropogatedToNbr");
8173 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8174 json_object_boolean_true_add(
8175 json_addr
, "unchangedMedPropogatedToNbr");
8176 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8177 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8178 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8179 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8180 PEER_FLAG_SEND_COMMUNITY
)
8181 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8182 PEER_FLAG_SEND_EXT_COMMUNITY
))
8183 json_object_string_add(json_addr
,
8184 "commAttriSentToNbr",
8185 "extendedAndStandard");
8186 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8187 PEER_FLAG_SEND_EXT_COMMUNITY
))
8188 json_object_string_add(json_addr
,
8189 "commAttriSentToNbr",
8192 json_object_string_add(json_addr
,
8193 "commAttriSentToNbr",
8196 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8197 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8198 if (p
->default_rmap
[afi
][safi
].name
)
8199 json_object_string_add(
8200 json_addr
, "defaultRouteMap",
8201 p
->default_rmap
[afi
][safi
].name
);
8203 if (paf
&& PAF_SUBGRP(paf
)
8204 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8205 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8206 json_object_boolean_true_add(json_addr
,
8209 json_object_boolean_true_add(json_addr
,
8213 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8214 if (is_evpn_enabled())
8215 json_object_boolean_true_add(
8216 json_addr
, "advertiseAllVnis");
8219 if (filter
->plist
[FILTER_IN
].name
8220 || filter
->dlist
[FILTER_IN
].name
8221 || filter
->aslist
[FILTER_IN
].name
8222 || filter
->map
[RMAP_IN
].name
)
8223 json_object_boolean_true_add(json_addr
,
8224 "inboundPathPolicyConfig");
8225 if (filter
->plist
[FILTER_OUT
].name
8226 || filter
->dlist
[FILTER_OUT
].name
8227 || filter
->aslist
[FILTER_OUT
].name
8228 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8229 json_object_boolean_true_add(
8230 json_addr
, "outboundPathPolicyConfig");
8233 if (filter
->plist
[FILTER_IN
].name
)
8234 json_object_string_add(json_addr
,
8235 "incomingUpdatePrefixFilterList",
8236 filter
->plist
[FILTER_IN
].name
);
8237 if (filter
->plist
[FILTER_OUT
].name
)
8238 json_object_string_add(json_addr
,
8239 "outgoingUpdatePrefixFilterList",
8240 filter
->plist
[FILTER_OUT
].name
);
8242 /* distribute-list */
8243 if (filter
->dlist
[FILTER_IN
].name
)
8244 json_object_string_add(
8245 json_addr
, "incomingUpdateNetworkFilterList",
8246 filter
->dlist
[FILTER_IN
].name
);
8247 if (filter
->dlist
[FILTER_OUT
].name
)
8248 json_object_string_add(
8249 json_addr
, "outgoingUpdateNetworkFilterList",
8250 filter
->dlist
[FILTER_OUT
].name
);
8253 if (filter
->aslist
[FILTER_IN
].name
)
8254 json_object_string_add(json_addr
,
8255 "incomingUpdateAsPathFilterList",
8256 filter
->aslist
[FILTER_IN
].name
);
8257 if (filter
->aslist
[FILTER_OUT
].name
)
8258 json_object_string_add(json_addr
,
8259 "outgoingUpdateAsPathFilterList",
8260 filter
->aslist
[FILTER_OUT
].name
);
8263 if (filter
->map
[RMAP_IN
].name
)
8264 json_object_string_add(
8265 json_addr
, "routeMapForIncomingAdvertisements",
8266 filter
->map
[RMAP_IN
].name
);
8267 if (filter
->map
[RMAP_OUT
].name
)
8268 json_object_string_add(
8269 json_addr
, "routeMapForOutgoingAdvertisements",
8270 filter
->map
[RMAP_OUT
].name
);
8272 /* unsuppress-map */
8273 if (filter
->usmap
.name
)
8274 json_object_string_add(json_addr
,
8275 "selectiveUnsuppressRouteMap",
8276 filter
->usmap
.name
);
8278 /* Receive prefix count */
8279 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8280 p
->pcount
[afi
][safi
]);
8282 /* Maximum prefix */
8283 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8284 json_object_int_add(json_addr
, "prefixAllowedMax",
8285 p
->pmax
[afi
][safi
]);
8286 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8287 PEER_FLAG_MAX_PREFIX_WARNING
))
8288 json_object_boolean_true_add(
8289 json_addr
, "prefixAllowedMaxWarning");
8290 json_object_int_add(json_addr
,
8291 "prefixAllowedWarningThresh",
8292 p
->pmax_threshold
[afi
][safi
]);
8293 if (p
->pmax_restart
[afi
][safi
])
8294 json_object_int_add(
8296 "prefixAllowedRestartIntervalMsecs",
8297 p
->pmax_restart
[afi
][safi
] * 60000);
8299 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8303 filter
= &p
->filter
[afi
][safi
];
8305 vty_out(vty
, " For address family: %s\n",
8306 afi_safi_print(afi
, safi
));
8308 if (peer_group_active(p
))
8309 vty_out(vty
, " %s peer-group member\n",
8312 paf
= peer_af_find(p
, afi
, safi
);
8313 if (paf
&& PAF_SUBGRP(paf
)) {
8314 vty_out(vty
, " Update group %" PRIu64
8315 ", subgroup %" PRIu64
"\n",
8316 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8317 vty_out(vty
, " Packet Queue length %d\n",
8318 bpacket_queue_virtual_length(paf
));
8320 vty_out(vty
, " Not part of any update group\n");
8322 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8323 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8324 PEER_CAP_ORF_PREFIX_SM_RCV
)
8325 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8326 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8327 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8328 PEER_CAP_ORF_PREFIX_RM_ADV
)
8329 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8330 PEER_CAP_ORF_PREFIX_RM_RCV
)
8331 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8332 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8333 vty_out(vty
, " AF-dependant capabilities:\n");
8335 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8336 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8337 PEER_CAP_ORF_PREFIX_SM_RCV
)
8338 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8339 PEER_CAP_ORF_PREFIX_RM_ADV
)
8340 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8341 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8343 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8345 bgp_show_peer_afi_orf_cap(
8346 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8347 PEER_CAP_ORF_PREFIX_RM_ADV
,
8348 PEER_CAP_ORF_PREFIX_SM_RCV
,
8349 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8351 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8352 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8353 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8354 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8355 PEER_CAP_ORF_PREFIX_RM_ADV
)
8356 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8357 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8359 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8360 ORF_TYPE_PREFIX_OLD
);
8361 bgp_show_peer_afi_orf_cap(
8362 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8363 PEER_CAP_ORF_PREFIX_RM_ADV
,
8364 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8365 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8368 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8369 orf_pfx_count
= prefix_bgp_show_prefix_list(
8370 NULL
, afi
, orf_pfx_name
, use_json
);
8372 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8373 PEER_STATUS_ORF_PREFIX_SEND
)
8375 vty_out(vty
, " Outbound Route Filter (ORF):");
8376 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8377 PEER_STATUS_ORF_PREFIX_SEND
))
8378 vty_out(vty
, " sent;");
8380 vty_out(vty
, " received (%d entries)",
8384 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8385 PEER_STATUS_ORF_WAIT_REFRESH
))
8387 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8389 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8390 PEER_FLAG_REFLECTOR_CLIENT
))
8391 vty_out(vty
, " Route-Reflector Client\n");
8392 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8393 PEER_FLAG_RSERVER_CLIENT
))
8394 vty_out(vty
, " Route-Server Client\n");
8395 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8397 " Inbound soft reconfiguration allowed\n");
8399 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8400 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8402 " Private AS numbers (all) replaced in updates to this neighbor\n");
8403 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8404 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8406 " Private AS numbers replaced in updates to this neighbor\n");
8407 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8408 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8410 " Private AS numbers (all) removed in updates to this neighbor\n");
8411 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8412 PEER_FLAG_REMOVE_PRIVATE_AS
))
8414 " Private AS numbers removed in updates to this neighbor\n");
8416 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8417 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8418 vty_out(vty
, " Advertise all paths via addpath\n");
8420 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8421 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8423 " Advertise bestpath per AS via addpath\n");
8425 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8427 " Override ASNs in outbound updates if aspath equals remote-as\n");
8429 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8430 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8431 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8432 vty_out(vty
, " NEXT_HOP is always this router\n");
8433 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8434 PEER_FLAG_AS_PATH_UNCHANGED
))
8436 " AS_PATH is propagated unchanged to this neighbor\n");
8437 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8438 PEER_FLAG_NEXTHOP_UNCHANGED
))
8440 " NEXT_HOP is propagated unchanged to this neighbor\n");
8441 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8443 " MED is propagated unchanged to this neighbor\n");
8444 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8445 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8446 PEER_FLAG_SEND_EXT_COMMUNITY
)
8447 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8448 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8450 " Community attribute sent to this neighbor");
8451 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8452 PEER_FLAG_SEND_COMMUNITY
)
8453 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8454 PEER_FLAG_SEND_EXT_COMMUNITY
)
8455 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8456 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8457 vty_out(vty
, "(all)\n");
8458 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8459 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8460 vty_out(vty
, "(large)\n");
8461 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8462 PEER_FLAG_SEND_EXT_COMMUNITY
))
8463 vty_out(vty
, "(extended)\n");
8465 vty_out(vty
, "(standard)\n");
8467 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8468 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8469 vty_out(vty
, " Default information originate,");
8471 if (p
->default_rmap
[afi
][safi
].name
)
8472 vty_out(vty
, " default route-map %s%s,",
8473 p
->default_rmap
[afi
][safi
].map
? "*"
8475 p
->default_rmap
[afi
][safi
].name
);
8476 if (paf
&& PAF_SUBGRP(paf
)
8477 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8478 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8479 vty_out(vty
, " default sent\n");
8481 vty_out(vty
, " default not sent\n");
8484 /* advertise-vni-all */
8485 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8486 if (is_evpn_enabled())
8487 vty_out(vty
, " advertise-all-vni\n");
8490 if (filter
->plist
[FILTER_IN
].name
8491 || filter
->dlist
[FILTER_IN
].name
8492 || filter
->aslist
[FILTER_IN
].name
8493 || filter
->map
[RMAP_IN
].name
)
8494 vty_out(vty
, " Inbound path policy configured\n");
8495 if (filter
->plist
[FILTER_OUT
].name
8496 || filter
->dlist
[FILTER_OUT
].name
8497 || filter
->aslist
[FILTER_OUT
].name
8498 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8499 vty_out(vty
, " Outbound path policy configured\n");
8502 if (filter
->plist
[FILTER_IN
].name
)
8504 " Incoming update prefix filter list is %s%s\n",
8505 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8506 filter
->plist
[FILTER_IN
].name
);
8507 if (filter
->plist
[FILTER_OUT
].name
)
8509 " Outgoing update prefix filter list is %s%s\n",
8510 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8511 filter
->plist
[FILTER_OUT
].name
);
8513 /* distribute-list */
8514 if (filter
->dlist
[FILTER_IN
].name
)
8516 " Incoming update network filter list is %s%s\n",
8517 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8518 filter
->dlist
[FILTER_IN
].name
);
8519 if (filter
->dlist
[FILTER_OUT
].name
)
8521 " Outgoing update network filter list is %s%s\n",
8522 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8523 filter
->dlist
[FILTER_OUT
].name
);
8526 if (filter
->aslist
[FILTER_IN
].name
)
8528 " Incoming update AS path filter list is %s%s\n",
8529 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8530 filter
->aslist
[FILTER_IN
].name
);
8531 if (filter
->aslist
[FILTER_OUT
].name
)
8533 " Outgoing update AS path filter list is %s%s\n",
8534 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8535 filter
->aslist
[FILTER_OUT
].name
);
8538 if (filter
->map
[RMAP_IN
].name
)
8540 " Route map for incoming advertisements is %s%s\n",
8541 filter
->map
[RMAP_IN
].map
? "*" : "",
8542 filter
->map
[RMAP_IN
].name
);
8543 if (filter
->map
[RMAP_OUT
].name
)
8545 " Route map for outgoing advertisements is %s%s\n",
8546 filter
->map
[RMAP_OUT
].map
? "*" : "",
8547 filter
->map
[RMAP_OUT
].name
);
8549 /* unsuppress-map */
8550 if (filter
->usmap
.name
)
8552 " Route map for selective unsuppress is %s%s\n",
8553 filter
->usmap
.map
? "*" : "",
8554 filter
->usmap
.name
);
8556 /* Receive prefix count */
8557 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8559 /* Maximum prefix */
8560 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8561 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8563 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8564 PEER_FLAG_MAX_PREFIX_WARNING
)
8567 vty_out(vty
, " Threshold for warning message %d%%",
8568 p
->pmax_threshold
[afi
][safi
]);
8569 if (p
->pmax_restart
[afi
][safi
])
8570 vty_out(vty
, ", restart interval %d min",
8571 p
->pmax_restart
[afi
][safi
]);
8579 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, u_char use_json
,
8583 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8584 char timebuf
[BGP_UPTIME_LEN
];
8586 const char *subcode_str
;
8587 const char *code_str
;
8592 json_object
*json_neigh
= NULL
;
8598 json_neigh
= json_object_new_object();
8600 memset(dn_flag
, '\0', sizeof(dn_flag
));
8601 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
8605 if (p
->conf_if
) /* Configured interface name. */
8606 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
8607 BGP_PEER_SU_UNSPEC(p
)
8609 : sockunion2str(&p
->su
, buf
,
8611 else /* Configured IP address. */
8612 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
8617 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
8618 json_object_string_add(json_neigh
, "bgpNeighborAddr",
8620 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
8621 json_object_string_add(
8622 json_neigh
, "bgpNeighborAddr",
8623 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
8625 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8627 if (p
->change_local_as
)
8628 json_object_int_add(json_neigh
, "localAs",
8629 p
->change_local_as
);
8631 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8633 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8634 json_object_boolean_true_add(json_neigh
,
8635 "localAsNoPrepend");
8637 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8638 json_object_boolean_true_add(json_neigh
,
8639 "localAsReplaceAs");
8641 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
8642 || (p
->as_type
== AS_INTERNAL
))
8643 vty_out(vty
, "remote AS %u, ", p
->as
);
8645 vty_out(vty
, "remote AS Unspecified, ");
8646 vty_out(vty
, "local AS %u%s%s, ",
8647 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
8648 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
8651 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
8655 /* peer type internal, external, confed-internal or confed-external */
8656 if (p
->as
== p
->local_as
) {
8658 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8659 json_object_boolean_true_add(
8660 json_neigh
, "nbrConfedInternalLink");
8662 json_object_boolean_true_add(json_neigh
,
8665 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8666 vty_out(vty
, "confed-internal link\n");
8668 vty_out(vty
, "internal link\n");
8672 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8673 json_object_boolean_true_add(
8674 json_neigh
, "nbrConfedExternalLink");
8676 json_object_boolean_true_add(json_neigh
,
8679 if (bgp_confederation_peers_check(bgp
, p
->as
))
8680 vty_out(vty
, "confed-external link\n");
8682 vty_out(vty
, "external link\n");
8689 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
8691 vty_out(vty
, " Description: %s\n", p
->desc
);
8697 json_object_string_add(json_neigh
, "hostname",
8701 json_object_string_add(json_neigh
, "domainname",
8704 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
8705 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
8708 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
8715 json_object_string_add(json_neigh
, "peerGroup",
8719 struct prefix prefix
, *range
= NULL
;
8721 sockunion2hostprefix(&(p
->su
), &prefix
);
8722 range
= peer_group_lookup_dynamic_neighbor_range(
8726 prefix2str(range
, buf1
, sizeof(buf1
));
8727 json_object_string_add(
8729 "peerSubnetRangeGroup", buf1
);
8734 " Member of peer-group %s for session parameters\n",
8738 struct prefix prefix
, *range
= NULL
;
8740 sockunion2hostprefix(&(p
->su
), &prefix
);
8741 range
= peer_group_lookup_dynamic_neighbor_range(
8745 prefix2str(range
, buf1
, sizeof(buf1
));
8747 " Belongs to the subnet range group: %s\n",
8755 /* Administrative shutdown. */
8756 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8757 json_object_boolean_true_add(json_neigh
,
8761 json_object_int_add(json_neigh
, "bgpVersion", 4);
8762 json_object_string_add(
8763 json_neigh
, "remoteRouterId",
8764 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
8767 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
8768 && bgp_confederation_peers_check(bgp
, p
->as
))
8769 json_object_boolean_true_add(json_neigh
,
8773 json_object_string_add(
8774 json_neigh
, "bgpState",
8775 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
8777 if (p
->status
== Established
) {
8780 uptime
= bgp_clock();
8781 uptime
-= p
->uptime
;
8782 epoch_tbuf
= time(NULL
) - uptime
;
8784 #if CONFDATE > 20200101
8786 "bgpTimerUp should be deprecated and can be removed now");
8789 * bgpTimerUp was miliseconds that was accurate
8790 * up to 1 day, then the value returned
8791 * became garbage. So in order to provide
8792 * some level of backwards compatability,
8793 * we still provde the data, but now
8794 * we are returning the correct value
8795 * and also adding a new bgpTimerUpMsec
8796 * which will allow us to deprecate
8799 json_object_int_add(json_neigh
, "bgpTimerUp",
8801 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
8803 json_object_string_add(json_neigh
, "bgpTimerUpString",
8804 peer_uptime(p
->uptime
, timebuf
,
8807 json_object_int_add(json_neigh
,
8808 "bgpTimerUpEstablishedEpoch",
8812 else if (p
->status
== Active
) {
8813 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
8814 json_object_string_add(json_neigh
, "bgpStateIs",
8816 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
8817 json_object_string_add(json_neigh
, "bgpStateIs",
8825 uptime
= bgp_clock();
8826 uptime
-= p
->readtime
;
8827 tm
= gmtime(&uptime
);
8828 json_object_int_add(json_neigh
, "bgpTimerLastRead",
8829 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8830 + (tm
->tm_hour
* 3600000));
8832 uptime
= bgp_clock();
8833 uptime
-= p
->last_write
;
8834 tm
= gmtime(&uptime
);
8835 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
8836 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8837 + (tm
->tm_hour
* 3600000));
8839 uptime
= bgp_clock();
8840 uptime
-= p
->update_time
;
8841 tm
= gmtime(&uptime
);
8842 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
8843 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8844 + (tm
->tm_hour
* 3600000));
8846 /* Configured timer values. */
8847 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
8848 p
->v_holdtime
* 1000);
8849 json_object_int_add(json_neigh
,
8850 "bgpTimerKeepAliveIntervalMsecs",
8851 p
->v_keepalive
* 1000);
8853 if (PEER_OR_GROUP_TIMER_SET(p
)) {
8854 json_object_int_add(json_neigh
,
8855 "bgpTimerConfiguredHoldTimeMsecs",
8856 p
->holdtime
* 1000);
8857 json_object_int_add(
8859 "bgpTimerConfiguredKeepAliveIntervalMsecs",
8860 p
->keepalive
* 1000);
8861 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
8862 || (bgp
->default_keepalive
8863 != BGP_DEFAULT_KEEPALIVE
)) {
8864 json_object_int_add(json_neigh
,
8865 "bgpTimerConfiguredHoldTimeMsecs",
8866 bgp
->default_holdtime
);
8867 json_object_int_add(
8869 "bgpTimerConfiguredKeepAliveIntervalMsecs",
8870 bgp
->default_keepalive
);
8873 /* Administrative shutdown. */
8874 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8875 vty_out(vty
, " Administratively shut down\n");
8878 vty_out(vty
, " BGP version 4");
8879 vty_out(vty
, ", remote router ID %s\n",
8880 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
8883 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
8884 && bgp_confederation_peers_check(bgp
, p
->as
))
8886 " Neighbor under common administration\n");
8889 vty_out(vty
, " BGP state = %s",
8890 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
8892 if (p
->status
== Established
)
8893 vty_out(vty
, ", up for %8s",
8894 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8897 else if (p
->status
== Active
) {
8898 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
8899 vty_out(vty
, " (passive)");
8900 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
8901 vty_out(vty
, " (NSF passive)");
8906 vty_out(vty
, " Last read %s",
8907 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
8909 vty_out(vty
, ", Last write %s\n",
8910 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
8913 /* Configured timer values. */
8915 " Hold time is %d, keepalive interval is %d seconds\n",
8916 p
->v_holdtime
, p
->v_keepalive
);
8917 if (PEER_OR_GROUP_TIMER_SET(p
)) {
8918 vty_out(vty
, " Configured hold time is %d",
8920 vty_out(vty
, ", keepalive interval is %d seconds\n",
8922 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
8923 || (bgp
->default_keepalive
8924 != BGP_DEFAULT_KEEPALIVE
)) {
8925 vty_out(vty
, " Configured hold time is %d",
8926 bgp
->default_holdtime
);
8927 vty_out(vty
, ", keepalive interval is %d seconds\n",
8928 bgp
->default_keepalive
);
8932 if (p
->status
== Established
) {
8933 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
8934 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
8935 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
8936 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
8937 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
8938 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
8939 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
8940 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
8941 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
8942 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
8943 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
8944 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
8945 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
8946 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
8947 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
8948 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
8950 json_object
*json_cap
= NULL
;
8952 json_cap
= json_object_new_object();
8955 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
8956 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
8957 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
8958 && CHECK_FLAG(p
->cap
,
8960 json_object_string_add(
8961 json_cap
, "4byteAs",
8962 "advertisedAndReceived");
8963 else if (CHECK_FLAG(p
->cap
,
8965 json_object_string_add(
8966 json_cap
, "4byteAs",
8968 else if (CHECK_FLAG(p
->cap
,
8970 json_object_string_add(
8971 json_cap
, "4byteAs",
8976 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
8977 || CHECK_FLAG(p
->cap
,
8978 PEER_CAP_ADDPATH_ADV
)) {
8979 json_object
*json_add
= NULL
;
8980 const char *print_store
;
8982 json_add
= json_object_new_object();
8984 FOREACH_AFI_SAFI (afi
, safi
) {
8985 json_object
*json_sub
= NULL
;
8987 json_object_new_object();
8988 print_store
= afi_safi_print(
8994 PEER_CAP_ADDPATH_AF_TX_ADV
)
8998 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9003 PEER_CAP_ADDPATH_AF_TX_ADV
)
9008 PEER_CAP_ADDPATH_AF_TX_RCV
))
9009 json_object_boolean_true_add(
9011 "txAdvertisedAndReceived");
9017 PEER_CAP_ADDPATH_AF_TX_ADV
))
9018 json_object_boolean_true_add(
9026 PEER_CAP_ADDPATH_AF_TX_RCV
))
9027 json_object_boolean_true_add(
9035 PEER_CAP_ADDPATH_AF_RX_ADV
)
9039 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9044 PEER_CAP_ADDPATH_AF_RX_ADV
)
9049 PEER_CAP_ADDPATH_AF_RX_RCV
))
9050 json_object_boolean_true_add(
9052 "rxAdvertisedAndReceived");
9058 PEER_CAP_ADDPATH_AF_RX_ADV
))
9059 json_object_boolean_true_add(
9067 PEER_CAP_ADDPATH_AF_RX_RCV
))
9068 json_object_boolean_true_add(
9076 PEER_CAP_ADDPATH_AF_TX_ADV
)
9080 PEER_CAP_ADDPATH_AF_TX_RCV
)
9084 PEER_CAP_ADDPATH_AF_RX_ADV
)
9088 PEER_CAP_ADDPATH_AF_RX_RCV
))
9089 json_object_object_add(
9098 json_object_object_add(
9099 json_cap
, "addPath", json_add
);
9103 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9104 || CHECK_FLAG(p
->cap
,
9105 PEER_CAP_DYNAMIC_ADV
)) {
9106 if (CHECK_FLAG(p
->cap
,
9107 PEER_CAP_DYNAMIC_ADV
)
9108 && CHECK_FLAG(p
->cap
,
9109 PEER_CAP_DYNAMIC_RCV
))
9110 json_object_string_add(
9111 json_cap
, "dynamic",
9112 "advertisedAndReceived");
9113 else if (CHECK_FLAG(
9115 PEER_CAP_DYNAMIC_ADV
))
9116 json_object_string_add(
9117 json_cap
, "dynamic",
9119 else if (CHECK_FLAG(
9121 PEER_CAP_DYNAMIC_RCV
))
9122 json_object_string_add(
9123 json_cap
, "dynamic",
9127 /* Extended nexthop */
9128 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9129 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9130 json_object
*json_nxt
= NULL
;
9131 const char *print_store
;
9134 if (CHECK_FLAG(p
->cap
,
9136 && CHECK_FLAG(p
->cap
,
9138 json_object_string_add(
9141 "advertisedAndReceived");
9142 else if (CHECK_FLAG(p
->cap
,
9144 json_object_string_add(
9148 else if (CHECK_FLAG(p
->cap
,
9150 json_object_string_add(
9155 if (CHECK_FLAG(p
->cap
,
9156 PEER_CAP_ENHE_RCV
)) {
9158 json_object_new_object();
9160 for (safi
= SAFI_UNICAST
;
9161 safi
< SAFI_MAX
; safi
++) {
9166 PEER_CAP_ENHE_AF_RCV
)) {
9167 print_store
= afi_safi_print(
9170 json_object_string_add(
9176 json_object_object_add(
9178 "extendedNexthopFamililesByPeer",
9184 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9185 || CHECK_FLAG(p
->cap
,
9186 PEER_CAP_REFRESH_NEW_RCV
)
9187 || CHECK_FLAG(p
->cap
,
9188 PEER_CAP_REFRESH_OLD_RCV
)) {
9189 if (CHECK_FLAG(p
->cap
,
9190 PEER_CAP_REFRESH_ADV
)
9193 PEER_CAP_REFRESH_NEW_RCV
)
9196 PEER_CAP_REFRESH_OLD_RCV
))) {
9199 PEER_CAP_REFRESH_OLD_RCV
)
9202 PEER_CAP_REFRESH_NEW_RCV
))
9203 json_object_string_add(
9206 "advertisedAndReceivedOldNew");
9210 PEER_CAP_REFRESH_OLD_RCV
))
9211 json_object_string_add(
9214 "advertisedAndReceivedOld");
9216 json_object_string_add(
9219 "advertisedAndReceivedNew");
9224 PEER_CAP_REFRESH_ADV
))
9225 json_object_string_add(
9232 PEER_CAP_REFRESH_NEW_RCV
)
9235 PEER_CAP_REFRESH_OLD_RCV
))
9236 json_object_string_add(
9242 /* Multiprotocol Extensions */
9243 json_object
*json_multi
= NULL
;
9244 json_multi
= json_object_new_object();
9246 FOREACH_AFI_SAFI (afi
, safi
) {
9247 if (p
->afc_adv
[afi
][safi
]
9248 || p
->afc_recv
[afi
][safi
]) {
9249 json_object
*json_exten
= NULL
;
9251 json_object_new_object();
9253 if (p
->afc_adv
[afi
][safi
]
9254 && p
->afc_recv
[afi
][safi
])
9255 json_object_boolean_true_add(
9257 "advertisedAndReceived");
9258 else if (p
->afc_adv
[afi
][safi
])
9259 json_object_boolean_true_add(
9262 else if (p
->afc_recv
[afi
][safi
])
9263 json_object_boolean_true_add(
9267 json_object_object_add(
9274 json_object_object_add(
9275 json_cap
, "multiprotocolExtensions",
9278 /* Hostname capabilities */
9279 json_object
*json_hname
= NULL
;
9281 json_hname
= json_object_new_object();
9283 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9284 json_object_string_add(
9285 json_hname
, "advHostName",
9286 bgp
->peer_self
->hostname
9290 json_object_string_add(
9291 json_hname
, "advDomainName",
9292 bgp
->peer_self
->domainname
9299 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9300 json_object_string_add(
9301 json_hname
, "rcvHostName",
9302 p
->hostname
? p
->hostname
9304 json_object_string_add(
9305 json_hname
, "rcvDomainName",
9306 p
->domainname
? p
->domainname
9310 json_object_object_add(json_cap
, "hostName",
9313 /* Gracefull Restart */
9314 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9315 || CHECK_FLAG(p
->cap
,
9316 PEER_CAP_RESTART_ADV
)) {
9317 if (CHECK_FLAG(p
->cap
,
9318 PEER_CAP_RESTART_ADV
)
9319 && CHECK_FLAG(p
->cap
,
9320 PEER_CAP_RESTART_RCV
))
9321 json_object_string_add(
9324 "advertisedAndReceived");
9325 else if (CHECK_FLAG(
9327 PEER_CAP_RESTART_ADV
))
9328 json_object_string_add(
9330 "gracefulRestartCapability",
9332 else if (CHECK_FLAG(
9334 PEER_CAP_RESTART_RCV
))
9335 json_object_string_add(
9337 "gracefulRestartCapability",
9340 if (CHECK_FLAG(p
->cap
,
9341 PEER_CAP_RESTART_RCV
)) {
9342 int restart_af_count
= 0;
9343 json_object
*json_restart
=
9346 json_object_new_object();
9348 json_object_int_add(
9350 "gracefulRestartRemoteTimerMsecs",
9351 p
->v_gr_restart
* 1000);
9353 FOREACH_AFI_SAFI (afi
, safi
) {
9358 PEER_CAP_RESTART_AF_RCV
)) {
9363 json_object_new_object();
9369 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9370 json_object_boolean_true_add(
9374 json_object_object_add(
9382 if (!restart_af_count
) {
9383 json_object_string_add(
9385 "addressFamiliesByPeer",
9390 json_object_object_add(
9392 "addressFamiliesByPeer",
9396 json_object_object_add(json_neigh
,
9397 "neighborCapabilities",
9400 vty_out(vty
, " Neighbor capabilities:\n");
9403 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9404 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9405 vty_out(vty
, " 4 Byte AS:");
9406 if (CHECK_FLAG(p
->cap
,
9408 vty_out(vty
, " advertised");
9409 if (CHECK_FLAG(p
->cap
,
9411 vty_out(vty
, " %sreceived",
9421 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9422 || CHECK_FLAG(p
->cap
,
9423 PEER_CAP_ADDPATH_ADV
)) {
9424 vty_out(vty
, " AddPath:\n");
9426 FOREACH_AFI_SAFI (afi
, safi
) {
9430 PEER_CAP_ADDPATH_AF_TX_ADV
)
9434 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9445 PEER_CAP_ADDPATH_AF_TX_ADV
))
9456 PEER_CAP_ADDPATH_AF_TX_RCV
))
9463 PEER_CAP_ADDPATH_AF_TX_ADV
)
9473 PEER_CAP_ADDPATH_AF_RX_ADV
)
9477 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9488 PEER_CAP_ADDPATH_AF_RX_ADV
))
9499 PEER_CAP_ADDPATH_AF_RX_RCV
))
9506 PEER_CAP_ADDPATH_AF_RX_ADV
)
9516 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9517 || CHECK_FLAG(p
->cap
,
9518 PEER_CAP_DYNAMIC_ADV
)) {
9519 vty_out(vty
, " Dynamic:");
9520 if (CHECK_FLAG(p
->cap
,
9521 PEER_CAP_DYNAMIC_ADV
))
9522 vty_out(vty
, " advertised");
9523 if (CHECK_FLAG(p
->cap
,
9524 PEER_CAP_DYNAMIC_RCV
))
9525 vty_out(vty
, " %sreceived",
9528 PEER_CAP_DYNAMIC_ADV
)
9534 /* Extended nexthop */
9535 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9536 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9537 vty_out(vty
, " Extended nexthop:");
9538 if (CHECK_FLAG(p
->cap
,
9540 vty_out(vty
, " advertised");
9541 if (CHECK_FLAG(p
->cap
,
9543 vty_out(vty
, " %sreceived",
9551 if (CHECK_FLAG(p
->cap
,
9552 PEER_CAP_ENHE_RCV
)) {
9554 " Address families by peer:\n ");
9555 for (safi
= SAFI_UNICAST
;
9556 safi
< SAFI_MAX
; safi
++)
9561 PEER_CAP_ENHE_AF_RCV
))
9571 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9572 || CHECK_FLAG(p
->cap
,
9573 PEER_CAP_REFRESH_NEW_RCV
)
9574 || CHECK_FLAG(p
->cap
,
9575 PEER_CAP_REFRESH_OLD_RCV
)) {
9576 vty_out(vty
, " Route refresh:");
9577 if (CHECK_FLAG(p
->cap
,
9578 PEER_CAP_REFRESH_ADV
))
9579 vty_out(vty
, " advertised");
9580 if (CHECK_FLAG(p
->cap
,
9581 PEER_CAP_REFRESH_NEW_RCV
)
9584 PEER_CAP_REFRESH_OLD_RCV
))
9585 vty_out(vty
, " %sreceived(%s)",
9588 PEER_CAP_REFRESH_ADV
)
9593 PEER_CAP_REFRESH_OLD_RCV
)
9596 PEER_CAP_REFRESH_NEW_RCV
))
9600 PEER_CAP_REFRESH_OLD_RCV
)
9607 /* Multiprotocol Extensions */
9608 FOREACH_AFI_SAFI (afi
, safi
)
9609 if (p
->afc_adv
[afi
][safi
]
9610 || p
->afc_recv
[afi
][safi
]) {
9612 " Address Family %s:",
9615 if (p
->afc_adv
[afi
][safi
])
9618 if (p
->afc_recv
[afi
][safi
])
9628 /* Hostname capability */
9629 vty_out(vty
, " Hostname Capability:");
9631 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9633 " advertised (name: %s,domain name: %s)",
9634 bgp
->peer_self
->hostname
9638 bgp
->peer_self
->domainname
9643 vty_out(vty
, " not advertised");
9646 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9648 " received (name: %s,domain name: %s)",
9649 p
->hostname
? p
->hostname
9651 p
->domainname
? p
->domainname
9654 vty_out(vty
, " not received");
9659 /* Gracefull Restart */
9660 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9661 || CHECK_FLAG(p
->cap
,
9662 PEER_CAP_RESTART_ADV
)) {
9664 " Graceful Restart Capabilty:");
9665 if (CHECK_FLAG(p
->cap
,
9666 PEER_CAP_RESTART_ADV
))
9667 vty_out(vty
, " advertised");
9668 if (CHECK_FLAG(p
->cap
,
9669 PEER_CAP_RESTART_RCV
))
9670 vty_out(vty
, " %sreceived",
9673 PEER_CAP_RESTART_ADV
)
9678 if (CHECK_FLAG(p
->cap
,
9679 PEER_CAP_RESTART_RCV
)) {
9680 int restart_af_count
= 0;
9683 " Remote Restart timer is %d seconds\n",
9686 " Address families by peer:\n ");
9688 FOREACH_AFI_SAFI (afi
, safi
)
9693 PEER_CAP_RESTART_AF_RCV
)) {
9706 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
9711 if (!restart_af_count
)
9712 vty_out(vty
, "none");
9720 /* graceful restart information */
9721 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
9723 json_object
*json_grace
= NULL
;
9724 json_object
*json_grace_send
= NULL
;
9725 json_object
*json_grace_recv
= NULL
;
9726 int eor_send_af_count
= 0;
9727 int eor_receive_af_count
= 0;
9730 json_grace
= json_object_new_object();
9731 json_grace_send
= json_object_new_object();
9732 json_grace_recv
= json_object_new_object();
9734 if (p
->status
== Established
) {
9735 FOREACH_AFI_SAFI (afi
, safi
) {
9736 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9737 PEER_STATUS_EOR_SEND
)) {
9738 json_object_boolean_true_add(
9742 eor_send_af_count
++;
9745 FOREACH_AFI_SAFI (afi
, safi
) {
9747 p
->af_sflags
[afi
][safi
],
9748 PEER_STATUS_EOR_RECEIVED
)) {
9749 json_object_boolean_true_add(
9753 eor_receive_af_count
++;
9758 json_object_object_add(json_grace
, "endOfRibSend",
9760 json_object_object_add(json_grace
, "endOfRibRecv",
9763 if (p
->t_gr_restart
)
9764 json_object_int_add(json_grace
,
9765 "gracefulRestartTimerMsecs",
9766 thread_timer_remain_second(
9771 json_object_int_add(
9773 "gracefulStalepathTimerMsecs",
9774 thread_timer_remain_second(
9778 json_object_object_add(
9779 json_neigh
, "gracefulRestartInfo", json_grace
);
9781 vty_out(vty
, " Graceful restart informations:\n");
9782 if (p
->status
== Established
) {
9783 vty_out(vty
, " End-of-RIB send: ");
9784 FOREACH_AFI_SAFI (afi
, safi
) {
9785 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9786 PEER_STATUS_EOR_SEND
)) {
9787 vty_out(vty
, "%s%s",
9788 eor_send_af_count
? ", "
9792 eor_send_af_count
++;
9796 vty_out(vty
, " End-of-RIB received: ");
9797 FOREACH_AFI_SAFI (afi
, safi
) {
9799 p
->af_sflags
[afi
][safi
],
9800 PEER_STATUS_EOR_RECEIVED
)) {
9801 vty_out(vty
, "%s%s",
9802 eor_receive_af_count
9807 eor_receive_af_count
++;
9813 if (p
->t_gr_restart
)
9815 " The remaining time of restart timer is %ld\n",
9816 thread_timer_remain_second(
9821 " The remaining time of stalepath timer is %ld\n",
9822 thread_timer_remain_second(
9827 json_object
*json_stat
= NULL
;
9828 json_stat
= json_object_new_object();
9829 /* Packet counts. */
9830 json_object_int_add(json_stat
, "depthInq", 0);
9831 json_object_int_add(json_stat
, "depthOutq",
9832 (unsigned long)p
->obuf
->count
);
9833 json_object_int_add(json_stat
, "opensSent",
9834 atomic_load_explicit(&p
->open_out
,
9835 memory_order_relaxed
));
9836 json_object_int_add(json_stat
, "opensRecv",
9837 atomic_load_explicit(&p
->open_in
,
9838 memory_order_relaxed
));
9839 json_object_int_add(json_stat
, "notificationsSent",
9840 atomic_load_explicit(&p
->notify_out
,
9841 memory_order_relaxed
));
9842 json_object_int_add(json_stat
, "notificationsRecv",
9843 atomic_load_explicit(&p
->notify_in
,
9844 memory_order_relaxed
));
9845 json_object_int_add(json_stat
, "updatesSent",
9846 atomic_load_explicit(&p
->update_out
,
9847 memory_order_relaxed
));
9848 json_object_int_add(json_stat
, "updatesRecv",
9849 atomic_load_explicit(&p
->update_in
,
9850 memory_order_relaxed
));
9851 json_object_int_add(json_stat
, "keepalivesSent",
9852 atomic_load_explicit(&p
->keepalive_out
,
9853 memory_order_relaxed
));
9854 json_object_int_add(json_stat
, "keepalivesRecv",
9855 atomic_load_explicit(&p
->keepalive_in
,
9856 memory_order_relaxed
));
9857 json_object_int_add(json_stat
, "routeRefreshSent",
9858 atomic_load_explicit(&p
->refresh_out
,
9859 memory_order_relaxed
));
9860 json_object_int_add(json_stat
, "routeRefreshRecv",
9861 atomic_load_explicit(&p
->refresh_in
,
9862 memory_order_relaxed
));
9863 json_object_int_add(json_stat
, "capabilitySent",
9864 atomic_load_explicit(&p
->dynamic_cap_out
,
9865 memory_order_relaxed
));
9866 json_object_int_add(json_stat
, "capabilityRecv",
9867 atomic_load_explicit(&p
->dynamic_cap_in
,
9868 memory_order_relaxed
));
9869 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
9870 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
9871 json_object_object_add(json_neigh
, "messageStats", json_stat
);
9873 /* Packet counts. */
9874 vty_out(vty
, " Message statistics:\n");
9875 vty_out(vty
, " Inq depth is 0\n");
9876 vty_out(vty
, " Outq depth is %lu\n",
9877 (unsigned long)p
->obuf
->count
);
9878 vty_out(vty
, " Sent Rcvd\n");
9879 vty_out(vty
, " Opens: %10d %10d\n",
9880 atomic_load_explicit(&p
->open_out
,
9881 memory_order_relaxed
),
9882 atomic_load_explicit(&p
->open_in
,
9883 memory_order_relaxed
));
9884 vty_out(vty
, " Notifications: %10d %10d\n",
9885 atomic_load_explicit(&p
->notify_out
,
9886 memory_order_relaxed
),
9887 atomic_load_explicit(&p
->notify_in
,
9888 memory_order_relaxed
));
9889 vty_out(vty
, " Updates: %10d %10d\n",
9890 atomic_load_explicit(&p
->update_out
,
9891 memory_order_relaxed
),
9892 atomic_load_explicit(&p
->update_in
,
9893 memory_order_relaxed
));
9894 vty_out(vty
, " Keepalives: %10d %10d\n",
9895 atomic_load_explicit(&p
->keepalive_out
,
9896 memory_order_relaxed
),
9897 atomic_load_explicit(&p
->keepalive_in
,
9898 memory_order_relaxed
));
9899 vty_out(vty
, " Route Refresh: %10d %10d\n",
9900 atomic_load_explicit(&p
->refresh_out
,
9901 memory_order_relaxed
),
9902 atomic_load_explicit(&p
->refresh_in
,
9903 memory_order_relaxed
));
9904 vty_out(vty
, " Capability: %10d %10d\n",
9905 atomic_load_explicit(&p
->dynamic_cap_out
,
9906 memory_order_relaxed
),
9907 atomic_load_explicit(&p
->dynamic_cap_in
,
9908 memory_order_relaxed
));
9909 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
9914 /* advertisement-interval */
9915 json_object_int_add(json_neigh
,
9916 "minBtwnAdvertisementRunsTimerMsecs",
9917 p
->v_routeadv
* 1000);
9919 /* Update-source. */
9920 if (p
->update_if
|| p
->update_source
) {
9922 json_object_string_add(json_neigh
,
9925 else if (p
->update_source
)
9926 json_object_string_add(
9927 json_neigh
, "updateSource",
9928 sockunion2str(p
->update_source
, buf1
,
9932 /* advertisement-interval */
9934 " Minimum time between advertisement runs is %d seconds\n",
9937 /* Update-source. */
9938 if (p
->update_if
|| p
->update_source
) {
9939 vty_out(vty
, " Update source is ");
9941 vty_out(vty
, "%s", p
->update_if
);
9942 else if (p
->update_source
)
9944 sockunion2str(p
->update_source
, buf1
,
9952 /* Address Family Information */
9953 json_object
*json_hold
= NULL
;
9956 json_hold
= json_object_new_object();
9958 FOREACH_AFI_SAFI (afi
, safi
)
9959 if (p
->afc
[afi
][safi
])
9960 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
9964 json_object_object_add(json_neigh
, "addressFamilyInfo",
9966 json_object_int_add(json_neigh
, "connectionsEstablished",
9968 json_object_int_add(json_neigh
, "connectionsDropped",
9971 vty_out(vty
, " Connections established %d; dropped %d\n",
9972 p
->established
, p
->dropped
);
9974 if (!p
->last_reset
) {
9976 json_object_string_add(json_neigh
, "lastReset",
9979 vty_out(vty
, " Last reset never\n");
9985 uptime
= bgp_clock();
9986 uptime
-= p
->resettime
;
9987 tm
= gmtime(&uptime
);
9988 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
9990 + (tm
->tm_min
* 60000)
9991 + (tm
->tm_hour
* 3600000));
9992 json_object_string_add(
9993 json_neigh
, "lastResetDueTo",
9994 peer_down_str
[(int)p
->last_reset
]);
9995 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9996 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9997 char errorcodesubcode_hexstr
[5];
9998 char errorcodesubcode_str
[256];
10000 code_str
= bgp_notify_code_str(p
->notify
.code
);
10001 subcode_str
= bgp_notify_subcode_str(
10002 p
->notify
.code
, p
->notify
.subcode
);
10004 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10005 p
->notify
.code
, p
->notify
.subcode
);
10006 json_object_string_add(json_neigh
,
10007 "lastErrorCodeSubcode",
10008 errorcodesubcode_hexstr
);
10009 snprintf(errorcodesubcode_str
, 255, "%s%s",
10010 code_str
, subcode_str
);
10011 json_object_string_add(json_neigh
,
10012 "lastNotificationReason",
10013 errorcodesubcode_str
);
10014 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10015 && p
->notify
.code
== BGP_NOTIFY_CEASE
10016 && (p
->notify
.subcode
10017 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10018 || p
->notify
.subcode
10019 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10020 && p
->notify
.length
) {
10022 const char *msg_str
;
10024 msg_str
= bgp_notify_admin_message(
10025 msgbuf
, sizeof(msgbuf
),
10026 (u_char
*)p
->notify
.data
,
10029 json_object_string_add(
10031 "lastShutdownDescription",
10036 vty_out(vty
, " Last reset %s, ",
10037 peer_uptime(p
->resettime
, timebuf
,
10038 BGP_UPTIME_LEN
, 0, NULL
));
10040 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10041 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10042 code_str
= bgp_notify_code_str(p
->notify
.code
);
10043 subcode_str
= bgp_notify_subcode_str(
10044 p
->notify
.code
, p
->notify
.subcode
);
10045 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10046 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10049 code_str
, subcode_str
);
10050 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10051 && p
->notify
.code
== BGP_NOTIFY_CEASE
10052 && (p
->notify
.subcode
10053 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10054 || p
->notify
.subcode
10055 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10056 && p
->notify
.length
) {
10058 const char *msg_str
;
10060 msg_str
= bgp_notify_admin_message(
10061 msgbuf
, sizeof(msgbuf
),
10062 (u_char
*)p
->notify
.data
,
10066 " Message: \"%s\"\n",
10070 vty_out(vty
, "due to %s\n",
10071 peer_down_str
[(int)p
->last_reset
]);
10074 if (p
->last_reset_cause_size
) {
10075 msg
= p
->last_reset_cause
;
10077 " Message received that caused BGP to send a NOTIFICATION:\n ");
10078 for (i
= 1; i
<= p
->last_reset_cause_size
;
10080 vty_out(vty
, "%02X", *msg
++);
10082 if (i
!= p
->last_reset_cause_size
) {
10084 vty_out(vty
, "\n ");
10085 } else if (i
% 4 == 0) {
10090 vty_out(vty
, "\n");
10095 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10097 json_object_boolean_true_add(json_neigh
,
10098 "prefixesConfigExceedMax");
10101 " Peer had exceeded the max. no. of prefixes configured.\n");
10103 if (p
->t_pmax_restart
) {
10105 json_object_boolean_true_add(
10106 json_neigh
, "reducePrefixNumFrom");
10107 json_object_int_add(json_neigh
,
10108 "restartInTimerMsec",
10109 thread_timer_remain_second(
10114 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10115 p
->host
, thread_timer_remain_second(
10116 p
->t_pmax_restart
));
10119 json_object_boolean_true_add(
10121 "reducePrefixNumAndClearIpBgp");
10124 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10129 /* EBGP Multihop and GTSM */
10130 if (p
->sort
!= BGP_PEER_IBGP
) {
10132 if (p
->gtsm_hops
> 0)
10133 json_object_int_add(json_neigh
,
10134 "externalBgpNbrMaxHopsAway",
10136 else if (p
->ttl
> 1)
10137 json_object_int_add(json_neigh
,
10138 "externalBgpNbrMaxHopsAway",
10141 if (p
->gtsm_hops
> 0)
10143 " External BGP neighbor may be up to %d hops away.\n",
10145 else if (p
->ttl
> 1)
10147 " External BGP neighbor may be up to %d hops away.\n",
10151 if (p
->gtsm_hops
> 0) {
10153 json_object_int_add(json_neigh
,
10154 "internalBgpNbrMaxHopsAway",
10158 " Internal BGP neighbor may be up to %d hops away.\n",
10163 /* Local address. */
10166 json_object_string_add(json_neigh
, "hostLocal",
10167 sockunion2str(p
->su_local
, buf1
,
10169 json_object_int_add(json_neigh
, "portLocal",
10170 ntohs(p
->su_local
->sin
.sin_port
));
10172 vty_out(vty
, "Local host: %s, Local port: %d\n",
10173 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10174 ntohs(p
->su_local
->sin
.sin_port
));
10177 /* Remote address. */
10178 if (p
->su_remote
) {
10180 json_object_string_add(json_neigh
, "hostForeign",
10181 sockunion2str(p
->su_remote
, buf1
,
10183 json_object_int_add(json_neigh
, "portForeign",
10184 ntohs(p
->su_remote
->sin
.sin_port
));
10186 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10187 sockunion2str(p
->su_remote
, buf1
,
10189 ntohs(p
->su_remote
->sin
.sin_port
));
10192 /* Nexthop display. */
10195 json_object_string_add(json_neigh
, "nexthop",
10197 &p
->nexthop
.v4
, buf1
,
10199 json_object_string_add(json_neigh
, "nexthopGlobal",
10200 inet_ntop(AF_INET6
,
10201 &p
->nexthop
.v6_global
,
10202 buf1
, sizeof(buf1
)));
10203 json_object_string_add(json_neigh
, "nexthopLocal",
10204 inet_ntop(AF_INET6
,
10205 &p
->nexthop
.v6_local
,
10206 buf1
, sizeof(buf1
)));
10207 if (p
->shared_network
)
10208 json_object_string_add(json_neigh
,
10212 json_object_string_add(json_neigh
,
10214 "nonSharedNetwork");
10216 vty_out(vty
, "Nexthop: %s\n",
10217 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10219 vty_out(vty
, "Nexthop global: %s\n",
10220 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10222 vty_out(vty
, "Nexthop local: %s\n",
10223 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10225 vty_out(vty
, "BGP connection: %s\n",
10226 p
->shared_network
? "shared network"
10227 : "non shared network");
10231 /* Timer information. */
10233 json_object_int_add(json_neigh
, "connectRetryTimer",
10235 if (p
->status
== Established
&& p
->rtt
)
10236 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10239 json_object_int_add(
10240 json_neigh
, "nextStartTimerDueInMsecs",
10241 thread_timer_remain_second(p
->t_start
) * 1000);
10243 json_object_int_add(
10244 json_neigh
, "nextConnectTimerDueInMsecs",
10245 thread_timer_remain_second(p
->t_connect
)
10247 if (p
->t_routeadv
) {
10248 json_object_int_add(json_neigh
, "mraiInterval",
10250 json_object_int_add(
10251 json_neigh
, "mraiTimerExpireInMsecs",
10252 thread_timer_remain_second(p
->t_routeadv
)
10256 json_object_int_add(json_neigh
, "authenticationEnabled",
10260 json_object_string_add(json_neigh
, "readThread", "on");
10262 json_object_string_add(json_neigh
, "readThread", "off");
10264 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10265 json_object_string_add(json_neigh
, "writeThread", "on");
10267 json_object_string_add(json_neigh
, "writeThread",
10270 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10272 if (p
->status
== Established
&& p
->rtt
)
10273 vty_out(vty
, "Estimated round trip time: %d ms\n",
10276 vty_out(vty
, "Next start timer due in %ld seconds\n",
10277 thread_timer_remain_second(p
->t_start
));
10279 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10280 thread_timer_remain_second(p
->t_connect
));
10283 "MRAI (interval %u) timer expires in %ld seconds\n",
10285 thread_timer_remain_second(p
->t_routeadv
));
10287 vty_out(vty
, "Peer Authentication Enabled\n");
10289 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10290 p
->t_read
? "on" : "off",
10291 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10296 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10297 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10298 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10301 vty_out(vty
, "\n");
10303 /* BFD information. */
10304 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10307 if (p
->conf_if
) /* Configured interface name. */
10308 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10309 else /* Configured IP address. */
10310 json_object_object_add(json
, p
->host
, json_neigh
);
10314 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10315 enum show_type type
, union sockunion
*su
,
10316 const char *conf_if
, u_char use_json
,
10319 struct listnode
*node
, *nnode
;
10323 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10324 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10329 bgp_show_peer(vty
, peer
, use_json
, json
);
10334 && !strcmp(peer
->conf_if
, conf_if
))
10336 && !strcmp(peer
->hostname
, conf_if
))) {
10338 bgp_show_peer(vty
, peer
, use_json
,
10342 if (sockunion_same(&peer
->su
, su
)) {
10344 bgp_show_peer(vty
, peer
, use_json
,
10352 if (type
== show_peer
&& !find
) {
10354 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10356 vty_out(vty
, "%% No such neighbor\n");
10360 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10361 json
, JSON_C_TO_STRING_PRETTY
));
10362 json_object_free(json
);
10364 vty_out(vty
, "\n");
10367 return CMD_SUCCESS
;
10370 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10371 enum show_type type
,
10372 const char *ip_str
,
10375 struct listnode
*node
, *nnode
;
10377 union sockunion su
;
10378 json_object
*json
= NULL
;
10379 int ret
, is_first
= 1;
10382 vty_out(vty
, "{\n");
10384 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10386 if (!(json
= json_object_new_object())) {
10388 "Unable to allocate memory for JSON object");
10390 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10394 json_object_int_add(json
, "vrfId",
10395 (bgp
->vrf_id
== VRF_UNKNOWN
)
10397 : (int64_t)bgp
->vrf_id
);
10398 json_object_string_add(
10400 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10405 vty_out(vty
, ",\n");
10409 vty_out(vty
, "\"%s\":",
10410 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10414 vty_out(vty
, "\nInstance %s:\n",
10415 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10420 if (type
== show_peer
) {
10421 ret
= str2sockunion(ip_str
, &su
);
10423 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10426 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10429 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10435 vty_out(vty
, "}\n");
10438 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10439 enum show_type type
, const char *ip_str
,
10444 union sockunion su
;
10445 json_object
*json
= NULL
;
10448 if (strmatch(name
, "all")) {
10449 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10451 return CMD_SUCCESS
;
10453 bgp
= bgp_lookup_by_name(name
);
10456 json
= json_object_new_object();
10457 json_object_boolean_true_add(
10458 json
, "bgpNoSuchInstance");
10459 vty_out(vty
, "%s\n",
10460 json_object_to_json_string_ext(
10462 JSON_C_TO_STRING_PRETTY
));
10463 json_object_free(json
);
10466 "%% No such BGP instance exist\n");
10468 return CMD_WARNING
;
10472 bgp
= bgp_get_default();
10476 json
= json_object_new_object();
10478 ret
= str2sockunion(ip_str
, &su
);
10480 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10483 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10486 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10489 json_object_free(json
);
10492 return CMD_SUCCESS
;
10495 /* "show [ip] bgp neighbors" commands. */
10496 DEFUN (show_ip_bgp_neighbors
,
10497 show_ip_bgp_neighbors_cmd
,
10498 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10502 BGP_INSTANCE_HELP_STR
10505 "Detailed information on TCP and BGP neighbor connections\n"
10506 "Neighbor to display information about\n"
10507 "Neighbor to display information about\n"
10508 "Neighbor on BGP configured interface\n"
10512 char *sh_arg
= NULL
;
10513 enum show_type sh_type
;
10515 u_char uj
= use_json(argc
, argv
);
10519 if (argv_find(argv
, argc
, "view", &idx
)
10520 || argv_find(argv
, argc
, "vrf", &idx
))
10521 vrf
= argv
[idx
+ 1]->arg
;
10524 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10525 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10526 || argv_find(argv
, argc
, "WORD", &idx
)) {
10527 sh_type
= show_peer
;
10528 sh_arg
= argv
[idx
]->arg
;
10530 sh_type
= show_all
;
10532 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10535 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10536 paths' and `show ip mbgp paths'. Those functions results are the
10538 DEFUN (show_ip_bgp_paths
,
10539 show_ip_bgp_paths_cmd
,
10540 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10545 "Path information\n")
10547 vty_out(vty
, "Address Refcnt Path\n");
10548 aspath_print_all_vty(vty
);
10549 return CMD_SUCCESS
;
10554 static void community_show_all_iterator(struct hash_backet
*backet
,
10557 struct community
*com
;
10559 com
= (struct community
*)backet
->data
;
10560 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10561 community_str(com
, false));
10564 /* Show BGP's community internal data. */
10565 DEFUN (show_ip_bgp_community_info
,
10566 show_ip_bgp_community_info_cmd
,
10567 "show [ip] bgp community-info",
10571 "List all bgp community information\n")
10573 vty_out(vty
, "Address Refcnt Community\n");
10575 hash_iterate(community_hash(),
10576 (void (*)(struct hash_backet
*,
10577 void *))community_show_all_iterator
,
10580 return CMD_SUCCESS
;
10583 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
10586 struct lcommunity
*lcom
;
10588 lcom
= (struct lcommunity
*)backet
->data
;
10589 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
10590 lcommunity_str(lcom
));
10593 /* Show BGP's community internal data. */
10594 DEFUN (show_ip_bgp_lcommunity_info
,
10595 show_ip_bgp_lcommunity_info_cmd
,
10596 "show ip bgp large-community-info",
10600 "List all bgp large-community information\n")
10602 vty_out(vty
, "Address Refcnt Large-community\n");
10604 hash_iterate(lcommunity_hash(),
10605 (void (*)(struct hash_backet
*,
10606 void *))lcommunity_show_all_iterator
,
10609 return CMD_SUCCESS
;
10613 DEFUN (show_ip_bgp_attr_info
,
10614 show_ip_bgp_attr_info_cmd
,
10615 "show [ip] bgp attribute-info",
10619 "List all bgp attribute information\n")
10621 attr_show_all(vty
);
10622 return CMD_SUCCESS
;
10625 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
10628 struct listnode
*node
, *nnode
;
10631 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10632 vty_out(vty
, "\nInstance %s:\n",
10633 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10636 update_group_show(bgp
, afi
, safi
, vty
, 0);
10640 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
10641 int safi
, uint64_t subgrp_id
)
10646 if (strmatch(name
, "all")) {
10647 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
10648 return CMD_SUCCESS
;
10650 bgp
= bgp_lookup_by_name(name
);
10653 bgp
= bgp_get_default();
10657 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
10658 return CMD_SUCCESS
;
10661 DEFUN (show_ip_bgp_updgrps
,
10662 show_ip_bgp_updgrps_cmd
,
10663 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
10667 BGP_INSTANCE_HELP_STR
10669 BGP_SAFI_WITH_LABEL_HELP_STR
10670 "Detailed info about dynamic update groups\n"
10671 "Specific subgroup to display detailed info for\n")
10674 afi_t afi
= AFI_IP6
;
10675 safi_t safi
= SAFI_UNICAST
;
10676 uint64_t subgrp_id
= 0;
10680 /* show [ip] bgp */
10681 if (argv_find(argv
, argc
, "ip", &idx
))
10683 /* [<view|vrf> VIEWVRFNAME] */
10684 if (argv_find(argv
, argc
, "view", &idx
)
10685 || argv_find(argv
, argc
, "vrf", &idx
))
10686 vrf
= argv
[++idx
]->arg
;
10687 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10688 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
10689 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10692 /* get subgroup id, if provided */
10694 if (argv
[idx
]->type
== VARIABLE_TKN
)
10695 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
10697 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
10700 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
10701 show_bgp_instance_all_ipv6_updgrps_cmd
,
10702 "show [ip] bgp <view|vrf> all update-groups",
10706 BGP_INSTANCE_ALL_HELP_STR
10707 "Detailed info about dynamic update groups\n")
10709 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
10710 return CMD_SUCCESS
;
10713 DEFUN (show_bgp_updgrps_stats
,
10714 show_bgp_updgrps_stats_cmd
,
10715 "show [ip] bgp update-groups statistics",
10719 "Detailed info about dynamic update groups\n"
10724 bgp
= bgp_get_default();
10726 update_group_show_stats(bgp
, vty
);
10728 return CMD_SUCCESS
;
10731 DEFUN (show_bgp_instance_updgrps_stats
,
10732 show_bgp_instance_updgrps_stats_cmd
,
10733 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
10737 BGP_INSTANCE_HELP_STR
10738 "Detailed info about dynamic update groups\n"
10744 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
10746 update_group_show_stats(bgp
, vty
);
10748 return CMD_SUCCESS
;
10751 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
10752 afi_t afi
, safi_t safi
,
10753 const char *what
, uint64_t subgrp_id
)
10758 bgp
= bgp_lookup_by_name(name
);
10760 bgp
= bgp_get_default();
10763 if (!strcmp(what
, "advertise-queue"))
10764 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
10766 else if (!strcmp(what
, "advertised-routes"))
10767 update_group_show_advertised(bgp
, afi
, safi
, vty
,
10769 else if (!strcmp(what
, "packet-queue"))
10770 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
10775 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
10776 show_ip_bgp_instance_updgrps_adj_s_cmd
,
10777 "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",
10778 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
10780 "Detailed info about dynamic update groups\n"
10781 "Specific subgroup to display info for\n"
10782 "Advertisement queue\n"
10783 "Announced routes\n"
10786 uint64_t subgrp_id
= 0;
10790 subgrp_id
= strtoull(sgid
, NULL
, 10);
10795 afiz
= bgp_vty_afi_from_str(afi
);
10799 afiz
= bgp_vty_afi_from_str(afi
);
10800 if (afiz
!= AFI_IP
)
10802 "%% Cannot specify both 'ip' and 'ipv6'\n");
10803 return CMD_WARNING
;
10806 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
10808 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
10809 return CMD_SUCCESS
;
10812 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
10814 struct listnode
*node
, *nnode
;
10815 struct prefix
*range
;
10818 char buf
[PREFIX2STR_BUFFER
];
10821 const char *peer_status
;
10822 const char *af_str
;
10827 conf
= group
->conf
;
10829 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
10830 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10832 } else if (conf
->as_type
== AS_INTERNAL
) {
10833 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10836 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
10839 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
10840 vty_out(vty
, " Peer-group type is internal\n");
10842 vty_out(vty
, " Peer-group type is external\n");
10844 /* Display AFs configured. */
10845 vty_out(vty
, " Configured address-families:");
10846 FOREACH_AFI_SAFI (afi
, safi
) {
10847 if (conf
->afc
[afi
][safi
]) {
10849 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
10853 vty_out(vty
, " none\n");
10855 vty_out(vty
, "\n");
10857 /* Display listen ranges (for dynamic neighbors), if any */
10858 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
10861 else if (afi
== AFI_IP6
)
10865 lr_count
= listcount(group
->listen_range
[afi
]);
10867 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
10871 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
10873 prefix2str(range
, buf
, sizeof(buf
));
10874 vty_out(vty
, " %s\n", buf
);
10879 /* Display group members and their status */
10880 if (listcount(group
->peer
)) {
10881 vty_out(vty
, " Peer-group members:\n");
10882 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
10883 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
10884 peer_status
= "Idle (Admin)";
10885 else if (CHECK_FLAG(peer
->sflags
,
10886 PEER_STATUS_PREFIX_OVERFLOW
))
10887 peer_status
= "Idle (PfxCt)";
10889 peer_status
= lookup_msg(bgp_status_msg
,
10890 peer
->status
, NULL
);
10892 dynamic
= peer_dynamic_neighbor(peer
);
10893 vty_out(vty
, " %s %s %s \n", peer
->host
,
10894 dynamic
? "(dynamic)" : "", peer_status
);
10898 return CMD_SUCCESS
;
10901 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
10902 const char *group_name
)
10905 struct listnode
*node
, *nnode
;
10906 struct peer_group
*group
;
10907 bool found
= false;
10909 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
10912 vty_out(vty
, "%% No such BGP instance exists\n");
10913 return CMD_WARNING
;
10916 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
10918 if (strmatch(group
->name
, group_name
)) {
10919 bgp_show_one_peer_group(vty
, group
);
10924 bgp_show_one_peer_group(vty
, group
);
10928 if (group_name
&& !found
)
10929 vty_out(vty
, "%% No such peer-group\n");
10931 return CMD_SUCCESS
;
10934 DEFUN (show_ip_bgp_peer_groups
,
10935 show_ip_bgp_peer_groups_cmd
,
10936 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
10940 BGP_INSTANCE_HELP_STR
10941 "Detailed information on BGP peer groups\n"
10942 "Peer group name\n")
10948 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
10950 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
10952 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
10956 /* Redistribute VTY commands. */
10958 DEFUN (bgp_redistribute_ipv4
,
10959 bgp_redistribute_ipv4_cmd
,
10960 "redistribute " FRR_IP_REDIST_STR_BGPD
,
10961 "Redistribute information from another routing protocol\n"
10962 FRR_IP_REDIST_HELP_STR_BGPD
)
10964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10965 int idx_protocol
= 1;
10968 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10970 vty_out(vty
, "%% Invalid route type\n");
10971 return CMD_WARNING_CONFIG_FAILED
;
10974 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10975 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10979 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
10980 "redistribute " FRR_IP_REDIST_STR_BGPD
,
10981 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
10983 DEFUN (bgp_redistribute_ipv4_rmap
,
10984 bgp_redistribute_ipv4_rmap_cmd
,
10985 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
10986 "Redistribute information from another routing protocol\n"
10987 FRR_IP_REDIST_HELP_STR_BGPD
10988 "Route map reference\n"
10989 "Pointer to route-map entries\n")
10991 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10992 int idx_protocol
= 1;
10995 struct bgp_redist
*red
;
10997 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10999 vty_out(vty
, "%% Invalid route type\n");
11000 return CMD_WARNING_CONFIG_FAILED
;
11003 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11004 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11005 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11009 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11010 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11011 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11012 "Route map reference\n"
11013 "Pointer to route-map entries\n")
11015 DEFUN (bgp_redistribute_ipv4_metric
,
11016 bgp_redistribute_ipv4_metric_cmd
,
11017 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11018 "Redistribute information from another routing protocol\n"
11019 FRR_IP_REDIST_HELP_STR_BGPD
11020 "Metric for redistributed routes\n"
11021 "Default metric\n")
11023 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11024 int idx_protocol
= 1;
11025 int idx_number
= 3;
11028 struct bgp_redist
*red
;
11030 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11032 vty_out(vty
, "%% Invalid route type\n");
11033 return CMD_WARNING_CONFIG_FAILED
;
11035 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11037 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11038 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11039 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11043 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11044 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11045 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11046 "Metric for redistributed routes\n"
11047 "Default metric\n")
11049 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11050 bgp_redistribute_ipv4_rmap_metric_cmd
,
11051 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11052 "Redistribute information from another routing protocol\n"
11053 FRR_IP_REDIST_HELP_STR_BGPD
11054 "Route map reference\n"
11055 "Pointer to route-map entries\n"
11056 "Metric for redistributed routes\n"
11057 "Default metric\n")
11059 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11060 int idx_protocol
= 1;
11062 int idx_number
= 5;
11065 struct bgp_redist
*red
;
11067 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11069 vty_out(vty
, "%% Invalid route type\n");
11070 return CMD_WARNING_CONFIG_FAILED
;
11072 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11074 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11075 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11076 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11077 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11081 bgp_redistribute_ipv4_rmap_metric
,
11082 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11083 "redistribute " FRR_IP_REDIST_STR_BGPD
11084 " route-map WORD metric (0-4294967295)",
11085 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11086 "Route map reference\n"
11087 "Pointer to route-map entries\n"
11088 "Metric for redistributed routes\n"
11089 "Default metric\n")
11091 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11092 bgp_redistribute_ipv4_metric_rmap_cmd
,
11093 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11094 "Redistribute information from another routing protocol\n"
11095 FRR_IP_REDIST_HELP_STR_BGPD
11096 "Metric for redistributed routes\n"
11098 "Route map reference\n"
11099 "Pointer to route-map entries\n")
11101 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11102 int idx_protocol
= 1;
11103 int idx_number
= 3;
11107 struct bgp_redist
*red
;
11109 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11111 vty_out(vty
, "%% Invalid route type\n");
11112 return CMD_WARNING_CONFIG_FAILED
;
11114 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11116 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11117 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11118 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11119 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11123 bgp_redistribute_ipv4_metric_rmap
,
11124 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11125 "redistribute " FRR_IP_REDIST_STR_BGPD
11126 " metric (0-4294967295) route-map WORD",
11127 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11128 "Metric for redistributed routes\n"
11130 "Route map reference\n"
11131 "Pointer to route-map entries\n")
11133 DEFUN (bgp_redistribute_ipv4_ospf
,
11134 bgp_redistribute_ipv4_ospf_cmd
,
11135 "redistribute <ospf|table> (1-65535)",
11136 "Redistribute information from another routing protocol\n"
11137 "Open Shortest Path First (OSPFv2)\n"
11138 "Non-main Kernel Routing Table\n"
11139 "Instance ID/Table ID\n")
11141 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11142 int idx_ospf_table
= 1;
11143 int idx_number
= 2;
11147 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11149 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11150 protocol
= ZEBRA_ROUTE_OSPF
;
11152 protocol
= ZEBRA_ROUTE_TABLE
;
11154 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11155 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11158 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11159 "redistribute <ospf|table> (1-65535)",
11160 "Redistribute information from another routing protocol\n"
11161 "Open Shortest Path First (OSPFv2)\n"
11162 "Non-main Kernel Routing Table\n"
11163 "Instance ID/Table ID\n")
11165 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11166 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11167 "redistribute <ospf|table> (1-65535) route-map WORD",
11168 "Redistribute information from another routing protocol\n"
11169 "Open Shortest Path First (OSPFv2)\n"
11170 "Non-main Kernel Routing Table\n"
11171 "Instance ID/Table ID\n"
11172 "Route map reference\n"
11173 "Pointer to route-map entries\n")
11175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11176 int idx_ospf_table
= 1;
11177 int idx_number
= 2;
11179 struct bgp_redist
*red
;
11183 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11184 protocol
= ZEBRA_ROUTE_OSPF
;
11186 protocol
= ZEBRA_ROUTE_TABLE
;
11188 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11189 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11190 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11191 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11194 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11195 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11196 "redistribute <ospf|table> (1-65535) route-map WORD",
11197 "Redistribute information from another routing protocol\n"
11198 "Open Shortest Path First (OSPFv2)\n"
11199 "Non-main Kernel Routing Table\n"
11200 "Instance ID/Table ID\n"
11201 "Route map reference\n"
11202 "Pointer to route-map entries\n")
11204 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11205 bgp_redistribute_ipv4_ospf_metric_cmd
,
11206 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11207 "Redistribute information from another routing protocol\n"
11208 "Open Shortest Path First (OSPFv2)\n"
11209 "Non-main Kernel Routing Table\n"
11210 "Instance ID/Table ID\n"
11211 "Metric for redistributed routes\n"
11212 "Default metric\n")
11214 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11215 int idx_ospf_table
= 1;
11216 int idx_number
= 2;
11217 int idx_number_2
= 4;
11219 struct bgp_redist
*red
;
11223 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11224 protocol
= ZEBRA_ROUTE_OSPF
;
11226 protocol
= ZEBRA_ROUTE_TABLE
;
11228 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11229 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11231 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11232 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11233 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11236 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11237 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11238 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11239 "Redistribute information from another routing protocol\n"
11240 "Open Shortest Path First (OSPFv2)\n"
11241 "Non-main Kernel Routing Table\n"
11242 "Instance ID/Table ID\n"
11243 "Metric for redistributed routes\n"
11244 "Default metric\n")
11246 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11247 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11248 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11249 "Redistribute information from another routing protocol\n"
11250 "Open Shortest Path First (OSPFv2)\n"
11251 "Non-main Kernel Routing Table\n"
11252 "Instance ID/Table ID\n"
11253 "Route map reference\n"
11254 "Pointer to route-map entries\n"
11255 "Metric for redistributed routes\n"
11256 "Default metric\n")
11258 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11259 int idx_ospf_table
= 1;
11260 int idx_number
= 2;
11262 int idx_number_2
= 6;
11264 struct bgp_redist
*red
;
11268 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11269 protocol
= ZEBRA_ROUTE_OSPF
;
11271 protocol
= ZEBRA_ROUTE_TABLE
;
11273 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11274 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11276 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11277 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11278 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11279 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11283 bgp_redistribute_ipv4_ospf_rmap_metric
,
11284 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11285 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11286 "Redistribute information from another routing protocol\n"
11287 "Open Shortest Path First (OSPFv2)\n"
11288 "Non-main Kernel Routing Table\n"
11289 "Instance ID/Table ID\n"
11290 "Route map reference\n"
11291 "Pointer to route-map entries\n"
11292 "Metric for redistributed routes\n"
11293 "Default metric\n")
11295 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11296 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11297 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11298 "Redistribute information from another routing protocol\n"
11299 "Open Shortest Path First (OSPFv2)\n"
11300 "Non-main Kernel Routing Table\n"
11301 "Instance ID/Table ID\n"
11302 "Metric for redistributed routes\n"
11304 "Route map reference\n"
11305 "Pointer to route-map entries\n")
11307 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11308 int idx_ospf_table
= 1;
11309 int idx_number
= 2;
11310 int idx_number_2
= 4;
11313 struct bgp_redist
*red
;
11317 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11318 protocol
= ZEBRA_ROUTE_OSPF
;
11320 protocol
= ZEBRA_ROUTE_TABLE
;
11322 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11323 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11325 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11326 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11327 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11328 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11332 bgp_redistribute_ipv4_ospf_metric_rmap
,
11333 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11334 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11335 "Redistribute information from another routing protocol\n"
11336 "Open Shortest Path First (OSPFv2)\n"
11337 "Non-main Kernel Routing Table\n"
11338 "Instance ID/Table ID\n"
11339 "Metric for redistributed routes\n"
11341 "Route map reference\n"
11342 "Pointer to route-map entries\n")
11344 DEFUN (no_bgp_redistribute_ipv4_ospf
,
11345 no_bgp_redistribute_ipv4_ospf_cmd
,
11346 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11348 "Redistribute information from another routing protocol\n"
11349 "Open Shortest Path First (OSPFv2)\n"
11350 "Non-main Kernel Routing Table\n"
11351 "Instance ID/Table ID\n"
11352 "Metric for redistributed routes\n"
11354 "Route map reference\n"
11355 "Pointer to route-map entries\n")
11357 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11358 int idx_ospf_table
= 2;
11359 int idx_number
= 3;
11363 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11364 protocol
= ZEBRA_ROUTE_OSPF
;
11366 protocol
= ZEBRA_ROUTE_TABLE
;
11368 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11369 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
11373 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
11374 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11376 "Redistribute information from another routing protocol\n"
11377 "Open Shortest Path First (OSPFv2)\n"
11378 "Non-main Kernel Routing Table\n"
11379 "Instance ID/Table ID\n"
11380 "Metric for redistributed routes\n"
11382 "Route map reference\n"
11383 "Pointer to route-map entries\n")
11385 DEFUN (no_bgp_redistribute_ipv4
,
11386 no_bgp_redistribute_ipv4_cmd
,
11387 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11389 "Redistribute information from another routing protocol\n"
11390 FRR_IP_REDIST_HELP_STR_BGPD
11391 "Metric for redistributed routes\n"
11393 "Route map reference\n"
11394 "Pointer to route-map entries\n")
11396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11397 int idx_protocol
= 2;
11400 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11402 vty_out(vty
, "%% Invalid route type\n");
11403 return CMD_WARNING_CONFIG_FAILED
;
11405 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
11409 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
11410 "no redistribute " FRR_IP_REDIST_STR_BGPD
11411 " [metric (0-4294967295)] [route-map WORD]",
11413 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11414 "Metric for redistributed routes\n"
11416 "Route map reference\n"
11417 "Pointer to route-map entries\n")
11419 DEFUN (bgp_redistribute_ipv6
,
11420 bgp_redistribute_ipv6_cmd
,
11421 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11422 "Redistribute information from another routing protocol\n"
11423 FRR_IP6_REDIST_HELP_STR_BGPD
)
11425 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11426 int idx_protocol
= 1;
11429 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11431 vty_out(vty
, "%% Invalid route type\n");
11432 return CMD_WARNING_CONFIG_FAILED
;
11435 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11436 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11439 DEFUN (bgp_redistribute_ipv6_rmap
,
11440 bgp_redistribute_ipv6_rmap_cmd
,
11441 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
11442 "Redistribute information from another routing protocol\n"
11443 FRR_IP6_REDIST_HELP_STR_BGPD
11444 "Route map reference\n"
11445 "Pointer to route-map entries\n")
11447 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11448 int idx_protocol
= 1;
11451 struct bgp_redist
*red
;
11453 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11455 vty_out(vty
, "%% Invalid route type\n");
11456 return CMD_WARNING_CONFIG_FAILED
;
11459 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11460 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11461 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11464 DEFUN (bgp_redistribute_ipv6_metric
,
11465 bgp_redistribute_ipv6_metric_cmd
,
11466 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
11467 "Redistribute information from another routing protocol\n"
11468 FRR_IP6_REDIST_HELP_STR_BGPD
11469 "Metric for redistributed routes\n"
11470 "Default metric\n")
11472 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11473 int idx_protocol
= 1;
11474 int idx_number
= 3;
11477 struct bgp_redist
*red
;
11479 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11481 vty_out(vty
, "%% Invalid route type\n");
11482 return CMD_WARNING_CONFIG_FAILED
;
11484 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11486 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11487 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11488 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11491 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
11492 bgp_redistribute_ipv6_rmap_metric_cmd
,
11493 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11494 "Redistribute information from another routing protocol\n"
11495 FRR_IP6_REDIST_HELP_STR_BGPD
11496 "Route map reference\n"
11497 "Pointer to route-map entries\n"
11498 "Metric for redistributed routes\n"
11499 "Default metric\n")
11501 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11502 int idx_protocol
= 1;
11504 int idx_number
= 5;
11507 struct bgp_redist
*red
;
11509 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11511 vty_out(vty
, "%% Invalid route type\n");
11512 return CMD_WARNING_CONFIG_FAILED
;
11514 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11516 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11517 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11518 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11519 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11522 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
11523 bgp_redistribute_ipv6_metric_rmap_cmd
,
11524 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11525 "Redistribute information from another routing protocol\n"
11526 FRR_IP6_REDIST_HELP_STR_BGPD
11527 "Metric for redistributed routes\n"
11529 "Route map reference\n"
11530 "Pointer to route-map entries\n")
11532 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11533 int idx_protocol
= 1;
11534 int idx_number
= 3;
11538 struct bgp_redist
*red
;
11540 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11542 vty_out(vty
, "%% Invalid route type\n");
11543 return CMD_WARNING_CONFIG_FAILED
;
11545 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11547 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11548 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
11549 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11550 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11553 DEFUN (no_bgp_redistribute_ipv6
,
11554 no_bgp_redistribute_ipv6_cmd
,
11555 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11557 "Redistribute information from another routing protocol\n"
11558 FRR_IP6_REDIST_HELP_STR_BGPD
11559 "Metric for redistributed routes\n"
11561 "Route map reference\n"
11562 "Pointer to route-map entries\n")
11564 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11565 int idx_protocol
= 2;
11568 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11570 vty_out(vty
, "%% Invalid route type\n");
11571 return CMD_WARNING_CONFIG_FAILED
;
11574 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
11577 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
11582 /* Unicast redistribution only. */
11583 if (safi
!= SAFI_UNICAST
)
11586 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
11587 /* Redistribute BGP does not make sense. */
11588 if (i
!= ZEBRA_ROUTE_BGP
) {
11589 struct list
*red_list
;
11590 struct listnode
*node
;
11591 struct bgp_redist
*red
;
11593 red_list
= bgp
->redist
[afi
][i
];
11597 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
11598 /* "redistribute" configuration. */
11599 vty_out(vty
, " redistribute %s",
11600 zebra_route_string(i
));
11602 vty_out(vty
, " %d", red
->instance
);
11603 if (red
->redist_metric_flag
)
11604 vty_out(vty
, " metric %u",
11605 red
->redist_metric
);
11606 if (red
->rmap
.name
)
11607 vty_out(vty
, " route-map %s",
11609 vty_out(vty
, "\n");
11615 /* This is part of the address-family block (unicast only) */
11616 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
11621 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
11622 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
11623 bgp
->vpn_policy
[afi
].tovpn_label
);
11625 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
11626 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
11627 char buf
[RD_ADDRSTRLEN
];
11628 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
11629 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
11632 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
11633 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
11635 char buf
[PREFIX_STRLEN
];
11636 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
11637 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
11640 vty_out(vty
, "%*snexthop vpn export %s\n",
11644 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
11645 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
11647 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
11648 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
11650 char *b
= ecommunity_ecom2str(
11651 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
11652 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
11653 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
11654 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
11656 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
11657 char *b
= ecommunity_ecom2str(
11658 bgp
->vpn_policy
[afi
]
11659 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
11660 ECOMMUNITY_FORMAT_ROUTE_MAP
,
11661 ECOMMUNITY_ROUTE_TARGET
);
11662 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
11663 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
11665 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
11666 char *b
= ecommunity_ecom2str(
11667 bgp
->vpn_policy
[afi
]
11668 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
11669 ECOMMUNITY_FORMAT_ROUTE_MAP
,
11670 ECOMMUNITY_ROUTE_TARGET
);
11671 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
11672 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
11675 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
11676 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
11677 bgp
->vpn_policy
[afi
]
11678 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
11680 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]) {
11681 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
11682 bgp
->vpn_policy
[afi
]
11683 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
11689 /* BGP node structure. */
11690 static struct cmd_node bgp_node
= {
11691 BGP_NODE
, "%s(config-router)# ", 1,
11694 static struct cmd_node bgp_ipv4_unicast_node
= {
11695 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
11698 static struct cmd_node bgp_ipv4_multicast_node
= {
11699 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
11702 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
11703 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
11706 static struct cmd_node bgp_ipv6_unicast_node
= {
11707 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
11710 static struct cmd_node bgp_ipv6_multicast_node
= {
11711 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
11714 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
11715 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
11718 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
11719 "%s(config-router-af)# ", 1};
11721 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
11722 "%s(config-router-af-vpnv6)# ", 1};
11724 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
11725 "%s(config-router-evpn)# ", 1};
11727 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
11728 "%s(config-router-af-vni)# ", 1};
11730 static void community_list_vty(void);
11732 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
11736 struct peer_group
*group
;
11737 struct listnode
*lnbgp
, *lnpeer
;
11739 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
11740 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
11741 /* only provide suggestions on the appropriate input
11743 * they'll otherwise show up multiple times */
11744 enum cmd_token_type match_type
;
11745 char *name
= peer
->host
;
11747 if (peer
->conf_if
) {
11748 match_type
= VARIABLE_TKN
;
11749 name
= peer
->conf_if
;
11750 } else if (strchr(peer
->host
, ':'))
11751 match_type
= IPV6_TKN
;
11753 match_type
= IPV4_TKN
;
11755 if (token
->type
!= match_type
)
11758 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
11761 if (token
->type
== VARIABLE_TKN
)
11762 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
11763 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
11768 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
11769 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
11770 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
11771 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
11772 {.completions
= NULL
}};
11774 void bgp_vty_init(void)
11776 cmd_variable_handler_register(bgp_var_neighbor
);
11778 /* Install bgp top node. */
11779 install_node(&bgp_node
, bgp_config_write
);
11780 install_node(&bgp_ipv4_unicast_node
, NULL
);
11781 install_node(&bgp_ipv4_multicast_node
, NULL
);
11782 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
11783 install_node(&bgp_ipv6_unicast_node
, NULL
);
11784 install_node(&bgp_ipv6_multicast_node
, NULL
);
11785 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
11786 install_node(&bgp_vpnv4_node
, NULL
);
11787 install_node(&bgp_vpnv6_node
, NULL
);
11788 install_node(&bgp_evpn_node
, NULL
);
11789 install_node(&bgp_evpn_vni_node
, NULL
);
11791 /* Install default VTY commands to new nodes. */
11792 install_default(BGP_NODE
);
11793 install_default(BGP_IPV4_NODE
);
11794 install_default(BGP_IPV4M_NODE
);
11795 install_default(BGP_IPV4L_NODE
);
11796 install_default(BGP_IPV6_NODE
);
11797 install_default(BGP_IPV6M_NODE
);
11798 install_default(BGP_IPV6L_NODE
);
11799 install_default(BGP_VPNV4_NODE
);
11800 install_default(BGP_VPNV6_NODE
);
11801 install_default(BGP_EVPN_NODE
);
11802 install_default(BGP_EVPN_VNI_NODE
);
11804 /* "bgp multiple-instance" commands. */
11805 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
11806 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
11808 /* "bgp config-type" commands. */
11809 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
11810 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
11812 /* bgp route-map delay-timer commands. */
11813 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
11814 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
11816 /* Dummy commands (Currently not supported) */
11817 install_element(BGP_NODE
, &no_synchronization_cmd
);
11818 install_element(BGP_NODE
, &no_auto_summary_cmd
);
11820 /* "router bgp" commands. */
11821 install_element(CONFIG_NODE
, &router_bgp_cmd
);
11823 /* "no router bgp" commands. */
11824 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
11826 /* "bgp router-id" commands. */
11827 install_element(BGP_NODE
, &bgp_router_id_cmd
);
11828 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
11830 /* "bgp cluster-id" commands. */
11831 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
11832 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
11834 /* "bgp confederation" commands. */
11835 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
11836 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
11838 /* "bgp confederation peers" commands. */
11839 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
11840 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
11842 /* bgp max-med command */
11843 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
11844 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
11845 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
11846 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
11847 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
11849 /* bgp disable-ebgp-connected-nh-check */
11850 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
11851 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
11853 /* bgp update-delay command */
11854 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
11855 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
11856 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
11858 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
11859 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
11860 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
11861 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
11863 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
11864 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
11866 /* "maximum-paths" commands. */
11867 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
11868 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
11869 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
11870 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
11871 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
11872 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
11873 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
11874 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
11875 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
11876 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
11877 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11878 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11879 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
11880 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11881 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11883 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
11884 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
11885 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
11886 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11887 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11889 /* "timers bgp" commands. */
11890 install_element(BGP_NODE
, &bgp_timers_cmd
);
11891 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
11893 /* route-map delay-timer commands - per instance for backwards compat.
11895 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
11896 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
11898 /* "bgp client-to-client reflection" commands */
11899 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
11900 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
11902 /* "bgp always-compare-med" commands */
11903 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
11904 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
11906 /* "bgp deterministic-med" commands */
11907 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
11908 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
11910 /* "bgp graceful-restart" commands */
11911 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
11912 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
11913 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
11914 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
11915 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
11916 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
11918 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
11919 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
11921 /* "bgp graceful-shutdown" commands */
11922 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
11923 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
11925 /* "bgp fast-external-failover" commands */
11926 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
11927 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
11929 /* "bgp enforce-first-as" commands */
11930 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
11931 install_element(BGP_NODE
, &no_bgp_enforce_first_as_cmd
);
11933 /* "bgp bestpath compare-routerid" commands */
11934 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
11935 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
11937 /* "bgp bestpath as-path ignore" commands */
11938 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
11939 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
11941 /* "bgp bestpath as-path confed" commands */
11942 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
11943 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
11945 /* "bgp bestpath as-path multipath-relax" commands */
11946 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
11947 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
11949 /* "bgp log-neighbor-changes" commands */
11950 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
11951 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
11953 /* "bgp bestpath med" commands */
11954 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
11955 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
11957 /* "no bgp default ipv4-unicast" commands. */
11958 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
11959 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
11961 /* "bgp network import-check" commands. */
11962 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
11963 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
11964 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
11966 /* "bgp default local-preference" commands. */
11967 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
11968 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
11970 /* bgp default show-hostname */
11971 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
11972 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
11974 /* "bgp default subgroup-pkt-queue-max" commands. */
11975 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
11976 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
11978 /* bgp ibgp-allow-policy-mods command */
11979 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
11980 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
11982 /* "bgp listen limit" commands. */
11983 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
11984 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
11986 /* "bgp listen range" commands. */
11987 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
11988 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
11990 /* "bgp default shutdown" command */
11991 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
11993 /* "neighbor remote-as" commands. */
11994 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
11995 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
11996 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
11997 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
11998 install_element(BGP_NODE
,
11999 &neighbor_interface_v6only_config_remote_as_cmd
);
12000 install_element(BGP_NODE
, &no_neighbor_cmd
);
12001 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12003 /* "neighbor peer-group" commands. */
12004 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12005 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12006 install_element(BGP_NODE
,
12007 &no_neighbor_interface_peer_group_remote_as_cmd
);
12009 /* "neighbor local-as" commands. */
12010 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12011 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12012 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12013 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12015 /* "neighbor solo" commands. */
12016 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12017 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12019 /* "neighbor password" commands. */
12020 install_element(BGP_NODE
, &neighbor_password_cmd
);
12021 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12023 /* "neighbor activate" commands. */
12024 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12025 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12026 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12027 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12028 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12029 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12030 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12031 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12032 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12033 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12035 /* "no neighbor activate" commands. */
12036 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12037 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12038 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12039 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12040 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12041 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12042 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12043 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12044 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12045 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12047 /* "neighbor peer-group" set commands. */
12048 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12049 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12050 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12051 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12052 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12053 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12054 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12055 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12057 /* "no neighbor peer-group unset" commands. */
12058 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12059 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12060 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12061 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12062 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12063 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12064 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12065 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12067 /* "neighbor softreconfiguration inbound" commands.*/
12068 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12069 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12070 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12071 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12072 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12073 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12074 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12075 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12076 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12077 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12078 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12079 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12080 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12081 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12082 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12083 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12084 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12085 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12087 /* "neighbor attribute-unchanged" commands. */
12088 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12089 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12090 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12091 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12092 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12093 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12094 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12095 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12096 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12097 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12098 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12099 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12100 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12101 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12102 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12103 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12104 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12105 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12107 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12108 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12110 /* "nexthop-local unchanged" commands */
12111 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12112 install_element(BGP_IPV6_NODE
,
12113 &no_neighbor_nexthop_local_unchanged_cmd
);
12115 /* "neighbor next-hop-self" commands. */
12116 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12117 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12118 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12119 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12120 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12121 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12122 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12123 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12124 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12125 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12126 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12127 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12128 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12129 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12130 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12131 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12132 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12133 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12135 /* "neighbor next-hop-self force" commands. */
12136 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12137 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12138 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12139 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12140 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12141 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12142 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12143 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12144 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12145 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12146 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12147 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12148 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12149 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12150 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12151 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12152 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12153 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12155 /* "neighbor as-override" commands. */
12156 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12157 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12158 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12159 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12160 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12161 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12162 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12163 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12164 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12165 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12166 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12167 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12168 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12169 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12170 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12171 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12172 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12173 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12175 /* "neighbor remove-private-AS" commands. */
12176 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12177 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12178 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12179 install_element(BGP_NODE
,
12180 &no_neighbor_remove_private_as_all_hidden_cmd
);
12181 install_element(BGP_NODE
,
12182 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12183 install_element(BGP_NODE
,
12184 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12185 install_element(BGP_NODE
,
12186 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12189 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12190 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12191 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12192 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12193 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12194 install_element(BGP_IPV4_NODE
,
12195 &neighbor_remove_private_as_replace_as_cmd
);
12196 install_element(BGP_IPV4_NODE
,
12197 &no_neighbor_remove_private_as_replace_as_cmd
);
12198 install_element(BGP_IPV4_NODE
,
12199 &neighbor_remove_private_as_all_replace_as_cmd
);
12200 install_element(BGP_IPV4_NODE
,
12201 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12202 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12203 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12204 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12205 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12206 install_element(BGP_IPV4M_NODE
,
12207 &neighbor_remove_private_as_replace_as_cmd
);
12208 install_element(BGP_IPV4M_NODE
,
12209 &no_neighbor_remove_private_as_replace_as_cmd
);
12210 install_element(BGP_IPV4M_NODE
,
12211 &neighbor_remove_private_as_all_replace_as_cmd
);
12212 install_element(BGP_IPV4M_NODE
,
12213 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12214 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12215 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12216 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12217 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12218 install_element(BGP_IPV4L_NODE
,
12219 &neighbor_remove_private_as_replace_as_cmd
);
12220 install_element(BGP_IPV4L_NODE
,
12221 &no_neighbor_remove_private_as_replace_as_cmd
);
12222 install_element(BGP_IPV4L_NODE
,
12223 &neighbor_remove_private_as_all_replace_as_cmd
);
12224 install_element(BGP_IPV4L_NODE
,
12225 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12226 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12227 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12228 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12229 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12230 install_element(BGP_IPV6_NODE
,
12231 &neighbor_remove_private_as_replace_as_cmd
);
12232 install_element(BGP_IPV6_NODE
,
12233 &no_neighbor_remove_private_as_replace_as_cmd
);
12234 install_element(BGP_IPV6_NODE
,
12235 &neighbor_remove_private_as_all_replace_as_cmd
);
12236 install_element(BGP_IPV6_NODE
,
12237 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12238 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12239 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12240 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12241 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12242 install_element(BGP_IPV6M_NODE
,
12243 &neighbor_remove_private_as_replace_as_cmd
);
12244 install_element(BGP_IPV6M_NODE
,
12245 &no_neighbor_remove_private_as_replace_as_cmd
);
12246 install_element(BGP_IPV6M_NODE
,
12247 &neighbor_remove_private_as_all_replace_as_cmd
);
12248 install_element(BGP_IPV6M_NODE
,
12249 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12250 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12251 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12252 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12253 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12254 install_element(BGP_IPV6L_NODE
,
12255 &neighbor_remove_private_as_replace_as_cmd
);
12256 install_element(BGP_IPV6L_NODE
,
12257 &no_neighbor_remove_private_as_replace_as_cmd
);
12258 install_element(BGP_IPV6L_NODE
,
12259 &neighbor_remove_private_as_all_replace_as_cmd
);
12260 install_element(BGP_IPV6L_NODE
,
12261 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12262 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
12263 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12264 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12265 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12266 install_element(BGP_VPNV4_NODE
,
12267 &neighbor_remove_private_as_replace_as_cmd
);
12268 install_element(BGP_VPNV4_NODE
,
12269 &no_neighbor_remove_private_as_replace_as_cmd
);
12270 install_element(BGP_VPNV4_NODE
,
12271 &neighbor_remove_private_as_all_replace_as_cmd
);
12272 install_element(BGP_VPNV4_NODE
,
12273 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12274 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
12275 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12276 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12277 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12278 install_element(BGP_VPNV6_NODE
,
12279 &neighbor_remove_private_as_replace_as_cmd
);
12280 install_element(BGP_VPNV6_NODE
,
12281 &no_neighbor_remove_private_as_replace_as_cmd
);
12282 install_element(BGP_VPNV6_NODE
,
12283 &neighbor_remove_private_as_all_replace_as_cmd
);
12284 install_element(BGP_VPNV6_NODE
,
12285 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12287 /* "neighbor send-community" commands.*/
12288 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
12289 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
12290 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
12291 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
12292 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
12293 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
12294 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
12295 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
12296 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
12297 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
12298 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
12299 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
12300 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
12301 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
12302 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
12303 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
12304 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
12305 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
12306 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
12307 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
12308 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
12309 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
12310 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
12311 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
12312 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
12313 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
12314 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
12315 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
12316 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
12317 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
12318 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
12319 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
12320 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
12321 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
12322 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
12323 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
12325 /* "neighbor route-reflector" commands.*/
12326 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
12327 install_element(BGP_NODE
,
12328 &no_neighbor_route_reflector_client_hidden_cmd
);
12329 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
12330 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
12331 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
12332 install_element(BGP_IPV4M_NODE
,
12333 &no_neighbor_route_reflector_client_cmd
);
12334 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
12335 install_element(BGP_IPV4L_NODE
,
12336 &no_neighbor_route_reflector_client_cmd
);
12337 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
12338 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
12339 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
12340 install_element(BGP_IPV6M_NODE
,
12341 &no_neighbor_route_reflector_client_cmd
);
12342 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
12343 install_element(BGP_IPV6L_NODE
,
12344 &no_neighbor_route_reflector_client_cmd
);
12345 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
12346 install_element(BGP_VPNV4_NODE
,
12347 &no_neighbor_route_reflector_client_cmd
);
12348 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
12349 install_element(BGP_VPNV6_NODE
,
12350 &no_neighbor_route_reflector_client_cmd
);
12351 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
12352 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
12354 /* "neighbor route-server" commands.*/
12355 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
12356 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
12357 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
12358 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
12359 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
12360 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
12361 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
12362 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
12363 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
12364 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
12365 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
12366 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
12367 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
12368 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
12369 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
12370 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
12371 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
12372 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
12374 /* "neighbor addpath-tx-all-paths" commands.*/
12375 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
12376 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
12377 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12378 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12379 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12380 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12381 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12382 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12383 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12384 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12385 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12386 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12387 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12388 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12389 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12390 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12391 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12392 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12394 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
12395 install_element(BGP_NODE
,
12396 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12397 install_element(BGP_NODE
,
12398 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12399 install_element(BGP_IPV4_NODE
,
12400 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12401 install_element(BGP_IPV4_NODE
,
12402 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12403 install_element(BGP_IPV4M_NODE
,
12404 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12405 install_element(BGP_IPV4M_NODE
,
12406 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12407 install_element(BGP_IPV4L_NODE
,
12408 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12409 install_element(BGP_IPV4L_NODE
,
12410 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12411 install_element(BGP_IPV6_NODE
,
12412 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12413 install_element(BGP_IPV6_NODE
,
12414 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12415 install_element(BGP_IPV6M_NODE
,
12416 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12417 install_element(BGP_IPV6M_NODE
,
12418 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12419 install_element(BGP_IPV6L_NODE
,
12420 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12421 install_element(BGP_IPV6L_NODE
,
12422 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12423 install_element(BGP_VPNV4_NODE
,
12424 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12425 install_element(BGP_VPNV4_NODE
,
12426 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12427 install_element(BGP_VPNV6_NODE
,
12428 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12429 install_element(BGP_VPNV6_NODE
,
12430 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12432 /* "neighbor passive" commands. */
12433 install_element(BGP_NODE
, &neighbor_passive_cmd
);
12434 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
12437 /* "neighbor shutdown" commands. */
12438 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
12439 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
12440 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
12441 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
12443 /* "neighbor capability extended-nexthop" commands.*/
12444 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
12445 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
12447 /* "neighbor capability orf prefix-list" commands.*/
12448 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
12449 install_element(BGP_NODE
,
12450 &no_neighbor_capability_orf_prefix_hidden_cmd
);
12451 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
12452 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12453 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
12454 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12455 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
12456 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12457 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
12458 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12459 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
12460 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12461 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
12462 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12464 /* "neighbor capability dynamic" commands.*/
12465 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
12466 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
12468 /* "neighbor dont-capability-negotiate" commands. */
12469 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
12470 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
12472 /* "neighbor ebgp-multihop" commands. */
12473 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
12474 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
12475 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
12477 /* "neighbor disable-connected-check" commands. */
12478 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
12479 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
12481 /* "neighbor description" commands. */
12482 install_element(BGP_NODE
, &neighbor_description_cmd
);
12483 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
12485 /* "neighbor update-source" commands. "*/
12486 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
12487 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
12489 /* "neighbor default-originate" commands. */
12490 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
12491 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
12492 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
12493 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
12494 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
12495 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
12496 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
12497 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
12498 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
12499 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
12500 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
12501 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
12502 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
12503 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
12504 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
12505 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
12506 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
12507 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
12508 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
12509 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
12510 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
12512 /* "neighbor port" commands. */
12513 install_element(BGP_NODE
, &neighbor_port_cmd
);
12514 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
12516 /* "neighbor weight" commands. */
12517 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
12518 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
12520 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
12521 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
12522 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
12523 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
12524 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
12525 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
12526 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
12527 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
12528 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
12529 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
12530 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
12531 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
12532 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
12533 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
12534 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
12535 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
12537 /* "neighbor override-capability" commands. */
12538 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
12539 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
12541 /* "neighbor strict-capability-match" commands. */
12542 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
12543 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
12545 /* "neighbor timers" commands. */
12546 install_element(BGP_NODE
, &neighbor_timers_cmd
);
12547 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
12549 /* "neighbor timers connect" commands. */
12550 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
12551 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
12553 /* "neighbor advertisement-interval" commands. */
12554 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
12555 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
12557 /* "neighbor interface" commands. */
12558 install_element(BGP_NODE
, &neighbor_interface_cmd
);
12559 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
12561 /* "neighbor distribute" commands. */
12562 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
12563 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
12564 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
12565 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
12566 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
12567 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
12568 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
12569 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
12570 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
12571 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
12572 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
12573 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
12574 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
12575 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
12576 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
12577 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
12578 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
12579 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
12581 /* "neighbor prefix-list" commands. */
12582 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
12583 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
12584 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
12585 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
12586 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
12587 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
12588 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
12589 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
12590 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
12591 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
12592 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
12593 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
12594 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
12595 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
12596 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
12597 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
12598 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
12599 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
12601 /* "neighbor filter-list" commands. */
12602 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
12603 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
12604 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
12605 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
12606 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
12607 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
12608 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
12609 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
12610 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
12611 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
12612 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
12613 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
12614 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
12615 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
12616 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
12617 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
12618 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
12619 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
12621 /* "neighbor route-map" commands. */
12622 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
12623 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
12624 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
12625 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
12626 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
12627 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
12628 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
12629 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
12630 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
12631 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
12632 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
12633 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
12634 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
12635 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
12636 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
12637 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
12638 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
12639 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
12640 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
12641 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
12643 /* "neighbor unsuppress-map" commands. */
12644 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
12645 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
12646 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
12647 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12648 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
12649 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12650 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
12651 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12652 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
12653 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12654 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
12655 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12656 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
12657 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12658 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
12659 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12660 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
12661 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12663 /* "neighbor maximum-prefix" commands. */
12664 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
12665 install_element(BGP_NODE
,
12666 &neighbor_maximum_prefix_threshold_hidden_cmd
);
12667 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
12668 install_element(BGP_NODE
,
12669 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
12670 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
12671 install_element(BGP_NODE
,
12672 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
12673 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
12674 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
12675 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12676 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12677 install_element(BGP_IPV4_NODE
,
12678 &neighbor_maximum_prefix_threshold_warning_cmd
);
12679 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12680 install_element(BGP_IPV4_NODE
,
12681 &neighbor_maximum_prefix_threshold_restart_cmd
);
12682 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12683 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
12684 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12685 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12686 install_element(BGP_IPV4M_NODE
,
12687 &neighbor_maximum_prefix_threshold_warning_cmd
);
12688 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12689 install_element(BGP_IPV4M_NODE
,
12690 &neighbor_maximum_prefix_threshold_restart_cmd
);
12691 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12692 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
12693 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12694 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12695 install_element(BGP_IPV4L_NODE
,
12696 &neighbor_maximum_prefix_threshold_warning_cmd
);
12697 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12698 install_element(BGP_IPV4L_NODE
,
12699 &neighbor_maximum_prefix_threshold_restart_cmd
);
12700 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12701 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
12702 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12703 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12704 install_element(BGP_IPV6_NODE
,
12705 &neighbor_maximum_prefix_threshold_warning_cmd
);
12706 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12707 install_element(BGP_IPV6_NODE
,
12708 &neighbor_maximum_prefix_threshold_restart_cmd
);
12709 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12710 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
12711 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12712 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12713 install_element(BGP_IPV6M_NODE
,
12714 &neighbor_maximum_prefix_threshold_warning_cmd
);
12715 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12716 install_element(BGP_IPV6M_NODE
,
12717 &neighbor_maximum_prefix_threshold_restart_cmd
);
12718 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12719 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
12720 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12721 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12722 install_element(BGP_IPV6L_NODE
,
12723 &neighbor_maximum_prefix_threshold_warning_cmd
);
12724 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12725 install_element(BGP_IPV6L_NODE
,
12726 &neighbor_maximum_prefix_threshold_restart_cmd
);
12727 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12728 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
12729 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12730 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12731 install_element(BGP_VPNV4_NODE
,
12732 &neighbor_maximum_prefix_threshold_warning_cmd
);
12733 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12734 install_element(BGP_VPNV4_NODE
,
12735 &neighbor_maximum_prefix_threshold_restart_cmd
);
12736 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12737 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
12738 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12739 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12740 install_element(BGP_VPNV6_NODE
,
12741 &neighbor_maximum_prefix_threshold_warning_cmd
);
12742 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12743 install_element(BGP_VPNV6_NODE
,
12744 &neighbor_maximum_prefix_threshold_restart_cmd
);
12745 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12747 /* "neighbor allowas-in" */
12748 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
12749 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
12750 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
12751 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
12752 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
12753 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
12754 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
12755 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
12756 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
12757 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
12758 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
12759 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
12760 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
12761 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
12762 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
12763 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
12764 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
12765 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
12766 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
12767 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
12769 /* address-family commands. */
12770 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
12771 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
12772 #ifdef KEEP_OLD_VPN_COMMANDS
12773 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
12774 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
12775 #endif /* KEEP_OLD_VPN_COMMANDS */
12777 install_element(BGP_NODE
, &address_family_evpn_cmd
);
12779 /* "exit-address-family" command. */
12780 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
12781 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
12782 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
12783 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
12784 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
12785 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
12786 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
12787 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
12788 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
12790 /* "clear ip bgp commands" */
12791 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
12793 /* clear ip bgp prefix */
12794 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
12795 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
12796 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
12798 /* "show [ip] bgp summary" commands. */
12799 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
12800 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
12801 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
12802 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
12803 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
12804 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
12806 /* "show [ip] bgp neighbors" commands. */
12807 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
12809 /* "show [ip] bgp peer-group" commands. */
12810 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
12812 /* "show [ip] bgp paths" commands. */
12813 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
12815 /* "show [ip] bgp community" commands. */
12816 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
12818 /* "show ip bgp large-community" commands. */
12819 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
12820 /* "show [ip] bgp attribute-info" commands. */
12821 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
12823 /* "redistribute" commands. */
12824 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
12825 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
12826 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
12827 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
12828 install_element(BGP_NODE
,
12829 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
12830 install_element(BGP_NODE
,
12831 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
12832 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
12833 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
12834 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
12835 install_element(BGP_NODE
,
12836 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
12837 install_element(BGP_NODE
,
12838 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
12839 install_element(BGP_NODE
,
12840 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
12841 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
12842 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
12843 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
12844 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
12845 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
12846 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
12847 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
12848 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
12849 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
12850 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
12851 install_element(BGP_IPV4_NODE
,
12852 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
12853 install_element(BGP_IPV4_NODE
,
12854 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
12855 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
12856 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
12857 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
12858 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
12859 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
12860 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
12862 /* import|export vpn [route-map WORD] */
12863 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
12864 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
12866 /* ttl_security commands */
12867 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
12868 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
12870 /* "show [ip] bgp memory" commands. */
12871 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
12873 /* "show bgp martian next-hop" */
12874 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
12876 /* "show [ip] bgp views" commands. */
12877 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
12879 /* "show [ip] bgp vrfs" commands. */
12880 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
12882 /* Community-list. */
12883 community_list_vty();
12885 /* vpn-policy commands */
12886 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
12887 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
12888 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
12889 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
12890 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
12891 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
12892 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
12893 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
12894 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
12895 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
12897 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
12898 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
12899 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
12900 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
12901 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
12902 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
12903 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
12904 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
12905 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
12906 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
12909 #include "memory.h"
12910 #include "bgp_regex.h"
12911 #include "bgp_clist.h"
12912 #include "bgp_ecommunity.h"
12914 /* VTY functions. */
12916 /* Direction value to string conversion. */
12917 static const char *community_direct_str(int direct
)
12920 case COMMUNITY_DENY
:
12922 case COMMUNITY_PERMIT
:
12929 /* Display error string. */
12930 static void community_list_perror(struct vty
*vty
, int ret
)
12933 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
12934 vty_out(vty
, "%% Can't find community-list\n");
12936 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
12937 vty_out(vty
, "%% Malformed community-list value\n");
12939 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
12941 "%% Community name conflict, previously defined as standard community\n");
12943 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
12945 "%% Community name conflict, previously defined as expanded community\n");
12950 /* "community-list" keyword help string. */
12951 #define COMMUNITY_LIST_STR "Add a community list entry\n"
12953 /* ip community-list standard */
12954 DEFUN (ip_community_list_standard
,
12955 ip_community_list_standard_cmd
,
12956 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
12959 "Community list number (standard)\n"
12960 "Add an standard community-list entry\n"
12961 "Community list name\n"
12962 "Specify community to reject\n"
12963 "Specify community to accept\n"
12966 char *cl_name_or_number
= NULL
;
12968 int style
= COMMUNITY_LIST_STANDARD
;
12971 argv_find(argv
, argc
, "(1-99)", &idx
);
12972 argv_find(argv
, argc
, "WORD", &idx
);
12973 cl_name_or_number
= argv
[idx
]->arg
;
12974 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12976 argv_find(argv
, argc
, "AA:NN", &idx
);
12977 char *str
= argv_concat(argv
, argc
, idx
);
12979 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
12982 XFREE(MTYPE_TMP
, str
);
12985 /* Display error string. */
12986 community_list_perror(vty
, ret
);
12987 return CMD_WARNING_CONFIG_FAILED
;
12990 return CMD_SUCCESS
;
12993 DEFUN (no_ip_community_list_standard_all
,
12994 no_ip_community_list_standard_all_cmd
,
12995 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
12999 "Community list number (standard)\n"
13000 "Add an standard community-list entry\n"
13001 "Community list name\n"
13002 "Specify community to reject\n"
13003 "Specify community to accept\n"
13006 int delete_all
= 0;
13008 char *cl_name_or_number
= NULL
;
13010 int style
= COMMUNITY_LIST_STANDARD
;
13013 argv_find(argv
, argc
, "(1-99)", &idx
);
13014 argv_find(argv
, argc
, "WORD", &idx
);
13015 cl_name_or_number
= argv
[idx
]->arg
;
13016 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13018 argv_find(argv
, argc
, "AA:NN", &idx
);
13019 char *str
= argv_concat(argv
, argc
, idx
);
13021 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13022 direct
, style
, delete_all
);
13024 XFREE(MTYPE_TMP
, str
);
13027 community_list_perror(vty
, ret
);
13028 return CMD_WARNING_CONFIG_FAILED
;
13031 return CMD_SUCCESS
;
13034 /* ip community-list expanded */
13035 DEFUN (ip_community_list_expanded_all
,
13036 ip_community_list_expanded_all_cmd
,
13037 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13040 "Community list number (expanded)\n"
13041 "Add an expanded community-list entry\n"
13042 "Community list name\n"
13043 "Specify community to reject\n"
13044 "Specify community to accept\n"
13047 char *cl_name_or_number
= NULL
;
13049 int style
= COMMUNITY_LIST_EXPANDED
;
13052 argv_find(argv
, argc
, "(100-500)", &idx
);
13053 argv_find(argv
, argc
, "WORD", &idx
);
13054 cl_name_or_number
= argv
[idx
]->arg
;
13055 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13057 argv_find(argv
, argc
, "AA:NN", &idx
);
13058 char *str
= argv_concat(argv
, argc
, idx
);
13060 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13063 XFREE(MTYPE_TMP
, str
);
13066 /* Display error string. */
13067 community_list_perror(vty
, ret
);
13068 return CMD_WARNING_CONFIG_FAILED
;
13071 return CMD_SUCCESS
;
13074 DEFUN (no_ip_community_list_expanded_all
,
13075 no_ip_community_list_expanded_all_cmd
,
13076 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13080 "Community list number (expanded)\n"
13081 "Add an expanded community-list entry\n"
13082 "Community list name\n"
13083 "Specify community to reject\n"
13084 "Specify community to accept\n"
13087 int delete_all
= 0;
13089 char *cl_name_or_number
= NULL
;
13091 int style
= COMMUNITY_LIST_EXPANDED
;
13094 argv_find(argv
, argc
, "(100-500)", &idx
);
13095 argv_find(argv
, argc
, "WORD", &idx
);
13096 cl_name_or_number
= argv
[idx
]->arg
;
13097 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13099 argv_find(argv
, argc
, "AA:NN", &idx
);
13100 char *str
= argv_concat(argv
, argc
, idx
);
13102 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13103 direct
, style
, delete_all
);
13105 XFREE(MTYPE_TMP
, str
);
13108 community_list_perror(vty
, ret
);
13109 return CMD_WARNING_CONFIG_FAILED
;
13112 return CMD_SUCCESS
;
13115 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13117 struct community_entry
*entry
;
13119 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13120 if (entry
== list
->head
) {
13121 if (all_digit(list
->name
))
13122 vty_out(vty
, "Community %s list %s\n",
13123 entry
->style
== COMMUNITY_LIST_STANDARD
13125 : "(expanded) access",
13128 vty_out(vty
, "Named Community %s list %s\n",
13129 entry
->style
== COMMUNITY_LIST_STANDARD
13135 vty_out(vty
, " %s\n",
13136 community_direct_str(entry
->direct
));
13138 vty_out(vty
, " %s %s\n",
13139 community_direct_str(entry
->direct
),
13140 entry
->style
== COMMUNITY_LIST_STANDARD
13141 ? community_str(entry
->u
.com
, false)
13146 DEFUN (show_ip_community_list
,
13147 show_ip_community_list_cmd
,
13148 "show ip community-list",
13151 "List community-list\n")
13153 struct community_list
*list
;
13154 struct community_list_master
*cm
;
13156 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13158 return CMD_SUCCESS
;
13160 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13161 community_list_show(vty
, list
);
13163 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13164 community_list_show(vty
, list
);
13166 return CMD_SUCCESS
;
13169 DEFUN (show_ip_community_list_arg
,
13170 show_ip_community_list_arg_cmd
,
13171 "show ip community-list <(1-500)|WORD>",
13174 "List community-list\n"
13175 "Community-list number\n"
13176 "Community-list name\n")
13178 int idx_comm_list
= 3;
13179 struct community_list
*list
;
13181 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13182 COMMUNITY_LIST_MASTER
);
13184 vty_out(vty
, "%% Can't find community-list\n");
13185 return CMD_WARNING
;
13188 community_list_show(vty
, list
);
13190 return CMD_SUCCESS
;
13194 * Large Community code.
13196 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
13197 struct cmd_token
**argv
, int style
,
13198 int reject_all_digit_name
)
13206 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13209 /* All digit name check. */
13211 argv_find(argv
, argc
, "WORD", &idx
);
13212 argv_find(argv
, argc
, "(1-99)", &idx
);
13213 argv_find(argv
, argc
, "(100-500)", &idx
);
13214 cl_name
= argv
[idx
]->arg
;
13215 if (reject_all_digit_name
&& all_digit(cl_name
)) {
13216 vty_out(vty
, "%% Community name cannot have all digits\n");
13217 return CMD_WARNING_CONFIG_FAILED
;
13221 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
13222 argv_find(argv
, argc
, "LINE", &idx
);
13223 /* Concat community string argument. */
13225 str
= argv_concat(argv
, argc
, idx
);
13229 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
13231 /* Free temporary community list string allocated by
13234 XFREE(MTYPE_TMP
, str
);
13237 community_list_perror(vty
, ret
);
13238 return CMD_WARNING_CONFIG_FAILED
;
13240 return CMD_SUCCESS
;
13243 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
13244 struct cmd_token
**argv
, int style
)
13251 argv_find(argv
, argc
, "permit", &idx
);
13252 argv_find(argv
, argc
, "deny", &idx
);
13255 /* Check the list direct. */
13256 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
13257 direct
= COMMUNITY_PERMIT
;
13259 direct
= COMMUNITY_DENY
;
13262 argv_find(argv
, argc
, "LINE", &idx
);
13263 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
13264 /* Concat community string argument. */
13265 str
= argv_concat(argv
, argc
, idx
);
13269 argv_find(argv
, argc
, "(1-99)", &idx
);
13270 argv_find(argv
, argc
, "(100-500)", &idx
);
13271 argv_find(argv
, argc
, "WORD", &idx
);
13273 /* Unset community list. */
13274 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
13277 /* Free temporary community list string allocated by
13280 XFREE(MTYPE_TMP
, str
);
13283 community_list_perror(vty
, ret
);
13284 return CMD_WARNING_CONFIG_FAILED
;
13287 return CMD_SUCCESS
;
13290 /* "large-community-list" keyword help string. */
13291 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
13292 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
13294 DEFUN (ip_lcommunity_list_standard
,
13295 ip_lcommunity_list_standard_cmd
,
13296 "ip large-community-list (1-99) <deny|permit>",
13298 LCOMMUNITY_LIST_STR
13299 "Large Community list number (standard)\n"
13300 "Specify large community to reject\n"
13301 "Specify large community to accept\n")
13303 return lcommunity_list_set_vty(vty
, argc
, argv
,
13304 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13307 DEFUN (ip_lcommunity_list_standard1
,
13308 ip_lcommunity_list_standard1_cmd
,
13309 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
13311 LCOMMUNITY_LIST_STR
13312 "Large Community list number (standard)\n"
13313 "Specify large community to reject\n"
13314 "Specify large community to accept\n"
13315 LCOMMUNITY_VAL_STR
)
13317 return lcommunity_list_set_vty(vty
, argc
, argv
,
13318 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13321 DEFUN (ip_lcommunity_list_expanded
,
13322 ip_lcommunity_list_expanded_cmd
,
13323 "ip large-community-list (100-500) <deny|permit> LINE...",
13325 LCOMMUNITY_LIST_STR
13326 "Large Community list number (expanded)\n"
13327 "Specify large community to reject\n"
13328 "Specify large community to accept\n"
13329 "An ordered list as a regular-expression\n")
13331 return lcommunity_list_set_vty(vty
, argc
, argv
,
13332 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
13335 DEFUN (ip_lcommunity_list_name_standard
,
13336 ip_lcommunity_list_name_standard_cmd
,
13337 "ip large-community-list standard WORD <deny|permit>",
13339 LCOMMUNITY_LIST_STR
13340 "Specify standard large-community-list\n"
13341 "Large Community list name\n"
13342 "Specify large community to reject\n"
13343 "Specify large community to accept\n")
13345 return lcommunity_list_set_vty(vty
, argc
, argv
,
13346 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13349 DEFUN (ip_lcommunity_list_name_standard1
,
13350 ip_lcommunity_list_name_standard1_cmd
,
13351 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
13353 LCOMMUNITY_LIST_STR
13354 "Specify standard large-community-list\n"
13355 "Large Community list name\n"
13356 "Specify large community to reject\n"
13357 "Specify large community to accept\n"
13358 LCOMMUNITY_VAL_STR
)
13360 return lcommunity_list_set_vty(vty
, argc
, argv
,
13361 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13364 DEFUN (ip_lcommunity_list_name_expanded
,
13365 ip_lcommunity_list_name_expanded_cmd
,
13366 "ip large-community-list expanded WORD <deny|permit> LINE...",
13368 LCOMMUNITY_LIST_STR
13369 "Specify expanded large-community-list\n"
13370 "Large Community list name\n"
13371 "Specify large community to reject\n"
13372 "Specify large community to accept\n"
13373 "An ordered list as a regular-expression\n")
13375 return lcommunity_list_set_vty(vty
, argc
, argv
,
13376 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
13379 DEFUN (no_ip_lcommunity_list_standard_all
,
13380 no_ip_lcommunity_list_standard_all_cmd
,
13381 "no ip large-community-list <(1-99)|(100-500)|WORD>",
13384 LCOMMUNITY_LIST_STR
13385 "Large Community list number (standard)\n"
13386 "Large Community list number (expanded)\n"
13387 "Large Community list name\n")
13389 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13390 LARGE_COMMUNITY_LIST_STANDARD
);
13393 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
13394 no_ip_lcommunity_list_name_expanded_all_cmd
,
13395 "no ip large-community-list expanded WORD",
13398 LCOMMUNITY_LIST_STR
13399 "Specify expanded large-community-list\n"
13400 "Large Community list name\n")
13402 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13403 LARGE_COMMUNITY_LIST_EXPANDED
);
13406 DEFUN (no_ip_lcommunity_list_standard
,
13407 no_ip_lcommunity_list_standard_cmd
,
13408 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
13411 LCOMMUNITY_LIST_STR
13412 "Large Community list number (standard)\n"
13413 "Specify large community to reject\n"
13414 "Specify large community to accept\n"
13415 LCOMMUNITY_VAL_STR
)
13417 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13418 LARGE_COMMUNITY_LIST_STANDARD
);
13421 DEFUN (no_ip_lcommunity_list_expanded
,
13422 no_ip_lcommunity_list_expanded_cmd
,
13423 "no ip large-community-list (100-500) <deny|permit> LINE...",
13426 LCOMMUNITY_LIST_STR
13427 "Large Community list number (expanded)\n"
13428 "Specify large community to reject\n"
13429 "Specify large community to accept\n"
13430 "An ordered list as a regular-expression\n")
13432 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13433 LARGE_COMMUNITY_LIST_EXPANDED
);
13436 DEFUN (no_ip_lcommunity_list_name_standard
,
13437 no_ip_lcommunity_list_name_standard_cmd
,
13438 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
13441 LCOMMUNITY_LIST_STR
13442 "Specify standard large-community-list\n"
13443 "Large Community list name\n"
13444 "Specify large community to reject\n"
13445 "Specify large community to accept\n"
13446 LCOMMUNITY_VAL_STR
)
13448 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13449 LARGE_COMMUNITY_LIST_STANDARD
);
13452 DEFUN (no_ip_lcommunity_list_name_expanded
,
13453 no_ip_lcommunity_list_name_expanded_cmd
,
13454 "no ip large-community-list expanded WORD <deny|permit> LINE...",
13457 LCOMMUNITY_LIST_STR
13458 "Specify expanded large-community-list\n"
13459 "Large community list name\n"
13460 "Specify large community to reject\n"
13461 "Specify large community to accept\n"
13462 "An ordered list as a regular-expression\n")
13464 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13465 LARGE_COMMUNITY_LIST_EXPANDED
);
13468 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
13470 struct community_entry
*entry
;
13472 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13473 if (entry
== list
->head
) {
13474 if (all_digit(list
->name
))
13475 vty_out(vty
, "Large community %s list %s\n",
13476 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13478 : "(expanded) access",
13482 "Named large community %s list %s\n",
13483 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13489 vty_out(vty
, " %s\n",
13490 community_direct_str(entry
->direct
));
13492 vty_out(vty
, " %s %s\n",
13493 community_direct_str(entry
->direct
),
13494 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13495 ? entry
->u
.ecom
->str
13500 DEFUN (show_ip_lcommunity_list
,
13501 show_ip_lcommunity_list_cmd
,
13502 "show ip large-community-list",
13505 "List large-community list\n")
13507 struct community_list
*list
;
13508 struct community_list_master
*cm
;
13510 cm
= community_list_master_lookup(bgp_clist
,
13511 LARGE_COMMUNITY_LIST_MASTER
);
13513 return CMD_SUCCESS
;
13515 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13516 lcommunity_list_show(vty
, list
);
13518 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13519 lcommunity_list_show(vty
, list
);
13521 return CMD_SUCCESS
;
13524 DEFUN (show_ip_lcommunity_list_arg
,
13525 show_ip_lcommunity_list_arg_cmd
,
13526 "show ip large-community-list <(1-500)|WORD>",
13529 "List large-community list\n"
13530 "large-community-list number\n"
13531 "large-community-list name\n")
13533 struct community_list
*list
;
13535 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
13536 LARGE_COMMUNITY_LIST_MASTER
);
13538 vty_out(vty
, "%% Can't find extcommunity-list\n");
13539 return CMD_WARNING
;
13542 lcommunity_list_show(vty
, list
);
13544 return CMD_SUCCESS
;
13547 /* "extcommunity-list" keyword help string. */
13548 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
13549 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
13551 DEFUN (ip_extcommunity_list_standard
,
13552 ip_extcommunity_list_standard_cmd
,
13553 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13555 EXTCOMMUNITY_LIST_STR
13556 "Extended Community list number (standard)\n"
13557 "Specify standard extcommunity-list\n"
13558 "Community list name\n"
13559 "Specify community to reject\n"
13560 "Specify community to accept\n"
13561 EXTCOMMUNITY_VAL_STR
)
13563 int style
= EXTCOMMUNITY_LIST_STANDARD
;
13565 char *cl_number_or_name
= NULL
;
13568 argv_find(argv
, argc
, "(1-99)", &idx
);
13569 argv_find(argv
, argc
, "WORD", &idx
);
13570 cl_number_or_name
= argv
[idx
]->arg
;
13571 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13573 argv_find(argv
, argc
, "AA:NN", &idx
);
13574 char *str
= argv_concat(argv
, argc
, idx
);
13576 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
13579 XFREE(MTYPE_TMP
, str
);
13582 community_list_perror(vty
, ret
);
13583 return CMD_WARNING_CONFIG_FAILED
;
13586 return CMD_SUCCESS
;
13589 DEFUN (ip_extcommunity_list_name_expanded
,
13590 ip_extcommunity_list_name_expanded_cmd
,
13591 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
13593 EXTCOMMUNITY_LIST_STR
13594 "Extended Community list number (expanded)\n"
13595 "Specify expanded extcommunity-list\n"
13596 "Extended Community list name\n"
13597 "Specify community to reject\n"
13598 "Specify community to accept\n"
13599 "An ordered list as a regular-expression\n")
13601 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
13603 char *cl_number_or_name
= NULL
;
13606 argv_find(argv
, argc
, "(100-500)", &idx
);
13607 argv_find(argv
, argc
, "WORD", &idx
);
13608 cl_number_or_name
= argv
[idx
]->arg
;
13609 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13611 argv_find(argv
, argc
, "LINE", &idx
);
13612 char *str
= argv_concat(argv
, argc
, idx
);
13614 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
13617 XFREE(MTYPE_TMP
, str
);
13620 community_list_perror(vty
, ret
);
13621 return CMD_WARNING_CONFIG_FAILED
;
13624 return CMD_SUCCESS
;
13627 DEFUN (no_ip_extcommunity_list_standard_all
,
13628 no_ip_extcommunity_list_standard_all_cmd
,
13629 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13632 EXTCOMMUNITY_LIST_STR
13633 "Extended Community list number (standard)\n"
13634 "Specify standard extcommunity-list\n"
13635 "Community list name\n"
13636 "Specify community to reject\n"
13637 "Specify community to accept\n"
13638 EXTCOMMUNITY_VAL_STR
)
13642 int style
= EXTCOMMUNITY_LIST_STANDARD
;
13644 char *cl_number_or_name
= NULL
;
13647 argv_find(argv
, argc
, "(1-99)", &idx
);
13648 argv_find(argv
, argc
, "WORD", &idx
);
13649 cl_number_or_name
= argv
[idx
]->arg
;
13650 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13652 argv_find(argv
, argc
, "AA:NN", &idx
);
13653 char *str
= argv_concat(argv
, argc
, idx
);
13655 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13656 direct
, style
, deleteall
);
13658 XFREE(MTYPE_TMP
, str
);
13661 community_list_perror(vty
, ret
);
13662 return CMD_WARNING_CONFIG_FAILED
;
13665 return CMD_SUCCESS
;
13668 DEFUN (no_ip_extcommunity_list_expanded_all
,
13669 no_ip_extcommunity_list_expanded_all_cmd
,
13670 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
13673 EXTCOMMUNITY_LIST_STR
13674 "Extended Community list number (expanded)\n"
13675 "Specify expanded extcommunity-list\n"
13676 "Extended Community list name\n"
13677 "Specify community to reject\n"
13678 "Specify community to accept\n"
13679 "An ordered list as a regular-expression\n")
13683 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
13685 char *cl_number_or_name
= NULL
;
13688 argv_find(argv
, argc
, "(100-500)", &idx
);
13689 argv_find(argv
, argc
, "WORD", &idx
);
13690 cl_number_or_name
= argv
[idx
]->arg
;
13691 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13693 argv_find(argv
, argc
, "LINE", &idx
);
13694 char *str
= argv_concat(argv
, argc
, idx
);
13696 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13697 direct
, style
, deleteall
);
13699 XFREE(MTYPE_TMP
, str
);
13702 community_list_perror(vty
, ret
);
13703 return CMD_WARNING_CONFIG_FAILED
;
13706 return CMD_SUCCESS
;
13709 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
13711 struct community_entry
*entry
;
13713 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13714 if (entry
== list
->head
) {
13715 if (all_digit(list
->name
))
13716 vty_out(vty
, "Extended community %s list %s\n",
13717 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13719 : "(expanded) access",
13723 "Named extended community %s list %s\n",
13724 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13730 vty_out(vty
, " %s\n",
13731 community_direct_str(entry
->direct
));
13733 vty_out(vty
, " %s %s\n",
13734 community_direct_str(entry
->direct
),
13735 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13736 ? entry
->u
.ecom
->str
13741 DEFUN (show_ip_extcommunity_list
,
13742 show_ip_extcommunity_list_cmd
,
13743 "show ip extcommunity-list",
13746 "List extended-community list\n")
13748 struct community_list
*list
;
13749 struct community_list_master
*cm
;
13751 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
13753 return CMD_SUCCESS
;
13755 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13756 extcommunity_list_show(vty
, list
);
13758 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13759 extcommunity_list_show(vty
, list
);
13761 return CMD_SUCCESS
;
13764 DEFUN (show_ip_extcommunity_list_arg
,
13765 show_ip_extcommunity_list_arg_cmd
,
13766 "show ip extcommunity-list <(1-500)|WORD>",
13769 "List extended-community list\n"
13770 "Extcommunity-list number\n"
13771 "Extcommunity-list name\n")
13773 int idx_comm_list
= 3;
13774 struct community_list
*list
;
13776 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13777 EXTCOMMUNITY_LIST_MASTER
);
13779 vty_out(vty
, "%% Can't find extcommunity-list\n");
13780 return CMD_WARNING
;
13783 extcommunity_list_show(vty
, list
);
13785 return CMD_SUCCESS
;
13788 /* Return configuration string of community-list entry. */
13789 static const char *community_list_config_str(struct community_entry
*entry
)
13796 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13797 str
= community_str(entry
->u
.com
, false);
13799 str
= entry
->config
;
13804 /* Display community-list and extcommunity-list configuration. */
13805 static int community_list_config_write(struct vty
*vty
)
13807 struct community_list
*list
;
13808 struct community_entry
*entry
;
13809 struct community_list_master
*cm
;
13812 /* Community-list. */
13813 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13815 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13816 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13817 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
13818 community_direct_str(entry
->direct
),
13819 community_list_config_str(entry
));
13822 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13823 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13824 vty_out(vty
, "ip community-list %s %s %s %s\n",
13825 entry
->style
== COMMUNITY_LIST_STANDARD
13828 list
->name
, community_direct_str(entry
->direct
),
13829 community_list_config_str(entry
));
13833 /* Extcommunity-list. */
13834 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
13836 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13837 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13838 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
13839 list
->name
, community_direct_str(entry
->direct
),
13840 community_list_config_str(entry
));
13843 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13844 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13845 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
13846 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13849 list
->name
, community_direct_str(entry
->direct
),
13850 community_list_config_str(entry
));
13855 /* lcommunity-list. */
13856 cm
= community_list_master_lookup(bgp_clist
,
13857 LARGE_COMMUNITY_LIST_MASTER
);
13859 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13860 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13861 vty_out(vty
, "ip large-community-list %s %s %s\n",
13862 list
->name
, community_direct_str(entry
->direct
),
13863 community_list_config_str(entry
));
13866 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13867 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13868 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
13869 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
13872 list
->name
, community_direct_str(entry
->direct
),
13873 community_list_config_str(entry
));
13880 static struct cmd_node community_list_node
= {
13881 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
13884 static void community_list_vty(void)
13886 install_node(&community_list_node
, community_list_config_write
);
13888 /* Community-list. */
13889 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
13890 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
13891 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
13892 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
13893 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
13894 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
13896 /* Extcommunity-list. */
13897 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
13898 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
13899 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
13900 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
13901 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
13902 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
13904 /* Large Community List */
13905 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
13906 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
13907 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
13908 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
13909 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
13910 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
13911 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
13912 install_element(CONFIG_NODE
,
13913 &no_ip_lcommunity_list_name_expanded_all_cmd
);
13914 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
13915 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
13916 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
13917 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
13918 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
13919 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);