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) {
836 "%% Multiple BGP processes are configured\n");
837 return CMD_WARNING_CONFIG_FAILED
;
843 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
845 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
847 name
= argv
[idx_vrf
]->arg
;
849 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf"))
850 inst_type
= BGP_INSTANCE_TYPE_VRF
;
851 else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
852 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
855 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
857 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
859 "Please specify 'bgp multiple-instance' first\n");
860 return CMD_WARNING_CONFIG_FAILED
;
861 case BGP_ERR_AS_MISMATCH
:
862 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
863 return CMD_WARNING_CONFIG_FAILED
;
864 case BGP_ERR_INSTANCE_MISMATCH
:
866 "BGP instance name and AS number mismatch\n");
868 "BGP instance is already running; AS is %u\n",
870 return CMD_WARNING_CONFIG_FAILED
;
873 /* Pending: handle when user tries to change a view to vrf n vv.
877 /* unset the auto created flag as the user config is now present */
878 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
879 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
884 /* "no router bgp" commands. */
885 DEFUN (no_router_bgp
,
887 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
892 BGP_INSTANCE_HELP_STR
)
898 const char *name
= NULL
;
900 // "no router bgp" without an ASN
902 // Pending: Make VRF option available for ASN less config
903 bgp
= bgp_get_default();
906 vty_out(vty
, "%% No BGP process is configured\n");
907 return CMD_WARNING_CONFIG_FAILED
;
910 if (listcount(bm
->bgp
) > 1) {
912 "%% Multiple BGP processes are configured\n");
913 return CMD_WARNING_CONFIG_FAILED
;
917 vty_out(vty
, "%% Please unconfigure l3vni %u",
919 return CMD_WARNING_CONFIG_FAILED
;
922 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
925 name
= argv
[idx_vrf
]->arg
;
927 /* Lookup bgp structure. */
928 bgp
= bgp_lookup(as
, name
);
930 vty_out(vty
, "%% Can't find BGP instance\n");
931 return CMD_WARNING_CONFIG_FAILED
;
935 vty_out(vty
, "%% Please unconfigure l3vni %u",
937 return CMD_WARNING_CONFIG_FAILED
;
949 DEFPY (bgp_router_id
,
951 "bgp router-id A.B.C.D",
953 "Override configured router identifier\n"
954 "Manually configured router identifier\n")
956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
957 bgp_router_id_static_set(bgp
, router_id
);
961 DEFPY (no_bgp_router_id
,
962 no_bgp_router_id_cmd
,
963 "no bgp router-id [A.B.C.D]",
966 "Override configured router identifier\n"
967 "Manually configured router identifier\n")
969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
972 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
973 vty_out(vty
, "%% BGP router-id doesn't match\n");
974 return CMD_WARNING_CONFIG_FAILED
;
978 router_id
.s_addr
= 0;
979 bgp_router_id_static_set(bgp
, router_id
);
985 /* BGP Cluster ID. */
986 DEFUN (bgp_cluster_id
,
988 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
990 "Configure Route-Reflector Cluster-id\n"
991 "Route-Reflector Cluster-id in IP address format\n"
992 "Route-Reflector Cluster-id as 32 bit quantity\n")
994 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
997 struct in_addr cluster
;
999 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1001 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1002 return CMD_WARNING_CONFIG_FAILED
;
1005 bgp_cluster_id_set(bgp
, &cluster
);
1006 bgp_clear_star_soft_out(vty
, bgp
->name
);
1011 DEFUN (no_bgp_cluster_id
,
1012 no_bgp_cluster_id_cmd
,
1013 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1016 "Configure Route-Reflector Cluster-id\n"
1017 "Route-Reflector Cluster-id in IP address format\n"
1018 "Route-Reflector Cluster-id as 32 bit quantity\n")
1020 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1021 bgp_cluster_id_unset(bgp
);
1022 bgp_clear_star_soft_out(vty
, bgp
->name
);
1027 DEFUN (bgp_confederation_identifier
,
1028 bgp_confederation_identifier_cmd
,
1029 "bgp confederation identifier (1-4294967295)",
1030 "BGP specific commands\n"
1031 "AS confederation parameters\n"
1033 "Set routing domain confederation AS\n")
1035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1039 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1041 bgp_confederation_id_set(bgp
, as
);
1046 DEFUN (no_bgp_confederation_identifier
,
1047 no_bgp_confederation_identifier_cmd
,
1048 "no bgp confederation identifier [(1-4294967295)]",
1050 "BGP specific commands\n"
1051 "AS confederation parameters\n"
1053 "Set routing domain confederation AS\n")
1055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1056 bgp_confederation_id_unset(bgp
);
1061 DEFUN (bgp_confederation_peers
,
1062 bgp_confederation_peers_cmd
,
1063 "bgp confederation peers (1-4294967295)...",
1064 "BGP specific commands\n"
1065 "AS confederation parameters\n"
1066 "Peer ASs in BGP confederation\n"
1069 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1074 for (i
= idx_asn
; i
< argc
; i
++) {
1075 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1077 if (bgp
->as
== as
) {
1079 "%% Local member-AS not allowed in confed peer list\n");
1083 bgp_confederation_peers_add(bgp
, as
);
1088 DEFUN (no_bgp_confederation_peers
,
1089 no_bgp_confederation_peers_cmd
,
1090 "no bgp confederation peers (1-4294967295)...",
1092 "BGP specific commands\n"
1093 "AS confederation parameters\n"
1094 "Peer ASs in BGP confederation\n"
1097 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1102 for (i
= idx_asn
; i
< argc
; i
++) {
1103 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1105 bgp_confederation_peers_remove(bgp
, as
);
1111 * Central routine for maximum-paths configuration.
1112 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1113 * @set: 1 for setting values, 0 for removing the max-paths config.
1115 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1116 const char *mpaths
, u_int16_t options
,
1119 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1120 u_int16_t maxpaths
= 0;
1125 afi
= bgp_node_afi(vty
);
1126 safi
= bgp_node_safi(vty
);
1129 maxpaths
= strtol(mpaths
, NULL
, 10);
1130 if (maxpaths
> multipath_num
) {
1132 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1133 maxpaths
, multipath_num
);
1134 return CMD_WARNING_CONFIG_FAILED
;
1136 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1139 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1143 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1144 (set
== 1) ? "" : "un",
1145 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1146 maxpaths
, afi
, safi
);
1147 return CMD_WARNING_CONFIG_FAILED
;
1150 bgp_recalculate_all_bestpaths(bgp
);
1155 DEFUN (bgp_maxmed_admin
,
1156 bgp_maxmed_admin_cmd
,
1157 "bgp max-med administrative ",
1159 "Advertise routes with max-med\n"
1160 "Administratively applied, for an indefinite period\n")
1162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1164 bgp
->v_maxmed_admin
= 1;
1165 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1167 bgp_maxmed_update(bgp
);
1172 DEFUN (bgp_maxmed_admin_medv
,
1173 bgp_maxmed_admin_medv_cmd
,
1174 "bgp max-med administrative (0-4294967295)",
1176 "Advertise routes with max-med\n"
1177 "Administratively applied, for an indefinite period\n"
1178 "Max MED value to be used\n")
1180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1183 bgp
->v_maxmed_admin
= 1;
1184 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1186 bgp_maxmed_update(bgp
);
1191 DEFUN (no_bgp_maxmed_admin
,
1192 no_bgp_maxmed_admin_cmd
,
1193 "no bgp max-med administrative [(0-4294967295)]",
1196 "Advertise routes with max-med\n"
1197 "Administratively applied, for an indefinite period\n"
1198 "Max MED value to be used\n")
1200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1201 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1202 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1203 bgp_maxmed_update(bgp
);
1208 DEFUN (bgp_maxmed_onstartup
,
1209 bgp_maxmed_onstartup_cmd
,
1210 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1212 "Advertise routes with max-med\n"
1213 "Effective on a startup\n"
1214 "Time (seconds) period for max-med\n"
1215 "Max MED value to be used\n")
1217 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1220 argv_find(argv
, argc
, "(5-86400)", &idx
);
1221 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1222 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1223 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1225 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1227 bgp_maxmed_update(bgp
);
1232 DEFUN (no_bgp_maxmed_onstartup
,
1233 no_bgp_maxmed_onstartup_cmd
,
1234 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1237 "Advertise routes with max-med\n"
1238 "Effective on a startup\n"
1239 "Time (seconds) period for max-med\n"
1240 "Max MED value to be used\n")
1242 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1244 /* Cancel max-med onstartup if its on */
1245 if (bgp
->t_maxmed_onstartup
) {
1246 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1247 bgp
->maxmed_onstartup_over
= 1;
1250 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1251 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1253 bgp_maxmed_update(bgp
);
1258 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1261 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1262 u_int16_t update_delay
;
1263 u_int16_t establish_wait
;
1265 update_delay
= strtoul(delay
, NULL
, 10);
1267 if (!wait
) /* update-delay <delay> */
1269 bgp
->v_update_delay
= update_delay
;
1270 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1274 /* update-delay <delay> <establish-wait> */
1275 establish_wait
= atoi(wait
);
1276 if (update_delay
< establish_wait
) {
1278 "%%Failed: update-delay less than the establish-wait!\n");
1279 return CMD_WARNING_CONFIG_FAILED
;
1282 bgp
->v_update_delay
= update_delay
;
1283 bgp
->v_establish_wait
= establish_wait
;
1288 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1290 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1292 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1293 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1298 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1300 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1301 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1302 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1303 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1309 /* Update-delay configuration */
1310 DEFUN (bgp_update_delay
,
1311 bgp_update_delay_cmd
,
1312 "update-delay (0-3600)",
1313 "Force initial delay for best-path and updates\n"
1317 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1320 DEFUN (bgp_update_delay_establish_wait
,
1321 bgp_update_delay_establish_wait_cmd
,
1322 "update-delay (0-3600) (1-3600)",
1323 "Force initial delay for best-path and updates\n"
1328 int idx_number_2
= 2;
1329 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1330 argv
[idx_number_2
]->arg
);
1333 /* Update-delay deconfiguration */
1334 DEFUN (no_bgp_update_delay
,
1335 no_bgp_update_delay_cmd
,
1336 "no update-delay [(0-3600) [(1-3600)]]",
1338 "Force initial delay for best-path and updates\n"
1342 return bgp_update_delay_deconfig_vty(vty
);
1346 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1349 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1352 uint32_t quanta
= strtoul(num
, NULL
, 10);
1353 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1354 memory_order_relaxed
);
1356 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1357 memory_order_relaxed
);
1363 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1366 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1369 uint32_t quanta
= strtoul(num
, NULL
, 10);
1370 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1371 memory_order_relaxed
);
1373 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1374 memory_order_relaxed
);
1380 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1383 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1384 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1385 vty_out(vty
, " write-quanta %d\n", quanta
);
1388 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1391 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1392 if (quanta
!= BGP_READ_PACKET_MAX
)
1393 vty_out(vty
, " read-quanta %d\n", quanta
);
1396 /* Packet quanta configuration */
1397 DEFUN (bgp_wpkt_quanta
,
1398 bgp_wpkt_quanta_cmd
,
1399 "write-quanta (1-10)",
1400 "How many packets to write to peer socket per run\n"
1401 "Number of packets\n")
1404 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1407 DEFUN (no_bgp_wpkt_quanta
,
1408 no_bgp_wpkt_quanta_cmd
,
1409 "no write-quanta (1-10)",
1411 "How many packets to write to peer socket per I/O cycle\n"
1412 "Number of packets\n")
1415 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1418 DEFUN (bgp_rpkt_quanta
,
1419 bgp_rpkt_quanta_cmd
,
1420 "read-quanta (1-10)",
1421 "How many packets to read from peer socket per I/O cycle\n"
1422 "Number of packets\n")
1425 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1428 DEFUN (no_bgp_rpkt_quanta
,
1429 no_bgp_rpkt_quanta_cmd
,
1430 "no read-quanta (1-10)",
1432 "How many packets to read from peer socket per I/O cycle\n"
1433 "Number of packets\n")
1436 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1439 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1441 if (!bgp
->heuristic_coalesce
)
1442 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1446 DEFUN (bgp_coalesce_time
,
1447 bgp_coalesce_time_cmd
,
1448 "coalesce-time (0-4294967295)",
1449 "Subgroup coalesce timer\n"
1450 "Subgroup coalesce timer value (in ms)\n")
1452 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1455 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1456 bgp
->heuristic_coalesce
= false;
1457 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1461 DEFUN (no_bgp_coalesce_time
,
1462 no_bgp_coalesce_time_cmd
,
1463 "no coalesce-time (0-4294967295)",
1465 "Subgroup coalesce timer\n"
1466 "Subgroup coalesce timer value (in ms)\n")
1468 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1470 bgp
->heuristic_coalesce
= true;
1471 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1475 /* Maximum-paths configuration */
1476 DEFUN (bgp_maxpaths
,
1478 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1479 "Forward packets over multiple paths\n"
1480 "Number of paths\n")
1483 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1484 argv
[idx_number
]->arg
, 0, 1);
1487 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1488 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1489 "Forward packets over multiple paths\n"
1490 "Number of paths\n")
1492 DEFUN (bgp_maxpaths_ibgp
,
1493 bgp_maxpaths_ibgp_cmd
,
1494 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1495 "Forward packets over multiple paths\n"
1497 "Number of paths\n")
1500 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1501 argv
[idx_number
]->arg
, 0, 1);
1504 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1505 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1506 "Forward packets over multiple paths\n"
1508 "Number of paths\n")
1510 DEFUN (bgp_maxpaths_ibgp_cluster
,
1511 bgp_maxpaths_ibgp_cluster_cmd
,
1512 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1513 "Forward packets over multiple paths\n"
1516 "Match the cluster length\n")
1519 return bgp_maxpaths_config_vty(
1520 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1521 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1524 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1525 "maximum-paths ibgp " CMD_RANGE_STR(
1526 1, MULTIPATH_NUM
) " equal-cluster-length",
1527 "Forward packets over multiple paths\n"
1530 "Match the cluster length\n")
1532 DEFUN (no_bgp_maxpaths
,
1533 no_bgp_maxpaths_cmd
,
1534 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1536 "Forward packets over multiple paths\n"
1537 "Number of paths\n")
1539 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1542 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1543 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1544 "Forward packets over multiple paths\n"
1545 "Number of paths\n")
1547 DEFUN (no_bgp_maxpaths_ibgp
,
1548 no_bgp_maxpaths_ibgp_cmd
,
1549 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1551 "Forward packets over multiple paths\n"
1554 "Match the cluster length\n")
1556 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1559 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1560 "no maximum-paths ibgp [" CMD_RANGE_STR(
1561 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1563 "Forward packets over multiple paths\n"
1566 "Match the cluster length\n")
1568 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1571 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1572 vty_out(vty
, " maximum-paths %d\n",
1573 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1576 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1577 vty_out(vty
, " maximum-paths ibgp %d",
1578 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1579 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1580 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1581 vty_out(vty
, " equal-cluster-length");
1590 "timers bgp (0-65535) (0-65535)",
1591 "Adjust routing timers\n"
1593 "Keepalive interval\n"
1596 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1598 int idx_number_2
= 3;
1599 unsigned long keepalive
= 0;
1600 unsigned long holdtime
= 0;
1602 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1603 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1605 /* Holdtime value check. */
1606 if (holdtime
< 3 && holdtime
!= 0) {
1608 "%% hold time value must be either 0 or greater than 3\n");
1609 return CMD_WARNING_CONFIG_FAILED
;
1612 bgp_timers_set(bgp
, keepalive
, holdtime
);
1617 DEFUN (no_bgp_timers
,
1619 "no timers bgp [(0-65535) (0-65535)]",
1621 "Adjust routing timers\n"
1623 "Keepalive interval\n"
1626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1627 bgp_timers_unset(bgp
);
1633 DEFUN (bgp_client_to_client_reflection
,
1634 bgp_client_to_client_reflection_cmd
,
1635 "bgp client-to-client reflection",
1636 "BGP specific commands\n"
1637 "Configure client to client route reflection\n"
1638 "reflection of routes allowed\n")
1640 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1641 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1642 bgp_clear_star_soft_out(vty
, bgp
->name
);
1647 DEFUN (no_bgp_client_to_client_reflection
,
1648 no_bgp_client_to_client_reflection_cmd
,
1649 "no bgp client-to-client reflection",
1651 "BGP specific commands\n"
1652 "Configure client to client route reflection\n"
1653 "reflection of routes allowed\n")
1655 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1656 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1657 bgp_clear_star_soft_out(vty
, bgp
->name
);
1662 /* "bgp always-compare-med" configuration. */
1663 DEFUN (bgp_always_compare_med
,
1664 bgp_always_compare_med_cmd
,
1665 "bgp always-compare-med",
1666 "BGP specific commands\n"
1667 "Allow comparing MED from different neighbors\n")
1669 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1670 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1671 bgp_recalculate_all_bestpaths(bgp
);
1676 DEFUN (no_bgp_always_compare_med
,
1677 no_bgp_always_compare_med_cmd
,
1678 "no bgp always-compare-med",
1680 "BGP specific commands\n"
1681 "Allow comparing MED from different neighbors\n")
1683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1684 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1685 bgp_recalculate_all_bestpaths(bgp
);
1690 /* "bgp deterministic-med" configuration. */
1691 DEFUN (bgp_deterministic_med
,
1692 bgp_deterministic_med_cmd
,
1693 "bgp deterministic-med",
1694 "BGP specific commands\n"
1695 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1697 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1699 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1700 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1701 bgp_recalculate_all_bestpaths(bgp
);
1707 DEFUN (no_bgp_deterministic_med
,
1708 no_bgp_deterministic_med_cmd
,
1709 "no bgp deterministic-med",
1711 "BGP specific commands\n"
1712 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1714 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1715 int bestpath_per_as_used
;
1719 struct listnode
*node
, *nnode
;
1721 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1722 bestpath_per_as_used
= 0;
1724 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1725 FOREACH_AFI_SAFI (afi
, safi
)
1727 peer
->af_flags
[afi
][safi
],
1728 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1729 bestpath_per_as_used
= 1;
1733 if (bestpath_per_as_used
)
1737 if (bestpath_per_as_used
) {
1739 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1740 return CMD_WARNING_CONFIG_FAILED
;
1742 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1743 bgp_recalculate_all_bestpaths(bgp
);
1750 /* "bgp graceful-restart" configuration. */
1751 DEFUN (bgp_graceful_restart
,
1752 bgp_graceful_restart_cmd
,
1753 "bgp graceful-restart",
1754 "BGP specific commands\n"
1755 "Graceful restart capability parameters\n")
1757 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1758 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1762 DEFUN (no_bgp_graceful_restart
,
1763 no_bgp_graceful_restart_cmd
,
1764 "no bgp graceful-restart",
1766 "BGP specific commands\n"
1767 "Graceful restart capability parameters\n")
1769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1770 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1774 DEFUN (bgp_graceful_restart_stalepath_time
,
1775 bgp_graceful_restart_stalepath_time_cmd
,
1776 "bgp graceful-restart stalepath-time (1-3600)",
1777 "BGP specific commands\n"
1778 "Graceful restart capability parameters\n"
1779 "Set the max time to hold onto restarting peer's stale paths\n"
1780 "Delay value (seconds)\n")
1782 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1784 u_int32_t stalepath
;
1786 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1787 bgp
->stalepath_time
= stalepath
;
1791 DEFUN (bgp_graceful_restart_restart_time
,
1792 bgp_graceful_restart_restart_time_cmd
,
1793 "bgp graceful-restart restart-time (1-3600)",
1794 "BGP specific commands\n"
1795 "Graceful restart capability parameters\n"
1796 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1797 "Delay value (seconds)\n")
1799 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1803 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1804 bgp
->restart_time
= restart
;
1808 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1809 no_bgp_graceful_restart_stalepath_time_cmd
,
1810 "no bgp graceful-restart stalepath-time [(1-3600)]",
1812 "BGP specific commands\n"
1813 "Graceful restart capability parameters\n"
1814 "Set the max time to hold onto restarting peer's stale paths\n"
1815 "Delay value (seconds)\n")
1817 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1819 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1823 DEFUN (no_bgp_graceful_restart_restart_time
,
1824 no_bgp_graceful_restart_restart_time_cmd
,
1825 "no bgp graceful-restart restart-time [(1-3600)]",
1827 "BGP specific commands\n"
1828 "Graceful restart capability parameters\n"
1829 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1830 "Delay value (seconds)\n")
1832 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1834 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1838 DEFUN (bgp_graceful_restart_preserve_fw
,
1839 bgp_graceful_restart_preserve_fw_cmd
,
1840 "bgp graceful-restart preserve-fw-state",
1841 "BGP specific commands\n"
1842 "Graceful restart capability parameters\n"
1843 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1845 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1846 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1850 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1851 no_bgp_graceful_restart_preserve_fw_cmd
,
1852 "no bgp graceful-restart preserve-fw-state",
1854 "BGP specific commands\n"
1855 "Graceful restart capability parameters\n"
1856 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1858 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1859 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1863 static void bgp_redistribute_redo(struct bgp
*bgp
)
1867 struct list
*red_list
;
1868 struct listnode
*node
;
1869 struct bgp_redist
*red
;
1871 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1872 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1874 red_list
= bgp
->redist
[afi
][i
];
1878 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1879 bgp_redistribute_resend(bgp
, afi
, i
,
1886 /* "bgp graceful-shutdown" configuration */
1887 DEFUN (bgp_graceful_shutdown
,
1888 bgp_graceful_shutdown_cmd
,
1889 "bgp graceful-shutdown",
1891 "Graceful shutdown parameters\n")
1893 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1895 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1896 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1897 bgp_static_redo_import_check(bgp
);
1898 bgp_redistribute_redo(bgp
);
1899 bgp_clear_star_soft_out(vty
, bgp
->name
);
1900 bgp_clear_star_soft_in(vty
, bgp
->name
);
1906 DEFUN (no_bgp_graceful_shutdown
,
1907 no_bgp_graceful_shutdown_cmd
,
1908 "no bgp graceful-shutdown",
1911 "Graceful shutdown parameters\n")
1913 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1915 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1916 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1917 bgp_static_redo_import_check(bgp
);
1918 bgp_redistribute_redo(bgp
);
1919 bgp_clear_star_soft_out(vty
, bgp
->name
);
1920 bgp_clear_star_soft_in(vty
, bgp
->name
);
1926 /* "bgp fast-external-failover" configuration. */
1927 DEFUN (bgp_fast_external_failover
,
1928 bgp_fast_external_failover_cmd
,
1929 "bgp fast-external-failover",
1931 "Immediately reset session if a link to a directly connected external peer goes down\n")
1933 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1934 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1938 DEFUN (no_bgp_fast_external_failover
,
1939 no_bgp_fast_external_failover_cmd
,
1940 "no bgp fast-external-failover",
1943 "Immediately reset session if a link to a directly connected external peer goes down\n")
1945 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1946 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1950 /* "bgp enforce-first-as" configuration. */
1951 DEFUN (bgp_enforce_first_as
,
1952 bgp_enforce_first_as_cmd
,
1953 "bgp enforce-first-as",
1955 "Enforce the first AS for EBGP routes\n")
1957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1958 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1959 bgp_clear_star_soft_in(vty
, bgp
->name
);
1964 DEFUN (no_bgp_enforce_first_as
,
1965 no_bgp_enforce_first_as_cmd
,
1966 "no bgp enforce-first-as",
1969 "Enforce the first AS for EBGP routes\n")
1971 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1972 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1973 bgp_clear_star_soft_in(vty
, bgp
->name
);
1978 /* "bgp bestpath compare-routerid" configuration. */
1979 DEFUN (bgp_bestpath_compare_router_id
,
1980 bgp_bestpath_compare_router_id_cmd
,
1981 "bgp bestpath compare-routerid",
1982 "BGP specific commands\n"
1983 "Change the default bestpath selection\n"
1984 "Compare router-id for identical EBGP paths\n")
1986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1987 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
1988 bgp_recalculate_all_bestpaths(bgp
);
1993 DEFUN (no_bgp_bestpath_compare_router_id
,
1994 no_bgp_bestpath_compare_router_id_cmd
,
1995 "no bgp bestpath compare-routerid",
1997 "BGP specific commands\n"
1998 "Change the default bestpath selection\n"
1999 "Compare router-id for identical EBGP paths\n")
2001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2002 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2003 bgp_recalculate_all_bestpaths(bgp
);
2008 /* "bgp bestpath as-path ignore" configuration. */
2009 DEFUN (bgp_bestpath_aspath_ignore
,
2010 bgp_bestpath_aspath_ignore_cmd
,
2011 "bgp bestpath as-path ignore",
2012 "BGP specific commands\n"
2013 "Change the default bestpath selection\n"
2014 "AS-path attribute\n"
2015 "Ignore as-path length in selecting a route\n")
2017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2018 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2019 bgp_recalculate_all_bestpaths(bgp
);
2024 DEFUN (no_bgp_bestpath_aspath_ignore
,
2025 no_bgp_bestpath_aspath_ignore_cmd
,
2026 "no bgp bestpath as-path ignore",
2028 "BGP specific commands\n"
2029 "Change the default bestpath selection\n"
2030 "AS-path attribute\n"
2031 "Ignore as-path length in selecting a route\n")
2033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2034 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2035 bgp_recalculate_all_bestpaths(bgp
);
2040 /* "bgp bestpath as-path confed" configuration. */
2041 DEFUN (bgp_bestpath_aspath_confed
,
2042 bgp_bestpath_aspath_confed_cmd
,
2043 "bgp bestpath as-path confed",
2044 "BGP specific commands\n"
2045 "Change the default bestpath selection\n"
2046 "AS-path attribute\n"
2047 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2049 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2050 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2051 bgp_recalculate_all_bestpaths(bgp
);
2056 DEFUN (no_bgp_bestpath_aspath_confed
,
2057 no_bgp_bestpath_aspath_confed_cmd
,
2058 "no bgp bestpath as-path confed",
2060 "BGP specific commands\n"
2061 "Change the default bestpath selection\n"
2062 "AS-path attribute\n"
2063 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2065 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2066 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2067 bgp_recalculate_all_bestpaths(bgp
);
2072 /* "bgp bestpath as-path multipath-relax" configuration. */
2073 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2074 bgp_bestpath_aspath_multipath_relax_cmd
,
2075 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2076 "BGP specific commands\n"
2077 "Change the default bestpath selection\n"
2078 "AS-path attribute\n"
2079 "Allow load sharing across routes that have different AS paths (but same length)\n"
2080 "Generate an AS_SET\n"
2081 "Do not generate an AS_SET\n")
2083 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2085 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2087 /* no-as-set is now the default behavior so we can silently
2089 if (argv_find(argv
, argc
, "as-set", &idx
))
2090 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2092 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2094 bgp_recalculate_all_bestpaths(bgp
);
2099 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2100 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2101 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2103 "BGP specific commands\n"
2104 "Change the default bestpath selection\n"
2105 "AS-path attribute\n"
2106 "Allow load sharing across routes that have different AS paths (but same length)\n"
2107 "Generate an AS_SET\n"
2108 "Do not generate an AS_SET\n")
2110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2111 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2112 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2113 bgp_recalculate_all_bestpaths(bgp
);
2118 /* "bgp log-neighbor-changes" configuration. */
2119 DEFUN (bgp_log_neighbor_changes
,
2120 bgp_log_neighbor_changes_cmd
,
2121 "bgp log-neighbor-changes",
2122 "BGP specific commands\n"
2123 "Log neighbor up/down and reset reason\n")
2125 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2126 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2130 DEFUN (no_bgp_log_neighbor_changes
,
2131 no_bgp_log_neighbor_changes_cmd
,
2132 "no bgp log-neighbor-changes",
2134 "BGP specific commands\n"
2135 "Log neighbor up/down and reset reason\n")
2137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2138 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2142 /* "bgp bestpath med" configuration. */
2143 DEFUN (bgp_bestpath_med
,
2144 bgp_bestpath_med_cmd
,
2145 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2146 "BGP specific commands\n"
2147 "Change the default bestpath selection\n"
2149 "Compare MED among confederation paths\n"
2150 "Treat missing MED as the least preferred one\n"
2151 "Treat missing MED as the least preferred one\n"
2152 "Compare MED among confederation paths\n")
2154 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2157 if (argv_find(argv
, argc
, "confed", &idx
))
2158 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2160 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2161 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2163 bgp_recalculate_all_bestpaths(bgp
);
2168 DEFUN (no_bgp_bestpath_med
,
2169 no_bgp_bestpath_med_cmd
,
2170 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2172 "BGP specific commands\n"
2173 "Change the default bestpath selection\n"
2175 "Compare MED among confederation paths\n"
2176 "Treat missing MED as the least preferred one\n"
2177 "Treat missing MED as the least preferred one\n"
2178 "Compare MED among confederation paths\n")
2180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2183 if (argv_find(argv
, argc
, "confed", &idx
))
2184 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2186 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2187 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2189 bgp_recalculate_all_bestpaths(bgp
);
2194 /* "no bgp default ipv4-unicast". */
2195 DEFUN (no_bgp_default_ipv4_unicast
,
2196 no_bgp_default_ipv4_unicast_cmd
,
2197 "no bgp default ipv4-unicast",
2199 "BGP specific commands\n"
2200 "Configure BGP defaults\n"
2201 "Activate ipv4-unicast for a peer by default\n")
2203 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2204 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2208 DEFUN (bgp_default_ipv4_unicast
,
2209 bgp_default_ipv4_unicast_cmd
,
2210 "bgp default ipv4-unicast",
2211 "BGP specific commands\n"
2212 "Configure BGP defaults\n"
2213 "Activate ipv4-unicast for a peer by default\n")
2215 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2216 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2220 /* Display hostname in certain command outputs */
2221 DEFUN (bgp_default_show_hostname
,
2222 bgp_default_show_hostname_cmd
,
2223 "bgp default show-hostname",
2224 "BGP specific commands\n"
2225 "Configure BGP defaults\n"
2226 "Show hostname in certain command ouputs\n")
2228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2229 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2233 DEFUN (no_bgp_default_show_hostname
,
2234 no_bgp_default_show_hostname_cmd
,
2235 "no bgp default show-hostname",
2237 "BGP specific commands\n"
2238 "Configure BGP defaults\n"
2239 "Show hostname in certain command ouputs\n")
2241 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2242 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2246 /* "bgp network import-check" configuration. */
2247 DEFUN (bgp_network_import_check
,
2248 bgp_network_import_check_cmd
,
2249 "bgp network import-check",
2250 "BGP specific commands\n"
2251 "BGP network command\n"
2252 "Check BGP network route exists in IGP\n")
2254 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2255 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2256 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2257 bgp_static_redo_import_check(bgp
);
2263 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2264 "bgp network import-check exact",
2265 "BGP specific commands\n"
2266 "BGP network command\n"
2267 "Check BGP network route exists in IGP\n"
2268 "Match route precisely\n")
2270 DEFUN (no_bgp_network_import_check
,
2271 no_bgp_network_import_check_cmd
,
2272 "no bgp network import-check",
2274 "BGP specific commands\n"
2275 "BGP network command\n"
2276 "Check BGP network route exists in IGP\n")
2278 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2279 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2280 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2281 bgp_static_redo_import_check(bgp
);
2287 DEFUN (bgp_default_local_preference
,
2288 bgp_default_local_preference_cmd
,
2289 "bgp default local-preference (0-4294967295)",
2290 "BGP specific commands\n"
2291 "Configure BGP defaults\n"
2292 "local preference (higher=more preferred)\n"
2293 "Configure default local preference value\n")
2295 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2297 u_int32_t local_pref
;
2299 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2301 bgp_default_local_preference_set(bgp
, local_pref
);
2302 bgp_clear_star_soft_in(vty
, bgp
->name
);
2307 DEFUN (no_bgp_default_local_preference
,
2308 no_bgp_default_local_preference_cmd
,
2309 "no bgp default local-preference [(0-4294967295)]",
2311 "BGP specific commands\n"
2312 "Configure BGP defaults\n"
2313 "local preference (higher=more preferred)\n"
2314 "Configure default local preference value\n")
2316 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2317 bgp_default_local_preference_unset(bgp
);
2318 bgp_clear_star_soft_in(vty
, bgp
->name
);
2324 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2325 bgp_default_subgroup_pkt_queue_max_cmd
,
2326 "bgp default subgroup-pkt-queue-max (20-100)",
2327 "BGP specific commands\n"
2328 "Configure BGP defaults\n"
2329 "subgroup-pkt-queue-max\n"
2330 "Configure subgroup packet queue max\n")
2332 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2336 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2338 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2343 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2344 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2345 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2347 "BGP specific commands\n"
2348 "Configure BGP defaults\n"
2349 "subgroup-pkt-queue-max\n"
2350 "Configure subgroup packet queue max\n")
2352 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2353 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2358 DEFUN (bgp_rr_allow_outbound_policy
,
2359 bgp_rr_allow_outbound_policy_cmd
,
2360 "bgp route-reflector allow-outbound-policy",
2361 "BGP specific commands\n"
2362 "Allow modifications made by out route-map\n"
2363 "on ibgp neighbors\n")
2365 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2367 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2368 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2369 update_group_announce_rrclients(bgp
);
2370 bgp_clear_star_soft_out(vty
, bgp
->name
);
2376 DEFUN (no_bgp_rr_allow_outbound_policy
,
2377 no_bgp_rr_allow_outbound_policy_cmd
,
2378 "no bgp route-reflector allow-outbound-policy",
2380 "BGP specific commands\n"
2381 "Allow modifications made by out route-map\n"
2382 "on ibgp neighbors\n")
2384 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2386 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2387 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2388 update_group_announce_rrclients(bgp
);
2389 bgp_clear_star_soft_out(vty
, bgp
->name
);
2395 DEFUN (bgp_listen_limit
,
2396 bgp_listen_limit_cmd
,
2397 "bgp listen limit (1-5000)",
2398 "BGP specific commands\n"
2399 "Configure BGP defaults\n"
2400 "maximum number of BGP Dynamic Neighbors that can be created\n"
2401 "Configure Dynamic Neighbors listen limit value\n")
2403 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2407 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2409 bgp_listen_limit_set(bgp
, listen_limit
);
2414 DEFUN (no_bgp_listen_limit
,
2415 no_bgp_listen_limit_cmd
,
2416 "no bgp listen limit [(1-5000)]",
2417 "BGP specific commands\n"
2418 "Configure BGP defaults\n"
2419 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2420 "Configure Dynamic Neighbors listen limit value to default\n"
2421 "Configure Dynamic Neighbors listen limit value\n")
2423 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2424 bgp_listen_limit_unset(bgp
);
2430 * Check if this listen range is already configured. Check for exact
2431 * match or overlap based on input.
2433 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2434 struct prefix
*range
, int exact
)
2436 struct listnode
*node
, *nnode
;
2437 struct listnode
*node1
, *nnode1
;
2438 struct peer_group
*group
;
2443 afi
= family2afi(range
->family
);
2444 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2445 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2448 match
= prefix_same(range
, lr
);
2450 match
= (prefix_match(range
, lr
)
2451 || prefix_match(lr
, range
));
2460 DEFUN (bgp_listen_range
,
2461 bgp_listen_range_cmd
,
2462 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2463 "BGP specific commands\n"
2464 "Configure BGP dynamic neighbors listen range\n"
2465 "Configure BGP dynamic neighbors listen range\n"
2467 "Member of the peer-group\n"
2468 "Peer-group name\n")
2470 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2471 struct prefix range
;
2472 struct peer_group
*group
, *existing_group
;
2477 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2478 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2479 char *prefix
= argv
[idx
]->arg
;
2480 argv_find(argv
, argc
, "WORD", &idx
);
2481 char *peergroup
= argv
[idx
]->arg
;
2483 /* Convert IP prefix string to struct prefix. */
2484 ret
= str2prefix(prefix
, &range
);
2486 vty_out(vty
, "%% Malformed listen range\n");
2487 return CMD_WARNING_CONFIG_FAILED
;
2490 afi
= family2afi(range
.family
);
2492 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2494 "%% Malformed listen range (link-local address)\n");
2495 return CMD_WARNING_CONFIG_FAILED
;
2500 /* Check if same listen range is already configured. */
2501 existing_group
= listen_range_exists(bgp
, &range
, 1);
2502 if (existing_group
) {
2503 if (strcmp(existing_group
->name
, peergroup
) == 0)
2507 "%% Same listen range is attached to peer-group %s\n",
2508 existing_group
->name
);
2509 return CMD_WARNING_CONFIG_FAILED
;
2513 /* Check if an overlapping listen range exists. */
2514 if (listen_range_exists(bgp
, &range
, 0)) {
2516 "%% Listen range overlaps with existing listen range\n");
2517 return CMD_WARNING_CONFIG_FAILED
;
2520 group
= peer_group_lookup(bgp
, peergroup
);
2522 vty_out(vty
, "%% Configure the peer-group first\n");
2523 return CMD_WARNING_CONFIG_FAILED
;
2526 ret
= peer_group_listen_range_add(group
, &range
);
2527 return bgp_vty_return(vty
, ret
);
2530 DEFUN (no_bgp_listen_range
,
2531 no_bgp_listen_range_cmd
,
2532 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2534 "BGP specific commands\n"
2535 "Unconfigure BGP dynamic neighbors listen range\n"
2536 "Unconfigure BGP dynamic neighbors listen range\n"
2538 "Member of the peer-group\n"
2539 "Peer-group name\n")
2541 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2542 struct prefix range
;
2543 struct peer_group
*group
;
2548 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2549 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2550 char *prefix
= argv
[idx
]->arg
;
2551 argv_find(argv
, argc
, "WORD", &idx
);
2552 char *peergroup
= argv
[idx
]->arg
;
2554 /* Convert IP prefix string to struct prefix. */
2555 ret
= str2prefix(prefix
, &range
);
2557 vty_out(vty
, "%% Malformed listen range\n");
2558 return CMD_WARNING_CONFIG_FAILED
;
2561 afi
= family2afi(range
.family
);
2563 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2565 "%% Malformed listen range (link-local address)\n");
2566 return CMD_WARNING_CONFIG_FAILED
;
2571 group
= peer_group_lookup(bgp
, peergroup
);
2573 vty_out(vty
, "%% Peer-group does not exist\n");
2574 return CMD_WARNING_CONFIG_FAILED
;
2577 ret
= peer_group_listen_range_del(group
, &range
);
2578 return bgp_vty_return(vty
, ret
);
2581 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2583 struct peer_group
*group
;
2584 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2585 struct prefix
*range
;
2587 char buf
[PREFIX2STR_BUFFER
];
2589 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2590 vty_out(vty
, " bgp listen limit %d\n",
2591 bgp
->dynamic_neighbors_limit
);
2593 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2594 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2595 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2597 prefix2str(range
, buf
, sizeof(buf
));
2599 " bgp listen range %s peer-group %s\n",
2607 DEFUN (bgp_disable_connected_route_check
,
2608 bgp_disable_connected_route_check_cmd
,
2609 "bgp disable-ebgp-connected-route-check",
2610 "BGP specific commands\n"
2611 "Disable checking if nexthop is connected on ebgp sessions\n")
2613 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2614 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2615 bgp_clear_star_soft_in(vty
, bgp
->name
);
2620 DEFUN (no_bgp_disable_connected_route_check
,
2621 no_bgp_disable_connected_route_check_cmd
,
2622 "no bgp disable-ebgp-connected-route-check",
2624 "BGP specific commands\n"
2625 "Disable checking if nexthop is connected on ebgp sessions\n")
2627 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2628 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2629 bgp_clear_star_soft_in(vty
, bgp
->name
);
2635 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2636 const char *as_str
, afi_t afi
, safi_t safi
)
2638 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2641 int as_type
= AS_SPECIFIED
;
2644 if (as_str
[0] == 'i') {
2646 as_type
= AS_INTERNAL
;
2647 } else if (as_str
[0] == 'e') {
2649 as_type
= AS_EXTERNAL
;
2651 /* Get AS number. */
2652 as
= strtoul(as_str
, NULL
, 10);
2655 /* If peer is peer group, call proper function. */
2656 ret
= str2sockunion(peer_str
, &su
);
2658 /* Check for peer by interface */
2659 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2662 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2665 "%% Create the peer-group or interface first\n");
2666 return CMD_WARNING_CONFIG_FAILED
;
2671 if (peer_address_self_check(bgp
, &su
)) {
2673 "%% Can not configure the local system as neighbor\n");
2674 return CMD_WARNING_CONFIG_FAILED
;
2676 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2679 /* This peer belongs to peer group. */
2681 case BGP_ERR_PEER_GROUP_MEMBER
:
2683 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2685 return CMD_WARNING_CONFIG_FAILED
;
2686 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2688 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2690 return CMD_WARNING_CONFIG_FAILED
;
2692 return bgp_vty_return(vty
, ret
);
2695 DEFUN (bgp_default_shutdown
,
2696 bgp_default_shutdown_cmd
,
2697 "[no] bgp default shutdown",
2700 "Configure BGP defaults\n"
2701 "Apply administrative shutdown to newly configured peers\n")
2703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2704 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2708 DEFUN (neighbor_remote_as
,
2709 neighbor_remote_as_cmd
,
2710 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2713 "Specify a BGP neighbor\n"
2715 "Internal BGP peer\n"
2716 "External BGP peer\n")
2719 int idx_remote_as
= 3;
2720 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2721 argv
[idx_remote_as
]->arg
, AFI_IP
,
2725 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2726 afi_t afi
, safi_t safi
, int v6only
,
2727 const char *peer_group_name
,
2730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2732 int as_type
= AS_UNSPECIFIED
;
2734 struct peer_group
*group
;
2738 group
= peer_group_lookup(bgp
, conf_if
);
2741 vty_out(vty
, "%% Name conflict with peer-group \n");
2742 return CMD_WARNING_CONFIG_FAILED
;
2746 if (as_str
[0] == 'i') {
2747 as_type
= AS_INTERNAL
;
2748 } else if (as_str
[0] == 'e') {
2749 as_type
= AS_EXTERNAL
;
2751 /* Get AS number. */
2752 as
= strtoul(as_str
, NULL
, 10);
2753 as_type
= AS_SPECIFIED
;
2757 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2760 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2763 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2764 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2765 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2766 as_type
, 0, 0, NULL
);
2768 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2769 as_type
, afi
, safi
, NULL
);
2772 vty_out(vty
, "%% BGP failed to create peer\n");
2773 return CMD_WARNING_CONFIG_FAILED
;
2777 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2779 /* Request zebra to initiate IPv6 RAs on this interface. We do
2781 * any unnumbered peer in order to not worry about run-time
2783 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2785 * gets deleted later etc.)
2788 bgp_zebra_initiate_radv(bgp
, peer
);
2791 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2792 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2794 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2796 UNSET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2798 /* v6only flag changed. Reset bgp seesion */
2799 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2800 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2801 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2802 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2804 bgp_session_reset(peer
);
2807 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
2808 peer_flag_set(peer
, PEER_FLAG_CAPABILITY_ENHE
);
2810 if (peer_group_name
) {
2811 group
= peer_group_lookup(bgp
, peer_group_name
);
2813 vty_out(vty
, "%% Configure the peer-group first\n");
2814 return CMD_WARNING_CONFIG_FAILED
;
2817 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2820 return bgp_vty_return(vty
, ret
);
2823 DEFUN (neighbor_interface_config
,
2824 neighbor_interface_config_cmd
,
2825 "neighbor WORD interface [peer-group WORD]",
2827 "Interface name or neighbor tag\n"
2828 "Enable BGP on interface\n"
2829 "Member of the peer-group\n"
2830 "Peer-group name\n")
2833 int idx_peer_group_word
= 4;
2835 if (argc
> idx_peer_group_word
)
2836 return peer_conf_interface_get(
2837 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2838 argv
[idx_peer_group_word
]->arg
, NULL
);
2840 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2841 SAFI_UNICAST
, 0, NULL
, NULL
);
2844 DEFUN (neighbor_interface_config_v6only
,
2845 neighbor_interface_config_v6only_cmd
,
2846 "neighbor WORD interface v6only [peer-group WORD]",
2848 "Interface name or neighbor tag\n"
2849 "Enable BGP on interface\n"
2850 "Enable BGP with v6 link-local only\n"
2851 "Member of the peer-group\n"
2852 "Peer-group name\n")
2855 int idx_peer_group_word
= 5;
2857 if (argc
> idx_peer_group_word
)
2858 return peer_conf_interface_get(
2859 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2860 argv
[idx_peer_group_word
]->arg
, NULL
);
2862 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2863 SAFI_UNICAST
, 1, NULL
, NULL
);
2867 DEFUN (neighbor_interface_config_remote_as
,
2868 neighbor_interface_config_remote_as_cmd
,
2869 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2871 "Interface name or neighbor tag\n"
2872 "Enable BGP on interface\n"
2873 "Specify a BGP neighbor\n"
2875 "Internal BGP peer\n"
2876 "External BGP peer\n")
2879 int idx_remote_as
= 4;
2880 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2881 SAFI_UNICAST
, 0, NULL
,
2882 argv
[idx_remote_as
]->arg
);
2885 DEFUN (neighbor_interface_v6only_config_remote_as
,
2886 neighbor_interface_v6only_config_remote_as_cmd
,
2887 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2889 "Interface name or neighbor tag\n"
2890 "Enable BGP with v6 link-local only\n"
2891 "Enable BGP on interface\n"
2892 "Specify a BGP neighbor\n"
2894 "Internal BGP peer\n"
2895 "External BGP peer\n")
2898 int idx_remote_as
= 5;
2899 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2900 SAFI_UNICAST
, 1, NULL
,
2901 argv
[idx_remote_as
]->arg
);
2904 DEFUN (neighbor_peer_group
,
2905 neighbor_peer_group_cmd
,
2906 "neighbor WORD peer-group",
2908 "Interface name or neighbor tag\n"
2909 "Configure peer-group\n")
2911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2914 struct peer_group
*group
;
2916 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2918 vty_out(vty
, "%% Name conflict with interface: \n");
2919 return CMD_WARNING_CONFIG_FAILED
;
2922 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2924 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2925 return CMD_WARNING_CONFIG_FAILED
;
2933 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
2937 "Specify a BGP neighbor\n"
2939 "Internal BGP peer\n"
2940 "External BGP peer\n")
2942 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2946 struct peer_group
*group
;
2950 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
2952 /* look up for neighbor by interface name config. */
2953 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
2955 /* Request zebra to terminate IPv6 RAs on this
2958 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
2963 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
2965 peer_group_delete(group
);
2967 vty_out(vty
, "%% Create the peer-group first\n");
2968 return CMD_WARNING_CONFIG_FAILED
;
2971 peer
= peer_lookup(bgp
, &su
);
2973 if (peer_dynamic_neighbor(peer
)) {
2975 "%% Operation not allowed on a dynamic neighbor\n");
2976 return CMD_WARNING_CONFIG_FAILED
;
2979 other
= peer
->doppelganger
;
2981 if (other
&& other
->status
!= Deleted
)
2989 DEFUN (no_neighbor_interface_config
,
2990 no_neighbor_interface_config_cmd
,
2991 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
2995 "Configure BGP on interface\n"
2996 "Enable BGP with v6 link-local only\n"
2997 "Member of the peer-group\n"
2999 "Specify a BGP neighbor\n"
3001 "Internal BGP peer\n"
3002 "External BGP peer\n")
3004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3008 /* look up for neighbor by interface name config. */
3009 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3011 /* Request zebra to terminate IPv6 RAs on this interface. */
3013 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3016 vty_out(vty
, "%% Create the bgp interface first\n");
3017 return CMD_WARNING_CONFIG_FAILED
;
3022 DEFUN (no_neighbor_peer_group
,
3023 no_neighbor_peer_group_cmd
,
3024 "no neighbor WORD peer-group",
3028 "Configure peer-group\n")
3030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3032 struct peer_group
*group
;
3034 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3036 peer_group_delete(group
);
3038 vty_out(vty
, "%% Create the peer-group first\n");
3039 return CMD_WARNING_CONFIG_FAILED
;
3044 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3045 no_neighbor_interface_peer_group_remote_as_cmd
,
3046 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3049 "Interface name or neighbor tag\n"
3050 "Specify a BGP neighbor\n"
3052 "Internal BGP peer\n"
3053 "External BGP peer\n")
3055 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3057 struct peer_group
*group
;
3060 /* look up for neighbor by interface name config. */
3061 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3063 peer_as_change(peer
, 0, AS_SPECIFIED
);
3067 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3069 peer_group_remote_as_delete(group
);
3071 vty_out(vty
, "%% Create the peer-group or interface first\n");
3072 return CMD_WARNING_CONFIG_FAILED
;
3077 DEFUN (neighbor_local_as
,
3078 neighbor_local_as_cmd
,
3079 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3082 "Specify a local-as number\n"
3083 "AS number used as local AS\n")
3091 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3093 return CMD_WARNING_CONFIG_FAILED
;
3095 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3096 ret
= peer_local_as_set(peer
, as
, 0, 0);
3097 return bgp_vty_return(vty
, ret
);
3100 DEFUN (neighbor_local_as_no_prepend
,
3101 neighbor_local_as_no_prepend_cmd
,
3102 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3105 "Specify a local-as number\n"
3106 "AS number used as local AS\n"
3107 "Do not prepend local-as to updates from ebgp peers\n")
3115 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3117 return CMD_WARNING_CONFIG_FAILED
;
3119 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3120 ret
= peer_local_as_set(peer
, as
, 1, 0);
3121 return bgp_vty_return(vty
, ret
);
3124 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3125 neighbor_local_as_no_prepend_replace_as_cmd
,
3126 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3129 "Specify a local-as number\n"
3130 "AS number used as local AS\n"
3131 "Do not prepend local-as to updates from ebgp peers\n"
3132 "Do not prepend local-as to updates from ibgp peers\n")
3140 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3142 return CMD_WARNING_CONFIG_FAILED
;
3144 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3145 ret
= peer_local_as_set(peer
, as
, 1, 1);
3146 return bgp_vty_return(vty
, ret
);
3149 DEFUN (no_neighbor_local_as
,
3150 no_neighbor_local_as_cmd
,
3151 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3155 "Specify a local-as number\n"
3156 "AS number used as local AS\n"
3157 "Do not prepend local-as to updates from ebgp peers\n"
3158 "Do not prepend local-as to updates from ibgp peers\n")
3164 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3166 return CMD_WARNING_CONFIG_FAILED
;
3168 ret
= peer_local_as_unset(peer
);
3169 return bgp_vty_return(vty
, ret
);
3173 DEFUN (neighbor_solo
,
3175 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3178 "Solo peer - part of its own update group\n")
3184 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3186 return CMD_WARNING_CONFIG_FAILED
;
3188 ret
= update_group_adjust_soloness(peer
, 1);
3189 return bgp_vty_return(vty
, ret
);
3192 DEFUN (no_neighbor_solo
,
3193 no_neighbor_solo_cmd
,
3194 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3198 "Solo peer - part of its own update group\n")
3204 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3206 return CMD_WARNING_CONFIG_FAILED
;
3208 ret
= update_group_adjust_soloness(peer
, 0);
3209 return bgp_vty_return(vty
, ret
);
3212 DEFUN (neighbor_password
,
3213 neighbor_password_cmd
,
3214 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3225 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3227 return CMD_WARNING_CONFIG_FAILED
;
3229 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3230 return bgp_vty_return(vty
, ret
);
3233 DEFUN (no_neighbor_password
,
3234 no_neighbor_password_cmd
,
3235 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3246 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3248 return CMD_WARNING_CONFIG_FAILED
;
3250 ret
= peer_password_unset(peer
);
3251 return bgp_vty_return(vty
, ret
);
3254 DEFUN (neighbor_activate
,
3255 neighbor_activate_cmd
,
3256 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3259 "Enable the Address Family for this Neighbor\n")
3265 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3267 return CMD_WARNING_CONFIG_FAILED
;
3269 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3270 return bgp_vty_return(vty
, ret
);
3273 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3274 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3275 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3276 "Enable the Address Family for this Neighbor\n")
3278 DEFUN (no_neighbor_activate
,
3279 no_neighbor_activate_cmd
,
3280 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3284 "Enable the Address Family for this Neighbor\n")
3291 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3293 return CMD_WARNING_CONFIG_FAILED
;
3295 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3296 return bgp_vty_return(vty
, ret
);
3299 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3300 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3301 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3302 "Enable the Address Family for this Neighbor\n")
3304 DEFUN (neighbor_set_peer_group
,
3305 neighbor_set_peer_group_cmd
,
3306 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3309 "Member of the peer-group\n"
3310 "Peer-group name\n")
3312 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3319 struct peer_group
*group
;
3323 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3325 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3327 vty_out(vty
, "%% Malformed address or name: %s\n",
3328 argv
[idx_peer
]->arg
);
3329 return CMD_WARNING_CONFIG_FAILED
;
3332 if (peer_address_self_check(bgp
, &su
)) {
3334 "%% Can not configure the local system as neighbor\n");
3335 return CMD_WARNING_CONFIG_FAILED
;
3338 /* Disallow for dynamic neighbor. */
3339 peer
= peer_lookup(bgp
, &su
);
3340 if (peer
&& peer_dynamic_neighbor(peer
)) {
3342 "%% Operation not allowed on a dynamic neighbor\n");
3343 return CMD_WARNING_CONFIG_FAILED
;
3347 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3349 vty_out(vty
, "%% Configure the peer-group first\n");
3350 return CMD_WARNING_CONFIG_FAILED
;
3353 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3355 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3357 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3359 return CMD_WARNING_CONFIG_FAILED
;
3362 return bgp_vty_return(vty
, ret
);
3365 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3366 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3367 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3368 "Member of the peer-group\n"
3369 "Peer-group name\n")
3371 DEFUN (no_neighbor_set_peer_group
,
3372 no_neighbor_set_peer_group_cmd
,
3373 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3377 "Member of the peer-group\n"
3378 "Peer-group name\n")
3380 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3385 struct peer_group
*group
;
3387 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3389 return CMD_WARNING_CONFIG_FAILED
;
3391 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3393 vty_out(vty
, "%% Configure the peer-group first\n");
3394 return CMD_WARNING_CONFIG_FAILED
;
3397 ret
= peer_group_unbind(bgp
, peer
, group
);
3399 return bgp_vty_return(vty
, ret
);
3402 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3403 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3404 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3405 "Member of the peer-group\n"
3406 "Peer-group name\n")
3408 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3409 u_int16_t flag
, int set
)
3414 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3416 return CMD_WARNING_CONFIG_FAILED
;
3419 * If 'neighbor <interface>', then this is for directly connected peers,
3420 * we should not accept disable-connected-check.
3422 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3424 "%s is directly connected peer, cannot accept disable-"
3425 "connected-check\n",
3427 return CMD_WARNING_CONFIG_FAILED
;
3430 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3431 peer_tx_shutdown_message_unset(peer
);
3434 ret
= peer_flag_set(peer
, flag
);
3436 ret
= peer_flag_unset(peer
, flag
);
3438 return bgp_vty_return(vty
, ret
);
3441 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
,
3444 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3447 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3450 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3453 /* neighbor passive. */
3454 DEFUN (neighbor_passive
,
3455 neighbor_passive_cmd
,
3456 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3459 "Don't send open messages to this neighbor\n")
3462 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3465 DEFUN (no_neighbor_passive
,
3466 no_neighbor_passive_cmd
,
3467 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3471 "Don't send open messages to this neighbor\n")
3474 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3477 /* neighbor shutdown. */
3478 DEFUN (neighbor_shutdown_msg
,
3479 neighbor_shutdown_msg_cmd
,
3480 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3483 "Administratively shut down this neighbor\n"
3484 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3485 "Shutdown message\n")
3491 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3495 return CMD_WARNING_CONFIG_FAILED
;
3496 message
= argv_concat(argv
, argc
, 4);
3497 peer_tx_shutdown_message_set(peer
, message
);
3498 XFREE(MTYPE_TMP
, message
);
3501 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3504 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3505 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3506 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3507 "Administratively shut down this neighbor\n")
3509 DEFUN (no_neighbor_shutdown_msg
,
3510 no_neighbor_shutdown_msg_cmd
,
3511 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3515 "Administratively shut down this neighbor\n"
3516 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3517 "Shutdown message\n")
3521 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3522 PEER_FLAG_SHUTDOWN
);
3525 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3526 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3527 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3528 "Administratively shut down this neighbor\n")
3530 /* neighbor capability dynamic. */
3531 DEFUN (neighbor_capability_dynamic
,
3532 neighbor_capability_dynamic_cmd
,
3533 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3536 "Advertise capability to the peer\n"
3537 "Advertise dynamic capability to this neighbor\n")
3540 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3541 PEER_FLAG_DYNAMIC_CAPABILITY
);
3544 DEFUN (no_neighbor_capability_dynamic
,
3545 no_neighbor_capability_dynamic_cmd
,
3546 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3550 "Advertise capability to the peer\n"
3551 "Advertise dynamic capability to this neighbor\n")
3554 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3555 PEER_FLAG_DYNAMIC_CAPABILITY
);
3558 /* neighbor dont-capability-negotiate */
3559 DEFUN (neighbor_dont_capability_negotiate
,
3560 neighbor_dont_capability_negotiate_cmd
,
3561 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3564 "Do not perform capability negotiation\n")
3567 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3568 PEER_FLAG_DONT_CAPABILITY
);
3571 DEFUN (no_neighbor_dont_capability_negotiate
,
3572 no_neighbor_dont_capability_negotiate_cmd
,
3573 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3577 "Do not perform capability negotiation\n")
3580 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3581 PEER_FLAG_DONT_CAPABILITY
);
3584 /* neighbor capability extended next hop encoding */
3585 DEFUN (neighbor_capability_enhe
,
3586 neighbor_capability_enhe_cmd
,
3587 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3590 "Advertise capability to the peer\n"
3591 "Advertise extended next-hop capability to the peer\n")
3594 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3595 PEER_FLAG_CAPABILITY_ENHE
);
3598 DEFUN (no_neighbor_capability_enhe
,
3599 no_neighbor_capability_enhe_cmd
,
3600 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3604 "Advertise capability to the peer\n"
3605 "Advertise extended next-hop capability to the peer\n")
3608 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3609 PEER_FLAG_CAPABILITY_ENHE
);
3612 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3613 afi_t afi
, safi_t safi
, u_int32_t flag
,
3619 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3621 return CMD_WARNING_CONFIG_FAILED
;
3624 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3626 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3628 return bgp_vty_return(vty
, ret
);
3631 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3632 afi_t afi
, safi_t safi
, u_int32_t flag
)
3634 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3637 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3638 afi_t afi
, safi_t safi
, u_int32_t flag
)
3640 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3643 /* neighbor capability orf prefix-list. */
3644 DEFUN (neighbor_capability_orf_prefix
,
3645 neighbor_capability_orf_prefix_cmd
,
3646 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3649 "Advertise capability to the peer\n"
3650 "Advertise ORF capability to the peer\n"
3651 "Advertise prefixlist ORF capability to this neighbor\n"
3652 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3653 "Capability to RECEIVE the ORF from this neighbor\n"
3654 "Capability to SEND the ORF to this neighbor\n")
3657 int idx_send_recv
= 5;
3660 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3661 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3662 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3663 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3664 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3665 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3667 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3668 return CMD_WARNING_CONFIG_FAILED
;
3671 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3672 bgp_node_safi(vty
), flag
);
3676 neighbor_capability_orf_prefix
,
3677 neighbor_capability_orf_prefix_hidden_cmd
,
3678 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3679 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3680 "Advertise capability to the peer\n"
3681 "Advertise ORF capability to the peer\n"
3682 "Advertise prefixlist ORF capability to this neighbor\n"
3683 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3684 "Capability to RECEIVE the ORF from this neighbor\n"
3685 "Capability to SEND the ORF to this neighbor\n")
3687 DEFUN (no_neighbor_capability_orf_prefix
,
3688 no_neighbor_capability_orf_prefix_cmd
,
3689 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3693 "Advertise capability to the peer\n"
3694 "Advertise ORF capability to the peer\n"
3695 "Advertise prefixlist ORF capability to this neighbor\n"
3696 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3697 "Capability to RECEIVE the ORF from this neighbor\n"
3698 "Capability to SEND the ORF to this neighbor\n")
3701 int idx_send_recv
= 6;
3704 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3705 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3706 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3707 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3708 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3709 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3711 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3712 return CMD_WARNING_CONFIG_FAILED
;
3715 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3716 bgp_node_afi(vty
), bgp_node_safi(vty
),
3721 no_neighbor_capability_orf_prefix
,
3722 no_neighbor_capability_orf_prefix_hidden_cmd
,
3723 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3724 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3725 "Advertise capability to the peer\n"
3726 "Advertise ORF capability to the peer\n"
3727 "Advertise prefixlist ORF capability to this neighbor\n"
3728 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3729 "Capability to RECEIVE the ORF from this neighbor\n"
3730 "Capability to SEND the ORF to this neighbor\n")
3732 /* neighbor next-hop-self. */
3733 DEFUN (neighbor_nexthop_self
,
3734 neighbor_nexthop_self_cmd
,
3735 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3738 "Disable the next hop calculation for this neighbor\n")
3741 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3742 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3745 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3746 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3747 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3748 "Disable the next hop calculation for this neighbor\n")
3750 /* neighbor next-hop-self. */
3751 DEFUN (neighbor_nexthop_self_force
,
3752 neighbor_nexthop_self_force_cmd
,
3753 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3756 "Disable the next hop calculation for this neighbor\n"
3757 "Set the next hop to self for reflected routes\n")
3760 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3762 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3765 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3766 neighbor_nexthop_self_force_hidden_cmd
,
3767 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3768 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3769 "Disable the next hop calculation for this neighbor\n"
3770 "Set the next hop to self for reflected routes\n")
3772 DEFUN (no_neighbor_nexthop_self
,
3773 no_neighbor_nexthop_self_cmd
,
3774 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3778 "Disable the next hop calculation for this neighbor\n")
3781 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3782 bgp_node_afi(vty
), bgp_node_safi(vty
),
3783 PEER_FLAG_NEXTHOP_SELF
);
3786 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3787 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3788 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3789 "Disable the next hop calculation for this neighbor\n")
3791 DEFUN (no_neighbor_nexthop_self_force
,
3792 no_neighbor_nexthop_self_force_cmd
,
3793 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3797 "Disable the next hop calculation for this neighbor\n"
3798 "Set the next hop to self for reflected routes\n")
3801 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3802 bgp_node_afi(vty
), bgp_node_safi(vty
),
3803 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3806 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3807 no_neighbor_nexthop_self_force_hidden_cmd
,
3808 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3809 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3810 "Disable the next hop calculation for this neighbor\n"
3811 "Set the next hop to self for reflected routes\n")
3813 /* neighbor as-override */
3814 DEFUN (neighbor_as_override
,
3815 neighbor_as_override_cmd
,
3816 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3819 "Override ASNs in outbound updates if aspath equals remote-as\n")
3822 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3823 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3826 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3827 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3828 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3829 "Override ASNs in outbound updates if aspath equals remote-as\n")
3831 DEFUN (no_neighbor_as_override
,
3832 no_neighbor_as_override_cmd
,
3833 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3837 "Override ASNs in outbound updates if aspath equals remote-as\n")
3840 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3841 bgp_node_afi(vty
), bgp_node_safi(vty
),
3842 PEER_FLAG_AS_OVERRIDE
);
3845 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3846 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3847 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3848 "Override ASNs in outbound updates if aspath equals remote-as\n")
3850 /* neighbor remove-private-AS. */
3851 DEFUN (neighbor_remove_private_as
,
3852 neighbor_remove_private_as_cmd
,
3853 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3856 "Remove private ASNs in outbound updates\n")
3859 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3861 PEER_FLAG_REMOVE_PRIVATE_AS
);
3864 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3865 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3866 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3867 "Remove private ASNs in outbound updates\n")
3869 DEFUN (neighbor_remove_private_as_all
,
3870 neighbor_remove_private_as_all_cmd
,
3871 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3874 "Remove private ASNs in outbound updates\n"
3875 "Apply to all AS numbers\n")
3878 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3880 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3883 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3884 neighbor_remove_private_as_all_hidden_cmd
,
3885 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3886 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3887 "Remove private ASNs in outbound updates\n"
3888 "Apply to all AS numbers")
3890 DEFUN (neighbor_remove_private_as_replace_as
,
3891 neighbor_remove_private_as_replace_as_cmd
,
3892 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3895 "Remove private ASNs in outbound updates\n"
3896 "Replace private ASNs with our ASN in outbound updates\n")
3899 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3901 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3904 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3905 neighbor_remove_private_as_replace_as_hidden_cmd
,
3906 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3907 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3908 "Remove private ASNs in outbound updates\n"
3909 "Replace private ASNs with our ASN in outbound updates\n")
3911 DEFUN (neighbor_remove_private_as_all_replace_as
,
3912 neighbor_remove_private_as_all_replace_as_cmd
,
3913 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3916 "Remove private ASNs in outbound updates\n"
3917 "Apply to all AS numbers\n"
3918 "Replace private ASNs with our ASN in outbound updates\n")
3921 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3923 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3927 neighbor_remove_private_as_all_replace_as
,
3928 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3929 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3930 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3931 "Remove private ASNs in outbound updates\n"
3932 "Apply to all AS numbers\n"
3933 "Replace private ASNs with our ASN in outbound updates\n")
3935 DEFUN (no_neighbor_remove_private_as
,
3936 no_neighbor_remove_private_as_cmd
,
3937 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3941 "Remove private ASNs in outbound updates\n")
3944 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3945 bgp_node_afi(vty
), bgp_node_safi(vty
),
3946 PEER_FLAG_REMOVE_PRIVATE_AS
);
3949 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
3950 no_neighbor_remove_private_as_hidden_cmd
,
3951 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3952 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3953 "Remove private ASNs in outbound updates\n")
3955 DEFUN (no_neighbor_remove_private_as_all
,
3956 no_neighbor_remove_private_as_all_cmd
,
3957 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3961 "Remove private ASNs in outbound updates\n"
3962 "Apply to all AS numbers\n")
3965 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3966 bgp_node_afi(vty
), bgp_node_safi(vty
),
3967 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3970 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
3971 no_neighbor_remove_private_as_all_hidden_cmd
,
3972 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3973 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3974 "Remove private ASNs in outbound updates\n"
3975 "Apply to all AS numbers\n")
3977 DEFUN (no_neighbor_remove_private_as_replace_as
,
3978 no_neighbor_remove_private_as_replace_as_cmd
,
3979 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3983 "Remove private ASNs in outbound updates\n"
3984 "Replace private ASNs with our ASN in outbound updates\n")
3987 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3988 bgp_node_afi(vty
), bgp_node_safi(vty
),
3989 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3992 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
3993 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
3994 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3995 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3996 "Remove private ASNs in outbound updates\n"
3997 "Replace private ASNs with our ASN in outbound updates\n")
3999 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4000 no_neighbor_remove_private_as_all_replace_as_cmd
,
4001 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4005 "Remove private ASNs in outbound updates\n"
4006 "Apply to all AS numbers\n"
4007 "Replace private ASNs with our ASN in outbound updates\n")
4010 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4011 bgp_node_afi(vty
), bgp_node_safi(vty
),
4012 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4016 no_neighbor_remove_private_as_all_replace_as
,
4017 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4018 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4019 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4020 "Remove private ASNs in outbound updates\n"
4021 "Apply to all AS numbers\n"
4022 "Replace private ASNs with our ASN in outbound updates\n")
4025 /* neighbor send-community. */
4026 DEFUN (neighbor_send_community
,
4027 neighbor_send_community_cmd
,
4028 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4031 "Send Community attribute to this neighbor\n")
4034 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4036 PEER_FLAG_SEND_COMMUNITY
);
4039 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4040 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4041 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4042 "Send Community attribute to this neighbor\n")
4044 DEFUN (no_neighbor_send_community
,
4045 no_neighbor_send_community_cmd
,
4046 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4050 "Send Community attribute to this neighbor\n")
4053 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4054 bgp_node_afi(vty
), bgp_node_safi(vty
),
4055 PEER_FLAG_SEND_COMMUNITY
);
4058 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4059 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4060 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4061 "Send Community attribute to this neighbor\n")
4063 /* neighbor send-community extended. */
4064 DEFUN (neighbor_send_community_type
,
4065 neighbor_send_community_type_cmd
,
4066 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4069 "Send Community attribute to this neighbor\n"
4070 "Send Standard and Extended Community attributes\n"
4071 "Send Standard, Large and Extended Community attributes\n"
4072 "Send Extended Community attributes\n"
4073 "Send Standard Community attributes\n"
4074 "Send Large Community attributes\n")
4079 char *peer
= argv
[1]->arg
;
4081 if (argv_find(argv
, argc
, "standard", &idx
))
4082 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4083 else if (argv_find(argv
, argc
, "extended", &idx
))
4084 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4085 else if (argv_find(argv
, argc
, "large", &idx
))
4086 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4087 else if (argv_find(argv
, argc
, "both", &idx
)) {
4088 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4089 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4091 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4092 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4093 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4096 return peer_af_flag_set_vty(vty
, peer
, bgp_node_afi(vty
),
4097 bgp_node_safi(vty
), flag
);
4101 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4102 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4103 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4104 "Send Community attribute to this neighbor\n"
4105 "Send Standard and Extended Community attributes\n"
4106 "Send Standard, Large and Extended Community attributes\n"
4107 "Send Extended Community attributes\n"
4108 "Send Standard Community attributes\n"
4109 "Send Large Community attributes\n")
4111 DEFUN (no_neighbor_send_community_type
,
4112 no_neighbor_send_community_type_cmd
,
4113 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4117 "Send Community attribute to this neighbor\n"
4118 "Send Standard and Extended Community attributes\n"
4119 "Send Standard, Large and Extended Community attributes\n"
4120 "Send Extended Community attributes\n"
4121 "Send Standard Community attributes\n"
4122 "Send Large Community attributes\n")
4126 const char *type
= argv
[argc
- 1]->text
;
4128 if (strmatch(type
, "standard"))
4129 return peer_af_flag_unset_vty(
4130 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4131 bgp_node_safi(vty
), PEER_FLAG_SEND_COMMUNITY
);
4132 if (strmatch(type
, "extended"))
4133 return peer_af_flag_unset_vty(
4134 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4135 bgp_node_safi(vty
), PEER_FLAG_SEND_EXT_COMMUNITY
);
4136 if (strmatch(type
, "large"))
4137 return peer_af_flag_unset_vty(
4138 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4139 bgp_node_safi(vty
), PEER_FLAG_SEND_LARGE_COMMUNITY
);
4140 if (strmatch(type
, "both"))
4141 return peer_af_flag_unset_vty(
4142 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4144 PEER_FLAG_SEND_COMMUNITY
4145 | PEER_FLAG_SEND_EXT_COMMUNITY
);
4147 /* if (strmatch (type, "all")) */
4148 return peer_af_flag_unset_vty(
4149 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4150 (PEER_FLAG_SEND_COMMUNITY
| PEER_FLAG_SEND_EXT_COMMUNITY
4151 | PEER_FLAG_SEND_LARGE_COMMUNITY
));
4155 no_neighbor_send_community_type
,
4156 no_neighbor_send_community_type_hidden_cmd
,
4157 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4158 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4159 "Send Community attribute to this neighbor\n"
4160 "Send Standard and Extended Community attributes\n"
4161 "Send Standard, Large and Extended Community attributes\n"
4162 "Send Extended Community attributes\n"
4163 "Send Standard Community attributes\n"
4164 "Send Large Community attributes\n")
4166 /* neighbor soft-reconfig. */
4167 DEFUN (neighbor_soft_reconfiguration
,
4168 neighbor_soft_reconfiguration_cmd
,
4169 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4172 "Per neighbor soft reconfiguration\n"
4173 "Allow inbound soft reconfiguration for this neighbor\n")
4176 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4178 PEER_FLAG_SOFT_RECONFIG
);
4181 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4182 neighbor_soft_reconfiguration_hidden_cmd
,
4183 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4184 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4185 "Per neighbor soft reconfiguration\n"
4186 "Allow inbound soft reconfiguration for this neighbor\n")
4188 DEFUN (no_neighbor_soft_reconfiguration
,
4189 no_neighbor_soft_reconfiguration_cmd
,
4190 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4194 "Per neighbor soft reconfiguration\n"
4195 "Allow inbound soft reconfiguration for this neighbor\n")
4198 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4199 bgp_node_afi(vty
), bgp_node_safi(vty
),
4200 PEER_FLAG_SOFT_RECONFIG
);
4203 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4204 no_neighbor_soft_reconfiguration_hidden_cmd
,
4205 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4206 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4207 "Per neighbor soft reconfiguration\n"
4208 "Allow inbound soft reconfiguration for this neighbor\n")
4210 DEFUN (neighbor_route_reflector_client
,
4211 neighbor_route_reflector_client_cmd
,
4212 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4215 "Configure a neighbor as Route Reflector client\n")
4221 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4223 return CMD_WARNING_CONFIG_FAILED
;
4225 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4227 PEER_FLAG_REFLECTOR_CLIENT
);
4230 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4231 neighbor_route_reflector_client_hidden_cmd
,
4232 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4233 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4234 "Configure a neighbor as Route Reflector client\n")
4236 DEFUN (no_neighbor_route_reflector_client
,
4237 no_neighbor_route_reflector_client_cmd
,
4238 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4242 "Configure a neighbor as Route Reflector client\n")
4245 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4246 bgp_node_afi(vty
), bgp_node_safi(vty
),
4247 PEER_FLAG_REFLECTOR_CLIENT
);
4250 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4251 no_neighbor_route_reflector_client_hidden_cmd
,
4252 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4253 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4254 "Configure a neighbor as Route Reflector client\n")
4256 /* neighbor route-server-client. */
4257 DEFUN (neighbor_route_server_client
,
4258 neighbor_route_server_client_cmd
,
4259 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4262 "Configure a neighbor as Route Server client\n")
4267 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4269 return CMD_WARNING_CONFIG_FAILED
;
4270 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4272 PEER_FLAG_RSERVER_CLIENT
);
4275 ALIAS_HIDDEN(neighbor_route_server_client
,
4276 neighbor_route_server_client_hidden_cmd
,
4277 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4278 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4279 "Configure a neighbor as Route Server client\n")
4281 DEFUN (no_neighbor_route_server_client
,
4282 no_neighbor_route_server_client_cmd
,
4283 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4287 "Configure a neighbor as Route Server client\n")
4290 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4291 bgp_node_afi(vty
), bgp_node_safi(vty
),
4292 PEER_FLAG_RSERVER_CLIENT
);
4295 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4296 no_neighbor_route_server_client_hidden_cmd
,
4297 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4298 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4299 "Configure a neighbor as Route Server client\n")
4301 DEFUN (neighbor_nexthop_local_unchanged
,
4302 neighbor_nexthop_local_unchanged_cmd
,
4303 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4306 "Configure treatment of outgoing link-local nexthop attribute\n"
4307 "Leave link-local nexthop unchanged for this peer\n")
4310 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4312 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4315 DEFUN (no_neighbor_nexthop_local_unchanged
,
4316 no_neighbor_nexthop_local_unchanged_cmd
,
4317 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4321 "Configure treatment of outgoing link-local-nexthop attribute\n"
4322 "Leave link-local nexthop unchanged for this peer\n")
4325 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4326 bgp_node_afi(vty
), bgp_node_safi(vty
),
4327 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4330 DEFUN (neighbor_attr_unchanged
,
4331 neighbor_attr_unchanged_cmd
,
4332 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4335 "BGP attribute is propagated unchanged to this neighbor\n"
4336 "As-path attribute\n"
4337 "Nexthop attribute\n"
4341 char *peer_str
= argv
[1]->arg
;
4343 u_int16_t flags
= 0;
4344 afi_t afi
= bgp_node_afi(vty
);
4345 safi_t safi
= bgp_node_safi(vty
);
4347 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4349 return CMD_WARNING_CONFIG_FAILED
;
4351 if (argv_find(argv
, argc
, "as-path", &idx
))
4352 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4354 if (argv_find(argv
, argc
, "next-hop", &idx
))
4355 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4357 if (argv_find(argv
, argc
, "med", &idx
))
4358 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4360 /* no flags means all of them! */
4362 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4363 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4364 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4366 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
) &&
4367 peer_af_flag_check(peer
, afi
, safi
,
4368 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4369 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4370 PEER_FLAG_AS_PATH_UNCHANGED
);
4373 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
) &&
4374 peer_af_flag_check(peer
, afi
, safi
,
4375 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4376 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4377 PEER_FLAG_NEXTHOP_UNCHANGED
);
4380 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
) &&
4381 peer_af_flag_check(peer
, afi
, safi
,
4382 PEER_FLAG_MED_UNCHANGED
)) {
4383 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4384 PEER_FLAG_MED_UNCHANGED
);
4388 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4392 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4393 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4394 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4395 "BGP attribute is propagated unchanged to this neighbor\n"
4396 "As-path attribute\n"
4397 "Nexthop attribute\n"
4400 DEFUN (no_neighbor_attr_unchanged
,
4401 no_neighbor_attr_unchanged_cmd
,
4402 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4406 "BGP attribute is propagated unchanged to this neighbor\n"
4407 "As-path attribute\n"
4408 "Nexthop attribute\n"
4412 char *peer
= argv
[2]->arg
;
4413 u_int16_t flags
= 0;
4415 if (argv_find(argv
, argc
, "as-path", &idx
))
4416 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4418 if (argv_find(argv
, argc
, "next-hop", &idx
))
4419 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4421 if (argv_find(argv
, argc
, "med", &idx
))
4422 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4424 if (!flags
) // no flags means all of them!
4426 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4427 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4428 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4431 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4432 bgp_node_safi(vty
), flags
);
4436 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4437 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4438 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4439 "BGP attribute is propagated unchanged to this neighbor\n"
4440 "As-path attribute\n"
4441 "Nexthop attribute\n"
4444 /* EBGP multihop configuration. */
4445 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4446 const char *ttl_str
)
4451 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4453 return CMD_WARNING_CONFIG_FAILED
;
4456 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4461 ttl
= strtoul(ttl_str
, NULL
, 10);
4463 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4466 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4470 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4472 return CMD_WARNING_CONFIG_FAILED
;
4474 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4477 /* neighbor ebgp-multihop. */
4478 DEFUN (neighbor_ebgp_multihop
,
4479 neighbor_ebgp_multihop_cmd
,
4480 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4483 "Allow EBGP neighbors not on directly connected networks\n")
4486 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4489 DEFUN (neighbor_ebgp_multihop_ttl
,
4490 neighbor_ebgp_multihop_ttl_cmd
,
4491 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4494 "Allow EBGP neighbors not on directly connected networks\n"
4495 "maximum hop count\n")
4499 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4500 argv
[idx_number
]->arg
);
4503 DEFUN (no_neighbor_ebgp_multihop
,
4504 no_neighbor_ebgp_multihop_cmd
,
4505 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4509 "Allow EBGP neighbors not on directly connected networks\n"
4510 "maximum hop count\n")
4513 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4517 /* disable-connected-check */
4518 DEFUN (neighbor_disable_connected_check
,
4519 neighbor_disable_connected_check_cmd
,
4520 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4523 "one-hop away EBGP peer using loopback address\n"
4524 "Enforce EBGP neighbors perform multihop\n")
4527 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4528 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4531 DEFUN (no_neighbor_disable_connected_check
,
4532 no_neighbor_disable_connected_check_cmd
,
4533 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4537 "one-hop away EBGP peer using loopback address\n"
4538 "Enforce EBGP neighbors perform multihop\n")
4541 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4542 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4545 DEFUN (neighbor_description
,
4546 neighbor_description_cmd
,
4547 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4550 "Neighbor specific description\n"
4551 "Up to 80 characters describing this neighbor\n")
4558 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4560 return CMD_WARNING_CONFIG_FAILED
;
4562 str
= argv_concat(argv
, argc
, idx_line
);
4564 peer_description_set(peer
, str
);
4566 XFREE(MTYPE_TMP
, str
);
4571 DEFUN (no_neighbor_description
,
4572 no_neighbor_description_cmd
,
4573 "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]",
4577 "Neighbor specific description\n"
4578 "Up to 80 characters describing this neighbor\n")
4583 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4585 return CMD_WARNING_CONFIG_FAILED
;
4587 peer_description_unset(peer
);
4593 /* Neighbor update-source. */
4594 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4595 const char *source_str
)
4600 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4602 return CMD_WARNING_CONFIG_FAILED
;
4609 int ret
= str2sockunion(source_str
, &su
);
4612 peer_update_source_addr_set(peer
, &su
);
4614 if (str2prefix(source_str
, &p
)) {
4616 "%% Invalid update-source, remove prefix length \n");
4617 return CMD_WARNING_CONFIG_FAILED
;
4619 peer_update_source_if_set(peer
, source_str
);
4622 peer_update_source_unset(peer
);
4627 #define BGP_UPDATE_SOURCE_HELP_STR \
4630 "Interface name (requires zebra to be running)\n"
4632 DEFUN (neighbor_update_source
,
4633 neighbor_update_source_cmd
,
4634 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4637 "Source of routing updates\n"
4638 BGP_UPDATE_SOURCE_HELP_STR
)
4642 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4643 argv
[idx_peer_2
]->arg
);
4646 DEFUN (no_neighbor_update_source
,
4647 no_neighbor_update_source_cmd
,
4648 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4652 "Source of routing updates\n"
4653 BGP_UPDATE_SOURCE_HELP_STR
)
4656 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4659 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4660 afi_t afi
, safi_t safi
,
4661 const char *rmap
, int set
)
4666 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4668 return CMD_WARNING_CONFIG_FAILED
;
4671 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4673 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4675 return bgp_vty_return(vty
, ret
);
4678 /* neighbor default-originate. */
4679 DEFUN (neighbor_default_originate
,
4680 neighbor_default_originate_cmd
,
4681 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4684 "Originate default route to this neighbor\n")
4687 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4689 bgp_node_safi(vty
), NULL
, 1);
4692 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4693 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4694 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4695 "Originate default route to this neighbor\n")
4697 DEFUN (neighbor_default_originate_rmap
,
4698 neighbor_default_originate_rmap_cmd
,
4699 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4702 "Originate default route to this neighbor\n"
4703 "Route-map to specify criteria to originate default\n"
4708 return peer_default_originate_set_vty(
4709 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4710 argv
[idx_word
]->arg
, 1);
4714 neighbor_default_originate_rmap
,
4715 neighbor_default_originate_rmap_hidden_cmd
,
4716 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4717 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4718 "Originate default route to this neighbor\n"
4719 "Route-map to specify criteria to originate default\n"
4722 DEFUN (no_neighbor_default_originate
,
4723 no_neighbor_default_originate_cmd
,
4724 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4728 "Originate default route to this neighbor\n"
4729 "Route-map to specify criteria to originate default\n"
4733 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4735 bgp_node_safi(vty
), NULL
, 0);
4739 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4740 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4741 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4742 "Originate default route to this neighbor\n"
4743 "Route-map to specify criteria to originate default\n"
4747 /* Set neighbor's BGP port. */
4748 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4749 const char *port_str
)
4755 peer
= peer_lookup_vty(vty
, ip_str
);
4757 return CMD_WARNING_CONFIG_FAILED
;
4760 sp
= getservbyname("bgp", "tcp");
4761 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4763 port
= strtoul(port_str
, NULL
, 10);
4766 peer_port_set(peer
, port
);
4771 /* Set specified peer's BGP port. */
4772 DEFUN (neighbor_port
,
4774 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4777 "Neighbor's BGP port\n"
4778 "TCP port number\n")
4782 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4783 argv
[idx_number
]->arg
);
4786 DEFUN (no_neighbor_port
,
4787 no_neighbor_port_cmd
,
4788 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4792 "Neighbor's BGP port\n"
4793 "TCP port number\n")
4796 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4800 /* neighbor weight. */
4801 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4802 safi_t safi
, const char *weight_str
)
4806 unsigned long weight
;
4808 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4810 return CMD_WARNING_CONFIG_FAILED
;
4812 weight
= strtoul(weight_str
, NULL
, 10);
4814 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4815 return bgp_vty_return(vty
, ret
);
4818 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4824 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4826 return CMD_WARNING_CONFIG_FAILED
;
4828 ret
= peer_weight_unset(peer
, afi
, safi
);
4829 return bgp_vty_return(vty
, ret
);
4832 DEFUN (neighbor_weight
,
4833 neighbor_weight_cmd
,
4834 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4837 "Set default weight for routes from this neighbor\n"
4842 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4843 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4846 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4847 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4848 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4849 "Set default weight for routes from this neighbor\n"
4852 DEFUN (no_neighbor_weight
,
4853 no_neighbor_weight_cmd
,
4854 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4858 "Set default weight for routes from this neighbor\n"
4862 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4863 bgp_node_afi(vty
), bgp_node_safi(vty
));
4866 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4867 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4868 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4869 "Set default weight for routes from this neighbor\n"
4873 /* Override capability negotiation. */
4874 DEFUN (neighbor_override_capability
,
4875 neighbor_override_capability_cmd
,
4876 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4879 "Override capability negotiation result\n")
4882 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4883 PEER_FLAG_OVERRIDE_CAPABILITY
);
4886 DEFUN (no_neighbor_override_capability
,
4887 no_neighbor_override_capability_cmd
,
4888 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4892 "Override capability negotiation result\n")
4895 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4896 PEER_FLAG_OVERRIDE_CAPABILITY
);
4899 DEFUN (neighbor_strict_capability
,
4900 neighbor_strict_capability_cmd
,
4901 "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4904 "Strict capability negotiation match\n")
4907 return peer_flag_set_vty(vty
, argv
[idx_ip
]->arg
,
4908 PEER_FLAG_STRICT_CAP_MATCH
);
4911 DEFUN (no_neighbor_strict_capability
,
4912 no_neighbor_strict_capability_cmd
,
4913 "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4917 "Strict capability negotiation match\n")
4920 return peer_flag_unset_vty(vty
, argv
[idx_ip
]->arg
,
4921 PEER_FLAG_STRICT_CAP_MATCH
);
4924 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
4925 const char *keep_str
, const char *hold_str
)
4929 u_int32_t keepalive
;
4932 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4934 return CMD_WARNING_CONFIG_FAILED
;
4936 keepalive
= strtoul(keep_str
, NULL
, 10);
4937 holdtime
= strtoul(hold_str
, NULL
, 10);
4939 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
4941 return bgp_vty_return(vty
, ret
);
4944 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
4949 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4951 return CMD_WARNING_CONFIG_FAILED
;
4953 ret
= peer_timers_unset(peer
);
4955 return bgp_vty_return(vty
, ret
);
4958 DEFUN (neighbor_timers
,
4959 neighbor_timers_cmd
,
4960 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
4963 "BGP per neighbor timers\n"
4964 "Keepalive interval\n"
4969 int idx_number_2
= 4;
4970 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
4971 argv
[idx_number
]->arg
,
4972 argv
[idx_number_2
]->arg
);
4975 DEFUN (no_neighbor_timers
,
4976 no_neighbor_timers_cmd
,
4977 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
4981 "BGP per neighbor timers\n"
4982 "Keepalive interval\n"
4986 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
4990 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
4991 const char *time_str
)
4997 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4999 return CMD_WARNING_CONFIG_FAILED
;
5001 connect
= strtoul(time_str
, NULL
, 10);
5003 ret
= peer_timers_connect_set(peer
, connect
);
5005 return bgp_vty_return(vty
, ret
);
5008 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5013 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5015 return CMD_WARNING_CONFIG_FAILED
;
5017 ret
= peer_timers_connect_unset(peer
);
5019 return bgp_vty_return(vty
, ret
);
5022 DEFUN (neighbor_timers_connect
,
5023 neighbor_timers_connect_cmd
,
5024 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5027 "BGP per neighbor timers\n"
5028 "BGP connect timer\n"
5033 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5034 argv
[idx_number
]->arg
);
5037 DEFUN (no_neighbor_timers_connect
,
5038 no_neighbor_timers_connect_cmd
,
5039 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5043 "BGP per neighbor timers\n"
5044 "BGP connect timer\n"
5048 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5052 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5053 const char *time_str
, int set
)
5057 u_int32_t routeadv
= 0;
5059 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5061 return CMD_WARNING_CONFIG_FAILED
;
5064 routeadv
= strtoul(time_str
, NULL
, 10);
5067 ret
= peer_advertise_interval_set(peer
, routeadv
);
5069 ret
= peer_advertise_interval_unset(peer
);
5071 return bgp_vty_return(vty
, ret
);
5074 DEFUN (neighbor_advertise_interval
,
5075 neighbor_advertise_interval_cmd
,
5076 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5079 "Minimum interval between sending BGP routing updates\n"
5080 "time in seconds\n")
5084 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5085 argv
[idx_number
]->arg
, 1);
5088 DEFUN (no_neighbor_advertise_interval
,
5089 no_neighbor_advertise_interval_cmd
,
5090 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5094 "Minimum interval between sending BGP routing updates\n"
5095 "time in seconds\n")
5098 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5102 /* Time to wait before processing route-map updates */
5103 DEFUN (bgp_set_route_map_delay_timer
,
5104 bgp_set_route_map_delay_timer_cmd
,
5105 "bgp route-map delay-timer (0-600)",
5107 "BGP route-map delay timer\n"
5108 "Time in secs to wait before processing route-map changes\n"
5109 "0 disables the timer, no route updates happen when route-maps change\n")
5112 u_int32_t rmap_delay_timer
;
5114 if (argv
[idx_number
]->arg
) {
5115 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5116 bm
->rmap_update_timer
= rmap_delay_timer
;
5118 /* if the dynamic update handling is being disabled, and a timer
5120 * running, stop the timer and act as if the timer has already
5123 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5124 BGP_TIMER_OFF(bm
->t_rmap_update
);
5125 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5130 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5131 return CMD_WARNING_CONFIG_FAILED
;
5135 DEFUN (no_bgp_set_route_map_delay_timer
,
5136 no_bgp_set_route_map_delay_timer_cmd
,
5137 "no bgp route-map delay-timer [(0-600)]",
5140 "Default BGP route-map delay timer\n"
5141 "Reset to default time to wait for processing route-map changes\n"
5142 "0 disables the timer, no route updates happen when route-maps change\n")
5145 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5151 /* neighbor interface */
5152 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5157 peer
= peer_lookup_vty(vty
, ip_str
);
5158 if (!peer
|| peer
->conf_if
) {
5159 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5160 return CMD_WARNING_CONFIG_FAILED
;
5164 peer_interface_set(peer
, str
);
5166 peer_interface_unset(peer
);
5171 DEFUN (neighbor_interface
,
5172 neighbor_interface_cmd
,
5173 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5181 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5184 DEFUN (no_neighbor_interface
,
5185 no_neighbor_interface_cmd
,
5186 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5194 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5197 DEFUN (neighbor_distribute_list
,
5198 neighbor_distribute_list_cmd
,
5199 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5202 "Filter updates to/from this neighbor\n"
5203 "IP access-list number\n"
5204 "IP access-list number (expanded range)\n"
5205 "IP Access-list name\n"
5206 "Filter incoming updates\n"
5207 "Filter outgoing updates\n")
5214 const char *pstr
= argv
[idx_peer
]->arg
;
5215 const char *acl
= argv
[idx_acl
]->arg
;
5216 const char *inout
= argv
[argc
- 1]->text
;
5218 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5220 return CMD_WARNING_CONFIG_FAILED
;
5222 /* Check filter direction. */
5223 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5224 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5227 return bgp_vty_return(vty
, ret
);
5231 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5232 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5233 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5234 "Filter updates to/from this neighbor\n"
5235 "IP access-list number\n"
5236 "IP access-list number (expanded range)\n"
5237 "IP Access-list name\n"
5238 "Filter incoming updates\n"
5239 "Filter outgoing updates\n")
5241 DEFUN (no_neighbor_distribute_list
,
5242 no_neighbor_distribute_list_cmd
,
5243 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5247 "Filter updates to/from this neighbor\n"
5248 "IP access-list number\n"
5249 "IP access-list number (expanded range)\n"
5250 "IP Access-list name\n"
5251 "Filter incoming updates\n"
5252 "Filter outgoing updates\n")
5258 const char *pstr
= argv
[idx_peer
]->arg
;
5259 const char *inout
= argv
[argc
- 1]->text
;
5261 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5263 return CMD_WARNING_CONFIG_FAILED
;
5265 /* Check filter direction. */
5266 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5267 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5270 return bgp_vty_return(vty
, ret
);
5274 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5275 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5276 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5277 "Filter updates to/from this neighbor\n"
5278 "IP access-list number\n"
5279 "IP access-list number (expanded range)\n"
5280 "IP Access-list name\n"
5281 "Filter incoming updates\n"
5282 "Filter outgoing updates\n")
5284 /* Set prefix list to the peer. */
5285 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5286 afi_t afi
, safi_t safi
,
5287 const char *name_str
,
5288 const char *direct_str
)
5292 int direct
= FILTER_IN
;
5294 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5296 return CMD_WARNING_CONFIG_FAILED
;
5298 /* Check filter direction. */
5299 if (strncmp(direct_str
, "i", 1) == 0)
5301 else if (strncmp(direct_str
, "o", 1) == 0)
5302 direct
= FILTER_OUT
;
5304 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5306 return bgp_vty_return(vty
, ret
);
5309 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5310 afi_t afi
, safi_t safi
,
5311 const char *direct_str
)
5315 int direct
= FILTER_IN
;
5317 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5319 return CMD_WARNING_CONFIG_FAILED
;
5321 /* Check filter direction. */
5322 if (strncmp(direct_str
, "i", 1) == 0)
5324 else if (strncmp(direct_str
, "o", 1) == 0)
5325 direct
= FILTER_OUT
;
5327 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5329 return bgp_vty_return(vty
, ret
);
5332 DEFUN (neighbor_prefix_list
,
5333 neighbor_prefix_list_cmd
,
5334 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5337 "Filter updates to/from this neighbor\n"
5338 "Name of a prefix list\n"
5339 "Filter incoming updates\n"
5340 "Filter outgoing updates\n")
5345 return peer_prefix_list_set_vty(
5346 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5347 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5350 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5351 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5352 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5353 "Filter updates to/from this neighbor\n"
5354 "Name of a prefix list\n"
5355 "Filter incoming updates\n"
5356 "Filter outgoing updates\n")
5358 DEFUN (no_neighbor_prefix_list
,
5359 no_neighbor_prefix_list_cmd
,
5360 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5364 "Filter updates to/from this neighbor\n"
5365 "Name of a prefix list\n"
5366 "Filter incoming updates\n"
5367 "Filter outgoing updates\n")
5371 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5372 bgp_node_afi(vty
), bgp_node_safi(vty
),
5373 argv
[idx_in_out
]->arg
);
5376 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5377 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5378 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5379 "Filter updates to/from this neighbor\n"
5380 "Name of a prefix list\n"
5381 "Filter incoming updates\n"
5382 "Filter outgoing updates\n")
5384 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5385 safi_t safi
, const char *name_str
,
5386 const char *direct_str
)
5390 int direct
= FILTER_IN
;
5392 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5394 return CMD_WARNING_CONFIG_FAILED
;
5396 /* Check filter direction. */
5397 if (strncmp(direct_str
, "i", 1) == 0)
5399 else if (strncmp(direct_str
, "o", 1) == 0)
5400 direct
= FILTER_OUT
;
5402 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5404 return bgp_vty_return(vty
, ret
);
5407 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5408 safi_t safi
, const char *direct_str
)
5412 int direct
= FILTER_IN
;
5414 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5416 return CMD_WARNING_CONFIG_FAILED
;
5418 /* Check filter direction. */
5419 if (strncmp(direct_str
, "i", 1) == 0)
5421 else if (strncmp(direct_str
, "o", 1) == 0)
5422 direct
= FILTER_OUT
;
5424 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5426 return bgp_vty_return(vty
, ret
);
5429 DEFUN (neighbor_filter_list
,
5430 neighbor_filter_list_cmd
,
5431 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5434 "Establish BGP filters\n"
5435 "AS path access-list name\n"
5436 "Filter incoming routes\n"
5437 "Filter outgoing routes\n")
5442 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5443 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5444 argv
[idx_in_out
]->arg
);
5447 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5448 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5449 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5450 "Establish BGP filters\n"
5451 "AS path access-list name\n"
5452 "Filter incoming routes\n"
5453 "Filter outgoing routes\n")
5455 DEFUN (no_neighbor_filter_list
,
5456 no_neighbor_filter_list_cmd
,
5457 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5461 "Establish BGP filters\n"
5462 "AS path access-list name\n"
5463 "Filter incoming routes\n"
5464 "Filter outgoing routes\n")
5468 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5469 bgp_node_afi(vty
), bgp_node_safi(vty
),
5470 argv
[idx_in_out
]->arg
);
5473 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5474 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5475 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5476 "Establish BGP filters\n"
5477 "AS path access-list name\n"
5478 "Filter incoming routes\n"
5479 "Filter outgoing routes\n")
5481 /* Set route-map to the peer. */
5482 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5483 afi_t afi
, safi_t safi
, const char *name_str
,
5484 const char *direct_str
)
5488 int direct
= RMAP_IN
;
5490 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5492 return CMD_WARNING_CONFIG_FAILED
;
5494 /* Check filter direction. */
5495 if (strncmp(direct_str
, "in", 2) == 0)
5497 else if (strncmp(direct_str
, "o", 1) == 0)
5500 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5502 return bgp_vty_return(vty
, ret
);
5505 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5506 afi_t afi
, safi_t safi
,
5507 const char *direct_str
)
5511 int direct
= RMAP_IN
;
5513 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5515 return CMD_WARNING_CONFIG_FAILED
;
5517 /* Check filter direction. */
5518 if (strncmp(direct_str
, "in", 2) == 0)
5520 else if (strncmp(direct_str
, "o", 1) == 0)
5523 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5525 return bgp_vty_return(vty
, ret
);
5528 DEFUN (neighbor_route_map
,
5529 neighbor_route_map_cmd
,
5530 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5533 "Apply route map to neighbor\n"
5534 "Name of route map\n"
5535 "Apply map to incoming routes\n"
5536 "Apply map to outbound routes\n")
5541 return peer_route_map_set_vty(
5542 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5543 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5546 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5547 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5548 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5549 "Apply route map to neighbor\n"
5550 "Name of route map\n"
5551 "Apply map to incoming routes\n"
5552 "Apply map to outbound routes\n")
5554 DEFUN (no_neighbor_route_map
,
5555 no_neighbor_route_map_cmd
,
5556 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5560 "Apply route map to neighbor\n"
5561 "Name of route map\n"
5562 "Apply map to incoming routes\n"
5563 "Apply map to outbound routes\n")
5567 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5568 bgp_node_afi(vty
), bgp_node_safi(vty
),
5569 argv
[idx_in_out
]->arg
);
5572 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5573 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5574 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5575 "Apply route map to neighbor\n"
5576 "Name of route map\n"
5577 "Apply map to incoming routes\n"
5578 "Apply map to outbound routes\n")
5580 /* Set unsuppress-map to the peer. */
5581 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5582 afi_t afi
, safi_t safi
,
5583 const char *name_str
)
5588 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5590 return CMD_WARNING_CONFIG_FAILED
;
5592 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5594 return bgp_vty_return(vty
, ret
);
5597 /* Unset route-map from the peer. */
5598 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5599 afi_t afi
, safi_t safi
)
5604 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5606 return CMD_WARNING_CONFIG_FAILED
;
5608 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5610 return bgp_vty_return(vty
, ret
);
5613 DEFUN (neighbor_unsuppress_map
,
5614 neighbor_unsuppress_map_cmd
,
5615 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5618 "Route-map to selectively unsuppress suppressed routes\n"
5619 "Name of route map\n")
5623 return peer_unsuppress_map_set_vty(
5624 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5625 argv
[idx_word
]->arg
);
5628 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5629 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5630 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5631 "Route-map to selectively unsuppress suppressed routes\n"
5632 "Name of route map\n")
5634 DEFUN (no_neighbor_unsuppress_map
,
5635 no_neighbor_unsuppress_map_cmd
,
5636 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5640 "Route-map to selectively unsuppress suppressed routes\n"
5641 "Name of route map\n")
5644 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5646 bgp_node_safi(vty
));
5649 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5650 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5651 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5652 "Route-map to selectively unsuppress suppressed routes\n"
5653 "Name of route map\n")
5655 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5656 afi_t afi
, safi_t safi
,
5657 const char *num_str
,
5658 const char *threshold_str
, int warning
,
5659 const char *restart_str
)
5667 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5669 return CMD_WARNING_CONFIG_FAILED
;
5671 max
= strtoul(num_str
, NULL
, 10);
5673 threshold
= atoi(threshold_str
);
5675 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5678 restart
= atoi(restart_str
);
5682 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5685 return bgp_vty_return(vty
, ret
);
5688 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5689 afi_t afi
, safi_t safi
)
5694 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5696 return CMD_WARNING_CONFIG_FAILED
;
5698 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5700 return bgp_vty_return(vty
, ret
);
5703 /* Maximum number of prefix configuration. prefix count is different
5704 for each peer configuration. So this configuration can be set for
5705 each peer configuration. */
5706 DEFUN (neighbor_maximum_prefix
,
5707 neighbor_maximum_prefix_cmd
,
5708 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5711 "Maximum number of prefix accept from this peer\n"
5712 "maximum no. of prefix limit\n")
5716 return peer_maximum_prefix_set_vty(
5717 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5718 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5721 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5722 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5723 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5724 "Maximum number of prefix accept from this peer\n"
5725 "maximum no. of prefix limit\n")
5727 DEFUN (neighbor_maximum_prefix_threshold
,
5728 neighbor_maximum_prefix_threshold_cmd
,
5729 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5732 "Maximum number of prefix accept from this peer\n"
5733 "maximum no. of prefix limit\n"
5734 "Threshold value (%) at which to generate a warning msg\n")
5738 int idx_number_2
= 4;
5739 return peer_maximum_prefix_set_vty(
5740 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5741 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5745 neighbor_maximum_prefix_threshold
,
5746 neighbor_maximum_prefix_threshold_hidden_cmd
,
5747 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5748 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5749 "Maximum number of prefix accept from this peer\n"
5750 "maximum no. of prefix limit\n"
5751 "Threshold value (%) at which to generate a warning msg\n")
5753 DEFUN (neighbor_maximum_prefix_warning
,
5754 neighbor_maximum_prefix_warning_cmd
,
5755 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5758 "Maximum number of prefix accept from this peer\n"
5759 "maximum no. of prefix limit\n"
5760 "Only give warning message when limit is exceeded\n")
5764 return peer_maximum_prefix_set_vty(
5765 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5766 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5770 neighbor_maximum_prefix_warning
,
5771 neighbor_maximum_prefix_warning_hidden_cmd
,
5772 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5773 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5774 "Maximum number of prefix accept from this peer\n"
5775 "maximum no. of prefix limit\n"
5776 "Only give warning message when limit is exceeded\n")
5778 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5779 neighbor_maximum_prefix_threshold_warning_cmd
,
5780 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5783 "Maximum number of prefix accept from this peer\n"
5784 "maximum no. of prefix limit\n"
5785 "Threshold value (%) at which to generate a warning msg\n"
5786 "Only give warning message when limit is exceeded\n")
5790 int idx_number_2
= 4;
5791 return peer_maximum_prefix_set_vty(
5792 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5793 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5797 neighbor_maximum_prefix_threshold_warning
,
5798 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5799 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5800 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5801 "Maximum number of prefix accept from this peer\n"
5802 "maximum no. of prefix limit\n"
5803 "Threshold value (%) at which to generate a warning msg\n"
5804 "Only give warning message when limit is exceeded\n")
5806 DEFUN (neighbor_maximum_prefix_restart
,
5807 neighbor_maximum_prefix_restart_cmd
,
5808 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5811 "Maximum number of prefix accept from this peer\n"
5812 "maximum no. of prefix limit\n"
5813 "Restart bgp connection after limit is exceeded\n"
5814 "Restart interval in minutes\n")
5818 int idx_number_2
= 5;
5819 return peer_maximum_prefix_set_vty(
5820 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5821 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5825 neighbor_maximum_prefix_restart
,
5826 neighbor_maximum_prefix_restart_hidden_cmd
,
5827 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5828 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5829 "Maximum number of prefix accept from this peer\n"
5830 "maximum no. of prefix limit\n"
5831 "Restart bgp connection after limit is exceeded\n"
5832 "Restart interval in minutes\n")
5834 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5835 neighbor_maximum_prefix_threshold_restart_cmd
,
5836 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5839 "Maximum number of prefixes to accept from this peer\n"
5840 "maximum no. of prefix limit\n"
5841 "Threshold value (%) at which to generate a warning msg\n"
5842 "Restart bgp connection after limit is exceeded\n"
5843 "Restart interval in minutes\n")
5847 int idx_number_2
= 4;
5848 int idx_number_3
= 6;
5849 return peer_maximum_prefix_set_vty(
5850 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5851 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5852 argv
[idx_number_3
]->arg
);
5856 neighbor_maximum_prefix_threshold_restart
,
5857 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5858 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5859 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5860 "Maximum number of prefixes to accept from this peer\n"
5861 "maximum no. of prefix limit\n"
5862 "Threshold value (%) at which to generate a warning msg\n"
5863 "Restart bgp connection after limit is exceeded\n"
5864 "Restart interval in minutes\n")
5866 DEFUN (no_neighbor_maximum_prefix
,
5867 no_neighbor_maximum_prefix_cmd
,
5868 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5872 "Maximum number of prefixes to accept from this peer\n"
5873 "maximum no. of prefix limit\n"
5874 "Threshold value (%) at which to generate a warning msg\n"
5875 "Restart bgp connection after limit is exceeded\n"
5876 "Restart interval in minutes\n"
5877 "Only give warning message when limit is exceeded\n")
5880 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5882 bgp_node_safi(vty
));
5886 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5887 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5888 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5889 "Maximum number of prefixes to accept from this peer\n"
5890 "maximum no. of prefix limit\n"
5891 "Threshold value (%) at which to generate a warning msg\n"
5892 "Restart bgp connection after limit is exceeded\n"
5893 "Restart interval in minutes\n"
5894 "Only give warning message when limit is exceeded\n")
5897 /* "neighbor allowas-in" */
5898 DEFUN (neighbor_allowas_in
,
5899 neighbor_allowas_in_cmd
,
5900 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5903 "Accept as-path with my AS present in it\n"
5904 "Number of occurances of AS number\n"
5905 "Only accept my AS in the as-path if the route was originated in my AS\n")
5908 int idx_number_origin
= 3;
5914 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5916 return CMD_WARNING_CONFIG_FAILED
;
5918 if (argc
<= idx_number_origin
)
5921 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
5924 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
5927 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5930 return bgp_vty_return(vty
, ret
);
5934 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
5935 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5936 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5937 "Accept as-path with my AS present in it\n"
5938 "Number of occurances of AS number\n"
5939 "Only accept my AS in the as-path if the route was originated in my AS\n")
5941 DEFUN (no_neighbor_allowas_in
,
5942 no_neighbor_allowas_in_cmd
,
5943 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5947 "allow local ASN appears in aspath attribute\n"
5948 "Number of occurances of AS number\n"
5949 "Only accept my AS in the as-path if the route was originated in my AS\n")
5955 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5957 return CMD_WARNING_CONFIG_FAILED
;
5959 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
5960 bgp_node_safi(vty
));
5962 return bgp_vty_return(vty
, ret
);
5966 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
5967 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5968 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5969 "allow local ASN appears in aspath attribute\n"
5970 "Number of occurances of AS number\n"
5971 "Only accept my AS in the as-path if the route was originated in my AS\n")
5973 DEFUN (neighbor_ttl_security
,
5974 neighbor_ttl_security_cmd
,
5975 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
5978 "BGP ttl-security parameters\n"
5979 "Specify the maximum number of hops to the BGP peer\n"
5980 "Number of hops to BGP peer\n")
5987 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5989 return CMD_WARNING_CONFIG_FAILED
;
5991 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5994 * If 'neighbor swpX', then this is for directly connected peers,
5995 * we should not accept a ttl-security hops value greater than 1.
5997 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
5999 "%s is directly connected peer, hops cannot exceed 1\n",
6000 argv
[idx_peer
]->arg
);
6001 return CMD_WARNING_CONFIG_FAILED
;
6004 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6007 DEFUN (no_neighbor_ttl_security
,
6008 no_neighbor_ttl_security_cmd
,
6009 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6013 "BGP ttl-security parameters\n"
6014 "Specify the maximum number of hops to the BGP peer\n"
6015 "Number of hops to BGP peer\n")
6020 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6022 return CMD_WARNING_CONFIG_FAILED
;
6024 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6027 DEFUN (neighbor_addpath_tx_all_paths
,
6028 neighbor_addpath_tx_all_paths_cmd
,
6029 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6032 "Use addpath to advertise all paths to a neighbor\n")
6037 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6039 return CMD_WARNING_CONFIG_FAILED
;
6041 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6043 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6046 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6047 neighbor_addpath_tx_all_paths_hidden_cmd
,
6048 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6049 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6050 "Use addpath to advertise all paths to a neighbor\n")
6052 DEFUN (no_neighbor_addpath_tx_all_paths
,
6053 no_neighbor_addpath_tx_all_paths_cmd
,
6054 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6058 "Use addpath to advertise all paths to a neighbor\n")
6061 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6062 bgp_node_afi(vty
), bgp_node_safi(vty
),
6063 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6066 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6067 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6068 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6069 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6070 "Use addpath to advertise all paths to a neighbor\n")
6072 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6073 neighbor_addpath_tx_bestpath_per_as_cmd
,
6074 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6077 "Use addpath to advertise the bestpath per each neighboring AS\n")
6082 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6084 return CMD_WARNING_CONFIG_FAILED
;
6086 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6088 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6091 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6092 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6093 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6094 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6095 "Use addpath to advertise the bestpath per each neighboring AS\n")
6097 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6098 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6099 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6103 "Use addpath to advertise the bestpath per each neighboring AS\n")
6106 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6107 bgp_node_afi(vty
), bgp_node_safi(vty
),
6108 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6111 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6112 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6113 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6114 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6115 "Use addpath to advertise the bestpath per each neighboring AS\n")
6117 DEFUN_NOSH (address_family_ipv4_safi
,
6118 address_family_ipv4_safi_cmd
,
6119 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]",
6120 "Enter Address Family command mode\n"
6122 BGP_SAFI_WITH_LABEL_HELP_STR
)
6126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6127 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6128 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
&&
6129 safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6130 && safi
!= SAFI_EVPN
) {
6132 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6133 return CMD_WARNING_CONFIG_FAILED
;
6135 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6137 vty
->node
= BGP_IPV4_NODE
;
6142 DEFUN_NOSH (address_family_ipv6_safi
,
6143 address_family_ipv6_safi_cmd
,
6144 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]",
6145 "Enter Address Family command mode\n"
6147 BGP_SAFI_WITH_LABEL_HELP_STR
)
6150 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6151 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6152 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
&&
6153 safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6154 && safi
!= SAFI_EVPN
) {
6156 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6157 return CMD_WARNING_CONFIG_FAILED
;
6159 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6161 vty
->node
= BGP_IPV6_NODE
;
6166 #ifdef KEEP_OLD_VPN_COMMANDS
6167 DEFUN_NOSH (address_family_vpnv4
,
6168 address_family_vpnv4_cmd
,
6169 "address-family vpnv4 [unicast]",
6170 "Enter Address Family command mode\n"
6172 "Address Family modifier\n")
6174 vty
->node
= BGP_VPNV4_NODE
;
6178 DEFUN_NOSH (address_family_vpnv6
,
6179 address_family_vpnv6_cmd
,
6180 "address-family vpnv6 [unicast]",
6181 "Enter Address Family command mode\n"
6183 "Address Family modifier\n")
6185 vty
->node
= BGP_VPNV6_NODE
;
6190 DEFUN_NOSH (address_family_evpn
,
6191 address_family_evpn_cmd
,
6192 "address-family l2vpn evpn",
6193 "Enter Address Family command mode\n"
6195 "Address Family modifier\n")
6197 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6198 vty
->node
= BGP_EVPN_NODE
;
6202 DEFUN_NOSH (exit_address_family
,
6203 exit_address_family_cmd
,
6204 "exit-address-family",
6205 "Exit from Address Family configuration mode\n")
6207 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
6208 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
6209 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
6210 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
6211 || vty
->node
== BGP_EVPN_NODE
)
6212 vty
->node
= BGP_NODE
;
6216 /* Recalculate bestpath and re-advertise a prefix */
6217 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
6218 const char *ip_str
, afi_t afi
, safi_t safi
,
6219 struct prefix_rd
*prd
)
6222 struct prefix match
;
6223 struct bgp_node
*rn
;
6224 struct bgp_node
*rm
;
6226 struct bgp_table
*table
;
6227 struct bgp_table
*rib
;
6229 /* BGP structure lookup. */
6231 bgp
= bgp_lookup_by_name(view_name
);
6233 vty_out(vty
, "%% Can't find BGP instance %s\n",
6238 bgp
= bgp_get_default();
6240 vty_out(vty
, "%% No BGP process is configured\n");
6245 /* Check IP address argument. */
6246 ret
= str2prefix(ip_str
, &match
);
6248 vty_out(vty
, "%% address is malformed\n");
6252 match
.family
= afi2family(afi
);
6253 rib
= bgp
->rib
[afi
][safi
];
6255 if (safi
== SAFI_MPLS_VPN
) {
6256 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
6257 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
6260 if ((table
= rn
->info
) != NULL
) {
6261 if ((rm
= bgp_node_match(table
, &match
))
6264 == match
.prefixlen
) {
6266 BGP_NODE_USER_CLEAR
);
6267 bgp_process(bgp
, rm
, afi
, safi
);
6269 bgp_unlock_node(rm
);
6274 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
6275 if (rn
->p
.prefixlen
== match
.prefixlen
) {
6276 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
6277 bgp_process(bgp
, rn
, afi
, safi
);
6279 bgp_unlock_node(rn
);
6286 /* one clear bgp command to rule them all */
6287 DEFUN (clear_ip_bgp_all
,
6288 clear_ip_bgp_all_cmd
,
6289 "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>]",
6293 BGP_INSTANCE_HELP_STR
6295 BGP_SAFI_WITH_LABEL_HELP_STR
6297 "BGP neighbor address to clear\n"
6298 "BGP IPv6 neighbor to clear\n"
6299 "BGP neighbor on interface to clear\n"
6300 "Clear peers with the AS number\n"
6301 "Clear all external peers\n"
6302 "Clear all members of peer-group\n"
6303 "BGP peer-group name\n"
6308 "Push out prefix-list ORF and do inbound soft reconfig\n"
6313 afi_t afi
= AFI_IP6
;
6314 safi_t safi
= SAFI_UNICAST
;
6315 enum clear_sort clr_sort
= clear_peer
;
6316 enum bgp_clear_type clr_type
;
6317 char *clr_arg
= NULL
;
6321 /* clear [ip] bgp */
6322 if (argv_find(argv
, argc
, "ip", &idx
))
6325 /* [<view|vrf> VIEWVRFNAME] */
6326 if (argv_find(argv
, argc
, "view", &idx
)
6327 || argv_find(argv
, argc
, "vrf", &idx
)) {
6328 vrf
= argv
[idx
+ 1]->arg
;
6332 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
6333 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
6334 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
6336 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
6337 if (argv_find(argv
, argc
, "*", &idx
)) {
6338 clr_sort
= clear_all
;
6339 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6340 clr_sort
= clear_peer
;
6341 clr_arg
= argv
[idx
]->arg
;
6342 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
6343 clr_sort
= clear_peer
;
6344 clr_arg
= argv
[idx
]->arg
;
6345 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
6346 clr_sort
= clear_group
;
6348 clr_arg
= argv
[idx
]->arg
;
6349 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
6350 clr_sort
= clear_peer
;
6351 clr_arg
= argv
[idx
]->arg
;
6352 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
6353 clr_sort
= clear_as
;
6354 clr_arg
= argv
[idx
]->arg
;
6355 } else if (argv_find(argv
, argc
, "external", &idx
)) {
6356 clr_sort
= clear_external
;
6359 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
6360 if (argv_find(argv
, argc
, "soft", &idx
)) {
6361 if (argv_find(argv
, argc
, "in", &idx
)
6362 || argv_find(argv
, argc
, "out", &idx
))
6363 clr_type
= strmatch(argv
[idx
]->text
, "in")
6365 : BGP_CLEAR_SOFT_OUT
;
6367 clr_type
= BGP_CLEAR_SOFT_BOTH
;
6368 } else if (argv_find(argv
, argc
, "in", &idx
)) {
6369 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
6370 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
6371 : BGP_CLEAR_SOFT_IN
;
6372 } else if (argv_find(argv
, argc
, "out", &idx
)) {
6373 clr_type
= BGP_CLEAR_SOFT_OUT
;
6375 clr_type
= BGP_CLEAR_SOFT_NONE
;
6377 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
6380 DEFUN (clear_ip_bgp_prefix
,
6381 clear_ip_bgp_prefix_cmd
,
6382 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
6386 BGP_INSTANCE_HELP_STR
6387 "Clear bestpath and re-advertise\n"
6391 char *prefix
= NULL
;
6395 /* [<view|vrf> VIEWVRFNAME] */
6396 if (argv_find(argv
, argc
, "VIEWVRFNAME", &idx
))
6397 vrf
= argv
[idx
]->arg
;
6399 prefix
= argv
[argc
- 1]->arg
;
6401 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
6404 DEFUN (clear_bgp_ipv6_safi_prefix
,
6405 clear_bgp_ipv6_safi_prefix_cmd
,
6406 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
6412 "Clear bestpath and re-advertise\n"
6416 int idx_ipv6_prefixlen
= 5;
6417 return bgp_clear_prefix(
6418 vty
, NULL
, argv
[idx_ipv6_prefixlen
]->arg
, AFI_IP6
,
6419 bgp_vty_safi_from_str(argv
[idx_safi
]->text
), NULL
);
6422 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
6423 clear_bgp_instance_ipv6_safi_prefix_cmd
,
6424 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
6428 BGP_INSTANCE_HELP_STR
6431 "Clear bestpath and re-advertise\n"
6436 int idx_ipv6_prefixlen
= 7;
6437 return bgp_clear_prefix(
6438 vty
, argv
[idx_word
]->arg
, argv
[idx_ipv6_prefixlen
]->arg
,
6439 AFI_IP6
, bgp_vty_safi_from_str(argv
[idx_safi
]->text
), NULL
);
6442 DEFUN (show_bgp_views
,
6444 "show [ip] bgp views",
6448 "Show the defined BGP views\n")
6450 struct list
*inst
= bm
->bgp
;
6451 struct listnode
*node
;
6454 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
6455 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
6459 vty_out(vty
, "Defined BGP views:\n");
6460 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
6462 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
6464 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
6471 DEFUN (show_bgp_vrfs
,
6473 "show [ip] bgp vrfs [json]",
6480 char buf
[ETHER_ADDR_STRLEN
];
6481 struct list
*inst
= bm
->bgp
;
6482 struct listnode
*node
;
6484 u_char uj
= use_json(argc
, argv
);
6485 json_object
*json
= NULL
;
6486 json_object
*json_vrfs
= NULL
;
6489 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
6490 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
6495 json
= json_object_new_object();
6496 json_vrfs
= json_object_new_object();
6499 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
6500 const char *name
, *type
;
6502 struct listnode
*node
, *nnode
;
6503 int peers_cfg
, peers_estb
;
6504 json_object
*json_vrf
= NULL
;
6507 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
6511 if (!uj
&& count
== 1)
6513 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
6514 "Type", "Id", "routerId", "#PeersVfg",
6515 "#PeersEstb", "Name", "L3-VNI", "Rmac");
6517 peers_cfg
= peers_estb
= 0;
6519 json_vrf
= json_object_new_object();
6522 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
6523 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
6526 if (peer
->status
== Established
)
6530 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
6540 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
) ? -1 :
6541 (int64_t)bgp
->vrf_id
;
6542 json_object_string_add(json_vrf
, "type", type
);
6543 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
6544 json_object_string_add(json_vrf
, "routerId",
6545 inet_ntoa(bgp
->router_id
));
6546 json_object_int_add(json_vrf
, "numConfiguredPeers",
6548 json_object_int_add(json_vrf
, "numEstablishedPeers",
6551 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
6552 json_object_string_add(json_vrf
, "rmac",
6553 prefix_mac2str(&bgp
->rmac
, buf
,
6555 json_object_object_add(json_vrfs
, name
, json_vrf
);
6558 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
6559 type
, bgp
->vrf_id
== VRF_UNKNOWN
?
6560 -1 : (int)bgp
->vrf_id
,
6561 inet_ntoa(bgp
->router_id
),
6562 peers_cfg
, peers_estb
, name
, bgp
->l3vni
,
6563 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
6567 json_object_object_add(json
, "vrfs", json_vrfs
);
6569 json_object_int_add(json
, "totalVrfs", count
);
6571 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
6572 json
, JSON_C_TO_STRING_PRETTY
));
6573 json_object_free(json
);
6577 "\nTotal number of VRFs (including default): %d\n",
6584 static void show_address_entry(struct hash_backet
*backet
, void *args
)
6586 struct vty
*vty
= (struct vty
*)args
;
6587 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
6589 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
6593 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
6595 struct vty
*vty
= (struct vty
*)args
;
6596 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
6598 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
6602 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
6604 vty_out(vty
, "self nexthop database:\n");
6605 hash_iterate(bgp
->address_hash
,
6606 (void (*)(struct hash_backet
*, void *))show_address_entry
,
6609 vty_out(vty
, "Tunnel-ip database:\n");
6610 hash_iterate(bgp
->tip_hash
,
6611 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
6615 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
6616 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
6617 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
6618 "martian next-hops\n"
6619 "martian next-hop database\n")
6621 struct bgp
*bgp
= NULL
;
6624 if (argv_find(argv
, argc
, "view", &idx
)
6625 || argv_find(argv
, argc
, "vrf", &idx
))
6626 bgp
= bgp_lookup_by_name(argv
[idx
+ 1]->arg
);
6628 bgp
= bgp_get_default();
6631 vty_out(vty
, "%% No BGP process is configured\n");
6634 bgp_show_martian_nexthops(vty
, bgp
);
6639 DEFUN (show_bgp_memory
,
6640 show_bgp_memory_cmd
,
6641 "show [ip] bgp memory",
6645 "Global BGP memory statistics\n")
6647 char memstrbuf
[MTYPE_MEMSTR_LEN
];
6648 unsigned long count
;
6650 /* RIB related usage stats */
6651 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
6652 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
6653 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6654 count
* sizeof(struct bgp_node
)));
6656 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
6657 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
6658 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6659 count
* sizeof(struct bgp_info
)));
6660 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
6661 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
6663 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6664 count
* sizeof(struct bgp_info_extra
)));
6666 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
6667 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
6668 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6669 count
* sizeof(struct bgp_static
)));
6671 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
6672 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
6673 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6674 count
* sizeof(struct bpacket
)));
6677 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
6678 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
6679 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6680 count
* sizeof(struct bgp_adj_in
)));
6681 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
6682 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
6683 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6684 count
* sizeof(struct bgp_adj_out
)));
6686 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
6687 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
6689 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6690 count
* sizeof(struct bgp_nexthop_cache
)));
6692 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
6693 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
6695 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6696 count
* sizeof(struct bgp_damp_info
)));
6699 count
= attr_count();
6700 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
6701 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6702 count
* sizeof(struct attr
)));
6704 if ((count
= attr_unknown_count()))
6705 vty_out(vty
, "%ld unknown attributes\n", count
);
6707 /* AS_PATH attributes */
6708 count
= aspath_count();
6709 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
6710 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6711 count
* sizeof(struct aspath
)));
6713 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
6714 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
6715 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6716 count
* sizeof(struct assegment
)));
6718 /* Other attributes */
6719 if ((count
= community_count()))
6720 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
6721 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6722 count
* sizeof(struct community
)));
6723 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
6724 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
6725 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6726 count
* sizeof(struct ecommunity
)));
6727 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
6729 "%ld BGP large-community entries, using %s of memory\n",
6730 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6731 count
* sizeof(struct lcommunity
)));
6733 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
6734 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
6735 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6736 count
* sizeof(struct cluster_list
)));
6738 /* Peer related usage */
6739 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
6740 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
6741 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6742 count
* sizeof(struct peer
)));
6744 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
6745 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
6746 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6747 count
* sizeof(struct peer_group
)));
6750 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
6751 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
6752 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6753 count
* sizeof(struct hash
)));
6754 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
6755 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
6756 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6757 count
* sizeof(struct hash_backet
)));
6758 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
6759 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
6760 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6761 count
* sizeof(regex_t
)));
6765 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
6767 json_object
*bestpath
= json_object_new_object();
6769 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
6770 json_object_string_add(bestpath
, "asPath", "ignore");
6772 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
6773 json_object_string_add(bestpath
, "asPath", "confed");
6775 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
6776 if (bgp_flag_check(bgp
,
6777 BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
6778 json_object_string_add(bestpath
,
6782 json_object_string_add(bestpath
,
6786 json_object_string_add(bestpath
,
6790 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
6791 json_object_string_add(bestpath
, "compareRouterId", "true");
6792 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
6793 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
6794 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
6795 json_object_string_add(bestpath
, "med",
6797 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
6798 json_object_string_add(bestpath
, "med",
6799 "missing-as-worst");
6801 json_object_string_add(bestpath
, "med", "true");
6804 json_object_object_add(json
, "bestPath", bestpath
);
6807 /* Show BGP peer's summary information. */
6808 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
6809 u_char use_json
, json_object
*json
)
6812 struct listnode
*node
, *nnode
;
6813 unsigned int count
= 0, dn_count
= 0;
6814 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
6815 char neighbor_buf
[VTY_BUFSIZ
];
6816 int neighbor_col_default_width
= 16;
6818 int max_neighbor_width
= 0;
6820 json_object
*json_peer
= NULL
;
6821 json_object
*json_peers
= NULL
;
6823 /* labeled-unicast routes are installed in the unicast table so in order
6825 * display the correct PfxRcd value we must look at SAFI_UNICAST
6827 if (safi
== SAFI_LABELED_UNICAST
)
6828 pfx_rcd_safi
= SAFI_UNICAST
;
6830 pfx_rcd_safi
= safi
;
6834 json
= json_object_new_object();
6836 json_peers
= json_object_new_object();
6838 /* Loop over all neighbors that will be displayed to determine
6840 * characters are needed for the Neighbor column
6842 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
6843 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
6846 if (peer
->afc
[afi
][safi
]) {
6847 memset(dn_flag
, '\0', sizeof(dn_flag
));
6848 if (peer_dynamic_neighbor(peer
))
6852 && bgp_flag_check(bgp
,
6853 BGP_FLAG_SHOW_HOSTNAME
))
6854 sprintf(neighbor_buf
, "%s%s(%s) ",
6855 dn_flag
, peer
->hostname
,
6858 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
6861 len
= strlen(neighbor_buf
);
6863 if (len
> max_neighbor_width
)
6864 max_neighbor_width
= len
;
6868 /* Originally we displayed the Neighbor column as 16
6869 * characters wide so make that the default
6871 if (max_neighbor_width
< neighbor_col_default_width
)
6872 max_neighbor_width
= neighbor_col_default_width
;
6875 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
6876 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
6879 if (!peer
->afc
[afi
][safi
])
6884 char memstrbuf
[MTYPE_MEMSTR_LEN
];
6888 (bgp
->vrf_id
== VRF_UNKNOWN
) ? -1 :
6889 (int64_t)bgp
->vrf_id
;
6891 /* Usage summary and header */
6893 json_object_string_add(
6895 inet_ntoa(bgp
->router_id
));
6896 json_object_int_add(json
, "as", bgp
->as
);
6897 json_object_int_add(json
, "vrfId", vrf_id_ui
);
6898 json_object_string_add(
6901 == BGP_INSTANCE_TYPE_DEFAULT
)
6906 "BGP router identifier %s, local AS number %u vrf-id %d",
6907 inet_ntoa(bgp
->router_id
), bgp
->as
,
6908 bgp
->vrf_id
== VRF_UNKNOWN
? -1 :
6913 if (bgp_update_delay_configured(bgp
)) {
6915 json_object_int_add(
6916 json
, "updateDelayLimit",
6917 bgp
->v_update_delay
);
6919 if (bgp
->v_update_delay
6920 != bgp
->v_establish_wait
)
6921 json_object_int_add(
6923 "updateDelayEstablishWait",
6924 bgp
->v_establish_wait
);
6926 if (bgp_update_delay_active(bgp
)) {
6927 json_object_string_add(
6929 "updateDelayFirstNeighbor",
6930 bgp
->update_delay_begin_time
);
6931 json_object_boolean_true_add(
6933 "updateDelayInProgress");
6935 if (bgp
->update_delay_over
) {
6936 json_object_string_add(
6938 "updateDelayFirstNeighbor",
6939 bgp
->update_delay_begin_time
);
6940 json_object_string_add(
6942 "updateDelayBestpathResumed",
6943 bgp
->update_delay_end_time
);
6944 json_object_string_add(
6946 "updateDelayZebraUpdateResume",
6947 bgp
->update_delay_zebra_resume_time
);
6948 json_object_string_add(
6950 "updateDelayPeerUpdateResume",
6951 bgp
->update_delay_peers_resume_time
);
6956 "Read-only mode update-delay limit: %d seconds\n",
6957 bgp
->v_update_delay
);
6958 if (bgp
->v_update_delay
6959 != bgp
->v_establish_wait
)
6961 " Establish wait: %d seconds\n",
6962 bgp
->v_establish_wait
);
6964 if (bgp_update_delay_active(bgp
)) {
6966 " First neighbor established: %s\n",
6967 bgp
->update_delay_begin_time
);
6969 " Delay in progress\n");
6971 if (bgp
->update_delay_over
) {
6973 " First neighbor established: %s\n",
6974 bgp
->update_delay_begin_time
);
6976 " Best-paths resumed: %s\n",
6977 bgp
->update_delay_end_time
);
6979 " zebra update resumed: %s\n",
6980 bgp
->update_delay_zebra_resume_time
);
6982 " peers update resumed: %s\n",
6983 bgp
->update_delay_peers_resume_time
);
6990 if (bgp_maxmed_onstartup_configured(bgp
)
6991 && bgp
->maxmed_active
)
6992 json_object_boolean_true_add(
6993 json
, "maxMedOnStartup");
6994 if (bgp
->v_maxmed_admin
)
6995 json_object_boolean_true_add(
6996 json
, "maxMedAdministrative");
6998 json_object_int_add(
6999 json
, "tableVersion",
7000 bgp_table_version(bgp
->rib
[afi
][safi
]));
7002 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7003 json_object_int_add(json
, "ribCount", ents
);
7004 json_object_int_add(
7006 ents
* sizeof(struct bgp_node
));
7008 ents
= listcount(bgp
->peer
);
7009 json_object_int_add(json
, "peerCount", ents
);
7010 json_object_int_add(json
, "peerMemory",
7011 ents
* sizeof(struct peer
));
7013 if ((ents
= listcount(bgp
->group
))) {
7014 json_object_int_add(
7015 json
, "peerGroupCount", ents
);
7016 json_object_int_add(
7017 json
, "peerGroupMemory",
7018 ents
* sizeof(struct
7022 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7023 BGP_CONFIG_DAMPENING
))
7024 json_object_boolean_true_add(
7025 json
, "dampeningEnabled");
7027 if (bgp_maxmed_onstartup_configured(bgp
)
7028 && bgp
->maxmed_active
)
7030 "Max-med on-startup active\n");
7031 if (bgp
->v_maxmed_admin
)
7033 "Max-med administrative active\n");
7035 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7036 bgp_table_version(bgp
->rib
[afi
][safi
]));
7038 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7040 "RIB entries %ld, using %s of memory\n",
7042 mtype_memstr(memstrbuf
,
7044 ents
* sizeof(struct
7047 /* Peer related usage */
7048 ents
= listcount(bgp
->peer
);
7049 vty_out(vty
, "Peers %ld, using %s of memory\n",
7052 memstrbuf
, sizeof(memstrbuf
),
7053 ents
* sizeof(struct peer
)));
7055 if ((ents
= listcount(bgp
->group
)))
7057 "Peer groups %ld, using %s of memory\n",
7062 ents
* sizeof(struct
7065 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7066 BGP_CONFIG_DAMPENING
))
7067 vty_out(vty
, "Dampening enabled.\n");
7070 /* Subtract 8 here because 'Neighbor' is
7072 vty_out(vty
, "Neighbor");
7073 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7076 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7083 json_peer
= json_object_new_object();
7085 if (peer_dynamic_neighbor(peer
))
7086 json_object_boolean_true_add(json_peer
,
7090 json_object_string_add(json_peer
, "hostname",
7093 if (peer
->domainname
)
7094 json_object_string_add(json_peer
, "domainname",
7097 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7098 json_object_int_add(json_peer
, "version", 4);
7099 json_object_int_add(json_peer
, "msgRcvd",
7100 PEER_TOTAL_RX(peer
));
7101 json_object_int_add(json_peer
, "msgSent",
7102 PEER_TOTAL_TX(peer
));
7104 json_object_int_add(json_peer
, "tableVersion",
7105 peer
->version
[afi
][safi
]);
7106 json_object_int_add(json_peer
, "outq",
7108 json_object_int_add(json_peer
, "inq", 0);
7109 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7110 use_json
, json_peer
);
7111 json_object_int_add(json_peer
, "prefixReceivedCount",
7112 peer
->pcount
[afi
][pfx_rcd_safi
]);
7114 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7115 json_object_string_add(json_peer
, "state",
7117 else if (CHECK_FLAG(peer
->sflags
,
7118 PEER_STATUS_PREFIX_OVERFLOW
))
7119 json_object_string_add(json_peer
, "state",
7122 json_object_string_add(
7124 lookup_msg(bgp_status_msg
, peer
->status
,
7128 json_object_string_add(json_peer
, "idType",
7130 else if (peer
->su
.sa
.sa_family
== AF_INET
)
7131 json_object_string_add(json_peer
, "idType",
7133 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
7134 json_object_string_add(json_peer
, "idType",
7137 json_object_object_add(json_peers
, peer
->host
,
7140 memset(dn_flag
, '\0', sizeof(dn_flag
));
7141 if (peer_dynamic_neighbor(peer
)) {
7147 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7148 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7149 peer
->hostname
, peer
->host
);
7151 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7153 /* pad the neighbor column with spaces */
7154 if (len
< max_neighbor_width
)
7155 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7158 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
7159 peer
->as
, PEER_TOTAL_RX(peer
),
7160 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
7161 0, peer
->obuf
->count
,
7162 peer_uptime(peer
->uptime
, timebuf
,
7163 BGP_UPTIME_LEN
, 0, NULL
));
7165 if (peer
->status
== Established
)
7166 if (peer
->afc_recv
[afi
][pfx_rcd_safi
])
7167 vty_out(vty
, " %12ld",
7168 peer
->pcount
[afi
][pfx_rcd_safi
]);
7170 vty_out(vty
, " NoNeg");
7172 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7173 vty_out(vty
, " Idle (Admin)");
7174 else if (CHECK_FLAG(
7176 PEER_STATUS_PREFIX_OVERFLOW
))
7177 vty_out(vty
, " Idle (PfxCt)");
7179 vty_out(vty
, " %12s",
7180 lookup_msg(bgp_status_msg
,
7181 peer
->status
, NULL
));
7188 json_object_object_add(json
, "peers", json_peers
);
7190 json_object_int_add(json
, "totalPeers", count
);
7191 json_object_int_add(json
, "dynamicPeers", dn_count
);
7193 bgp_show_bestpath_json(bgp
, json
);
7195 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7196 json
, JSON_C_TO_STRING_PRETTY
));
7197 json_object_free(json
);
7200 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
7204 "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n",
7205 afi_safi_print(afi
, safi
));
7207 vty_out(vty
, "No %s neighbor is configured\n",
7208 afi_safi_print(afi
, safi
));
7211 if (dn_count
&& !use_json
) {
7212 vty_out(vty
, "* - dynamic neighbor\n");
7213 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
7214 dn_count
, bgp
->dynamic_neighbors_limit
);
7221 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
7222 int safi
, u_char use_json
,
7226 int afi_wildcard
= (afi
== AFI_MAX
);
7227 int safi_wildcard
= (safi
== SAFI_MAX
);
7228 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
7229 bool json_output
= false;
7231 if (use_json
&& is_wildcard
)
7232 vty_out(vty
, "{\n");
7234 afi
= 1; /* AFI_IP */
7235 while (afi
< AFI_MAX
) {
7237 safi
= 1; /* SAFI_UNICAST */
7238 while (safi
< SAFI_MAX
) {
7239 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
7243 * So limit output to those afi/safi
7245 * actualy have something interesting in
7249 json
= json_object_new_object();
7252 vty_out(vty
, ",\n");
7256 vty_out(vty
, "\"%s\":",
7260 vty_out(vty
, "\n%s Summary:\n",
7265 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
7274 || afi
== AFI_L2VPN
) /* special case, not handled yet */
7278 if (use_json
&& is_wildcard
)
7279 vty_out(vty
, "}\n");
7280 else if (use_json
&& !json_output
)
7281 vty_out(vty
, "{}\n");
7284 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
7285 safi_t safi
, u_char use_json
)
7287 struct listnode
*node
, *nnode
;
7289 json_object
*json
= NULL
;
7293 vty_out(vty
, "{\n");
7295 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
7297 json
= json_object_new_object();
7300 vty_out(vty
, ",\n");
7304 vty_out(vty
, "\"%s\":",
7305 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7309 vty_out(vty
, "\nInstance %s:\n",
7310 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7314 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
7318 vty_out(vty
, "}\n");
7321 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
7322 safi_t safi
, u_char use_json
)
7327 if (strmatch(name
, "all")) {
7328 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
7332 bgp
= bgp_lookup_by_name(name
);
7336 vty_out(vty
, "{}\n");
7339 "%% No such BGP instance exist\n");
7343 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
7349 bgp
= bgp_get_default();
7352 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
7357 /* `show [ip] bgp summary' commands. */
7358 DEFUN (show_ip_bgp_summary
,
7359 show_ip_bgp_summary_cmd
,
7360 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
7364 BGP_INSTANCE_HELP_STR
7366 BGP_SAFI_WITH_LABEL_HELP_STR
7367 "Summary of BGP neighbor status\n"
7371 afi_t afi
= AFI_MAX
;
7372 safi_t safi
= SAFI_MAX
;
7377 if (argv_find(argv
, argc
, "ip", &idx
))
7379 /* [<view|vrf> VIEWVRFNAME] */
7380 if (argv_find(argv
, argc
, "view", &idx
)
7381 || argv_find(argv
, argc
, "vrf", &idx
))
7382 vrf
= argv
[++idx
]->arg
;
7383 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7384 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
7385 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7388 int uj
= use_json(argc
, argv
);
7390 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
7393 const char *afi_safi_print(afi_t afi
, safi_t safi
)
7395 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
7396 return "IPv4 Unicast";
7397 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
7398 return "IPv4 Multicast";
7399 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
7400 return "IPv4 Labeled Unicast";
7401 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7403 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
7404 return "IPv4 Encap";
7405 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
7406 return "IPv6 Unicast";
7407 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
7408 return "IPv6 Multicast";
7409 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
7410 return "IPv6 Labeled Unicast";
7411 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
7413 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
7414 return "IPv6 Encap";
7415 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
7416 return "L2VPN EVPN";
7422 * Please note that we have intentionally camelCased
7423 * the return strings here. So if you want
7424 * to use this function, please ensure you
7425 * are doing this within json output
7427 const char *afi_safi_json(afi_t afi
, safi_t safi
)
7429 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
7430 return "ipv4Unicast";
7431 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
7432 return "ipv4Multicast";
7433 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
7434 return "ipv4LabeledUnicast";
7435 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7437 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
7439 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
7440 return "ipv6Unicast";
7441 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
7442 return "ipv6Multicast";
7443 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
7444 return "ipv6LabeledUnicast";
7445 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
7447 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
7449 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
7455 /* Show BGP peer's information. */
7456 enum show_type
{ show_all
, show_peer
};
7458 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
7459 afi_t afi
, safi_t safi
,
7460 u_int16_t adv_smcap
, u_int16_t adv_rmcap
,
7461 u_int16_t rcv_smcap
, u_int16_t rcv_rmcap
,
7462 u_char use_json
, json_object
*json_pref
)
7465 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
7466 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
7468 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
7469 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7470 json_object_string_add(json_pref
, "sendMode",
7471 "advertisedAndReceived");
7472 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
7473 json_object_string_add(json_pref
, "sendMode",
7475 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7476 json_object_string_add(json_pref
, "sendMode",
7479 vty_out(vty
, " Send-mode: ");
7480 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
7481 vty_out(vty
, "advertised");
7482 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7483 vty_out(vty
, "%sreceived",
7484 CHECK_FLAG(p
->af_cap
[afi
][safi
],
7493 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
7494 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
7496 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
7497 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7498 json_object_string_add(json_pref
, "recvMode",
7499 "advertisedAndReceived");
7500 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
7501 json_object_string_add(json_pref
, "recvMode",
7503 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7504 json_object_string_add(json_pref
, "recvMode",
7507 vty_out(vty
, " Receive-mode: ");
7508 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
7509 vty_out(vty
, "advertised");
7510 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7511 vty_out(vty
, "%sreceived",
7512 CHECK_FLAG(p
->af_cap
[afi
][safi
],
7521 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
7522 safi_t safi
, u_char use_json
,
7523 json_object
*json_neigh
)
7525 struct bgp_filter
*filter
;
7526 struct peer_af
*paf
;
7527 char orf_pfx_name
[BUFSIZ
];
7529 json_object
*json_af
= NULL
;
7530 json_object
*json_prefA
= NULL
;
7531 json_object
*json_prefB
= NULL
;
7532 json_object
*json_addr
= NULL
;
7535 json_addr
= json_object_new_object();
7536 json_af
= json_object_new_object();
7537 filter
= &p
->filter
[afi
][safi
];
7539 if (peer_group_active(p
))
7540 json_object_string_add(json_addr
, "peerGroupMember",
7543 paf
= peer_af_find(p
, afi
, safi
);
7544 if (paf
&& PAF_SUBGRP(paf
)) {
7545 json_object_int_add(json_addr
, "updateGroupId",
7546 PAF_UPDGRP(paf
)->id
);
7547 json_object_int_add(json_addr
, "subGroupId",
7548 PAF_SUBGRP(paf
)->id
);
7549 json_object_int_add(json_addr
, "packetQueueLength",
7550 bpacket_queue_virtual_length(paf
));
7553 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7554 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7555 PEER_CAP_ORF_PREFIX_SM_RCV
)
7556 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7557 PEER_CAP_ORF_PREFIX_RM_ADV
)
7558 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7559 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
7560 json_object_int_add(json_af
, "orfType",
7562 json_prefA
= json_object_new_object();
7563 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
7564 PEER_CAP_ORF_PREFIX_SM_ADV
,
7565 PEER_CAP_ORF_PREFIX_RM_ADV
,
7566 PEER_CAP_ORF_PREFIX_SM_RCV
,
7567 PEER_CAP_ORF_PREFIX_RM_RCV
,
7568 use_json
, json_prefA
);
7569 json_object_object_add(json_af
, "orfPrefixList",
7573 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7574 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7575 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7576 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7577 PEER_CAP_ORF_PREFIX_RM_ADV
)
7578 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7579 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
7580 json_object_int_add(json_af
, "orfOldType",
7581 ORF_TYPE_PREFIX_OLD
);
7582 json_prefB
= json_object_new_object();
7583 bgp_show_peer_afi_orf_cap(
7584 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
7585 PEER_CAP_ORF_PREFIX_RM_ADV
,
7586 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
7587 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
7589 json_object_object_add(json_af
, "orfOldPrefixList",
7593 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7594 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7595 PEER_CAP_ORF_PREFIX_SM_RCV
)
7596 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7597 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7598 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7599 PEER_CAP_ORF_PREFIX_RM_ADV
)
7600 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7601 PEER_CAP_ORF_PREFIX_RM_RCV
)
7602 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7603 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
7604 json_object_object_add(json_addr
, "afDependentCap",
7607 json_object_free(json_af
);
7609 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
7610 orf_pfx_count
= prefix_bgp_show_prefix_list(
7611 NULL
, afi
, orf_pfx_name
, use_json
);
7613 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7614 PEER_STATUS_ORF_PREFIX_SEND
)
7616 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7617 PEER_STATUS_ORF_PREFIX_SEND
))
7618 json_object_boolean_true_add(json_neigh
,
7621 json_object_int_add(json_addr
, "orfRecvCounter",
7624 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7625 PEER_STATUS_ORF_WAIT_REFRESH
))
7626 json_object_string_add(
7627 json_addr
, "orfFirstUpdate",
7628 "deferredUntilORFOrRouteRefreshRecvd");
7630 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7631 PEER_FLAG_REFLECTOR_CLIENT
))
7632 json_object_boolean_true_add(json_addr
,
7633 "routeReflectorClient");
7634 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7635 PEER_FLAG_RSERVER_CLIENT
))
7636 json_object_boolean_true_add(json_addr
,
7637 "routeServerClient");
7638 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
7639 json_object_boolean_true_add(json_addr
,
7640 "inboundSoftConfigPermit");
7642 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7643 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
7644 json_object_boolean_true_add(
7646 "privateAsNumsAllReplacedInUpdatesToNbr");
7647 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7648 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
7649 json_object_boolean_true_add(
7651 "privateAsNumsReplacedInUpdatesToNbr");
7652 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7653 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
7654 json_object_boolean_true_add(
7656 "privateAsNumsAllRemovedInUpdatesToNbr");
7657 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7658 PEER_FLAG_REMOVE_PRIVATE_AS
))
7659 json_object_boolean_true_add(
7661 "privateAsNumsRemovedInUpdatesToNbr");
7663 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7664 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
7665 json_object_boolean_true_add(json_addr
,
7666 "addpathTxAllPaths");
7668 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7669 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
7670 json_object_boolean_true_add(json_addr
,
7671 "addpathTxBestpathPerAS");
7673 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
7674 json_object_string_add(json_addr
,
7675 "overrideASNsInOutboundUpdates",
7676 "ifAspathEqualRemoteAs");
7678 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
7679 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7680 PEER_FLAG_FORCE_NEXTHOP_SELF
))
7681 json_object_boolean_true_add(json_addr
,
7682 "routerAlwaysNextHop");
7683 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7684 PEER_FLAG_AS_PATH_UNCHANGED
))
7685 json_object_boolean_true_add(
7686 json_addr
, "unchangedAsPathPropogatedToNbr");
7687 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7688 PEER_FLAG_NEXTHOP_UNCHANGED
))
7689 json_object_boolean_true_add(
7690 json_addr
, "unchangedNextHopPropogatedToNbr");
7691 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
7692 json_object_boolean_true_add(
7693 json_addr
, "unchangedMedPropogatedToNbr");
7694 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
7695 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7696 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
7697 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7698 PEER_FLAG_SEND_COMMUNITY
)
7699 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
7700 PEER_FLAG_SEND_EXT_COMMUNITY
))
7701 json_object_string_add(json_addr
,
7702 "commAttriSentToNbr",
7703 "extendedAndStandard");
7704 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7705 PEER_FLAG_SEND_EXT_COMMUNITY
))
7706 json_object_string_add(json_addr
,
7707 "commAttriSentToNbr",
7710 json_object_string_add(json_addr
,
7711 "commAttriSentToNbr",
7714 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7715 PEER_FLAG_DEFAULT_ORIGINATE
)) {
7716 if (p
->default_rmap
[afi
][safi
].name
)
7717 json_object_string_add(
7718 json_addr
, "defaultRouteMap",
7719 p
->default_rmap
[afi
][safi
].name
);
7721 if (paf
&& PAF_SUBGRP(paf
)
7722 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
7723 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
7724 json_object_boolean_true_add(json_addr
,
7727 json_object_boolean_true_add(json_addr
,
7731 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
7732 if (is_evpn_enabled())
7733 json_object_boolean_true_add(
7734 json_addr
, "advertiseAllVnis");
7737 if (filter
->plist
[FILTER_IN
].name
7738 || filter
->dlist
[FILTER_IN
].name
7739 || filter
->aslist
[FILTER_IN
].name
7740 || filter
->map
[RMAP_IN
].name
)
7741 json_object_boolean_true_add(json_addr
,
7742 "inboundPathPolicyConfig");
7743 if (filter
->plist
[FILTER_OUT
].name
7744 || filter
->dlist
[FILTER_OUT
].name
7745 || filter
->aslist
[FILTER_OUT
].name
7746 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
7747 json_object_boolean_true_add(
7748 json_addr
, "outboundPathPolicyConfig");
7751 if (filter
->plist
[FILTER_IN
].name
)
7752 json_object_string_add(json_addr
,
7753 "incomingUpdatePrefixFilterList",
7754 filter
->plist
[FILTER_IN
].name
);
7755 if (filter
->plist
[FILTER_OUT
].name
)
7756 json_object_string_add(json_addr
,
7757 "outgoingUpdatePrefixFilterList",
7758 filter
->plist
[FILTER_OUT
].name
);
7760 /* distribute-list */
7761 if (filter
->dlist
[FILTER_IN
].name
)
7762 json_object_string_add(
7763 json_addr
, "incomingUpdateNetworkFilterList",
7764 filter
->dlist
[FILTER_IN
].name
);
7765 if (filter
->dlist
[FILTER_OUT
].name
)
7766 json_object_string_add(
7767 json_addr
, "outgoingUpdateNetworkFilterList",
7768 filter
->dlist
[FILTER_OUT
].name
);
7771 if (filter
->aslist
[FILTER_IN
].name
)
7772 json_object_string_add(json_addr
,
7773 "incomingUpdateAsPathFilterList",
7774 filter
->aslist
[FILTER_IN
].name
);
7775 if (filter
->aslist
[FILTER_OUT
].name
)
7776 json_object_string_add(json_addr
,
7777 "outgoingUpdateAsPathFilterList",
7778 filter
->aslist
[FILTER_OUT
].name
);
7781 if (filter
->map
[RMAP_IN
].name
)
7782 json_object_string_add(
7783 json_addr
, "routeMapForIncomingAdvertisements",
7784 filter
->map
[RMAP_IN
].name
);
7785 if (filter
->map
[RMAP_OUT
].name
)
7786 json_object_string_add(
7787 json_addr
, "routeMapForOutgoingAdvertisements",
7788 filter
->map
[RMAP_OUT
].name
);
7790 /* unsuppress-map */
7791 if (filter
->usmap
.name
)
7792 json_object_string_add(json_addr
,
7793 "selectiveUnsuppressRouteMap",
7794 filter
->usmap
.name
);
7796 /* Receive prefix count */
7797 json_object_int_add(json_addr
, "acceptedPrefixCounter",
7798 p
->pcount
[afi
][safi
]);
7800 /* Maximum prefix */
7801 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
7802 json_object_int_add(json_addr
, "prefixAllowedMax",
7803 p
->pmax
[afi
][safi
]);
7804 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7805 PEER_FLAG_MAX_PREFIX_WARNING
))
7806 json_object_boolean_true_add(
7807 json_addr
, "prefixAllowedMaxWarning");
7808 json_object_int_add(json_addr
,
7809 "prefixAllowedWarningThresh",
7810 p
->pmax_threshold
[afi
][safi
]);
7811 if (p
->pmax_restart
[afi
][safi
])
7812 json_object_int_add(
7814 "prefixAllowedRestartIntervalMsecs",
7815 p
->pmax_restart
[afi
][safi
] * 60000);
7817 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
7821 filter
= &p
->filter
[afi
][safi
];
7823 vty_out(vty
, " For address family: %s\n",
7824 afi_safi_print(afi
, safi
));
7826 if (peer_group_active(p
))
7827 vty_out(vty
, " %s peer-group member\n",
7830 paf
= peer_af_find(p
, afi
, safi
);
7831 if (paf
&& PAF_SUBGRP(paf
)) {
7832 vty_out(vty
, " Update group %" PRIu64
7833 ", subgroup %" PRIu64
"\n",
7834 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
7835 vty_out(vty
, " Packet Queue length %d\n",
7836 bpacket_queue_virtual_length(paf
));
7838 vty_out(vty
, " Not part of any update group\n");
7840 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7841 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7842 PEER_CAP_ORF_PREFIX_SM_RCV
)
7843 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7844 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7845 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7846 PEER_CAP_ORF_PREFIX_RM_ADV
)
7847 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7848 PEER_CAP_ORF_PREFIX_RM_RCV
)
7849 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7850 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
7851 vty_out(vty
, " AF-dependant capabilities:\n");
7853 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7854 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7855 PEER_CAP_ORF_PREFIX_SM_RCV
)
7856 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7857 PEER_CAP_ORF_PREFIX_RM_ADV
)
7858 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7859 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
7861 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
7863 bgp_show_peer_afi_orf_cap(
7864 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
7865 PEER_CAP_ORF_PREFIX_RM_ADV
,
7866 PEER_CAP_ORF_PREFIX_SM_RCV
,
7867 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
7869 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7870 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7871 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7872 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7873 PEER_CAP_ORF_PREFIX_RM_ADV
)
7874 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7875 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
7877 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
7878 ORF_TYPE_PREFIX_OLD
);
7879 bgp_show_peer_afi_orf_cap(
7880 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
7881 PEER_CAP_ORF_PREFIX_RM_ADV
,
7882 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
7883 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
7886 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
7887 orf_pfx_count
= prefix_bgp_show_prefix_list(
7888 NULL
, afi
, orf_pfx_name
, use_json
);
7890 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7891 PEER_STATUS_ORF_PREFIX_SEND
)
7893 vty_out(vty
, " Outbound Route Filter (ORF):");
7894 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7895 PEER_STATUS_ORF_PREFIX_SEND
))
7896 vty_out(vty
, " sent;");
7898 vty_out(vty
, " received (%d entries)",
7902 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7903 PEER_STATUS_ORF_WAIT_REFRESH
))
7905 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
7907 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7908 PEER_FLAG_REFLECTOR_CLIENT
))
7909 vty_out(vty
, " Route-Reflector Client\n");
7910 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7911 PEER_FLAG_RSERVER_CLIENT
))
7912 vty_out(vty
, " Route-Server Client\n");
7913 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
7915 " Inbound soft reconfiguration allowed\n");
7917 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7918 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
7920 " Private AS numbers (all) replaced in updates to this neighbor\n");
7921 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7922 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
7924 " Private AS numbers replaced in updates to this neighbor\n");
7925 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7926 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
7928 " Private AS numbers (all) removed in updates to this neighbor\n");
7929 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7930 PEER_FLAG_REMOVE_PRIVATE_AS
))
7932 " Private AS numbers removed in updates to this neighbor\n");
7934 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7935 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
7936 vty_out(vty
, " Advertise all paths via addpath\n");
7938 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7939 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
7941 " Advertise bestpath per AS via addpath\n");
7943 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
7945 " Override ASNs in outbound updates if aspath equals remote-as\n");
7947 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
7948 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7949 PEER_FLAG_FORCE_NEXTHOP_SELF
))
7950 vty_out(vty
, " NEXT_HOP is always this router\n");
7951 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7952 PEER_FLAG_AS_PATH_UNCHANGED
))
7954 " AS_PATH is propagated unchanged to this neighbor\n");
7955 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7956 PEER_FLAG_NEXTHOP_UNCHANGED
))
7958 " NEXT_HOP is propagated unchanged to this neighbor\n");
7959 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
7961 " MED is propagated unchanged to this neighbor\n");
7962 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
7963 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7964 PEER_FLAG_SEND_EXT_COMMUNITY
)
7965 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7966 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
7968 " Community attribute sent to this neighbor");
7969 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7970 PEER_FLAG_SEND_COMMUNITY
)
7971 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
7972 PEER_FLAG_SEND_EXT_COMMUNITY
)
7973 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
7974 PEER_FLAG_SEND_LARGE_COMMUNITY
))
7975 vty_out(vty
, "(all)\n");
7976 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7977 PEER_FLAG_SEND_LARGE_COMMUNITY
))
7978 vty_out(vty
, "(large)\n");
7979 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7980 PEER_FLAG_SEND_EXT_COMMUNITY
))
7981 vty_out(vty
, "(extended)\n");
7983 vty_out(vty
, "(standard)\n");
7985 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7986 PEER_FLAG_DEFAULT_ORIGINATE
)) {
7987 vty_out(vty
, " Default information originate,");
7989 if (p
->default_rmap
[afi
][safi
].name
)
7990 vty_out(vty
, " default route-map %s%s,",
7991 p
->default_rmap
[afi
][safi
].map
? "*"
7993 p
->default_rmap
[afi
][safi
].name
);
7994 if (paf
&& PAF_SUBGRP(paf
)
7995 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
7996 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
7997 vty_out(vty
, " default sent\n");
7999 vty_out(vty
, " default not sent\n");
8002 /* advertise-vni-all */
8003 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8004 if (is_evpn_enabled())
8005 vty_out(vty
, " advertise-all-vni\n");
8008 if (filter
->plist
[FILTER_IN
].name
8009 || filter
->dlist
[FILTER_IN
].name
8010 || filter
->aslist
[FILTER_IN
].name
8011 || filter
->map
[RMAP_IN
].name
)
8012 vty_out(vty
, " Inbound path policy configured\n");
8013 if (filter
->plist
[FILTER_OUT
].name
8014 || filter
->dlist
[FILTER_OUT
].name
8015 || filter
->aslist
[FILTER_OUT
].name
8016 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8017 vty_out(vty
, " Outbound path policy configured\n");
8020 if (filter
->plist
[FILTER_IN
].name
)
8022 " Incoming update prefix filter list is %s%s\n",
8023 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8024 filter
->plist
[FILTER_IN
].name
);
8025 if (filter
->plist
[FILTER_OUT
].name
)
8027 " Outgoing update prefix filter list is %s%s\n",
8028 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8029 filter
->plist
[FILTER_OUT
].name
);
8031 /* distribute-list */
8032 if (filter
->dlist
[FILTER_IN
].name
)
8034 " Incoming update network filter list is %s%s\n",
8035 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8036 filter
->dlist
[FILTER_IN
].name
);
8037 if (filter
->dlist
[FILTER_OUT
].name
)
8039 " Outgoing update network filter list is %s%s\n",
8040 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8041 filter
->dlist
[FILTER_OUT
].name
);
8044 if (filter
->aslist
[FILTER_IN
].name
)
8046 " Incoming update AS path filter list is %s%s\n",
8047 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8048 filter
->aslist
[FILTER_IN
].name
);
8049 if (filter
->aslist
[FILTER_OUT
].name
)
8051 " Outgoing update AS path filter list is %s%s\n",
8052 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8053 filter
->aslist
[FILTER_OUT
].name
);
8056 if (filter
->map
[RMAP_IN
].name
)
8058 " Route map for incoming advertisements is %s%s\n",
8059 filter
->map
[RMAP_IN
].map
? "*" : "",
8060 filter
->map
[RMAP_IN
].name
);
8061 if (filter
->map
[RMAP_OUT
].name
)
8063 " Route map for outgoing advertisements is %s%s\n",
8064 filter
->map
[RMAP_OUT
].map
? "*" : "",
8065 filter
->map
[RMAP_OUT
].name
);
8067 /* unsuppress-map */
8068 if (filter
->usmap
.name
)
8070 " Route map for selective unsuppress is %s%s\n",
8071 filter
->usmap
.map
? "*" : "",
8072 filter
->usmap
.name
);
8074 /* Receive prefix count */
8075 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8077 /* Maximum prefix */
8078 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8079 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8081 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8082 PEER_FLAG_MAX_PREFIX_WARNING
)
8085 vty_out(vty
, " Threshold for warning message %d%%",
8086 p
->pmax_threshold
[afi
][safi
]);
8087 if (p
->pmax_restart
[afi
][safi
])
8088 vty_out(vty
, ", restart interval %d min",
8089 p
->pmax_restart
[afi
][safi
]);
8097 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, u_char use_json
,
8101 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8102 char timebuf
[BGP_UPTIME_LEN
];
8104 const char *subcode_str
;
8105 const char *code_str
;
8110 json_object
*json_neigh
= NULL
;
8116 json_neigh
= json_object_new_object();
8118 memset(dn_flag
, '\0', sizeof(dn_flag
));
8119 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
8123 if (p
->conf_if
) /* Configured interface name. */
8124 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
8125 BGP_PEER_SU_UNSPEC(p
)
8127 : sockunion2str(&p
->su
, buf
,
8129 else /* Configured IP address. */
8130 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
8135 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
8136 json_object_string_add(json_neigh
, "bgpNeighborAddr",
8138 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
8139 json_object_string_add(
8140 json_neigh
, "bgpNeighborAddr",
8141 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
8143 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8145 if (p
->change_local_as
)
8146 json_object_int_add(json_neigh
, "localAs",
8147 p
->change_local_as
);
8149 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8151 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8152 json_object_boolean_true_add(json_neigh
,
8153 "localAsNoPrepend");
8155 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8156 json_object_boolean_true_add(json_neigh
,
8157 "localAsReplaceAs");
8159 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
8160 || (p
->as_type
== AS_INTERNAL
))
8161 vty_out(vty
, "remote AS %u, ", p
->as
);
8163 vty_out(vty
, "remote AS Unspecified, ");
8164 vty_out(vty
, "local AS %u%s%s, ",
8165 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
8166 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
8169 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
8173 /* peer type internal, external, confed-internal or confed-external */
8174 if (p
->as
== p
->local_as
) {
8176 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8177 json_object_boolean_true_add(
8178 json_neigh
, "nbrConfedInternalLink");
8180 json_object_boolean_true_add(json_neigh
,
8183 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8184 vty_out(vty
, "confed-internal link\n");
8186 vty_out(vty
, "internal link\n");
8190 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8191 json_object_boolean_true_add(
8192 json_neigh
, "nbrConfedExternalLink");
8194 json_object_boolean_true_add(json_neigh
,
8197 if (bgp_confederation_peers_check(bgp
, p
->as
))
8198 vty_out(vty
, "confed-external link\n");
8200 vty_out(vty
, "external link\n");
8207 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
8209 vty_out(vty
, " Description: %s\n", p
->desc
);
8215 json_object_string_add(json_neigh
, "hostname",
8219 json_object_string_add(json_neigh
, "domainname",
8222 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
8223 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
8226 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
8233 json_object_string_add(json_neigh
, "peerGroup",
8237 struct prefix prefix
, *range
= NULL
;
8239 sockunion2hostprefix(&(p
->su
), &prefix
);
8240 range
= peer_group_lookup_dynamic_neighbor_range(
8244 prefix2str(range
, buf1
, sizeof(buf1
));
8245 json_object_string_add(
8247 "peerSubnetRangeGroup", buf1
);
8252 " Member of peer-group %s for session parameters\n",
8256 struct prefix prefix
, *range
= NULL
;
8258 sockunion2hostprefix(&(p
->su
), &prefix
);
8259 range
= peer_group_lookup_dynamic_neighbor_range(
8263 prefix2str(range
, buf1
, sizeof(buf1
));
8265 " Belongs to the subnet range group: %s\n",
8273 /* Administrative shutdown. */
8274 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8275 json_object_boolean_true_add(json_neigh
,
8279 json_object_int_add(json_neigh
, "bgpVersion", 4);
8280 json_object_string_add(
8281 json_neigh
, "remoteRouterId",
8282 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
8285 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
8286 && bgp_confederation_peers_check(bgp
, p
->as
))
8287 json_object_boolean_true_add(json_neigh
,
8291 json_object_string_add(
8292 json_neigh
, "bgpState",
8293 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
8295 if (p
->status
== Established
) {
8298 uptime
= bgp_clock();
8299 uptime
-= p
->uptime
;
8300 epoch_tbuf
= time(NULL
) - uptime
;
8302 #if CONFDATE > 20200101
8303 CPP_NOTICE("bgpTimerUp should be deprecated and can be removed now");
8306 * bgpTimerUp was miliseconds that was accurate
8307 * up to 1 day, then the value returned
8308 * became garbage. So in order to provide
8309 * some level of backwards compatability,
8310 * we still provde the data, but now
8311 * we are returning the correct value
8312 * and also adding a new bgpTimerUpMsec
8313 * which will allow us to deprecate
8316 json_object_int_add(json_neigh
, "bgpTimerUp",
8318 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
8320 json_object_string_add(json_neigh
, "bgpTimerUpString",
8321 peer_uptime(p
->uptime
, timebuf
,
8324 json_object_int_add(json_neigh
,
8325 "bgpTimerUpEstablishedEpoch",
8329 else if (p
->status
== Active
) {
8330 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
8331 json_object_string_add(json_neigh
, "bgpStateIs",
8333 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
8334 json_object_string_add(json_neigh
, "bgpStateIs",
8342 uptime
= bgp_clock();
8343 uptime
-= p
->readtime
;
8344 tm
= gmtime(&uptime
);
8345 json_object_int_add(json_neigh
, "bgpTimerLastRead",
8346 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8347 + (tm
->tm_hour
* 3600000));
8349 uptime
= bgp_clock();
8350 uptime
-= p
->last_write
;
8351 tm
= gmtime(&uptime
);
8352 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
8353 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8354 + (tm
->tm_hour
* 3600000));
8356 uptime
= bgp_clock();
8357 uptime
-= p
->update_time
;
8358 tm
= gmtime(&uptime
);
8359 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
8360 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8361 + (tm
->tm_hour
* 3600000));
8363 /* Configured timer values. */
8364 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
8365 p
->v_holdtime
* 1000);
8366 json_object_int_add(json_neigh
,
8367 "bgpTimerKeepAliveIntervalMsecs",
8368 p
->v_keepalive
* 1000);
8370 if (PEER_OR_GROUP_TIMER_SET(p
)) {
8371 json_object_int_add(json_neigh
,
8372 "bgpTimerConfiguredHoldTimeMsecs",
8373 p
->holdtime
* 1000);
8374 json_object_int_add(
8376 "bgpTimerConfiguredKeepAliveIntervalMsecs",
8377 p
->keepalive
* 1000);
8378 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
8379 || (bgp
->default_keepalive
!=
8380 BGP_DEFAULT_KEEPALIVE
)) {
8381 json_object_int_add(json_neigh
,
8382 "bgpTimerConfiguredHoldTimeMsecs",
8383 bgp
->default_holdtime
);
8384 json_object_int_add(
8386 "bgpTimerConfiguredKeepAliveIntervalMsecs",
8387 bgp
->default_keepalive
);
8390 /* Administrative shutdown. */
8391 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8392 vty_out(vty
, " Administratively shut down\n");
8395 vty_out(vty
, " BGP version 4");
8396 vty_out(vty
, ", remote router ID %s\n",
8397 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
8400 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
8401 && bgp_confederation_peers_check(bgp
, p
->as
))
8403 " Neighbor under common administration\n");
8406 vty_out(vty
, " BGP state = %s",
8407 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
8409 if (p
->status
== Established
)
8410 vty_out(vty
, ", up for %8s",
8411 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8414 else if (p
->status
== Active
) {
8415 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
8416 vty_out(vty
, " (passive)");
8417 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
8418 vty_out(vty
, " (NSF passive)");
8423 vty_out(vty
, " Last read %s",
8424 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
8426 vty_out(vty
, ", Last write %s\n",
8427 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
8430 /* Configured timer values. */
8432 " Hold time is %d, keepalive interval is %d seconds\n",
8433 p
->v_holdtime
, p
->v_keepalive
);
8434 if (PEER_OR_GROUP_TIMER_SET(p
)) {
8435 vty_out(vty
, " Configured hold time is %d",
8437 vty_out(vty
, ", keepalive interval is %d seconds\n",
8439 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
8440 || (bgp
->default_keepalive
!=
8441 BGP_DEFAULT_KEEPALIVE
)) {
8442 vty_out(vty
, " Configured hold time is %d",
8443 bgp
->default_holdtime
);
8444 vty_out(vty
, ", keepalive interval is %d seconds\n",
8445 bgp
->default_keepalive
);
8449 if (p
->status
== Established
) {
8450 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
8451 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
8452 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
8453 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
8454 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
8455 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
8456 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
8457 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
8458 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
8459 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
8460 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
8461 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
8462 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
8463 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
8464 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
8465 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
8467 json_object
*json_cap
= NULL
;
8469 json_cap
= json_object_new_object();
8472 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
8473 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
8474 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
8475 && CHECK_FLAG(p
->cap
,
8477 json_object_string_add(
8478 json_cap
, "4byteAs",
8479 "advertisedAndReceived");
8480 else if (CHECK_FLAG(p
->cap
,
8482 json_object_string_add(
8483 json_cap
, "4byteAs",
8485 else if (CHECK_FLAG(p
->cap
,
8487 json_object_string_add(
8488 json_cap
, "4byteAs",
8493 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
8494 || CHECK_FLAG(p
->cap
,
8495 PEER_CAP_ADDPATH_ADV
)) {
8496 json_object
*json_add
= NULL
;
8497 const char *print_store
;
8499 json_add
= json_object_new_object();
8501 FOREACH_AFI_SAFI (afi
, safi
) {
8502 json_object
*json_sub
= NULL
;
8504 json_object_new_object();
8505 print_store
= afi_safi_print(
8511 PEER_CAP_ADDPATH_AF_TX_ADV
)
8515 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
8520 PEER_CAP_ADDPATH_AF_TX_ADV
)
8525 PEER_CAP_ADDPATH_AF_TX_RCV
))
8526 json_object_boolean_true_add(
8528 "txAdvertisedAndReceived");
8534 PEER_CAP_ADDPATH_AF_TX_ADV
))
8535 json_object_boolean_true_add(
8543 PEER_CAP_ADDPATH_AF_TX_RCV
))
8544 json_object_boolean_true_add(
8552 PEER_CAP_ADDPATH_AF_RX_ADV
)
8556 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
8561 PEER_CAP_ADDPATH_AF_RX_ADV
)
8566 PEER_CAP_ADDPATH_AF_RX_RCV
))
8567 json_object_boolean_true_add(
8569 "rxAdvertisedAndReceived");
8575 PEER_CAP_ADDPATH_AF_RX_ADV
))
8576 json_object_boolean_true_add(
8584 PEER_CAP_ADDPATH_AF_RX_RCV
))
8585 json_object_boolean_true_add(
8593 PEER_CAP_ADDPATH_AF_TX_ADV
)
8597 PEER_CAP_ADDPATH_AF_TX_RCV
)
8601 PEER_CAP_ADDPATH_AF_RX_ADV
)
8605 PEER_CAP_ADDPATH_AF_RX_RCV
))
8606 json_object_object_add(
8615 json_object_object_add(
8616 json_cap
, "addPath", json_add
);
8620 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
8621 || CHECK_FLAG(p
->cap
,
8622 PEER_CAP_DYNAMIC_ADV
)) {
8623 if (CHECK_FLAG(p
->cap
,
8624 PEER_CAP_DYNAMIC_ADV
)
8625 && CHECK_FLAG(p
->cap
,
8626 PEER_CAP_DYNAMIC_RCV
))
8627 json_object_string_add(
8628 json_cap
, "dynamic",
8629 "advertisedAndReceived");
8630 else if (CHECK_FLAG(
8632 PEER_CAP_DYNAMIC_ADV
))
8633 json_object_string_add(
8634 json_cap
, "dynamic",
8636 else if (CHECK_FLAG(
8638 PEER_CAP_DYNAMIC_RCV
))
8639 json_object_string_add(
8640 json_cap
, "dynamic",
8644 /* Extended nexthop */
8645 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
8646 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
8647 json_object
*json_nxt
= NULL
;
8648 const char *print_store
;
8651 if (CHECK_FLAG(p
->cap
,
8653 && CHECK_FLAG(p
->cap
,
8655 json_object_string_add(
8658 "advertisedAndReceived");
8659 else if (CHECK_FLAG(p
->cap
,
8661 json_object_string_add(
8665 else if (CHECK_FLAG(p
->cap
,
8667 json_object_string_add(
8672 if (CHECK_FLAG(p
->cap
,
8673 PEER_CAP_ENHE_RCV
)) {
8675 json_object_new_object();
8677 for (safi
= SAFI_UNICAST
;
8678 safi
< SAFI_MAX
; safi
++) {
8683 PEER_CAP_ENHE_AF_RCV
)) {
8684 print_store
= afi_safi_print(
8687 json_object_string_add(
8693 json_object_object_add(
8695 "extendedNexthopFamililesByPeer",
8701 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
8702 || CHECK_FLAG(p
->cap
,
8703 PEER_CAP_REFRESH_NEW_RCV
)
8704 || CHECK_FLAG(p
->cap
,
8705 PEER_CAP_REFRESH_OLD_RCV
)) {
8706 if (CHECK_FLAG(p
->cap
,
8707 PEER_CAP_REFRESH_ADV
)
8710 PEER_CAP_REFRESH_NEW_RCV
)
8713 PEER_CAP_REFRESH_OLD_RCV
))) {
8716 PEER_CAP_REFRESH_OLD_RCV
)
8719 PEER_CAP_REFRESH_NEW_RCV
))
8720 json_object_string_add(
8723 "advertisedAndReceivedOldNew");
8727 PEER_CAP_REFRESH_OLD_RCV
))
8728 json_object_string_add(
8731 "advertisedAndReceivedOld");
8733 json_object_string_add(
8736 "advertisedAndReceivedNew");
8741 PEER_CAP_REFRESH_ADV
))
8742 json_object_string_add(
8749 PEER_CAP_REFRESH_NEW_RCV
)
8752 PEER_CAP_REFRESH_OLD_RCV
))
8753 json_object_string_add(
8759 /* Multiprotocol Extensions */
8760 json_object
*json_multi
= NULL
;
8761 json_multi
= json_object_new_object();
8763 FOREACH_AFI_SAFI (afi
, safi
) {
8764 if (p
->afc_adv
[afi
][safi
]
8765 || p
->afc_recv
[afi
][safi
]) {
8766 json_object
*json_exten
= NULL
;
8768 json_object_new_object();
8770 if (p
->afc_adv
[afi
][safi
]
8771 && p
->afc_recv
[afi
][safi
])
8772 json_object_boolean_true_add(
8774 "advertisedAndReceived");
8775 else if (p
->afc_adv
[afi
][safi
])
8776 json_object_boolean_true_add(
8779 else if (p
->afc_recv
[afi
][safi
])
8780 json_object_boolean_true_add(
8784 json_object_object_add(
8791 json_object_object_add(
8792 json_cap
, "multiprotocolExtensions",
8795 /* Hostname capabilities */
8796 json_object
*json_hname
= NULL
;
8798 json_hname
= json_object_new_object();
8800 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
8801 json_object_string_add(
8802 json_hname
, "advHostName",
8803 bgp
->peer_self
->hostname
8807 json_object_string_add(
8808 json_hname
, "advDomainName",
8809 bgp
->peer_self
->domainname
8816 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
8817 json_object_string_add(
8818 json_hname
, "rcvHostName",
8819 p
->hostname
? p
->hostname
8821 json_object_string_add(
8822 json_hname
, "rcvDomainName",
8823 p
->domainname
? p
->domainname
8827 json_object_object_add(json_cap
, "hostName",
8830 /* Gracefull Restart */
8831 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
8832 || CHECK_FLAG(p
->cap
,
8833 PEER_CAP_RESTART_ADV
)) {
8834 if (CHECK_FLAG(p
->cap
,
8835 PEER_CAP_RESTART_ADV
)
8836 && CHECK_FLAG(p
->cap
,
8837 PEER_CAP_RESTART_RCV
))
8838 json_object_string_add(
8841 "advertisedAndReceived");
8842 else if (CHECK_FLAG(
8844 PEER_CAP_RESTART_ADV
))
8845 json_object_string_add(
8847 "gracefulRestartCapability",
8849 else if (CHECK_FLAG(
8851 PEER_CAP_RESTART_RCV
))
8852 json_object_string_add(
8854 "gracefulRestartCapability",
8857 if (CHECK_FLAG(p
->cap
,
8858 PEER_CAP_RESTART_RCV
)) {
8859 int restart_af_count
= 0;
8860 json_object
*json_restart
=
8863 json_object_new_object();
8865 json_object_int_add(
8867 "gracefulRestartRemoteTimerMsecs",
8868 p
->v_gr_restart
* 1000);
8870 FOREACH_AFI_SAFI (afi
, safi
) {
8875 PEER_CAP_RESTART_AF_RCV
)) {
8880 json_object_new_object();
8886 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
8887 json_object_boolean_true_add(
8891 json_object_object_add(
8899 if (!restart_af_count
) {
8900 json_object_string_add(
8902 "addressFamiliesByPeer",
8907 json_object_object_add(
8909 "addressFamiliesByPeer",
8913 json_object_object_add(json_neigh
,
8914 "neighborCapabilities",
8917 vty_out(vty
, " Neighbor capabilities:\n");
8920 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
8921 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
8922 vty_out(vty
, " 4 Byte AS:");
8923 if (CHECK_FLAG(p
->cap
,
8925 vty_out(vty
, " advertised");
8926 if (CHECK_FLAG(p
->cap
,
8928 vty_out(vty
, " %sreceived",
8938 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
8939 || CHECK_FLAG(p
->cap
,
8940 PEER_CAP_ADDPATH_ADV
)) {
8941 vty_out(vty
, " AddPath:\n");
8943 FOREACH_AFI_SAFI (afi
, safi
) {
8947 PEER_CAP_ADDPATH_AF_TX_ADV
)
8951 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
8962 PEER_CAP_ADDPATH_AF_TX_ADV
))
8973 PEER_CAP_ADDPATH_AF_TX_RCV
))
8980 PEER_CAP_ADDPATH_AF_TX_ADV
)
8990 PEER_CAP_ADDPATH_AF_RX_ADV
)
8994 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9005 PEER_CAP_ADDPATH_AF_RX_ADV
))
9016 PEER_CAP_ADDPATH_AF_RX_RCV
))
9023 PEER_CAP_ADDPATH_AF_RX_ADV
)
9033 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9034 || CHECK_FLAG(p
->cap
,
9035 PEER_CAP_DYNAMIC_ADV
)) {
9036 vty_out(vty
, " Dynamic:");
9037 if (CHECK_FLAG(p
->cap
,
9038 PEER_CAP_DYNAMIC_ADV
))
9039 vty_out(vty
, " advertised");
9040 if (CHECK_FLAG(p
->cap
,
9041 PEER_CAP_DYNAMIC_RCV
))
9042 vty_out(vty
, " %sreceived",
9045 PEER_CAP_DYNAMIC_ADV
)
9051 /* Extended nexthop */
9052 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9053 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9054 vty_out(vty
, " Extended nexthop:");
9055 if (CHECK_FLAG(p
->cap
,
9057 vty_out(vty
, " advertised");
9058 if (CHECK_FLAG(p
->cap
,
9060 vty_out(vty
, " %sreceived",
9068 if (CHECK_FLAG(p
->cap
,
9069 PEER_CAP_ENHE_RCV
)) {
9071 " Address families by peer:\n ");
9072 for (safi
= SAFI_UNICAST
;
9073 safi
< SAFI_MAX
; safi
++)
9078 PEER_CAP_ENHE_AF_RCV
))
9088 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9089 || CHECK_FLAG(p
->cap
,
9090 PEER_CAP_REFRESH_NEW_RCV
)
9091 || CHECK_FLAG(p
->cap
,
9092 PEER_CAP_REFRESH_OLD_RCV
)) {
9093 vty_out(vty
, " Route refresh:");
9094 if (CHECK_FLAG(p
->cap
,
9095 PEER_CAP_REFRESH_ADV
))
9096 vty_out(vty
, " advertised");
9097 if (CHECK_FLAG(p
->cap
,
9098 PEER_CAP_REFRESH_NEW_RCV
)
9101 PEER_CAP_REFRESH_OLD_RCV
))
9102 vty_out(vty
, " %sreceived(%s)",
9105 PEER_CAP_REFRESH_ADV
)
9110 PEER_CAP_REFRESH_OLD_RCV
)
9113 PEER_CAP_REFRESH_NEW_RCV
))
9117 PEER_CAP_REFRESH_OLD_RCV
)
9124 /* Multiprotocol Extensions */
9125 FOREACH_AFI_SAFI (afi
, safi
)
9126 if (p
->afc_adv
[afi
][safi
]
9127 || p
->afc_recv
[afi
][safi
]) {
9129 " Address Family %s:",
9132 if (p
->afc_adv
[afi
][safi
])
9135 if (p
->afc_recv
[afi
][safi
])
9145 /* Hostname capability */
9146 vty_out(vty
, " Hostname Capability:");
9148 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9150 " advertised (name: %s,domain name: %s)",
9151 bgp
->peer_self
->hostname
9155 bgp
->peer_self
->domainname
9160 vty_out(vty
, " not advertised");
9163 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9165 " received (name: %s,domain name: %s)",
9166 p
->hostname
? p
->hostname
9168 p
->domainname
? p
->domainname
9171 vty_out(vty
, " not received");
9176 /* Gracefull Restart */
9177 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9178 || CHECK_FLAG(p
->cap
,
9179 PEER_CAP_RESTART_ADV
)) {
9181 " Graceful Restart Capabilty:");
9182 if (CHECK_FLAG(p
->cap
,
9183 PEER_CAP_RESTART_ADV
))
9184 vty_out(vty
, " advertised");
9185 if (CHECK_FLAG(p
->cap
,
9186 PEER_CAP_RESTART_RCV
))
9187 vty_out(vty
, " %sreceived",
9190 PEER_CAP_RESTART_ADV
)
9195 if (CHECK_FLAG(p
->cap
,
9196 PEER_CAP_RESTART_RCV
)) {
9197 int restart_af_count
= 0;
9200 " Remote Restart timer is %d seconds\n",
9203 " Address families by peer:\n ");
9205 FOREACH_AFI_SAFI (afi
, safi
)
9210 PEER_CAP_RESTART_AF_RCV
)) {
9223 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
9228 if (!restart_af_count
)
9229 vty_out(vty
, "none");
9237 /* graceful restart information */
9238 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
9240 json_object
*json_grace
= NULL
;
9241 json_object
*json_grace_send
= NULL
;
9242 json_object
*json_grace_recv
= NULL
;
9243 int eor_send_af_count
= 0;
9244 int eor_receive_af_count
= 0;
9247 json_grace
= json_object_new_object();
9248 json_grace_send
= json_object_new_object();
9249 json_grace_recv
= json_object_new_object();
9251 if (p
->status
== Established
) {
9252 FOREACH_AFI_SAFI (afi
, safi
) {
9253 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9254 PEER_STATUS_EOR_SEND
)) {
9255 json_object_boolean_true_add(
9259 eor_send_af_count
++;
9262 FOREACH_AFI_SAFI (afi
, safi
) {
9264 p
->af_sflags
[afi
][safi
],
9265 PEER_STATUS_EOR_RECEIVED
)) {
9266 json_object_boolean_true_add(
9270 eor_receive_af_count
++;
9275 json_object_object_add(json_grace
, "endOfRibSend",
9277 json_object_object_add(json_grace
, "endOfRibRecv",
9280 if (p
->t_gr_restart
)
9281 json_object_int_add(json_grace
,
9282 "gracefulRestartTimerMsecs",
9283 thread_timer_remain_second(
9288 json_object_int_add(
9290 "gracefulStalepathTimerMsecs",
9291 thread_timer_remain_second(
9295 json_object_object_add(
9296 json_neigh
, "gracefulRestartInfo", json_grace
);
9298 vty_out(vty
, " Graceful restart informations:\n");
9299 if (p
->status
== Established
) {
9300 vty_out(vty
, " End-of-RIB send: ");
9301 FOREACH_AFI_SAFI (afi
, safi
) {
9302 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9303 PEER_STATUS_EOR_SEND
)) {
9304 vty_out(vty
, "%s%s",
9305 eor_send_af_count
? ", "
9309 eor_send_af_count
++;
9313 vty_out(vty
, " End-of-RIB received: ");
9314 FOREACH_AFI_SAFI (afi
, safi
) {
9316 p
->af_sflags
[afi
][safi
],
9317 PEER_STATUS_EOR_RECEIVED
)) {
9318 vty_out(vty
, "%s%s",
9319 eor_receive_af_count
9324 eor_receive_af_count
++;
9330 if (p
->t_gr_restart
)
9332 " The remaining time of restart timer is %ld\n",
9333 thread_timer_remain_second(
9338 " The remaining time of stalepath timer is %ld\n",
9339 thread_timer_remain_second(
9344 json_object
*json_stat
= NULL
;
9345 json_stat
= json_object_new_object();
9346 /* Packet counts. */
9347 json_object_int_add(json_stat
, "depthInq", 0);
9348 json_object_int_add(json_stat
, "depthOutq",
9349 (unsigned long)p
->obuf
->count
);
9350 json_object_int_add(json_stat
, "opensSent",
9351 atomic_load_explicit(&p
->open_out
,
9352 memory_order_relaxed
));
9353 json_object_int_add(json_stat
, "opensRecv",
9354 atomic_load_explicit(&p
->open_in
,
9355 memory_order_relaxed
));
9356 json_object_int_add(json_stat
, "notificationsSent",
9357 atomic_load_explicit(&p
->notify_out
,
9358 memory_order_relaxed
));
9359 json_object_int_add(json_stat
, "notificationsRecv",
9360 atomic_load_explicit(&p
->notify_in
,
9361 memory_order_relaxed
));
9362 json_object_int_add(json_stat
, "updatesSent",
9363 atomic_load_explicit(&p
->update_out
,
9364 memory_order_relaxed
));
9365 json_object_int_add(json_stat
, "updatesRecv",
9366 atomic_load_explicit(&p
->update_in
,
9367 memory_order_relaxed
));
9368 json_object_int_add(json_stat
, "keepalivesSent",
9369 atomic_load_explicit(&p
->keepalive_out
,
9370 memory_order_relaxed
));
9371 json_object_int_add(json_stat
, "keepalivesRecv",
9372 atomic_load_explicit(&p
->keepalive_in
,
9373 memory_order_relaxed
));
9374 json_object_int_add(json_stat
, "routeRefreshSent",
9375 atomic_load_explicit(&p
->refresh_out
,
9376 memory_order_relaxed
));
9377 json_object_int_add(json_stat
, "routeRefreshRecv",
9378 atomic_load_explicit(&p
->refresh_in
,
9379 memory_order_relaxed
));
9380 json_object_int_add(json_stat
, "capabilitySent",
9381 atomic_load_explicit(&p
->dynamic_cap_out
,
9382 memory_order_relaxed
));
9383 json_object_int_add(json_stat
, "capabilityRecv",
9384 atomic_load_explicit(&p
->dynamic_cap_in
,
9385 memory_order_relaxed
));
9386 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
9387 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
9388 json_object_object_add(json_neigh
, "messageStats", json_stat
);
9390 /* Packet counts. */
9391 vty_out(vty
, " Message statistics:\n");
9392 vty_out(vty
, " Inq depth is 0\n");
9393 vty_out(vty
, " Outq depth is %lu\n",
9394 (unsigned long)p
->obuf
->count
);
9395 vty_out(vty
, " Sent Rcvd\n");
9396 vty_out(vty
, " Opens: %10d %10d\n",
9397 atomic_load_explicit(&p
->open_out
,
9398 memory_order_relaxed
),
9399 atomic_load_explicit(&p
->open_in
,
9400 memory_order_relaxed
));
9401 vty_out(vty
, " Notifications: %10d %10d\n",
9402 atomic_load_explicit(&p
->notify_out
,
9403 memory_order_relaxed
),
9404 atomic_load_explicit(&p
->notify_in
,
9405 memory_order_relaxed
));
9406 vty_out(vty
, " Updates: %10d %10d\n",
9407 atomic_load_explicit(&p
->update_out
,
9408 memory_order_relaxed
),
9409 atomic_load_explicit(&p
->update_in
,
9410 memory_order_relaxed
));
9411 vty_out(vty
, " Keepalives: %10d %10d\n",
9412 atomic_load_explicit(&p
->keepalive_out
,
9413 memory_order_relaxed
),
9414 atomic_load_explicit(&p
->keepalive_in
,
9415 memory_order_relaxed
));
9416 vty_out(vty
, " Route Refresh: %10d %10d\n",
9417 atomic_load_explicit(&p
->refresh_out
,
9418 memory_order_relaxed
),
9419 atomic_load_explicit(&p
->refresh_in
,
9420 memory_order_relaxed
));
9421 vty_out(vty
, " Capability: %10d %10d\n",
9422 atomic_load_explicit(&p
->dynamic_cap_out
,
9423 memory_order_relaxed
),
9424 atomic_load_explicit(&p
->dynamic_cap_in
,
9425 memory_order_relaxed
));
9426 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
9431 /* advertisement-interval */
9432 json_object_int_add(json_neigh
,
9433 "minBtwnAdvertisementRunsTimerMsecs",
9434 p
->v_routeadv
* 1000);
9436 /* Update-source. */
9437 if (p
->update_if
|| p
->update_source
) {
9439 json_object_string_add(json_neigh
,
9442 else if (p
->update_source
)
9443 json_object_string_add(
9444 json_neigh
, "updateSource",
9445 sockunion2str(p
->update_source
, buf1
,
9449 /* advertisement-interval */
9451 " Minimum time between advertisement runs is %d seconds\n",
9454 /* Update-source. */
9455 if (p
->update_if
|| p
->update_source
) {
9456 vty_out(vty
, " Update source is ");
9458 vty_out(vty
, "%s", p
->update_if
);
9459 else if (p
->update_source
)
9461 sockunion2str(p
->update_source
, buf1
,
9469 /* Address Family Information */
9470 json_object
*json_hold
= NULL
;
9473 json_hold
= json_object_new_object();
9475 FOREACH_AFI_SAFI (afi
, safi
)
9476 if (p
->afc
[afi
][safi
])
9477 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
9481 json_object_object_add(json_neigh
, "addressFamilyInfo",
9483 json_object_int_add(json_neigh
, "connectionsEstablished",
9485 json_object_int_add(json_neigh
, "connectionsDropped",
9488 vty_out(vty
, " Connections established %d; dropped %d\n",
9489 p
->established
, p
->dropped
);
9491 if (!p
->last_reset
) {
9493 json_object_string_add(json_neigh
, "lastReset",
9496 vty_out(vty
, " Last reset never\n");
9502 uptime
= bgp_clock();
9503 uptime
-= p
->resettime
;
9504 tm
= gmtime(&uptime
);
9505 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
9507 + (tm
->tm_min
* 60000)
9508 + (tm
->tm_hour
* 3600000));
9509 json_object_string_add(
9510 json_neigh
, "lastResetDueTo",
9511 peer_down_str
[(int)p
->last_reset
]);
9512 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9513 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9514 char errorcodesubcode_hexstr
[5];
9515 char errorcodesubcode_str
[256];
9517 code_str
= bgp_notify_code_str(p
->notify
.code
);
9518 subcode_str
= bgp_notify_subcode_str(
9519 p
->notify
.code
, p
->notify
.subcode
);
9521 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
9522 p
->notify
.code
, p
->notify
.subcode
);
9523 json_object_string_add(json_neigh
,
9524 "lastErrorCodeSubcode",
9525 errorcodesubcode_hexstr
);
9526 snprintf(errorcodesubcode_str
, 255, "%s%s",
9527 code_str
, subcode_str
);
9528 json_object_string_add(json_neigh
,
9529 "lastNotificationReason",
9530 errorcodesubcode_str
);
9531 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
9532 && p
->notify
.code
== BGP_NOTIFY_CEASE
9533 && (p
->notify
.subcode
9534 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9535 || p
->notify
.subcode
9536 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
9537 && p
->notify
.length
) {
9539 const char *msg_str
;
9541 msg_str
= bgp_notify_admin_message(
9542 msgbuf
, sizeof(msgbuf
),
9543 (u_char
*)p
->notify
.data
,
9546 json_object_string_add(
9548 "lastShutdownDescription",
9553 vty_out(vty
, " Last reset %s, ",
9554 peer_uptime(p
->resettime
, timebuf
,
9555 BGP_UPTIME_LEN
, 0, NULL
));
9557 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9558 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9559 code_str
= bgp_notify_code_str(p
->notify
.code
);
9560 subcode_str
= bgp_notify_subcode_str(
9561 p
->notify
.code
, p
->notify
.subcode
);
9562 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
9563 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9566 code_str
, subcode_str
);
9567 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
9568 && p
->notify
.code
== BGP_NOTIFY_CEASE
9569 && (p
->notify
.subcode
9570 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9571 || p
->notify
.subcode
9572 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
9573 && p
->notify
.length
) {
9575 const char *msg_str
;
9577 msg_str
= bgp_notify_admin_message(
9578 msgbuf
, sizeof(msgbuf
),
9579 (u_char
*)p
->notify
.data
,
9583 " Message: \"%s\"\n",
9587 vty_out(vty
, "due to %s\n",
9588 peer_down_str
[(int)p
->last_reset
]);
9591 if (p
->last_reset_cause_size
) {
9592 msg
= p
->last_reset_cause
;
9594 " Message received that caused BGP to send a NOTIFICATION:\n ");
9595 for (i
= 1; i
<= p
->last_reset_cause_size
;
9597 vty_out(vty
, "%02X", *msg
++);
9599 if (i
!= p
->last_reset_cause_size
) {
9601 vty_out(vty
, "\n ");
9602 } else if (i
% 4 == 0) {
9612 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
9614 json_object_boolean_true_add(json_neigh
,
9615 "prefixesConfigExceedMax");
9618 " Peer had exceeded the max. no. of prefixes configured.\n");
9620 if (p
->t_pmax_restart
) {
9622 json_object_boolean_true_add(
9623 json_neigh
, "reducePrefixNumFrom");
9624 json_object_int_add(json_neigh
,
9625 "restartInTimerMsec",
9626 thread_timer_remain_second(
9631 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
9632 p
->host
, thread_timer_remain_second(
9633 p
->t_pmax_restart
));
9636 json_object_boolean_true_add(
9638 "reducePrefixNumAndClearIpBgp");
9641 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
9646 /* EBGP Multihop and GTSM */
9647 if (p
->sort
!= BGP_PEER_IBGP
) {
9649 if (p
->gtsm_hops
> 0)
9650 json_object_int_add(json_neigh
,
9651 "externalBgpNbrMaxHopsAway",
9653 else if (p
->ttl
> 1)
9654 json_object_int_add(json_neigh
,
9655 "externalBgpNbrMaxHopsAway",
9658 if (p
->gtsm_hops
> 0)
9660 " External BGP neighbor may be up to %d hops away.\n",
9662 else if (p
->ttl
> 1)
9664 " External BGP neighbor may be up to %d hops away.\n",
9668 if (p
->gtsm_hops
> 0) {
9670 json_object_int_add(json_neigh
,
9671 "internalBgpNbrMaxHopsAway",
9675 " Internal BGP neighbor may be up to %d hops away.\n",
9680 /* Local address. */
9683 json_object_string_add(json_neigh
, "hostLocal",
9684 sockunion2str(p
->su_local
, buf1
,
9686 json_object_int_add(json_neigh
, "portLocal",
9687 ntohs(p
->su_local
->sin
.sin_port
));
9689 vty_out(vty
, "Local host: %s, Local port: %d\n",
9690 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
9691 ntohs(p
->su_local
->sin
.sin_port
));
9694 /* Remote address. */
9697 json_object_string_add(json_neigh
, "hostForeign",
9698 sockunion2str(p
->su_remote
, buf1
,
9700 json_object_int_add(json_neigh
, "portForeign",
9701 ntohs(p
->su_remote
->sin
.sin_port
));
9703 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
9704 sockunion2str(p
->su_remote
, buf1
,
9706 ntohs(p
->su_remote
->sin
.sin_port
));
9709 /* Nexthop display. */
9712 json_object_string_add(json_neigh
, "nexthop",
9714 &p
->nexthop
.v4
, buf1
,
9716 json_object_string_add(json_neigh
, "nexthopGlobal",
9718 &p
->nexthop
.v6_global
,
9719 buf1
, sizeof(buf1
)));
9720 json_object_string_add(json_neigh
, "nexthopLocal",
9722 &p
->nexthop
.v6_local
,
9723 buf1
, sizeof(buf1
)));
9724 if (p
->shared_network
)
9725 json_object_string_add(json_neigh
,
9729 json_object_string_add(json_neigh
,
9731 "nonSharedNetwork");
9733 vty_out(vty
, "Nexthop: %s\n",
9734 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
9736 vty_out(vty
, "Nexthop global: %s\n",
9737 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
9739 vty_out(vty
, "Nexthop local: %s\n",
9740 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
9742 vty_out(vty
, "BGP connection: %s\n",
9743 p
->shared_network
? "shared network"
9744 : "non shared network");
9748 /* Timer information. */
9750 json_object_int_add(json_neigh
, "connectRetryTimer",
9752 if (p
->status
== Established
&& p
->rtt
)
9753 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
9756 json_object_int_add(
9757 json_neigh
, "nextStartTimerDueInMsecs",
9758 thread_timer_remain_second(p
->t_start
) * 1000);
9760 json_object_int_add(
9761 json_neigh
, "nextConnectTimerDueInMsecs",
9762 thread_timer_remain_second(p
->t_connect
)
9764 if (p
->t_routeadv
) {
9765 json_object_int_add(json_neigh
, "mraiInterval",
9767 json_object_int_add(
9768 json_neigh
, "mraiTimerExpireInMsecs",
9769 thread_timer_remain_second(p
->t_routeadv
)
9773 json_object_int_add(json_neigh
, "authenticationEnabled",
9777 json_object_string_add(json_neigh
, "readThread", "on");
9779 json_object_string_add(json_neigh
, "readThread", "off");
9781 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
9782 json_object_string_add(json_neigh
, "writeThread", "on");
9784 json_object_string_add(json_neigh
, "writeThread",
9787 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
9789 if (p
->status
== Established
&& p
->rtt
)
9790 vty_out(vty
, "Estimated round trip time: %d ms\n",
9793 vty_out(vty
, "Next start timer due in %ld seconds\n",
9794 thread_timer_remain_second(p
->t_start
));
9796 vty_out(vty
, "Next connect timer due in %ld seconds\n",
9797 thread_timer_remain_second(p
->t_connect
));
9800 "MRAI (interval %u) timer expires in %ld seconds\n",
9802 thread_timer_remain_second(p
->t_routeadv
));
9804 vty_out(vty
, "Peer Authentication Enabled\n");
9806 vty_out(vty
, "Read thread: %s Write thread: %s\n",
9807 p
->t_read
? "on" : "off",
9808 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
9813 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
9814 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
9815 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
9820 /* BFD information. */
9821 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
9824 if (p
->conf_if
) /* Configured interface name. */
9825 json_object_object_add(json
, p
->conf_if
, json_neigh
);
9826 else /* Configured IP address. */
9827 json_object_object_add(json
, p
->host
, json_neigh
);
9831 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
9832 enum show_type type
, union sockunion
*su
,
9833 const char *conf_if
, u_char use_json
,
9836 struct listnode
*node
, *nnode
;
9840 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9841 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9846 bgp_show_peer(vty
, peer
, use_json
, json
);
9851 && !strcmp(peer
->conf_if
, conf_if
))
9853 && !strcmp(peer
->hostname
, conf_if
))) {
9855 bgp_show_peer(vty
, peer
, use_json
,
9859 if (sockunion_same(&peer
->su
, su
)) {
9861 bgp_show_peer(vty
, peer
, use_json
,
9869 if (type
== show_peer
&& !find
) {
9871 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
9873 vty_out(vty
, "%% No such neighbor\n");
9877 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9878 json
, JSON_C_TO_STRING_PRETTY
));
9879 json_object_free(json
);
9887 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
9888 enum show_type type
,
9892 struct listnode
*node
, *nnode
;
9895 json_object
*json
= NULL
;
9896 int ret
, is_first
= 1;
9899 vty_out(vty
, "{\n");
9901 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
9903 if (!(json
= json_object_new_object())) {
9905 "Unable to allocate memory for JSON object");
9907 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
9911 json_object_int_add(json
, "vrfId",
9912 (bgp
->vrf_id
== VRF_UNKNOWN
)
9913 ? -1 : (int64_t) bgp
->vrf_id
);
9914 json_object_string_add(
9916 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9921 vty_out(vty
, ",\n");
9925 vty_out(vty
, "\"%s\":",
9926 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9930 vty_out(vty
, "\nInstance %s:\n",
9931 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9936 if (type
== show_peer
) {
9937 ret
= str2sockunion(ip_str
, &su
);
9939 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
9942 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
9945 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
9951 vty_out(vty
, "}\n");
9954 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
9955 enum show_type type
, const char *ip_str
,
9961 json_object
*json
= NULL
;
9964 if (strmatch(name
, "all")) {
9965 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
9969 bgp
= bgp_lookup_by_name(name
);
9972 json
= json_object_new_object();
9973 json_object_boolean_true_add(
9974 json
, "bgpNoSuchInstance");
9975 vty_out(vty
, "%s\n",
9976 json_object_to_json_string_ext(
9978 JSON_C_TO_STRING_PRETTY
));
9979 json_object_free(json
);
9982 "%% No such BGP instance exist\n");
9988 bgp
= bgp_get_default();
9992 json
= json_object_new_object();
9994 ret
= str2sockunion(ip_str
, &su
);
9996 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
9999 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10002 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10005 json_object_free(json
);
10008 return CMD_SUCCESS
;
10011 /* "show [ip] bgp neighbors" commands. */
10012 DEFUN (show_ip_bgp_neighbors
,
10013 show_ip_bgp_neighbors_cmd
,
10014 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10018 BGP_INSTANCE_HELP_STR
10021 "Detailed information on TCP and BGP neighbor connections\n"
10022 "Neighbor to display information about\n"
10023 "Neighbor to display information about\n"
10024 "Neighbor on BGP configured interface\n"
10028 char *sh_arg
= NULL
;
10029 enum show_type sh_type
;
10031 u_char uj
= use_json(argc
, argv
);
10035 if (argv_find(argv
, argc
, "view", &idx
)
10036 || argv_find(argv
, argc
, "vrf", &idx
))
10037 vrf
= argv
[idx
+ 1]->arg
;
10040 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10041 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10042 || argv_find(argv
, argc
, "WORD", &idx
)) {
10043 sh_type
= show_peer
;
10044 sh_arg
= argv
[idx
]->arg
;
10046 sh_type
= show_all
;
10048 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10051 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10052 paths' and `show ip mbgp paths'. Those functions results are the
10054 DEFUN (show_ip_bgp_paths
,
10055 show_ip_bgp_paths_cmd
,
10056 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10061 "Path information\n")
10063 vty_out(vty
, "Address Refcnt Path\n");
10064 aspath_print_all_vty(vty
);
10065 return CMD_SUCCESS
;
10070 static void community_show_all_iterator(struct hash_backet
*backet
,
10073 struct community
*com
;
10075 com
= (struct community
*)backet
->data
;
10076 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10077 community_str(com
, false));
10080 /* Show BGP's community internal data. */
10081 DEFUN (show_ip_bgp_community_info
,
10082 show_ip_bgp_community_info_cmd
,
10083 "show [ip] bgp community-info",
10087 "List all bgp community information\n")
10089 vty_out(vty
, "Address Refcnt Community\n");
10091 hash_iterate(community_hash(),
10092 (void (*)(struct hash_backet
*,
10093 void *))community_show_all_iterator
,
10096 return CMD_SUCCESS
;
10099 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
10102 struct lcommunity
*lcom
;
10104 lcom
= (struct lcommunity
*)backet
->data
;
10105 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
10106 lcommunity_str(lcom
));
10109 /* Show BGP's community internal data. */
10110 DEFUN (show_ip_bgp_lcommunity_info
,
10111 show_ip_bgp_lcommunity_info_cmd
,
10112 "show ip bgp large-community-info",
10116 "List all bgp large-community information\n")
10118 vty_out(vty
, "Address Refcnt Large-community\n");
10120 hash_iterate(lcommunity_hash(),
10121 (void (*)(struct hash_backet
*,
10122 void *))lcommunity_show_all_iterator
,
10125 return CMD_SUCCESS
;
10129 DEFUN (show_ip_bgp_attr_info
,
10130 show_ip_bgp_attr_info_cmd
,
10131 "show [ip] bgp attribute-info",
10135 "List all bgp attribute information\n")
10137 attr_show_all(vty
);
10138 return CMD_SUCCESS
;
10141 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
10144 struct listnode
*node
, *nnode
;
10147 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10148 vty_out(vty
, "\nInstance %s:\n",
10149 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10152 update_group_show(bgp
, afi
, safi
, vty
, 0);
10156 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
10157 int safi
, uint64_t subgrp_id
)
10162 if (strmatch(name
, "all")) {
10163 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
10164 return CMD_SUCCESS
;
10166 bgp
= bgp_lookup_by_name(name
);
10169 bgp
= bgp_get_default();
10173 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
10174 return CMD_SUCCESS
;
10177 DEFUN (show_ip_bgp_updgrps
,
10178 show_ip_bgp_updgrps_cmd
,
10179 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
10183 BGP_INSTANCE_HELP_STR
10185 BGP_SAFI_WITH_LABEL_HELP_STR
10186 "Detailed info about dynamic update groups\n"
10187 "Specific subgroup to display detailed info for\n")
10190 afi_t afi
= AFI_IP6
;
10191 safi_t safi
= SAFI_UNICAST
;
10192 uint64_t subgrp_id
= 0;
10196 /* show [ip] bgp */
10197 if (argv_find(argv
, argc
, "ip", &idx
))
10199 /* [<view|vrf> VIEWVRFNAME] */
10200 if (argv_find(argv
, argc
, "view", &idx
)
10201 || argv_find(argv
, argc
, "vrf", &idx
))
10202 vrf
= argv
[++idx
]->arg
;
10203 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10204 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
10205 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10208 /* get subgroup id, if provided */
10210 if (argv
[idx
]->type
== VARIABLE_TKN
)
10211 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
10213 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
10216 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
10217 show_bgp_instance_all_ipv6_updgrps_cmd
,
10218 "show [ip] bgp <view|vrf> all update-groups",
10222 BGP_INSTANCE_ALL_HELP_STR
10223 "Detailed info about dynamic update groups\n")
10225 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
10226 return CMD_SUCCESS
;
10229 DEFUN (show_bgp_updgrps_stats
,
10230 show_bgp_updgrps_stats_cmd
,
10231 "show [ip] bgp update-groups statistics",
10235 "Detailed info about dynamic update groups\n"
10240 bgp
= bgp_get_default();
10242 update_group_show_stats(bgp
, vty
);
10244 return CMD_SUCCESS
;
10247 DEFUN (show_bgp_instance_updgrps_stats
,
10248 show_bgp_instance_updgrps_stats_cmd
,
10249 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
10253 BGP_INSTANCE_HELP_STR
10254 "Detailed info about dynamic update groups\n"
10260 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
10262 update_group_show_stats(bgp
, vty
);
10264 return CMD_SUCCESS
;
10267 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
10268 afi_t afi
, safi_t safi
,
10269 const char *what
, uint64_t subgrp_id
)
10274 bgp
= bgp_lookup_by_name(name
);
10276 bgp
= bgp_get_default();
10279 if (!strcmp(what
, "advertise-queue"))
10280 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
10282 else if (!strcmp(what
, "advertised-routes"))
10283 update_group_show_advertised(bgp
, afi
, safi
, vty
,
10285 else if (!strcmp(what
, "packet-queue"))
10286 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
10291 DEFUN (show_ip_bgp_updgrps_adj
,
10292 show_ip_bgp_updgrps_adj_cmd
,
10293 "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
10297 "Detailed info about dynamic update groups\n"
10298 "Advertisement queue\n"
10299 "Announced routes\n"
10303 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10304 argv
[idx_type
]->arg
, 0);
10305 return CMD_SUCCESS
;
10308 DEFUN (show_ip_bgp_instance_updgrps_adj
,
10309 show_ip_bgp_instance_updgrps_adj_cmd
,
10310 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>",
10314 BGP_INSTANCE_HELP_STR
10315 "Detailed info about dynamic update groups\n"
10316 "Advertisement queue\n"
10317 "Announced routes\n"
10322 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_word
]->arg
, AFI_IP
,
10323 SAFI_UNICAST
, argv
[idx_type
]->arg
, 0);
10324 return CMD_SUCCESS
;
10327 DEFUN (show_bgp_updgrps_afi_adj
,
10328 show_bgp_updgrps_afi_adj_cmd
,
10329 "show [ip] bgp "BGP_AFI_SAFI_CMD_STR
" update-groups <advertise-queue|advertised-routes|packet-queue>",
10333 BGP_AFI_SAFI_HELP_STR
10334 "Detailed info about dynamic update groups\n"
10335 "Advertisement queue\n"
10336 "Announced routes\n"
10342 show_bgp_updgrps_adj_info_aux(
10343 vty
, NULL
, bgp_vty_afi_from_str(argv
[idx_afi
]->text
),
10344 bgp_vty_safi_from_str(argv
[idx_safi
]->text
),
10345 argv
[idx_type
]->arg
, 0);
10346 return CMD_SUCCESS
;
10349 DEFUN (show_bgp_updgrps_adj
,
10350 show_bgp_updgrps_adj_cmd
,
10351 "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
10355 "Detailed info about dynamic update groups\n"
10356 "Advertisement queue\n"
10357 "Announced routes\n"
10361 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10362 argv
[idx_type
]->arg
, 0);
10363 return CMD_SUCCESS
;
10366 DEFUN (show_bgp_instance_updgrps_adj
,
10367 show_bgp_instance_updgrps_adj_cmd
,
10368 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>",
10372 BGP_INSTANCE_HELP_STR
10373 "Detailed info about dynamic update groups\n"
10374 "Advertisement queue\n"
10375 "Announced routes\n"
10380 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_word
]->arg
, AFI_IP6
,
10381 SAFI_UNICAST
, argv
[idx_type
]->arg
, 0);
10382 return CMD_SUCCESS
;
10385 DEFUN (show_ip_bgp_updgrps_adj_s
,
10386 show_ip_bgp_updgrps_adj_s_cmd
,
10387 "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10391 "Detailed info about dynamic update groups\n"
10392 "Specific subgroup to display info for\n"
10393 "Advertisement queue\n"
10394 "Announced routes\n"
10397 int idx_subgroup_id
= 4;
10399 uint64_t subgrp_id
;
10401 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10403 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10404 argv
[idx_type
]->arg
, subgrp_id
);
10405 return CMD_SUCCESS
;
10408 DEFUN (show_ip_bgp_instance_updgrps_adj_s
,
10409 show_ip_bgp_instance_updgrps_adj_s_cmd
,
10410 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10414 BGP_INSTANCE_HELP_STR
10415 "Detailed info about dynamic update groups\n"
10416 "Specific subgroup to display info for\n"
10417 "Advertisement queue\n"
10418 "Announced routes\n"
10422 int idx_subgroup_id
= 6;
10424 uint64_t subgrp_id
;
10426 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10428 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_vrf
]->arg
, AFI_IP
,
10429 SAFI_UNICAST
, argv
[idx_type
]->arg
,
10431 return CMD_SUCCESS
;
10434 DEFUN (show_bgp_updgrps_afi_adj_s
,
10435 show_bgp_updgrps_afi_adj_s_cmd
,
10436 "show [ip] bgp "BGP_AFI_SAFI_CMD_STR
" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10440 BGP_AFI_SAFI_HELP_STR
10441 "Detailed info about dynamic update groups\n"
10442 "Specific subgroup to display info for\n"
10443 "Advertisement queue\n"
10444 "Announced routes\n"
10449 int idx_subgroup_id
= 5;
10451 uint64_t subgrp_id
;
10453 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10455 show_bgp_updgrps_adj_info_aux(
10456 vty
, NULL
, bgp_vty_afi_from_str(argv
[idx_afi
]->text
),
10457 bgp_vty_safi_from_str(argv
[idx_safi
]->text
),
10458 argv
[idx_type
]->arg
, subgrp_id
);
10459 return CMD_SUCCESS
;
10462 DEFUN (show_bgp_updgrps_adj_s
,
10463 show_bgp_updgrps_adj_s_cmd
,
10464 "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10468 "Detailed info about dynamic update groups\n"
10469 "Specific subgroup to display info for\n"
10470 "Advertisement queue\n"
10471 "Announced routes\n"
10474 int idx_subgroup_id
= 3;
10476 uint64_t subgrp_id
;
10478 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10480 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10481 argv
[idx_type
]->arg
, subgrp_id
);
10482 return CMD_SUCCESS
;
10485 DEFUN (show_bgp_instance_updgrps_adj_s
,
10486 show_bgp_instance_updgrps_adj_s_cmd
,
10487 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10491 BGP_INSTANCE_HELP_STR
10492 "Detailed info about dynamic update groups\n"
10493 "Specific subgroup to display info for\n"
10494 "Advertisement queue\n"
10495 "Announced routes\n"
10499 int idx_subgroup_id
= 5;
10501 uint64_t subgrp_id
;
10503 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10505 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_vrf
]->arg
, AFI_IP6
,
10506 SAFI_UNICAST
, argv
[idx_type
]->arg
,
10508 return CMD_SUCCESS
;
10512 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
10514 struct listnode
*node
, *nnode
;
10515 struct prefix
*range
;
10518 char buf
[PREFIX2STR_BUFFER
];
10521 const char *peer_status
;
10522 const char *af_str
;
10527 conf
= group
->conf
;
10529 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
10530 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10532 } else if (conf
->as_type
== AS_INTERNAL
) {
10533 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10536 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
10539 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
10540 vty_out(vty
, " Peer-group type is internal\n");
10542 vty_out(vty
, " Peer-group type is external\n");
10544 /* Display AFs configured. */
10545 vty_out(vty
, " Configured address-families:");
10546 FOREACH_AFI_SAFI (afi
, safi
) {
10547 if (conf
->afc
[afi
][safi
]) {
10549 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
10553 vty_out(vty
, " none\n");
10555 vty_out(vty
, "\n");
10557 /* Display listen ranges (for dynamic neighbors), if any */
10558 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
10561 else if (afi
== AFI_IP6
)
10565 lr_count
= listcount(group
->listen_range
[afi
]);
10567 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
10571 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
10573 prefix2str(range
, buf
, sizeof(buf
));
10574 vty_out(vty
, " %s\n", buf
);
10579 /* Display group members and their status */
10580 if (listcount(group
->peer
)) {
10581 vty_out(vty
, " Peer-group members:\n");
10582 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
10583 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
10584 peer_status
= "Idle (Admin)";
10585 else if (CHECK_FLAG(peer
->sflags
,
10586 PEER_STATUS_PREFIX_OVERFLOW
))
10587 peer_status
= "Idle (PfxCt)";
10589 peer_status
= lookup_msg(bgp_status_msg
,
10590 peer
->status
, NULL
);
10592 dynamic
= peer_dynamic_neighbor(peer
);
10593 vty_out(vty
, " %s %s %s \n", peer
->host
,
10594 dynamic
? "(dynamic)" : "", peer_status
);
10598 return CMD_SUCCESS
;
10601 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
10602 const char *group_name
)
10605 struct listnode
*node
, *nnode
;
10606 struct peer_group
*group
;
10607 bool found
= false;
10609 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
10612 vty_out(vty
, "%% No such BGP instance exists\n");
10613 return CMD_WARNING
;
10616 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
10618 if (strmatch(group
->name
, group_name
)) {
10619 bgp_show_one_peer_group(vty
, group
);
10624 bgp_show_one_peer_group(vty
, group
);
10628 if (group_name
&& !found
)
10629 vty_out(vty
, "%% No such peer-group\n");
10631 return CMD_SUCCESS
;
10634 DEFUN (show_ip_bgp_peer_groups
,
10635 show_ip_bgp_peer_groups_cmd
,
10636 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
10640 BGP_INSTANCE_HELP_STR
10641 "Detailed information on BGP peer groups\n"
10642 "Peer group name\n")
10648 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
10649 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
10651 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
10655 /* Redistribute VTY commands. */
10657 DEFUN (bgp_redistribute_ipv4
,
10658 bgp_redistribute_ipv4_cmd
,
10659 "redistribute " FRR_IP_REDIST_STR_BGPD
,
10660 "Redistribute information from another routing protocol\n"
10661 FRR_IP_REDIST_HELP_STR_BGPD
)
10663 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10664 int idx_protocol
= 1;
10667 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10669 vty_out(vty
, "%% Invalid route type\n");
10670 return CMD_WARNING_CONFIG_FAILED
;
10673 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10674 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10678 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
10679 "redistribute " FRR_IP_REDIST_STR_BGPD
,
10680 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
10682 DEFUN (bgp_redistribute_ipv4_rmap
,
10683 bgp_redistribute_ipv4_rmap_cmd
,
10684 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
10685 "Redistribute information from another routing protocol\n"
10686 FRR_IP_REDIST_HELP_STR_BGPD
10687 "Route map reference\n"
10688 "Pointer to route-map entries\n")
10690 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10691 int idx_protocol
= 1;
10694 struct bgp_redist
*red
;
10696 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10698 vty_out(vty
, "%% Invalid route type\n");
10699 return CMD_WARNING_CONFIG_FAILED
;
10702 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10703 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10704 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10708 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
10709 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
10710 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10711 "Route map reference\n"
10712 "Pointer to route-map entries\n")
10714 DEFUN (bgp_redistribute_ipv4_metric
,
10715 bgp_redistribute_ipv4_metric_cmd
,
10716 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
10717 "Redistribute information from another routing protocol\n"
10718 FRR_IP_REDIST_HELP_STR_BGPD
10719 "Metric for redistributed routes\n"
10720 "Default metric\n")
10722 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10723 int idx_protocol
= 1;
10724 int idx_number
= 3;
10727 struct bgp_redist
*red
;
10729 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10731 vty_out(vty
, "%% Invalid route type\n");
10732 return CMD_WARNING_CONFIG_FAILED
;
10734 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10736 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10737 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
10738 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10742 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
10743 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
10744 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10745 "Metric for redistributed routes\n"
10746 "Default metric\n")
10748 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
10749 bgp_redistribute_ipv4_rmap_metric_cmd
,
10750 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
10751 "Redistribute information from another routing protocol\n"
10752 FRR_IP_REDIST_HELP_STR_BGPD
10753 "Route map reference\n"
10754 "Pointer to route-map entries\n"
10755 "Metric for redistributed routes\n"
10756 "Default metric\n")
10758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10759 int idx_protocol
= 1;
10761 int idx_number
= 5;
10764 struct bgp_redist
*red
;
10766 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10768 vty_out(vty
, "%% Invalid route type\n");
10769 return CMD_WARNING_CONFIG_FAILED
;
10771 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10773 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10774 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10775 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
10776 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10780 bgp_redistribute_ipv4_rmap_metric
,
10781 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
10782 "redistribute " FRR_IP_REDIST_STR_BGPD
10783 " route-map WORD metric (0-4294967295)",
10784 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10785 "Route map reference\n"
10786 "Pointer to route-map entries\n"
10787 "Metric for redistributed routes\n"
10788 "Default metric\n")
10790 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
10791 bgp_redistribute_ipv4_metric_rmap_cmd
,
10792 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
10793 "Redistribute information from another routing protocol\n"
10794 FRR_IP_REDIST_HELP_STR_BGPD
10795 "Metric for redistributed routes\n"
10797 "Route map reference\n"
10798 "Pointer to route-map entries\n")
10800 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10801 int idx_protocol
= 1;
10802 int idx_number
= 3;
10806 struct bgp_redist
*red
;
10808 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10810 vty_out(vty
, "%% Invalid route type\n");
10811 return CMD_WARNING_CONFIG_FAILED
;
10813 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10815 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10816 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
10817 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10818 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10822 bgp_redistribute_ipv4_metric_rmap
,
10823 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
10824 "redistribute " FRR_IP_REDIST_STR_BGPD
10825 " metric (0-4294967295) route-map WORD",
10826 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10827 "Metric for redistributed routes\n"
10829 "Route map reference\n"
10830 "Pointer to route-map entries\n")
10832 DEFUN (bgp_redistribute_ipv4_ospf
,
10833 bgp_redistribute_ipv4_ospf_cmd
,
10834 "redistribute <ospf|table> (1-65535)",
10835 "Redistribute information from another routing protocol\n"
10836 "Open Shortest Path First (OSPFv2)\n"
10837 "Non-main Kernel Routing Table\n"
10838 "Instance ID/Table ID\n")
10840 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10841 int idx_ospf_table
= 1;
10842 int idx_number
= 2;
10846 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10848 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10849 protocol
= ZEBRA_ROUTE_OSPF
;
10851 protocol
= ZEBRA_ROUTE_TABLE
;
10853 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10854 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10857 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
10858 "redistribute <ospf|table> (1-65535)",
10859 "Redistribute information from another routing protocol\n"
10860 "Open Shortest Path First (OSPFv2)\n"
10861 "Non-main Kernel Routing Table\n"
10862 "Instance ID/Table ID\n")
10864 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
10865 bgp_redistribute_ipv4_ospf_rmap_cmd
,
10866 "redistribute <ospf|table> (1-65535) route-map WORD",
10867 "Redistribute information from another routing protocol\n"
10868 "Open Shortest Path First (OSPFv2)\n"
10869 "Non-main Kernel Routing Table\n"
10870 "Instance ID/Table ID\n"
10871 "Route map reference\n"
10872 "Pointer to route-map entries\n")
10874 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10875 int idx_ospf_table
= 1;
10876 int idx_number
= 2;
10878 struct bgp_redist
*red
;
10882 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10883 protocol
= ZEBRA_ROUTE_OSPF
;
10885 protocol
= ZEBRA_ROUTE_TABLE
;
10887 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10888 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10889 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10890 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10893 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
10894 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
10895 "redistribute <ospf|table> (1-65535) route-map WORD",
10896 "Redistribute information from another routing protocol\n"
10897 "Open Shortest Path First (OSPFv2)\n"
10898 "Non-main Kernel Routing Table\n"
10899 "Instance ID/Table ID\n"
10900 "Route map reference\n"
10901 "Pointer to route-map entries\n")
10903 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
10904 bgp_redistribute_ipv4_ospf_metric_cmd
,
10905 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
10906 "Redistribute information from another routing protocol\n"
10907 "Open Shortest Path First (OSPFv2)\n"
10908 "Non-main Kernel Routing Table\n"
10909 "Instance ID/Table ID\n"
10910 "Metric for redistributed routes\n"
10911 "Default metric\n")
10913 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10914 int idx_ospf_table
= 1;
10915 int idx_number
= 2;
10916 int idx_number_2
= 4;
10918 struct bgp_redist
*red
;
10922 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10923 protocol
= ZEBRA_ROUTE_OSPF
;
10925 protocol
= ZEBRA_ROUTE_TABLE
;
10927 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10928 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
10930 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10931 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
10932 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10935 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
10936 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
10937 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
10938 "Redistribute information from another routing protocol\n"
10939 "Open Shortest Path First (OSPFv2)\n"
10940 "Non-main Kernel Routing Table\n"
10941 "Instance ID/Table ID\n"
10942 "Metric for redistributed routes\n"
10943 "Default metric\n")
10945 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
10946 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
10947 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
10948 "Redistribute information from another routing protocol\n"
10949 "Open Shortest Path First (OSPFv2)\n"
10950 "Non-main Kernel Routing Table\n"
10951 "Instance ID/Table ID\n"
10952 "Route map reference\n"
10953 "Pointer to route-map entries\n"
10954 "Metric for redistributed routes\n"
10955 "Default metric\n")
10957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10958 int idx_ospf_table
= 1;
10959 int idx_number
= 2;
10961 int idx_number_2
= 6;
10963 struct bgp_redist
*red
;
10967 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10968 protocol
= ZEBRA_ROUTE_OSPF
;
10970 protocol
= ZEBRA_ROUTE_TABLE
;
10972 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10973 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
10975 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10976 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10977 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
10978 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10982 bgp_redistribute_ipv4_ospf_rmap_metric
,
10983 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
10984 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
10985 "Redistribute information from another routing protocol\n"
10986 "Open Shortest Path First (OSPFv2)\n"
10987 "Non-main Kernel Routing Table\n"
10988 "Instance ID/Table ID\n"
10989 "Route map reference\n"
10990 "Pointer to route-map entries\n"
10991 "Metric for redistributed routes\n"
10992 "Default metric\n")
10994 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
10995 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
10996 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
10997 "Redistribute information from another routing protocol\n"
10998 "Open Shortest Path First (OSPFv2)\n"
10999 "Non-main Kernel Routing Table\n"
11000 "Instance ID/Table ID\n"
11001 "Metric for redistributed routes\n"
11003 "Route map reference\n"
11004 "Pointer to route-map entries\n")
11006 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11007 int idx_ospf_table
= 1;
11008 int idx_number
= 2;
11009 int idx_number_2
= 4;
11012 struct bgp_redist
*red
;
11016 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11017 protocol
= ZEBRA_ROUTE_OSPF
;
11019 protocol
= ZEBRA_ROUTE_TABLE
;
11021 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11022 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11024 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11025 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11026 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11027 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11031 bgp_redistribute_ipv4_ospf_metric_rmap
,
11032 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11033 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11034 "Redistribute information from another routing protocol\n"
11035 "Open Shortest Path First (OSPFv2)\n"
11036 "Non-main Kernel Routing Table\n"
11037 "Instance ID/Table ID\n"
11038 "Metric for redistributed routes\n"
11040 "Route map reference\n"
11041 "Pointer to route-map entries\n")
11043 DEFUN (no_bgp_redistribute_ipv4_ospf
,
11044 no_bgp_redistribute_ipv4_ospf_cmd
,
11045 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11047 "Redistribute information from another routing protocol\n"
11048 "Open Shortest Path First (OSPFv2)\n"
11049 "Non-main Kernel Routing Table\n"
11050 "Instance ID/Table ID\n"
11051 "Metric for redistributed routes\n"
11053 "Route map reference\n"
11054 "Pointer to route-map entries\n")
11056 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11057 int idx_ospf_table
= 2;
11058 int idx_number
= 3;
11062 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11063 protocol
= ZEBRA_ROUTE_OSPF
;
11065 protocol
= ZEBRA_ROUTE_TABLE
;
11067 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11068 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
11072 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
11073 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11075 "Redistribute information from another routing protocol\n"
11076 "Open Shortest Path First (OSPFv2)\n"
11077 "Non-main Kernel Routing Table\n"
11078 "Instance ID/Table ID\n"
11079 "Metric for redistributed routes\n"
11081 "Route map reference\n"
11082 "Pointer to route-map entries\n")
11084 DEFUN (no_bgp_redistribute_ipv4
,
11085 no_bgp_redistribute_ipv4_cmd
,
11086 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11088 "Redistribute information from another routing protocol\n"
11089 FRR_IP_REDIST_HELP_STR_BGPD
11090 "Metric for redistributed routes\n"
11092 "Route map reference\n"
11093 "Pointer to route-map entries\n")
11095 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11096 int idx_protocol
= 2;
11099 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11101 vty_out(vty
, "%% Invalid route type\n");
11102 return CMD_WARNING_CONFIG_FAILED
;
11104 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
11108 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
11109 "no redistribute " FRR_IP_REDIST_STR_BGPD
11110 " [metric (0-4294967295)] [route-map WORD]",
11112 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11113 "Metric for redistributed routes\n"
11115 "Route map reference\n"
11116 "Pointer to route-map entries\n")
11118 DEFUN (bgp_redistribute_ipv6
,
11119 bgp_redistribute_ipv6_cmd
,
11120 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11121 "Redistribute information from another routing protocol\n"
11122 FRR_IP6_REDIST_HELP_STR_BGPD
)
11124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11125 int idx_protocol
= 1;
11128 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11130 vty_out(vty
, "%% Invalid route type\n");
11131 return CMD_WARNING_CONFIG_FAILED
;
11134 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11135 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11138 DEFUN (bgp_redistribute_ipv6_rmap
,
11139 bgp_redistribute_ipv6_rmap_cmd
,
11140 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
11141 "Redistribute information from another routing protocol\n"
11142 FRR_IP6_REDIST_HELP_STR_BGPD
11143 "Route map reference\n"
11144 "Pointer to route-map entries\n")
11146 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11147 int idx_protocol
= 1;
11150 struct bgp_redist
*red
;
11152 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11154 vty_out(vty
, "%% Invalid route type\n");
11155 return CMD_WARNING_CONFIG_FAILED
;
11158 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11159 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11160 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11163 DEFUN (bgp_redistribute_ipv6_metric
,
11164 bgp_redistribute_ipv6_metric_cmd
,
11165 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
11166 "Redistribute information from another routing protocol\n"
11167 FRR_IP6_REDIST_HELP_STR_BGPD
11168 "Metric for redistributed routes\n"
11169 "Default metric\n")
11171 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11172 int idx_protocol
= 1;
11173 int idx_number
= 3;
11176 struct bgp_redist
*red
;
11178 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11180 vty_out(vty
, "%% Invalid route type\n");
11181 return CMD_WARNING_CONFIG_FAILED
;
11183 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11185 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11186 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11187 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11190 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
11191 bgp_redistribute_ipv6_rmap_metric_cmd
,
11192 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11193 "Redistribute information from another routing protocol\n"
11194 FRR_IP6_REDIST_HELP_STR_BGPD
11195 "Route map reference\n"
11196 "Pointer to route-map entries\n"
11197 "Metric for redistributed routes\n"
11198 "Default metric\n")
11200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11201 int idx_protocol
= 1;
11203 int idx_number
= 5;
11206 struct bgp_redist
*red
;
11208 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11210 vty_out(vty
, "%% Invalid route type\n");
11211 return CMD_WARNING_CONFIG_FAILED
;
11213 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11215 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11216 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11217 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11218 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11221 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
11222 bgp_redistribute_ipv6_metric_rmap_cmd
,
11223 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11224 "Redistribute information from another routing protocol\n"
11225 FRR_IP6_REDIST_HELP_STR_BGPD
11226 "Metric for redistributed routes\n"
11228 "Route map reference\n"
11229 "Pointer to route-map entries\n")
11231 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11232 int idx_protocol
= 1;
11233 int idx_number
= 3;
11237 struct bgp_redist
*red
;
11239 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11241 vty_out(vty
, "%% Invalid route type\n");
11242 return CMD_WARNING_CONFIG_FAILED
;
11244 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11246 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11247 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
11248 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11249 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11252 DEFUN (no_bgp_redistribute_ipv6
,
11253 no_bgp_redistribute_ipv6_cmd
,
11254 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11256 "Redistribute information from another routing protocol\n"
11257 FRR_IP6_REDIST_HELP_STR_BGPD
11258 "Metric for redistributed routes\n"
11260 "Route map reference\n"
11261 "Pointer to route-map entries\n")
11263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11264 int idx_protocol
= 2;
11267 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11269 vty_out(vty
, "%% Invalid route type\n");
11270 return CMD_WARNING_CONFIG_FAILED
;
11273 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
11276 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
11281 /* Unicast redistribution only. */
11282 if (safi
!= SAFI_UNICAST
)
11285 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
11286 /* Redistribute BGP does not make sense. */
11287 if (i
!= ZEBRA_ROUTE_BGP
) {
11288 struct list
*red_list
;
11289 struct listnode
*node
;
11290 struct bgp_redist
*red
;
11292 red_list
= bgp
->redist
[afi
][i
];
11296 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
11297 /* "redistribute" configuration. */
11298 vty_out(vty
, " redistribute %s",
11299 zebra_route_string(i
));
11301 vty_out(vty
, " %d", red
->instance
);
11302 if (red
->redist_metric_flag
)
11303 vty_out(vty
, " metric %u",
11304 red
->redist_metric
);
11305 if (red
->rmap
.name
)
11306 vty_out(vty
, " route-map %s",
11308 vty_out(vty
, "\n");
11314 /* BGP node structure. */
11315 static struct cmd_node bgp_node
= {
11316 BGP_NODE
, "%s(config-router)# ", 1,
11319 static struct cmd_node bgp_ipv4_unicast_node
= {
11320 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
11323 static struct cmd_node bgp_ipv4_multicast_node
= {
11324 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
11327 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
11328 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
11331 static struct cmd_node bgp_ipv6_unicast_node
= {
11332 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
11335 static struct cmd_node bgp_ipv6_multicast_node
= {
11336 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
11339 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
11340 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
11343 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
11344 "%s(config-router-af)# ", 1};
11346 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
11347 "%s(config-router-af-vpnv6)# ", 1};
11349 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
11350 "%s(config-router-evpn)# ", 1};
11352 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
11353 "%s(config-router-af-vni)# ", 1};
11355 static void community_list_vty(void);
11357 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
11361 struct peer_group
*group
;
11362 struct listnode
*lnbgp
, *lnpeer
;
11364 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
11365 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
11366 /* only provide suggestions on the appropriate input
11368 * they'll otherwise show up multiple times */
11369 enum cmd_token_type match_type
;
11370 char *name
= peer
->host
;
11372 if (peer
->conf_if
) {
11373 match_type
= VARIABLE_TKN
;
11374 name
= peer
->conf_if
;
11375 } else if (strchr(peer
->host
, ':'))
11376 match_type
= IPV6_TKN
;
11378 match_type
= IPV4_TKN
;
11380 if (token
->type
!= match_type
)
11383 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
11386 if (token
->type
== VARIABLE_TKN
)
11387 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
11388 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
11393 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
11394 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
11395 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
11396 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
11397 {.completions
= NULL
}};
11399 void bgp_vty_init(void)
11401 cmd_variable_handler_register(bgp_var_neighbor
);
11403 /* Install bgp top node. */
11404 install_node(&bgp_node
, bgp_config_write
);
11405 install_node(&bgp_ipv4_unicast_node
, NULL
);
11406 install_node(&bgp_ipv4_multicast_node
, NULL
);
11407 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
11408 install_node(&bgp_ipv6_unicast_node
, NULL
);
11409 install_node(&bgp_ipv6_multicast_node
, NULL
);
11410 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
11411 install_node(&bgp_vpnv4_node
, NULL
);
11412 install_node(&bgp_vpnv6_node
, NULL
);
11413 install_node(&bgp_evpn_node
, NULL
);
11414 install_node(&bgp_evpn_vni_node
, NULL
);
11416 /* Install default VTY commands to new nodes. */
11417 install_default(BGP_NODE
);
11418 install_default(BGP_IPV4_NODE
);
11419 install_default(BGP_IPV4M_NODE
);
11420 install_default(BGP_IPV4L_NODE
);
11421 install_default(BGP_IPV6_NODE
);
11422 install_default(BGP_IPV6M_NODE
);
11423 install_default(BGP_IPV6L_NODE
);
11424 install_default(BGP_VPNV4_NODE
);
11425 install_default(BGP_VPNV6_NODE
);
11426 install_default(BGP_EVPN_NODE
);
11427 install_default(BGP_EVPN_VNI_NODE
);
11429 /* "bgp multiple-instance" commands. */
11430 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
11431 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
11433 /* "bgp config-type" commands. */
11434 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
11435 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
11437 /* bgp route-map delay-timer commands. */
11438 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
11439 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
11441 /* Dummy commands (Currently not supported) */
11442 install_element(BGP_NODE
, &no_synchronization_cmd
);
11443 install_element(BGP_NODE
, &no_auto_summary_cmd
);
11445 /* "router bgp" commands. */
11446 install_element(CONFIG_NODE
, &router_bgp_cmd
);
11448 /* "no router bgp" commands. */
11449 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
11451 /* "bgp router-id" commands. */
11452 install_element(BGP_NODE
, &bgp_router_id_cmd
);
11453 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
11455 /* "bgp cluster-id" commands. */
11456 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
11457 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
11459 /* "bgp confederation" commands. */
11460 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
11461 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
11463 /* "bgp confederation peers" commands. */
11464 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
11465 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
11467 /* bgp max-med command */
11468 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
11469 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
11470 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
11471 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
11472 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
11474 /* bgp disable-ebgp-connected-nh-check */
11475 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
11476 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
11478 /* bgp update-delay command */
11479 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
11480 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
11481 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
11483 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
11484 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
11485 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
11486 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
11488 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
11489 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
11491 /* "maximum-paths" commands. */
11492 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
11493 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
11494 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
11495 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
11496 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
11497 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
11498 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
11499 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
11500 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
11501 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
11502 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11503 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11504 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
11505 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11506 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11508 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
11509 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
11510 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
11511 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11512 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11514 /* "timers bgp" commands. */
11515 install_element(BGP_NODE
, &bgp_timers_cmd
);
11516 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
11518 /* route-map delay-timer commands - per instance for backwards compat.
11520 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
11521 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
11523 /* "bgp client-to-client reflection" commands */
11524 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
11525 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
11527 /* "bgp always-compare-med" commands */
11528 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
11529 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
11531 /* "bgp deterministic-med" commands */
11532 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
11533 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
11535 /* "bgp graceful-restart" commands */
11536 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
11537 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
11538 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
11539 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
11540 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
11541 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
11543 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
11544 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
11546 /* "bgp graceful-shutdown" commands */
11547 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
11548 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
11550 /* "bgp fast-external-failover" commands */
11551 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
11552 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
11554 /* "bgp enforce-first-as" commands */
11555 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
11556 install_element(BGP_NODE
, &no_bgp_enforce_first_as_cmd
);
11558 /* "bgp bestpath compare-routerid" commands */
11559 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
11560 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
11562 /* "bgp bestpath as-path ignore" commands */
11563 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
11564 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
11566 /* "bgp bestpath as-path confed" commands */
11567 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
11568 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
11570 /* "bgp bestpath as-path multipath-relax" commands */
11571 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
11572 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
11574 /* "bgp log-neighbor-changes" commands */
11575 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
11576 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
11578 /* "bgp bestpath med" commands */
11579 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
11580 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
11582 /* "no bgp default ipv4-unicast" commands. */
11583 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
11584 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
11586 /* "bgp network import-check" commands. */
11587 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
11588 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
11589 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
11591 /* "bgp default local-preference" commands. */
11592 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
11593 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
11595 /* bgp default show-hostname */
11596 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
11597 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
11599 /* "bgp default subgroup-pkt-queue-max" commands. */
11600 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
11601 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
11603 /* bgp ibgp-allow-policy-mods command */
11604 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
11605 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
11607 /* "bgp listen limit" commands. */
11608 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
11609 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
11611 /* "bgp listen range" commands. */
11612 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
11613 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
11615 /* "bgp default shutdown" command */
11616 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
11618 /* "neighbor remote-as" commands. */
11619 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
11620 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
11621 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
11622 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
11623 install_element(BGP_NODE
,
11624 &neighbor_interface_v6only_config_remote_as_cmd
);
11625 install_element(BGP_NODE
, &no_neighbor_cmd
);
11626 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
11628 /* "neighbor peer-group" commands. */
11629 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
11630 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
11631 install_element(BGP_NODE
,
11632 &no_neighbor_interface_peer_group_remote_as_cmd
);
11634 /* "neighbor local-as" commands. */
11635 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
11636 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
11637 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
11638 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
11640 /* "neighbor solo" commands. */
11641 install_element(BGP_NODE
, &neighbor_solo_cmd
);
11642 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
11644 /* "neighbor password" commands. */
11645 install_element(BGP_NODE
, &neighbor_password_cmd
);
11646 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
11648 /* "neighbor activate" commands. */
11649 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
11650 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
11651 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
11652 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
11653 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
11654 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
11655 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
11656 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
11657 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
11658 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
11660 /* "no neighbor activate" commands. */
11661 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
11662 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
11663 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
11664 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
11665 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
11666 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
11667 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
11668 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
11669 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
11670 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
11672 /* "neighbor peer-group" set commands. */
11673 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
11674 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11675 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11676 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11677 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11678 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11679 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11680 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11682 /* "no neighbor peer-group unset" commands. */
11683 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
11684 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11685 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11686 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11687 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11688 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11689 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11690 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11692 /* "neighbor softreconfiguration inbound" commands.*/
11693 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
11694 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
11695 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
11696 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11697 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
11698 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11699 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
11700 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11701 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
11702 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11703 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
11704 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11705 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
11706 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11707 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
11708 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11709 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
11710 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11712 /* "neighbor attribute-unchanged" commands. */
11713 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
11714 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
11715 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
11716 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
11717 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
11718 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
11719 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
11720 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
11721 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
11722 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
11723 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
11724 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
11725 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
11726 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
11727 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
11728 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
11729 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
11730 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
11732 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
11733 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
11735 /* "nexthop-local unchanged" commands */
11736 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
11737 install_element(BGP_IPV6_NODE
,
11738 &no_neighbor_nexthop_local_unchanged_cmd
);
11740 /* "neighbor next-hop-self" commands. */
11741 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
11742 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
11743 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
11744 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
11745 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
11746 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
11747 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
11748 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
11749 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
11750 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
11751 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
11752 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
11753 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
11754 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
11755 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
11756 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
11757 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
11758 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
11760 /* "neighbor next-hop-self force" commands. */
11761 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
11762 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
11763 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
11764 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11765 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
11766 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11767 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
11768 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11769 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
11770 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11771 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
11772 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11773 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
11774 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11775 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
11776 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11777 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
11778 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11780 /* "neighbor as-override" commands. */
11781 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
11782 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
11783 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
11784 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
11785 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
11786 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
11787 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
11788 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
11789 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
11790 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
11791 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
11792 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
11793 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
11794 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
11795 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
11796 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
11797 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
11798 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
11800 /* "neighbor remove-private-AS" commands. */
11801 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
11802 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
11803 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
11804 install_element(BGP_NODE
,
11805 &no_neighbor_remove_private_as_all_hidden_cmd
);
11806 install_element(BGP_NODE
,
11807 &neighbor_remove_private_as_replace_as_hidden_cmd
);
11808 install_element(BGP_NODE
,
11809 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
11810 install_element(BGP_NODE
,
11811 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
11814 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
11815 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
11816 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
11817 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
11818 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11819 install_element(BGP_IPV4_NODE
,
11820 &neighbor_remove_private_as_replace_as_cmd
);
11821 install_element(BGP_IPV4_NODE
,
11822 &no_neighbor_remove_private_as_replace_as_cmd
);
11823 install_element(BGP_IPV4_NODE
,
11824 &neighbor_remove_private_as_all_replace_as_cmd
);
11825 install_element(BGP_IPV4_NODE
,
11826 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11827 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
11828 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
11829 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
11830 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11831 install_element(BGP_IPV4M_NODE
,
11832 &neighbor_remove_private_as_replace_as_cmd
);
11833 install_element(BGP_IPV4M_NODE
,
11834 &no_neighbor_remove_private_as_replace_as_cmd
);
11835 install_element(BGP_IPV4M_NODE
,
11836 &neighbor_remove_private_as_all_replace_as_cmd
);
11837 install_element(BGP_IPV4M_NODE
,
11838 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11839 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
11840 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
11841 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
11842 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11843 install_element(BGP_IPV4L_NODE
,
11844 &neighbor_remove_private_as_replace_as_cmd
);
11845 install_element(BGP_IPV4L_NODE
,
11846 &no_neighbor_remove_private_as_replace_as_cmd
);
11847 install_element(BGP_IPV4L_NODE
,
11848 &neighbor_remove_private_as_all_replace_as_cmd
);
11849 install_element(BGP_IPV4L_NODE
,
11850 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11851 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
11852 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
11853 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
11854 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11855 install_element(BGP_IPV6_NODE
,
11856 &neighbor_remove_private_as_replace_as_cmd
);
11857 install_element(BGP_IPV6_NODE
,
11858 &no_neighbor_remove_private_as_replace_as_cmd
);
11859 install_element(BGP_IPV6_NODE
,
11860 &neighbor_remove_private_as_all_replace_as_cmd
);
11861 install_element(BGP_IPV6_NODE
,
11862 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11863 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
11864 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
11865 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
11866 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11867 install_element(BGP_IPV6M_NODE
,
11868 &neighbor_remove_private_as_replace_as_cmd
);
11869 install_element(BGP_IPV6M_NODE
,
11870 &no_neighbor_remove_private_as_replace_as_cmd
);
11871 install_element(BGP_IPV6M_NODE
,
11872 &neighbor_remove_private_as_all_replace_as_cmd
);
11873 install_element(BGP_IPV6M_NODE
,
11874 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11875 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
11876 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
11877 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
11878 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11879 install_element(BGP_IPV6L_NODE
,
11880 &neighbor_remove_private_as_replace_as_cmd
);
11881 install_element(BGP_IPV6L_NODE
,
11882 &no_neighbor_remove_private_as_replace_as_cmd
);
11883 install_element(BGP_IPV6L_NODE
,
11884 &neighbor_remove_private_as_all_replace_as_cmd
);
11885 install_element(BGP_IPV6L_NODE
,
11886 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11887 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
11888 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
11889 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
11890 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11891 install_element(BGP_VPNV4_NODE
,
11892 &neighbor_remove_private_as_replace_as_cmd
);
11893 install_element(BGP_VPNV4_NODE
,
11894 &no_neighbor_remove_private_as_replace_as_cmd
);
11895 install_element(BGP_VPNV4_NODE
,
11896 &neighbor_remove_private_as_all_replace_as_cmd
);
11897 install_element(BGP_VPNV4_NODE
,
11898 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11899 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
11900 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
11901 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
11902 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11903 install_element(BGP_VPNV6_NODE
,
11904 &neighbor_remove_private_as_replace_as_cmd
);
11905 install_element(BGP_VPNV6_NODE
,
11906 &no_neighbor_remove_private_as_replace_as_cmd
);
11907 install_element(BGP_VPNV6_NODE
,
11908 &neighbor_remove_private_as_all_replace_as_cmd
);
11909 install_element(BGP_VPNV6_NODE
,
11910 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11912 /* "neighbor send-community" commands.*/
11913 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
11914 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
11915 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
11916 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
11917 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
11918 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
11919 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
11920 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
11921 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
11922 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
11923 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
11924 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
11925 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
11926 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
11927 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
11928 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
11929 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
11930 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
11931 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
11932 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
11933 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
11934 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
11935 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
11936 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
11937 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
11938 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
11939 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
11940 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
11941 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
11942 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
11943 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
11944 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
11945 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
11946 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
11947 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
11948 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
11950 /* "neighbor route-reflector" commands.*/
11951 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
11952 install_element(BGP_NODE
,
11953 &no_neighbor_route_reflector_client_hidden_cmd
);
11954 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
11955 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
11956 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
11957 install_element(BGP_IPV4M_NODE
,
11958 &no_neighbor_route_reflector_client_cmd
);
11959 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
11960 install_element(BGP_IPV4L_NODE
,
11961 &no_neighbor_route_reflector_client_cmd
);
11962 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
11963 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
11964 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
11965 install_element(BGP_IPV6M_NODE
,
11966 &no_neighbor_route_reflector_client_cmd
);
11967 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
11968 install_element(BGP_IPV6L_NODE
,
11969 &no_neighbor_route_reflector_client_cmd
);
11970 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
11971 install_element(BGP_VPNV4_NODE
,
11972 &no_neighbor_route_reflector_client_cmd
);
11973 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
11974 install_element(BGP_VPNV6_NODE
,
11975 &no_neighbor_route_reflector_client_cmd
);
11976 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
11977 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
11979 /* "neighbor route-server" commands.*/
11980 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
11981 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
11982 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
11983 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
11984 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
11985 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
11986 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
11987 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
11988 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
11989 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
11990 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
11991 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
11992 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
11993 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
11994 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
11995 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
11996 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
11997 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
11999 /* "neighbor addpath-tx-all-paths" commands.*/
12000 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
12001 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
12002 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12003 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12004 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12005 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12006 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12007 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12008 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12009 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12010 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12011 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12012 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12013 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12014 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12015 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12016 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12017 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12019 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
12020 install_element(BGP_NODE
,
12021 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12022 install_element(BGP_NODE
,
12023 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12024 install_element(BGP_IPV4_NODE
,
12025 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12026 install_element(BGP_IPV4_NODE
,
12027 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12028 install_element(BGP_IPV4M_NODE
,
12029 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12030 install_element(BGP_IPV4M_NODE
,
12031 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12032 install_element(BGP_IPV4L_NODE
,
12033 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12034 install_element(BGP_IPV4L_NODE
,
12035 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12036 install_element(BGP_IPV6_NODE
,
12037 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12038 install_element(BGP_IPV6_NODE
,
12039 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12040 install_element(BGP_IPV6M_NODE
,
12041 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12042 install_element(BGP_IPV6M_NODE
,
12043 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12044 install_element(BGP_IPV6L_NODE
,
12045 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12046 install_element(BGP_IPV6L_NODE
,
12047 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12048 install_element(BGP_VPNV4_NODE
,
12049 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12050 install_element(BGP_VPNV4_NODE
,
12051 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12052 install_element(BGP_VPNV6_NODE
,
12053 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12054 install_element(BGP_VPNV6_NODE
,
12055 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12057 /* "neighbor passive" commands. */
12058 install_element(BGP_NODE
, &neighbor_passive_cmd
);
12059 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
12062 /* "neighbor shutdown" commands. */
12063 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
12064 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
12065 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
12066 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
12068 /* "neighbor capability extended-nexthop" commands.*/
12069 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
12070 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
12072 /* "neighbor capability orf prefix-list" commands.*/
12073 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
12074 install_element(BGP_NODE
,
12075 &no_neighbor_capability_orf_prefix_hidden_cmd
);
12076 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
12077 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12078 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
12079 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12080 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
12081 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12082 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
12083 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12084 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
12085 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12086 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
12087 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12089 /* "neighbor capability dynamic" commands.*/
12090 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
12091 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
12093 /* "neighbor dont-capability-negotiate" commands. */
12094 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
12095 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
12097 /* "neighbor ebgp-multihop" commands. */
12098 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
12099 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
12100 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
12102 /* "neighbor disable-connected-check" commands. */
12103 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
12104 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
12106 /* "neighbor description" commands. */
12107 install_element(BGP_NODE
, &neighbor_description_cmd
);
12108 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
12110 /* "neighbor update-source" commands. "*/
12111 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
12112 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
12114 /* "neighbor default-originate" commands. */
12115 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
12116 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
12117 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
12118 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
12119 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
12120 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
12121 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
12122 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
12123 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
12124 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
12125 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
12126 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
12127 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
12128 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
12129 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
12130 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
12131 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
12132 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
12133 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
12134 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
12135 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
12137 /* "neighbor port" commands. */
12138 install_element(BGP_NODE
, &neighbor_port_cmd
);
12139 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
12141 /* "neighbor weight" commands. */
12142 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
12143 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
12145 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
12146 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
12147 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
12148 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
12149 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
12150 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
12151 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
12152 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
12153 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
12154 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
12155 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
12156 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
12157 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
12158 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
12159 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
12160 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
12162 /* "neighbor override-capability" commands. */
12163 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
12164 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
12166 /* "neighbor strict-capability-match" commands. */
12167 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
12168 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
12170 /* "neighbor timers" commands. */
12171 install_element(BGP_NODE
, &neighbor_timers_cmd
);
12172 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
12174 /* "neighbor timers connect" commands. */
12175 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
12176 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
12178 /* "neighbor advertisement-interval" commands. */
12179 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
12180 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
12182 /* "neighbor interface" commands. */
12183 install_element(BGP_NODE
, &neighbor_interface_cmd
);
12184 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
12186 /* "neighbor distribute" commands. */
12187 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
12188 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
12189 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
12190 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
12191 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
12192 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
12193 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
12194 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
12195 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
12196 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
12197 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
12198 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
12199 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
12200 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
12201 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
12202 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
12203 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
12204 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
12206 /* "neighbor prefix-list" commands. */
12207 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
12208 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
12209 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
12210 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
12211 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
12212 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
12213 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
12214 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
12215 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
12216 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
12217 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
12218 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
12219 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
12220 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
12221 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
12222 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
12223 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
12224 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
12226 /* "neighbor filter-list" commands. */
12227 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
12228 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
12229 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
12230 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
12231 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
12232 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
12233 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
12234 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
12235 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
12236 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
12237 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
12238 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
12239 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
12240 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
12241 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
12242 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
12243 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
12244 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
12246 /* "neighbor route-map" commands. */
12247 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
12248 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
12249 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
12250 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
12251 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
12252 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
12253 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
12254 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
12255 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
12256 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
12257 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
12258 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
12259 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
12260 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
12261 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
12262 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
12263 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
12264 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
12265 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
12266 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
12268 /* "neighbor unsuppress-map" commands. */
12269 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
12270 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
12271 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
12272 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12273 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
12274 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12275 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
12276 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12277 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
12278 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12279 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
12280 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12281 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
12282 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12283 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
12284 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12285 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
12286 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12288 /* "neighbor maximum-prefix" commands. */
12289 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
12290 install_element(BGP_NODE
,
12291 &neighbor_maximum_prefix_threshold_hidden_cmd
);
12292 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
12293 install_element(BGP_NODE
,
12294 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
12295 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
12296 install_element(BGP_NODE
,
12297 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
12298 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
12299 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
12300 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12301 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12302 install_element(BGP_IPV4_NODE
,
12303 &neighbor_maximum_prefix_threshold_warning_cmd
);
12304 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12305 install_element(BGP_IPV4_NODE
,
12306 &neighbor_maximum_prefix_threshold_restart_cmd
);
12307 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12308 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
12309 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12310 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12311 install_element(BGP_IPV4M_NODE
,
12312 &neighbor_maximum_prefix_threshold_warning_cmd
);
12313 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12314 install_element(BGP_IPV4M_NODE
,
12315 &neighbor_maximum_prefix_threshold_restart_cmd
);
12316 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12317 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
12318 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12319 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12320 install_element(BGP_IPV4L_NODE
,
12321 &neighbor_maximum_prefix_threshold_warning_cmd
);
12322 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12323 install_element(BGP_IPV4L_NODE
,
12324 &neighbor_maximum_prefix_threshold_restart_cmd
);
12325 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12326 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
12327 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12328 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12329 install_element(BGP_IPV6_NODE
,
12330 &neighbor_maximum_prefix_threshold_warning_cmd
);
12331 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12332 install_element(BGP_IPV6_NODE
,
12333 &neighbor_maximum_prefix_threshold_restart_cmd
);
12334 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12335 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
12336 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12337 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12338 install_element(BGP_IPV6M_NODE
,
12339 &neighbor_maximum_prefix_threshold_warning_cmd
);
12340 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12341 install_element(BGP_IPV6M_NODE
,
12342 &neighbor_maximum_prefix_threshold_restart_cmd
);
12343 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12344 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
12345 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12346 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12347 install_element(BGP_IPV6L_NODE
,
12348 &neighbor_maximum_prefix_threshold_warning_cmd
);
12349 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12350 install_element(BGP_IPV6L_NODE
,
12351 &neighbor_maximum_prefix_threshold_restart_cmd
);
12352 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12353 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
12354 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12355 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12356 install_element(BGP_VPNV4_NODE
,
12357 &neighbor_maximum_prefix_threshold_warning_cmd
);
12358 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12359 install_element(BGP_VPNV4_NODE
,
12360 &neighbor_maximum_prefix_threshold_restart_cmd
);
12361 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12362 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
12363 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12364 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12365 install_element(BGP_VPNV6_NODE
,
12366 &neighbor_maximum_prefix_threshold_warning_cmd
);
12367 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12368 install_element(BGP_VPNV6_NODE
,
12369 &neighbor_maximum_prefix_threshold_restart_cmd
);
12370 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12372 /* "neighbor allowas-in" */
12373 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
12374 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
12375 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
12376 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
12377 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
12378 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
12379 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
12380 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
12381 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
12382 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
12383 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
12384 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
12385 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
12386 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
12387 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
12388 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
12389 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
12390 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
12391 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
12392 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
12394 /* address-family commands. */
12395 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
12396 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
12397 #ifdef KEEP_OLD_VPN_COMMANDS
12398 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
12399 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
12400 #endif /* KEEP_OLD_VPN_COMMANDS */
12402 install_element(BGP_NODE
, &address_family_evpn_cmd
);
12404 /* "exit-address-family" command. */
12405 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
12406 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
12407 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
12408 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
12409 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
12410 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
12411 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
12412 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
12413 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
12415 /* "clear ip bgp commands" */
12416 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
12418 /* clear ip bgp prefix */
12419 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
12420 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
12421 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
12423 /* "show [ip] bgp summary" commands. */
12424 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
12425 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_adj_cmd
);
12426 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_adj_s_cmd
);
12427 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
12428 install_element(VIEW_NODE
, &show_bgp_updgrps_adj_cmd
);
12429 install_element(VIEW_NODE
, &show_bgp_updgrps_adj_s_cmd
);
12430 install_element(VIEW_NODE
, &show_bgp_updgrps_afi_adj_cmd
);
12431 install_element(VIEW_NODE
, &show_bgp_updgrps_afi_adj_s_cmd
);
12432 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
12433 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_cmd
);
12434 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
12435 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
12436 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_adj_cmd
);
12437 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_adj_s_cmd
);
12438 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
12440 /* "show [ip] bgp neighbors" commands. */
12441 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
12443 /* "show [ip] bgp peer-group" commands. */
12444 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
12446 /* "show [ip] bgp paths" commands. */
12447 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
12449 /* "show [ip] bgp community" commands. */
12450 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
12452 /* "show ip bgp large-community" commands. */
12453 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
12454 /* "show [ip] bgp attribute-info" commands. */
12455 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
12457 /* "redistribute" commands. */
12458 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
12459 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
12460 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
12461 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
12462 install_element(BGP_NODE
,
12463 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
12464 install_element(BGP_NODE
,
12465 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
12466 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
12467 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
12468 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
12469 install_element(BGP_NODE
,
12470 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
12471 install_element(BGP_NODE
,
12472 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
12473 install_element(BGP_NODE
,
12474 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
12475 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
12476 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
12477 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
12478 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
12479 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
12480 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
12481 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
12482 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
12483 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
12484 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
12485 install_element(BGP_IPV4_NODE
,
12486 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
12487 install_element(BGP_IPV4_NODE
,
12488 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
12489 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
12490 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
12491 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
12492 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
12493 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
12494 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
12496 /* ttl_security commands */
12497 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
12498 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
12500 /* "show [ip] bgp memory" commands. */
12501 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
12503 /* "show bgp martian next-hop" */
12504 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
12506 /* "show [ip] bgp views" commands. */
12507 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
12509 /* "show [ip] bgp vrfs" commands. */
12510 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
12512 /* Community-list. */
12513 community_list_vty();
12516 #include "memory.h"
12517 #include "bgp_regex.h"
12518 #include "bgp_clist.h"
12519 #include "bgp_ecommunity.h"
12521 /* VTY functions. */
12523 /* Direction value to string conversion. */
12524 static const char *community_direct_str(int direct
)
12527 case COMMUNITY_DENY
:
12529 case COMMUNITY_PERMIT
:
12536 /* Display error string. */
12537 static void community_list_perror(struct vty
*vty
, int ret
)
12540 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
12541 vty_out(vty
, "%% Can't find community-list\n");
12543 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
12544 vty_out(vty
, "%% Malformed community-list value\n");
12546 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
12548 "%% Community name conflict, previously defined as standard community\n");
12550 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
12552 "%% Community name conflict, previously defined as expanded community\n");
12557 /* "community-list" keyword help string. */
12558 #define COMMUNITY_LIST_STR "Add a community list entry\n"
12560 /* ip community-list standard */
12561 DEFUN (ip_community_list_standard
,
12562 ip_community_list_standard_cmd
,
12563 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
12566 "Community list number (standard)\n"
12567 "Add an standard community-list entry\n"
12568 "Community list name\n"
12569 "Specify community to reject\n"
12570 "Specify community to accept\n"
12573 char *cl_name_or_number
= NULL
;
12575 int style
= COMMUNITY_LIST_STANDARD
;
12578 argv_find(argv
, argc
, "(1-99)", &idx
);
12579 argv_find(argv
, argc
, "WORD", &idx
);
12580 cl_name_or_number
= argv
[idx
]->arg
;
12581 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12583 argv_find(argv
, argc
, "AA:NN", &idx
);
12584 char *str
= argv_concat(argv
, argc
, idx
);
12586 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
12589 XFREE(MTYPE_TMP
, str
);
12592 /* Display error string. */
12593 community_list_perror(vty
, ret
);
12594 return CMD_WARNING_CONFIG_FAILED
;
12597 return CMD_SUCCESS
;
12600 DEFUN (no_ip_community_list_standard_all
,
12601 no_ip_community_list_standard_all_cmd
,
12602 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
12606 "Community list number (standard)\n"
12607 "Add an standard community-list entry\n"
12608 "Community list name\n"
12609 "Specify community to reject\n"
12610 "Specify community to accept\n"
12613 int delete_all
= 0;
12615 char *cl_name_or_number
= NULL
;
12617 int style
= COMMUNITY_LIST_STANDARD
;
12620 argv_find(argv
, argc
, "(1-99)", &idx
);
12621 argv_find(argv
, argc
, "WORD", &idx
);
12622 cl_name_or_number
= argv
[idx
]->arg
;
12623 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12625 argv_find(argv
, argc
, "AA:NN", &idx
);
12626 char *str
= argv_concat(argv
, argc
, idx
);
12628 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
12629 direct
, style
, delete_all
);
12631 XFREE(MTYPE_TMP
, str
);
12634 community_list_perror(vty
, ret
);
12635 return CMD_WARNING_CONFIG_FAILED
;
12638 return CMD_SUCCESS
;
12641 /* ip community-list expanded */
12642 DEFUN (ip_community_list_expanded_all
,
12643 ip_community_list_expanded_all_cmd
,
12644 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
12647 "Community list number (expanded)\n"
12648 "Add an expanded community-list entry\n"
12649 "Community list name\n"
12650 "Specify community to reject\n"
12651 "Specify community to accept\n"
12654 char *cl_name_or_number
= NULL
;
12656 int style
= COMMUNITY_LIST_EXPANDED
;
12659 argv_find(argv
, argc
, "(100-500)", &idx
);
12660 argv_find(argv
, argc
, "WORD", &idx
);
12661 cl_name_or_number
= argv
[idx
]->arg
;
12662 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12664 argv_find(argv
, argc
, "AA:NN", &idx
);
12665 char *str
= argv_concat(argv
, argc
, idx
);
12667 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
12670 XFREE(MTYPE_TMP
, str
);
12673 /* Display error string. */
12674 community_list_perror(vty
, ret
);
12675 return CMD_WARNING_CONFIG_FAILED
;
12678 return CMD_SUCCESS
;
12681 DEFUN (no_ip_community_list_expanded_all
,
12682 no_ip_community_list_expanded_all_cmd
,
12683 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
12687 "Community list number (expanded)\n"
12688 "Add an expanded community-list entry\n"
12689 "Community list name\n"
12690 "Specify community to reject\n"
12691 "Specify community to accept\n"
12694 int delete_all
= 0;
12696 char *cl_name_or_number
= NULL
;
12698 int style
= COMMUNITY_LIST_EXPANDED
;
12701 argv_find(argv
, argc
, "(100-500)", &idx
);
12702 argv_find(argv
, argc
, "WORD", &idx
);
12703 cl_name_or_number
= argv
[idx
]->arg
;
12704 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12706 argv_find(argv
, argc
, "AA:NN", &idx
);
12707 char *str
= argv_concat(argv
, argc
, idx
);
12709 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
12710 direct
, style
, delete_all
);
12712 XFREE(MTYPE_TMP
, str
);
12715 community_list_perror(vty
, ret
);
12716 return CMD_WARNING_CONFIG_FAILED
;
12719 return CMD_SUCCESS
;
12722 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
12724 struct community_entry
*entry
;
12726 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
12727 if (entry
== list
->head
) {
12728 if (all_digit(list
->name
))
12729 vty_out(vty
, "Community %s list %s\n",
12730 entry
->style
== COMMUNITY_LIST_STANDARD
12732 : "(expanded) access",
12735 vty_out(vty
, "Named Community %s list %s\n",
12736 entry
->style
== COMMUNITY_LIST_STANDARD
12742 vty_out(vty
, " %s\n",
12743 community_direct_str(entry
->direct
));
12745 vty_out(vty
, " %s %s\n",
12746 community_direct_str(entry
->direct
),
12747 entry
->style
== COMMUNITY_LIST_STANDARD
12748 ? community_str(entry
->u
.com
, false)
12753 DEFUN (show_ip_community_list
,
12754 show_ip_community_list_cmd
,
12755 "show ip community-list",
12758 "List community-list\n")
12760 struct community_list
*list
;
12761 struct community_list_master
*cm
;
12763 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
12765 return CMD_SUCCESS
;
12767 for (list
= cm
->num
.head
; list
; list
= list
->next
)
12768 community_list_show(vty
, list
);
12770 for (list
= cm
->str
.head
; list
; list
= list
->next
)
12771 community_list_show(vty
, list
);
12773 return CMD_SUCCESS
;
12776 DEFUN (show_ip_community_list_arg
,
12777 show_ip_community_list_arg_cmd
,
12778 "show ip community-list <(1-500)|WORD>",
12781 "List community-list\n"
12782 "Community-list number\n"
12783 "Community-list name\n")
12785 int idx_comm_list
= 3;
12786 struct community_list
*list
;
12788 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
12789 COMMUNITY_LIST_MASTER
);
12791 vty_out(vty
, "%% Can't find community-list\n");
12792 return CMD_WARNING
;
12795 community_list_show(vty
, list
);
12797 return CMD_SUCCESS
;
12801 * Large Community code.
12803 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
12804 struct cmd_token
**argv
, int style
,
12805 int reject_all_digit_name
)
12813 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12816 /* All digit name check. */
12818 argv_find(argv
, argc
, "WORD", &idx
);
12819 argv_find(argv
, argc
, "(1-99)", &idx
);
12820 argv_find(argv
, argc
, "(100-500)", &idx
);
12821 cl_name
= argv
[idx
]->arg
;
12822 if (reject_all_digit_name
&& all_digit(cl_name
)) {
12823 vty_out(vty
, "%% Community name cannot have all digits\n");
12824 return CMD_WARNING_CONFIG_FAILED
;
12828 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
12829 argv_find(argv
, argc
, "LINE", &idx
);
12830 /* Concat community string argument. */
12832 str
= argv_concat(argv
, argc
, idx
);
12836 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
12838 /* Free temporary community list string allocated by
12841 XFREE(MTYPE_TMP
, str
);
12844 community_list_perror(vty
, ret
);
12845 return CMD_WARNING_CONFIG_FAILED
;
12847 return CMD_SUCCESS
;
12850 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
12851 struct cmd_token
**argv
, int style
)
12858 argv_find(argv
, argc
, "permit", &idx
);
12859 argv_find(argv
, argc
, "deny", &idx
);
12862 /* Check the list direct. */
12863 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
12864 direct
= COMMUNITY_PERMIT
;
12866 direct
= COMMUNITY_DENY
;
12869 argv_find(argv
, argc
, "LINE", &idx
);
12870 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
12871 /* Concat community string argument. */
12872 str
= argv_concat(argv
, argc
, idx
);
12876 argv_find(argv
, argc
, "(1-99)", &idx
);
12877 argv_find(argv
, argc
, "(100-500)", &idx
);
12878 argv_find(argv
, argc
, "WORD", &idx
);
12880 /* Unset community list. */
12881 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
12884 /* Free temporary community list string allocated by
12887 XFREE(MTYPE_TMP
, str
);
12890 community_list_perror(vty
, ret
);
12891 return CMD_WARNING_CONFIG_FAILED
;
12894 return CMD_SUCCESS
;
12897 /* "large-community-list" keyword help string. */
12898 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
12899 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
12901 DEFUN (ip_lcommunity_list_standard
,
12902 ip_lcommunity_list_standard_cmd
,
12903 "ip large-community-list (1-99) <deny|permit>",
12905 LCOMMUNITY_LIST_STR
12906 "Large Community list number (standard)\n"
12907 "Specify large community to reject\n"
12908 "Specify large community to accept\n")
12910 return lcommunity_list_set_vty(vty
, argc
, argv
,
12911 LARGE_COMMUNITY_LIST_STANDARD
, 0);
12914 DEFUN (ip_lcommunity_list_standard1
,
12915 ip_lcommunity_list_standard1_cmd
,
12916 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
12918 LCOMMUNITY_LIST_STR
12919 "Large Community list number (standard)\n"
12920 "Specify large community to reject\n"
12921 "Specify large community to accept\n"
12922 LCOMMUNITY_VAL_STR
)
12924 return lcommunity_list_set_vty(vty
, argc
, argv
,
12925 LARGE_COMMUNITY_LIST_STANDARD
, 0);
12928 DEFUN (ip_lcommunity_list_expanded
,
12929 ip_lcommunity_list_expanded_cmd
,
12930 "ip large-community-list (100-500) <deny|permit> LINE...",
12932 LCOMMUNITY_LIST_STR
12933 "Large Community list number (expanded)\n"
12934 "Specify large community to reject\n"
12935 "Specify large community to accept\n"
12936 "An ordered list as a regular-expression\n")
12938 return lcommunity_list_set_vty(vty
, argc
, argv
,
12939 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
12942 DEFUN (ip_lcommunity_list_name_standard
,
12943 ip_lcommunity_list_name_standard_cmd
,
12944 "ip large-community-list standard WORD <deny|permit>",
12946 LCOMMUNITY_LIST_STR
12947 "Specify standard large-community-list\n"
12948 "Large Community list name\n"
12949 "Specify large community to reject\n"
12950 "Specify large community to accept\n")
12952 return lcommunity_list_set_vty(vty
, argc
, argv
,
12953 LARGE_COMMUNITY_LIST_STANDARD
, 1);
12956 DEFUN (ip_lcommunity_list_name_standard1
,
12957 ip_lcommunity_list_name_standard1_cmd
,
12958 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
12960 LCOMMUNITY_LIST_STR
12961 "Specify standard large-community-list\n"
12962 "Large Community list name\n"
12963 "Specify large community to reject\n"
12964 "Specify large community to accept\n"
12965 LCOMMUNITY_VAL_STR
)
12967 return lcommunity_list_set_vty(vty
, argc
, argv
,
12968 LARGE_COMMUNITY_LIST_STANDARD
, 1);
12971 DEFUN (ip_lcommunity_list_name_expanded
,
12972 ip_lcommunity_list_name_expanded_cmd
,
12973 "ip large-community-list expanded WORD <deny|permit> LINE...",
12975 LCOMMUNITY_LIST_STR
12976 "Specify expanded large-community-list\n"
12977 "Large Community list name\n"
12978 "Specify large community to reject\n"
12979 "Specify large community to accept\n"
12980 "An ordered list as a regular-expression\n")
12982 return lcommunity_list_set_vty(vty
, argc
, argv
,
12983 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
12986 DEFUN (no_ip_lcommunity_list_standard_all
,
12987 no_ip_lcommunity_list_standard_all_cmd
,
12988 "no ip large-community-list <(1-99)|(100-500)|WORD>",
12991 LCOMMUNITY_LIST_STR
12992 "Large Community list number (standard)\n"
12993 "Large Community list number (expanded)\n"
12994 "Large Community list name\n")
12996 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12997 LARGE_COMMUNITY_LIST_STANDARD
);
13000 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
13001 no_ip_lcommunity_list_name_expanded_all_cmd
,
13002 "no ip large-community-list expanded WORD",
13005 LCOMMUNITY_LIST_STR
13006 "Specify expanded large-community-list\n"
13007 "Large Community list name\n")
13009 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13010 LARGE_COMMUNITY_LIST_EXPANDED
);
13013 DEFUN (no_ip_lcommunity_list_standard
,
13014 no_ip_lcommunity_list_standard_cmd
,
13015 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
13018 LCOMMUNITY_LIST_STR
13019 "Large Community list number (standard)\n"
13020 "Specify large community to reject\n"
13021 "Specify large community to accept\n"
13022 LCOMMUNITY_VAL_STR
)
13024 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13025 LARGE_COMMUNITY_LIST_STANDARD
);
13028 DEFUN (no_ip_lcommunity_list_expanded
,
13029 no_ip_lcommunity_list_expanded_cmd
,
13030 "no ip large-community-list (100-500) <deny|permit> LINE...",
13033 LCOMMUNITY_LIST_STR
13034 "Large Community list number (expanded)\n"
13035 "Specify large community to reject\n"
13036 "Specify large community to accept\n"
13037 "An ordered list as a regular-expression\n")
13039 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13040 LARGE_COMMUNITY_LIST_EXPANDED
);
13043 DEFUN (no_ip_lcommunity_list_name_standard
,
13044 no_ip_lcommunity_list_name_standard_cmd
,
13045 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
13048 LCOMMUNITY_LIST_STR
13049 "Specify standard large-community-list\n"
13050 "Large Community list name\n"
13051 "Specify large community to reject\n"
13052 "Specify large community to accept\n"
13053 LCOMMUNITY_VAL_STR
)
13055 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13056 LARGE_COMMUNITY_LIST_STANDARD
);
13059 DEFUN (no_ip_lcommunity_list_name_expanded
,
13060 no_ip_lcommunity_list_name_expanded_cmd
,
13061 "no ip large-community-list expanded WORD <deny|permit> LINE...",
13064 LCOMMUNITY_LIST_STR
13065 "Specify expanded large-community-list\n"
13066 "Large community list name\n"
13067 "Specify large community to reject\n"
13068 "Specify large community to accept\n"
13069 "An ordered list as a regular-expression\n")
13071 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13072 LARGE_COMMUNITY_LIST_EXPANDED
);
13075 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
13077 struct community_entry
*entry
;
13079 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13080 if (entry
== list
->head
) {
13081 if (all_digit(list
->name
))
13082 vty_out(vty
, "Large community %s list %s\n",
13083 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13085 : "(expanded) access",
13089 "Named large community %s list %s\n",
13090 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13096 vty_out(vty
, " %s\n",
13097 community_direct_str(entry
->direct
));
13099 vty_out(vty
, " %s %s\n",
13100 community_direct_str(entry
->direct
),
13101 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13102 ? entry
->u
.ecom
->str
13107 DEFUN (show_ip_lcommunity_list
,
13108 show_ip_lcommunity_list_cmd
,
13109 "show ip large-community-list",
13112 "List large-community list\n")
13114 struct community_list
*list
;
13115 struct community_list_master
*cm
;
13117 cm
= community_list_master_lookup(bgp_clist
,
13118 LARGE_COMMUNITY_LIST_MASTER
);
13120 return CMD_SUCCESS
;
13122 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13123 lcommunity_list_show(vty
, list
);
13125 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13126 lcommunity_list_show(vty
, list
);
13128 return CMD_SUCCESS
;
13131 DEFUN (show_ip_lcommunity_list_arg
,
13132 show_ip_lcommunity_list_arg_cmd
,
13133 "show ip large-community-list <(1-500)|WORD>",
13136 "List large-community list\n"
13137 "large-community-list number\n"
13138 "large-community-list name\n")
13140 struct community_list
*list
;
13142 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
13143 LARGE_COMMUNITY_LIST_MASTER
);
13145 vty_out(vty
, "%% Can't find extcommunity-list\n");
13146 return CMD_WARNING
;
13149 lcommunity_list_show(vty
, list
);
13151 return CMD_SUCCESS
;
13154 /* "extcommunity-list" keyword help string. */
13155 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
13156 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
13158 DEFUN (ip_extcommunity_list_standard
,
13159 ip_extcommunity_list_standard_cmd
,
13160 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13162 EXTCOMMUNITY_LIST_STR
13163 "Extended Community list number (standard)\n"
13164 "Specify standard extcommunity-list\n"
13165 "Community list name\n"
13166 "Specify community to reject\n"
13167 "Specify community to accept\n"
13168 EXTCOMMUNITY_VAL_STR
)
13170 int style
= EXTCOMMUNITY_LIST_STANDARD
;
13172 char *cl_number_or_name
= NULL
;
13175 argv_find(argv
, argc
, "(1-99)", &idx
);
13176 argv_find(argv
, argc
, "WORD", &idx
);
13177 cl_number_or_name
= argv
[idx
]->arg
;
13178 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13180 argv_find(argv
, argc
, "AA:NN", &idx
);
13181 char *str
= argv_concat(argv
, argc
, idx
);
13183 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
13186 XFREE(MTYPE_TMP
, str
);
13189 community_list_perror(vty
, ret
);
13190 return CMD_WARNING_CONFIG_FAILED
;
13193 return CMD_SUCCESS
;
13196 DEFUN (ip_extcommunity_list_name_expanded
,
13197 ip_extcommunity_list_name_expanded_cmd
,
13198 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
13200 EXTCOMMUNITY_LIST_STR
13201 "Extended Community list number (expanded)\n"
13202 "Specify expanded extcommunity-list\n"
13203 "Extended Community list name\n"
13204 "Specify community to reject\n"
13205 "Specify community to accept\n"
13206 "An ordered list as a regular-expression\n")
13208 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
13210 char *cl_number_or_name
= NULL
;
13213 argv_find(argv
, argc
, "(100-500)", &idx
);
13214 argv_find(argv
, argc
, "WORD", &idx
);
13215 cl_number_or_name
= argv
[idx
]->arg
;
13216 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13218 argv_find(argv
, argc
, "LINE", &idx
);
13219 char *str
= argv_concat(argv
, argc
, idx
);
13221 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
13224 XFREE(MTYPE_TMP
, str
);
13227 community_list_perror(vty
, ret
);
13228 return CMD_WARNING_CONFIG_FAILED
;
13231 return CMD_SUCCESS
;
13234 DEFUN (no_ip_extcommunity_list_standard_all
,
13235 no_ip_extcommunity_list_standard_all_cmd
,
13236 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13239 EXTCOMMUNITY_LIST_STR
13240 "Extended Community list number (standard)\n"
13241 "Specify standard extcommunity-list\n"
13242 "Community list name\n"
13243 "Specify community to reject\n"
13244 "Specify community to accept\n"
13245 EXTCOMMUNITY_VAL_STR
)
13249 int style
= EXTCOMMUNITY_LIST_STANDARD
;
13251 char *cl_number_or_name
= NULL
;
13254 argv_find(argv
, argc
, "(1-99)", &idx
);
13255 argv_find(argv
, argc
, "WORD", &idx
);
13256 cl_number_or_name
= argv
[idx
]->arg
;
13257 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13259 argv_find(argv
, argc
, "AA:NN", &idx
);
13260 char *str
= argv_concat(argv
, argc
, idx
);
13262 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13263 direct
, style
, deleteall
);
13265 XFREE(MTYPE_TMP
, str
);
13268 community_list_perror(vty
, ret
);
13269 return CMD_WARNING_CONFIG_FAILED
;
13272 return CMD_SUCCESS
;
13275 DEFUN (no_ip_extcommunity_list_expanded_all
,
13276 no_ip_extcommunity_list_expanded_all_cmd
,
13277 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
13280 EXTCOMMUNITY_LIST_STR
13281 "Extended Community list number (expanded)\n"
13282 "Specify expanded extcommunity-list\n"
13283 "Extended Community list name\n"
13284 "Specify community to reject\n"
13285 "Specify community to accept\n"
13286 "An ordered list as a regular-expression\n")
13290 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
13292 char *cl_number_or_name
= NULL
;
13295 argv_find(argv
, argc
, "(100-500)", &idx
);
13296 argv_find(argv
, argc
, "WORD", &idx
);
13297 cl_number_or_name
= argv
[idx
]->arg
;
13298 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13300 argv_find(argv
, argc
, "LINE", &idx
);
13301 char *str
= argv_concat(argv
, argc
, idx
);
13303 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13304 direct
, style
, deleteall
);
13306 XFREE(MTYPE_TMP
, str
);
13309 community_list_perror(vty
, ret
);
13310 return CMD_WARNING_CONFIG_FAILED
;
13313 return CMD_SUCCESS
;
13316 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
13318 struct community_entry
*entry
;
13320 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13321 if (entry
== list
->head
) {
13322 if (all_digit(list
->name
))
13323 vty_out(vty
, "Extended community %s list %s\n",
13324 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13326 : "(expanded) access",
13330 "Named extended community %s list %s\n",
13331 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13337 vty_out(vty
, " %s\n",
13338 community_direct_str(entry
->direct
));
13340 vty_out(vty
, " %s %s\n",
13341 community_direct_str(entry
->direct
),
13342 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13343 ? entry
->u
.ecom
->str
13348 DEFUN (show_ip_extcommunity_list
,
13349 show_ip_extcommunity_list_cmd
,
13350 "show ip extcommunity-list",
13353 "List extended-community list\n")
13355 struct community_list
*list
;
13356 struct community_list_master
*cm
;
13358 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
13360 return CMD_SUCCESS
;
13362 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13363 extcommunity_list_show(vty
, list
);
13365 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13366 extcommunity_list_show(vty
, list
);
13368 return CMD_SUCCESS
;
13371 DEFUN (show_ip_extcommunity_list_arg
,
13372 show_ip_extcommunity_list_arg_cmd
,
13373 "show ip extcommunity-list <(1-500)|WORD>",
13376 "List extended-community list\n"
13377 "Extcommunity-list number\n"
13378 "Extcommunity-list name\n")
13380 int idx_comm_list
= 3;
13381 struct community_list
*list
;
13383 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13384 EXTCOMMUNITY_LIST_MASTER
);
13386 vty_out(vty
, "%% Can't find extcommunity-list\n");
13387 return CMD_WARNING
;
13390 extcommunity_list_show(vty
, list
);
13392 return CMD_SUCCESS
;
13395 /* Return configuration string of community-list entry. */
13396 static const char *community_list_config_str(struct community_entry
*entry
)
13403 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13404 str
= community_str(entry
->u
.com
, false);
13406 str
= entry
->config
;
13411 /* Display community-list and extcommunity-list configuration. */
13412 static int community_list_config_write(struct vty
*vty
)
13414 struct community_list
*list
;
13415 struct community_entry
*entry
;
13416 struct community_list_master
*cm
;
13419 /* Community-list. */
13420 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13422 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13423 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13424 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
13425 community_direct_str(entry
->direct
),
13426 community_list_config_str(entry
));
13429 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13430 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13431 vty_out(vty
, "ip community-list %s %s %s %s\n",
13432 entry
->style
== COMMUNITY_LIST_STANDARD
13435 list
->name
, community_direct_str(entry
->direct
),
13436 community_list_config_str(entry
));
13440 /* Extcommunity-list. */
13441 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
13443 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13444 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13445 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
13446 list
->name
, community_direct_str(entry
->direct
),
13447 community_list_config_str(entry
));
13450 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13451 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13452 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
13453 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13456 list
->name
, community_direct_str(entry
->direct
),
13457 community_list_config_str(entry
));
13462 /* lcommunity-list. */
13463 cm
= community_list_master_lookup(bgp_clist
,
13464 LARGE_COMMUNITY_LIST_MASTER
);
13466 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13467 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13468 vty_out(vty
, "ip large-community-list %s %s %s\n",
13469 list
->name
, community_direct_str(entry
->direct
),
13470 community_list_config_str(entry
));
13473 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13474 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13475 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
13476 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
13479 list
->name
, community_direct_str(entry
->direct
),
13480 community_list_config_str(entry
));
13487 static struct cmd_node community_list_node
= {
13488 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
13491 static void community_list_vty(void)
13493 install_node(&community_list_node
, community_list_config_write
);
13495 /* Community-list. */
13496 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
13497 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
13498 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
13499 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
13500 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
13501 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
13503 /* Extcommunity-list. */
13504 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
13505 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
13506 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
13507 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
13508 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
13509 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
13511 /* Large Community List */
13512 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
13513 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
13514 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
13515 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
13516 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
13517 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
13518 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
13519 install_element(CONFIG_NODE
,
13520 &no_ip_lcommunity_list_name_expanded_all_cmd
);
13521 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
13522 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
13523 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
13524 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
13525 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
13526 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);