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"
61 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
62 struct prefix
*range
, int exact
);
64 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
73 return BGP_IPV4M_NODE
;
75 case SAFI_LABELED_UNICAST
:
76 return BGP_IPV4L_NODE
;
79 return BGP_VPNV4_NODE
;
93 return BGP_IPV6M_NODE
;
95 case SAFI_LABELED_UNICAST
:
96 return BGP_IPV6L_NODE
;
99 return BGP_VPNV6_NODE
;
103 return BGP_IPV4_NODE
;
108 return BGP_EVPN_NODE
;
111 // We should never be here but to clarify the switch statement..
112 return BGP_IPV4_NODE
;
116 // Impossible to happen
117 return BGP_IPV4_NODE
;
120 /* Utility function to get address family from current node. */
121 afi_t
bgp_node_afi(struct vty
*vty
)
141 /* Utility function to get subsequent address family from current
143 safi_t
bgp_node_safi(struct vty
*vty
)
149 safi
= SAFI_MPLS_VPN
;
153 safi
= SAFI_MULTICAST
;
160 safi
= SAFI_LABELED_UNICAST
;
170 * Converts an AFI in string form to afi_t
172 * @param afi string, one of
175 * @return the corresponding afi_t
177 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
179 afi_t afi
= AFI_MAX
; /* unknown */
180 if (strmatch(afi_str
, "ipv4"))
182 else if (strmatch(afi_str
, "ipv6"))
187 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
191 if (argv_find(argv
, argc
, "ipv4", index
)) {
195 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
203 /* supports <unicast|multicast|vpn|labeled-unicast> */
204 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
206 safi_t safi
= SAFI_MAX
; /* unknown */
207 if (strmatch(safi_str
, "multicast"))
208 safi
= SAFI_MULTICAST
;
209 else if (strmatch(safi_str
, "unicast"))
211 else if (strmatch(safi_str
, "vpn"))
212 safi
= SAFI_MPLS_VPN
;
213 else if (strmatch(safi_str
, "labeled-unicast"))
214 safi
= SAFI_LABELED_UNICAST
;
218 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
222 if (argv_find(argv
, argc
, "unicast", index
)) {
225 *safi
= SAFI_UNICAST
;
226 } else if (argv_find(argv
, argc
, "multicast", index
)) {
229 *safi
= SAFI_MULTICAST
;
230 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
233 *safi
= SAFI_LABELED_UNICAST
;
234 } else if (argv_find(argv
, argc
, "vpn", index
)) {
237 *safi
= SAFI_MPLS_VPN
;
243 * bgp_vty_find_and_parse_afi_safi_bgp
245 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
246 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
247 * to appropriate values for the calling function. This is to allow the
248 * calling function to make decisions appropriate for the show command
249 * that is being parsed.
251 * The show commands are generally of the form:
252 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
253 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
255 * Since we use argv_find if the show command in particular doesn't have:
257 * [<view|vrf> VIEWVRFNAME]
258 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
259 * The command parsing should still be ok.
261 * vty -> The vty for the command so we can output some useful data in
262 * the event of a parse error in the vrf.
263 * argv -> The command tokens
264 * argc -> How many command tokens we have
265 * idx -> The current place in the command, generally should be 0 for this
267 * afi -> The parsed afi if it was included in the show command, returned here
268 * safi -> The parsed safi if it was included in the show command, returned here
269 * bgp -> Pointer to the bgp data structure we need to fill in.
271 * The function returns the correct location in the parse tree for the
274 * Returns 0 for failure to parse correctly, else the idx position of where
275 * it found the last token.
277 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
278 struct cmd_token
**argv
, int argc
,
279 int *idx
, afi_t
*afi
, safi_t
*safi
,
282 char *vrf_name
= NULL
;
288 if (argv_find(argv
, argc
, "ip", idx
))
291 if (argv_find(argv
, argc
, "view", idx
)
292 || argv_find(argv
, argc
, "vrf", idx
)) {
293 vrf_name
= argv
[*idx
+ 1]->arg
;
295 if (strmatch(vrf_name
, "all"))
298 *bgp
= bgp_lookup_by_name(vrf_name
);
301 "View/Vrf specified is unknown: %s\n",
308 *bgp
= bgp_get_default();
310 vty_out(vty
, "Unable to find default BGP instance\n");
316 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
317 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
323 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
325 struct interface
*ifp
= NULL
;
327 if (su
->sa
.sa_family
== AF_INET
)
328 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
329 else if (su
->sa
.sa_family
== AF_INET6
)
330 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
331 su
->sin6
.sin6_scope_id
,
340 /* Utility function for looking up peer from VTY. */
341 /* This is used only for configuration, so disallow if attempted on
342 * a dynamic neighbor.
344 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
346 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
355 ret
= str2sockunion(ip_str
, &su
);
357 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
359 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
362 "%% Malformed address or name: %s\n",
368 peer
= peer_lookup(bgp
, &su
);
371 "%% Specify remote-as or peer-group commands first\n");
374 if (peer_dynamic_neighbor(peer
)) {
376 "%% Operation not allowed on a dynamic neighbor\n");
383 /* Utility function for looking up peer or peer group. */
384 /* This is used only for configuration, so disallow if attempted on
385 * a dynamic neighbor.
387 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
389 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
392 struct peer
*peer
= NULL
;
393 struct peer_group
*group
= NULL
;
399 ret
= str2sockunion(peer_str
, &su
);
401 /* IP address, locate peer. */
402 peer
= peer_lookup(bgp
, &su
);
404 /* Not IP, could match either peer configured on interface or a
406 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
408 group
= peer_group_lookup(bgp
, peer_str
);
412 if (peer_dynamic_neighbor(peer
)) {
414 "%% Operation not allowed on a dynamic neighbor\n");
424 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
429 int bgp_vty_return(struct vty
*vty
, int ret
)
431 const char *str
= NULL
;
434 case BGP_ERR_INVALID_VALUE
:
435 str
= "Invalid value";
437 case BGP_ERR_INVALID_FLAG
:
438 str
= "Invalid flag";
440 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
441 str
= "Peer-group has been shutdown. Activate the peer-group first";
443 case BGP_ERR_PEER_FLAG_CONFLICT
:
444 str
= "Can't set override-capability and strict-capability-match at the same time";
446 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
447 str
= "Specify remote-as or peer-group remote AS first";
449 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
450 str
= "Cannot change the peer-group. Deconfigure first";
452 case BGP_ERR_PEER_GROUP_MISMATCH
:
453 str
= "Peer is not a member of this peer-group";
455 case BGP_ERR_PEER_FILTER_CONFLICT
:
456 str
= "Prefix/distribute list can not co-exist";
458 case BGP_ERR_NOT_INTERNAL_PEER
:
459 str
= "Invalid command. Not an internal neighbor";
461 case BGP_ERR_REMOVE_PRIVATE_AS
:
462 str
= "remove-private-AS cannot be configured for IBGP peers";
464 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
465 str
= "Local-AS allowed only for EBGP peers";
467 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
468 str
= "Cannot have local-as same as BGP AS number";
470 case BGP_ERR_TCPSIG_FAILED
:
471 str
= "Error while applying TCP-Sig to session(s)";
473 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
474 str
= "ebgp-multihop and ttl-security cannot be configured together";
476 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
477 str
= "ttl-security only allowed for EBGP peers";
479 case BGP_ERR_AS_OVERRIDE
:
480 str
= "as-override cannot be configured for IBGP peers";
482 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
483 str
= "Invalid limit for number of dynamic neighbors";
485 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
486 str
= "Dynamic neighbor listen range already exists";
488 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
489 str
= "Operation not allowed on a dynamic neighbor";
491 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
492 str
= "Operation not allowed on a directly connected neighbor";
494 case BGP_ERR_PEER_SAFI_CONFLICT
:
495 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
499 vty_out(vty
, "%% %s\n", str
);
500 return CMD_WARNING_CONFIG_FAILED
;
505 /* BGP clear sort. */
514 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
515 safi_t safi
, int error
)
518 case BGP_ERR_AF_UNCONFIGURED
:
520 "%%BGP: Enable %s address family for the neighbor %s\n",
521 afi_safi_print(afi
, safi
), peer
->host
);
523 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
525 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
533 /* `clear ip bgp' functions. */
534 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
535 enum clear_sort sort
, enum bgp_clear_type stype
,
540 struct listnode
*node
, *nnode
;
542 /* Clear all neighbors. */
544 * Pass along pointer to next node to peer_clear() when walking all
546 * on the BGP instance as that may get freed if it is a doppelganger
548 if (sort
== clear_all
) {
549 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
550 if (stype
== BGP_CLEAR_SOFT_NONE
)
551 ret
= peer_clear(peer
, &nnode
);
552 else if (peer
->afc
[afi
][safi
])
553 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
558 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
561 /* This is to apply read-only mode on this clear. */
562 if (stype
== BGP_CLEAR_SOFT_NONE
)
563 bgp
->update_delay_over
= 0;
568 /* Clear specified neighbors. */
569 if (sort
== clear_peer
) {
573 /* Make sockunion for lookup. */
574 ret
= str2sockunion(arg
, &su
);
576 peer
= peer_lookup_by_conf_if(bgp
, arg
);
578 peer
= peer_lookup_by_hostname(bgp
, arg
);
581 "Malformed address or name: %s\n",
587 peer
= peer_lookup(bgp
, &su
);
590 "%%BGP: Unknown neighbor - \"%s\"\n",
596 if (stype
== BGP_CLEAR_SOFT_NONE
)
597 ret
= peer_clear(peer
, NULL
);
599 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
602 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
607 /* Clear all peer-group members. */
608 if (sort
== clear_group
) {
609 struct peer_group
*group
;
611 group
= peer_group_lookup(bgp
, arg
);
613 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
617 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
618 if (stype
== BGP_CLEAR_SOFT_NONE
) {
619 peer_clear(peer
, NULL
);
623 if (!peer
->afc
[afi
][safi
])
626 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
629 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
634 if (sort
== clear_external
) {
635 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
636 if (peer
->sort
== BGP_PEER_IBGP
)
639 if (stype
== BGP_CLEAR_SOFT_NONE
)
640 ret
= peer_clear(peer
, &nnode
);
642 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
645 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
650 if (sort
== clear_as
) {
654 as
= strtoul(arg
, NULL
, 10);
656 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
661 if (stype
== BGP_CLEAR_SOFT_NONE
)
662 ret
= peer_clear(peer
, &nnode
);
664 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
667 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
671 "%%BGP: No peer is configured with AS %s\n",
679 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
680 safi_t safi
, enum clear_sort sort
,
681 enum bgp_clear_type stype
, const char *arg
)
685 /* BGP structure lookup. */
687 bgp
= bgp_lookup_by_name(name
);
689 vty_out(vty
, "Can't find BGP instance %s\n", name
);
693 bgp
= bgp_get_default();
695 vty_out(vty
, "No BGP process is configured\n");
700 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
703 /* clear soft inbound */
704 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
706 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
707 BGP_CLEAR_SOFT_IN
, NULL
);
708 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
709 BGP_CLEAR_SOFT_IN
, NULL
);
712 /* clear soft outbound */
713 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
715 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
716 BGP_CLEAR_SOFT_OUT
, NULL
);
717 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
718 BGP_CLEAR_SOFT_OUT
, NULL
);
722 #ifndef VTYSH_EXTRACT_PL
723 #include "bgp_vty_clippy.c"
726 /* BGP global configuration. */
728 DEFUN (bgp_multiple_instance_func
,
729 bgp_multiple_instance_cmd
,
730 "bgp multiple-instance",
732 "Enable bgp multiple instance\n")
734 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
738 DEFUN (no_bgp_multiple_instance
,
739 no_bgp_multiple_instance_cmd
,
740 "no bgp multiple-instance",
743 "BGP multiple instance\n")
747 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
749 vty_out(vty
, "%% There are more than two BGP instances\n");
750 return CMD_WARNING_CONFIG_FAILED
;
755 DEFUN (bgp_config_type
,
757 "bgp config-type <cisco|zebra>",
759 "Configuration type\n"
764 if (argv_find(argv
, argc
, "cisco", &idx
))
765 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
767 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
772 DEFUN (no_bgp_config_type
,
773 no_bgp_config_type_cmd
,
774 "no bgp config-type [<cisco|zebra>]",
777 "Display configuration type\n"
781 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
786 DEFUN (no_synchronization
,
787 no_synchronization_cmd
,
788 "no synchronization",
790 "Perform IGP synchronization\n")
795 DEFUN (no_auto_summary
,
799 "Enable automatic network number summarization\n")
804 /* "router bgp" commands. */
805 DEFUN_NOSH (router_bgp
,
807 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
811 BGP_INSTANCE_HELP_STR
)
814 int idx_view_vrf
= 3;
819 const char *name
= NULL
;
820 enum bgp_instance_type inst_type
;
822 // "router bgp" without an ASN
824 // Pending: Make VRF option available for ASN less config
825 bgp
= bgp_get_default();
828 vty_out(vty
, "%% No BGP process is configured\n");
829 return CMD_WARNING_CONFIG_FAILED
;
832 if (listcount(bm
->bgp
) > 1) {
834 "%% Multiple BGP processes are configured\n");
835 return CMD_WARNING_CONFIG_FAILED
;
841 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
843 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
845 name
= argv
[idx_vrf
]->arg
;
847 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf"))
848 inst_type
= BGP_INSTANCE_TYPE_VRF
;
849 else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
850 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
853 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
855 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
857 "Please specify 'bgp multiple-instance' first\n");
858 return CMD_WARNING_CONFIG_FAILED
;
859 case BGP_ERR_AS_MISMATCH
:
860 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
861 return CMD_WARNING_CONFIG_FAILED
;
862 case BGP_ERR_INSTANCE_MISMATCH
:
864 "BGP instance name and AS number mismatch\n");
866 "BGP instance is already running; AS is %u\n",
868 return CMD_WARNING_CONFIG_FAILED
;
871 /* Pending: handle when user tries to change a view to vrf n vv.
875 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
880 /* "no router bgp" commands. */
881 DEFUN (no_router_bgp
,
883 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
888 BGP_INSTANCE_HELP_STR
)
894 const char *name
= NULL
;
896 // "no router bgp" without an ASN
898 // Pending: Make VRF option available for ASN less config
899 bgp
= bgp_get_default();
902 vty_out(vty
, "%% No BGP process is configured\n");
903 return CMD_WARNING_CONFIG_FAILED
;
906 if (listcount(bm
->bgp
) > 1) {
908 "%% Multiple BGP processes are configured\n");
909 return CMD_WARNING_CONFIG_FAILED
;
912 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
915 name
= argv
[idx_vrf
]->arg
;
917 /* Lookup bgp structure. */
918 bgp
= bgp_lookup(as
, name
);
920 vty_out(vty
, "%% Can't find BGP instance\n");
921 return CMD_WARNING_CONFIG_FAILED
;
933 DEFPY (bgp_router_id
,
935 "bgp router-id A.B.C.D",
937 "Override configured router identifier\n"
938 "Manually configured router identifier\n")
940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
941 bgp_router_id_static_set(bgp
, router_id
);
945 DEFPY (no_bgp_router_id
,
946 no_bgp_router_id_cmd
,
947 "no bgp router-id [A.B.C.D]",
950 "Override configured router identifier\n"
951 "Manually configured router identifier\n")
953 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
956 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
957 vty_out(vty
, "%% BGP router-id doesn't match\n");
958 return CMD_WARNING_CONFIG_FAILED
;
962 router_id
.s_addr
= 0;
963 bgp_router_id_static_set(bgp
, router_id
);
969 /* BGP Cluster ID. */
970 DEFUN (bgp_cluster_id
,
972 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
974 "Configure Route-Reflector Cluster-id\n"
975 "Route-Reflector Cluster-id in IP address format\n"
976 "Route-Reflector Cluster-id as 32 bit quantity\n")
978 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
981 struct in_addr cluster
;
983 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
985 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
986 return CMD_WARNING_CONFIG_FAILED
;
989 bgp_cluster_id_set(bgp
, &cluster
);
990 bgp_clear_star_soft_out(vty
, bgp
->name
);
995 DEFUN (no_bgp_cluster_id
,
996 no_bgp_cluster_id_cmd
,
997 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1000 "Configure Route-Reflector Cluster-id\n"
1001 "Route-Reflector Cluster-id in IP address format\n"
1002 "Route-Reflector Cluster-id as 32 bit quantity\n")
1004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1005 bgp_cluster_id_unset(bgp
);
1006 bgp_clear_star_soft_out(vty
, bgp
->name
);
1011 DEFUN (bgp_confederation_identifier
,
1012 bgp_confederation_identifier_cmd
,
1013 "bgp confederation identifier (1-4294967295)",
1014 "BGP specific commands\n"
1015 "AS confederation parameters\n"
1017 "Set routing domain confederation AS\n")
1019 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1023 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1025 bgp_confederation_id_set(bgp
, as
);
1030 DEFUN (no_bgp_confederation_identifier
,
1031 no_bgp_confederation_identifier_cmd
,
1032 "no bgp confederation identifier [(1-4294967295)]",
1034 "BGP specific commands\n"
1035 "AS confederation parameters\n"
1037 "Set routing domain confederation AS\n")
1039 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1040 bgp_confederation_id_unset(bgp
);
1045 DEFUN (bgp_confederation_peers
,
1046 bgp_confederation_peers_cmd
,
1047 "bgp confederation peers (1-4294967295)...",
1048 "BGP specific commands\n"
1049 "AS confederation parameters\n"
1050 "Peer ASs in BGP confederation\n"
1053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1058 for (i
= idx_asn
; i
< argc
; i
++) {
1059 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1061 if (bgp
->as
== as
) {
1063 "%% Local member-AS not allowed in confed peer list\n");
1067 bgp_confederation_peers_add(bgp
, as
);
1072 DEFUN (no_bgp_confederation_peers
,
1073 no_bgp_confederation_peers_cmd
,
1074 "no bgp confederation peers (1-4294967295)...",
1076 "BGP specific commands\n"
1077 "AS confederation parameters\n"
1078 "Peer ASs in BGP confederation\n"
1081 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1086 for (i
= idx_asn
; i
< argc
; i
++) {
1087 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1089 bgp_confederation_peers_remove(bgp
, as
);
1095 * Central routine for maximum-paths configuration.
1096 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1097 * @set: 1 for setting values, 0 for removing the max-paths config.
1099 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1100 const char *mpaths
, u_int16_t options
,
1103 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1104 u_int16_t maxpaths
= 0;
1109 afi
= bgp_node_afi(vty
);
1110 safi
= bgp_node_safi(vty
);
1113 maxpaths
= strtol(mpaths
, NULL
, 10);
1114 if (maxpaths
> multipath_num
) {
1116 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1117 maxpaths
, multipath_num
);
1118 return CMD_WARNING_CONFIG_FAILED
;
1120 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1123 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1127 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1128 (set
== 1) ? "" : "un",
1129 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1130 maxpaths
, afi
, safi
);
1131 return CMD_WARNING_CONFIG_FAILED
;
1134 bgp_recalculate_all_bestpaths(bgp
);
1139 DEFUN (bgp_maxmed_admin
,
1140 bgp_maxmed_admin_cmd
,
1141 "bgp max-med administrative ",
1143 "Advertise routes with max-med\n"
1144 "Administratively applied, for an indefinite period\n")
1146 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1148 bgp
->v_maxmed_admin
= 1;
1149 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1151 bgp_maxmed_update(bgp
);
1156 DEFUN (bgp_maxmed_admin_medv
,
1157 bgp_maxmed_admin_medv_cmd
,
1158 "bgp max-med administrative (0-4294967295)",
1160 "Advertise routes with max-med\n"
1161 "Administratively applied, for an indefinite period\n"
1162 "Max MED value to be used\n")
1164 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1167 bgp
->v_maxmed_admin
= 1;
1168 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1170 bgp_maxmed_update(bgp
);
1175 DEFUN (no_bgp_maxmed_admin
,
1176 no_bgp_maxmed_admin_cmd
,
1177 "no bgp max-med administrative [(0-4294967295)]",
1180 "Advertise routes with max-med\n"
1181 "Administratively applied, for an indefinite period\n"
1182 "Max MED value to be used\n")
1184 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1185 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1186 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1187 bgp_maxmed_update(bgp
);
1192 DEFUN (bgp_maxmed_onstartup
,
1193 bgp_maxmed_onstartup_cmd
,
1194 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1196 "Advertise routes with max-med\n"
1197 "Effective on a startup\n"
1198 "Time (seconds) period for max-med\n"
1199 "Max MED value to be used\n")
1201 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1204 argv_find(argv
, argc
, "(5-86400)", &idx
);
1205 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1206 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1207 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1209 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1211 bgp_maxmed_update(bgp
);
1216 DEFUN (no_bgp_maxmed_onstartup
,
1217 no_bgp_maxmed_onstartup_cmd
,
1218 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1221 "Advertise routes with max-med\n"
1222 "Effective on a startup\n"
1223 "Time (seconds) period for max-med\n"
1224 "Max MED value to be used\n")
1226 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1228 /* Cancel max-med onstartup if its on */
1229 if (bgp
->t_maxmed_onstartup
) {
1230 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1231 bgp
->maxmed_onstartup_over
= 1;
1234 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1235 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1237 bgp_maxmed_update(bgp
);
1242 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1245 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1246 u_int16_t update_delay
;
1247 u_int16_t establish_wait
;
1249 update_delay
= strtoul(delay
, NULL
, 10);
1251 if (!wait
) /* update-delay <delay> */
1253 bgp
->v_update_delay
= update_delay
;
1254 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1258 /* update-delay <delay> <establish-wait> */
1259 establish_wait
= atoi(wait
);
1260 if (update_delay
< establish_wait
) {
1262 "%%Failed: update-delay less than the establish-wait!\n");
1263 return CMD_WARNING_CONFIG_FAILED
;
1266 bgp
->v_update_delay
= update_delay
;
1267 bgp
->v_establish_wait
= establish_wait
;
1272 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1274 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1276 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1277 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1282 int bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1284 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1285 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1286 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1287 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1295 /* Update-delay configuration */
1296 DEFUN (bgp_update_delay
,
1297 bgp_update_delay_cmd
,
1298 "update-delay (0-3600)",
1299 "Force initial delay for best-path and updates\n"
1303 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1306 DEFUN (bgp_update_delay_establish_wait
,
1307 bgp_update_delay_establish_wait_cmd
,
1308 "update-delay (0-3600) (1-3600)",
1309 "Force initial delay for best-path and updates\n"
1314 int idx_number_2
= 2;
1315 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1316 argv
[idx_number_2
]->arg
);
1319 /* Update-delay deconfiguration */
1320 DEFUN (no_bgp_update_delay
,
1321 no_bgp_update_delay_cmd
,
1322 "no update-delay [(0-3600) [(1-3600)]]",
1324 "Force initial delay for best-path and updates\n"
1328 return bgp_update_delay_deconfig_vty(vty
);
1332 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1335 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1338 bgp
->wpkt_quanta
= strtoul(num
, NULL
, 10);
1340 bgp
->wpkt_quanta
= BGP_WRITE_PACKET_MAX
;
1345 int bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1347 if (bgp
->wpkt_quanta
!= BGP_WRITE_PACKET_MAX
)
1348 vty_out(vty
, " write-quanta %d\n", bgp
->wpkt_quanta
);
1354 /* Update-delay configuration */
1355 DEFUN (bgp_wpkt_quanta
,
1356 bgp_wpkt_quanta_cmd
,
1357 "write-quanta (1-10000)",
1358 "How many packets to write to peer socket per run\n"
1359 "Number of packets\n")
1362 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1365 /* Update-delay deconfiguration */
1366 DEFUN (no_bgp_wpkt_quanta
,
1367 no_bgp_wpkt_quanta_cmd
,
1368 "no write-quanta (1-10000)",
1370 "How many packets to write to peer socket per run\n"
1371 "Number of packets\n")
1374 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1377 int bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1379 if (bgp
->coalesce_time
!= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
)
1380 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1386 DEFUN (bgp_coalesce_time
,
1387 bgp_coalesce_time_cmd
,
1388 "coalesce-time (0-4294967295)",
1389 "Subgroup coalesce timer\n"
1390 "Subgroup coalesce timer value (in ms)\n")
1392 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1395 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1396 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1400 DEFUN (no_bgp_coalesce_time
,
1401 no_bgp_coalesce_time_cmd
,
1402 "no coalesce-time (0-4294967295)",
1404 "Subgroup coalesce timer\n"
1405 "Subgroup coalesce timer value (in ms)\n")
1407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1409 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1413 /* Maximum-paths configuration */
1414 DEFUN (bgp_maxpaths
,
1416 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1417 "Forward packets over multiple paths\n"
1418 "Number of paths\n")
1421 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1422 argv
[idx_number
]->arg
, 0, 1);
1425 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1426 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1427 "Forward packets over multiple paths\n"
1428 "Number of paths\n")
1430 DEFUN (bgp_maxpaths_ibgp
,
1431 bgp_maxpaths_ibgp_cmd
,
1432 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1433 "Forward packets over multiple paths\n"
1435 "Number of paths\n")
1438 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1439 argv
[idx_number
]->arg
, 0, 1);
1442 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1443 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1444 "Forward packets over multiple paths\n"
1446 "Number of paths\n")
1448 DEFUN (bgp_maxpaths_ibgp_cluster
,
1449 bgp_maxpaths_ibgp_cluster_cmd
,
1450 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1451 "Forward packets over multiple paths\n"
1454 "Match the cluster length\n")
1457 return bgp_maxpaths_config_vty(
1458 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1459 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1462 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1463 "maximum-paths ibgp " CMD_RANGE_STR(
1464 1, MULTIPATH_NUM
) " equal-cluster-length",
1465 "Forward packets over multiple paths\n"
1468 "Match the cluster length\n")
1470 DEFUN (no_bgp_maxpaths
,
1471 no_bgp_maxpaths_cmd
,
1472 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1474 "Forward packets over multiple paths\n"
1475 "Number of paths\n")
1477 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1480 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1481 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1482 "Forward packets over multiple paths\n"
1483 "Number of paths\n")
1485 DEFUN (no_bgp_maxpaths_ibgp
,
1486 no_bgp_maxpaths_ibgp_cmd
,
1487 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1489 "Forward packets over multiple paths\n"
1492 "Match the cluster length\n")
1494 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1497 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1498 "no maximum-paths ibgp [" CMD_RANGE_STR(
1499 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1501 "Forward packets over multiple paths\n"
1504 "Match the cluster length\n")
1506 int bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1507 safi_t safi
, int *write
)
1509 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1510 bgp_config_write_family_header(vty
, afi
, safi
, write
);
1511 vty_out(vty
, " maximum-paths %d\n",
1512 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1515 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1516 bgp_config_write_family_header(vty
, afi
, safi
, write
);
1517 vty_out(vty
, " maximum-paths ibgp %d",
1518 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1519 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1520 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1521 vty_out(vty
, " equal-cluster-length");
1532 "timers bgp (0-65535) (0-65535)",
1533 "Adjust routing timers\n"
1535 "Keepalive interval\n"
1538 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1540 int idx_number_2
= 3;
1541 unsigned long keepalive
= 0;
1542 unsigned long holdtime
= 0;
1544 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1545 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1547 /* Holdtime value check. */
1548 if (holdtime
< 3 && holdtime
!= 0) {
1550 "%% hold time value must be either 0 or greater than 3\n");
1551 return CMD_WARNING_CONFIG_FAILED
;
1554 bgp_timers_set(bgp
, keepalive
, holdtime
);
1559 DEFUN (no_bgp_timers
,
1561 "no timers bgp [(0-65535) (0-65535)]",
1563 "Adjust routing timers\n"
1565 "Keepalive interval\n"
1568 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1569 bgp_timers_unset(bgp
);
1575 DEFUN (bgp_client_to_client_reflection
,
1576 bgp_client_to_client_reflection_cmd
,
1577 "bgp client-to-client reflection",
1578 "BGP specific commands\n"
1579 "Configure client to client route reflection\n"
1580 "reflection of routes allowed\n")
1582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1583 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1584 bgp_clear_star_soft_out(vty
, bgp
->name
);
1589 DEFUN (no_bgp_client_to_client_reflection
,
1590 no_bgp_client_to_client_reflection_cmd
,
1591 "no bgp client-to-client reflection",
1593 "BGP specific commands\n"
1594 "Configure client to client route reflection\n"
1595 "reflection of routes allowed\n")
1597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1598 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1599 bgp_clear_star_soft_out(vty
, bgp
->name
);
1604 /* "bgp always-compare-med" configuration. */
1605 DEFUN (bgp_always_compare_med
,
1606 bgp_always_compare_med_cmd
,
1607 "bgp always-compare-med",
1608 "BGP specific commands\n"
1609 "Allow comparing MED from different neighbors\n")
1611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1612 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1613 bgp_recalculate_all_bestpaths(bgp
);
1618 DEFUN (no_bgp_always_compare_med
,
1619 no_bgp_always_compare_med_cmd
,
1620 "no bgp always-compare-med",
1622 "BGP specific commands\n"
1623 "Allow comparing MED from different neighbors\n")
1625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1626 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1627 bgp_recalculate_all_bestpaths(bgp
);
1632 /* "bgp deterministic-med" configuration. */
1633 DEFUN (bgp_deterministic_med
,
1634 bgp_deterministic_med_cmd
,
1635 "bgp deterministic-med",
1636 "BGP specific commands\n"
1637 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1639 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1641 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1642 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1643 bgp_recalculate_all_bestpaths(bgp
);
1649 DEFUN (no_bgp_deterministic_med
,
1650 no_bgp_deterministic_med_cmd
,
1651 "no bgp deterministic-med",
1653 "BGP specific commands\n"
1654 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1656 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1657 int bestpath_per_as_used
;
1661 struct listnode
*node
, *nnode
;
1663 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1664 bestpath_per_as_used
= 0;
1666 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1667 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1668 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
;
1671 peer
->af_flags
[afi
][safi
],
1672 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1673 bestpath_per_as_used
= 1;
1677 if (bestpath_per_as_used
)
1681 if (bestpath_per_as_used
) {
1683 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1684 return CMD_WARNING_CONFIG_FAILED
;
1686 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1687 bgp_recalculate_all_bestpaths(bgp
);
1694 /* "bgp graceful-restart" configuration. */
1695 DEFUN (bgp_graceful_restart
,
1696 bgp_graceful_restart_cmd
,
1697 "bgp graceful-restart",
1698 "BGP specific commands\n"
1699 "Graceful restart capability parameters\n")
1701 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1702 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1706 DEFUN (no_bgp_graceful_restart
,
1707 no_bgp_graceful_restart_cmd
,
1708 "no bgp graceful-restart",
1710 "BGP specific commands\n"
1711 "Graceful restart capability parameters\n")
1713 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1714 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1718 DEFUN (bgp_graceful_restart_stalepath_time
,
1719 bgp_graceful_restart_stalepath_time_cmd
,
1720 "bgp graceful-restart stalepath-time (1-3600)",
1721 "BGP specific commands\n"
1722 "Graceful restart capability parameters\n"
1723 "Set the max time to hold onto restarting peer's stale paths\n"
1724 "Delay value (seconds)\n")
1726 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1728 u_int32_t stalepath
;
1730 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1731 bgp
->stalepath_time
= stalepath
;
1735 DEFUN (bgp_graceful_restart_restart_time
,
1736 bgp_graceful_restart_restart_time_cmd
,
1737 "bgp graceful-restart restart-time (1-3600)",
1738 "BGP specific commands\n"
1739 "Graceful restart capability parameters\n"
1740 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1741 "Delay value (seconds)\n")
1743 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1747 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1748 bgp
->restart_time
= restart
;
1752 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1753 no_bgp_graceful_restart_stalepath_time_cmd
,
1754 "no bgp graceful-restart stalepath-time [(1-3600)]",
1756 "BGP specific commands\n"
1757 "Graceful restart capability parameters\n"
1758 "Set the max time to hold onto restarting peer's stale paths\n"
1759 "Delay value (seconds)\n")
1761 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1763 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1767 DEFUN (no_bgp_graceful_restart_restart_time
,
1768 no_bgp_graceful_restart_restart_time_cmd
,
1769 "no bgp graceful-restart restart-time [(1-3600)]",
1771 "BGP specific commands\n"
1772 "Graceful restart capability parameters\n"
1773 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1774 "Delay value (seconds)\n")
1776 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1778 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1782 DEFUN (bgp_graceful_restart_preserve_fw
,
1783 bgp_graceful_restart_preserve_fw_cmd
,
1784 "bgp graceful-restart preserve-fw-state",
1785 "BGP specific commands\n"
1786 "Graceful restart capability parameters\n"
1787 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1789 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1790 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1794 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1795 no_bgp_graceful_restart_preserve_fw_cmd
,
1796 "no bgp graceful-restart preserve-fw-state",
1798 "BGP specific commands\n"
1799 "Graceful restart capability parameters\n"
1800 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1803 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1807 /* "bgp fast-external-failover" configuration. */
1808 DEFUN (bgp_fast_external_failover
,
1809 bgp_fast_external_failover_cmd
,
1810 "bgp fast-external-failover",
1812 "Immediately reset session if a link to a directly connected external peer goes down\n")
1814 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1815 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1819 DEFUN (no_bgp_fast_external_failover
,
1820 no_bgp_fast_external_failover_cmd
,
1821 "no bgp fast-external-failover",
1824 "Immediately reset session if a link to a directly connected external peer goes down\n")
1826 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1827 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1831 /* "bgp enforce-first-as" configuration. */
1832 DEFUN (bgp_enforce_first_as
,
1833 bgp_enforce_first_as_cmd
,
1834 "bgp enforce-first-as",
1836 "Enforce the first AS for EBGP routes\n")
1838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1839 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1840 bgp_clear_star_soft_in(vty
, bgp
->name
);
1845 DEFUN (no_bgp_enforce_first_as
,
1846 no_bgp_enforce_first_as_cmd
,
1847 "no bgp enforce-first-as",
1850 "Enforce the first AS for EBGP routes\n")
1852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1853 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1854 bgp_clear_star_soft_in(vty
, bgp
->name
);
1859 /* "bgp bestpath compare-routerid" configuration. */
1860 DEFUN (bgp_bestpath_compare_router_id
,
1861 bgp_bestpath_compare_router_id_cmd
,
1862 "bgp bestpath compare-routerid",
1863 "BGP specific commands\n"
1864 "Change the default bestpath selection\n"
1865 "Compare router-id for identical EBGP paths\n")
1867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1868 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
1869 bgp_recalculate_all_bestpaths(bgp
);
1874 DEFUN (no_bgp_bestpath_compare_router_id
,
1875 no_bgp_bestpath_compare_router_id_cmd
,
1876 "no bgp bestpath compare-routerid",
1878 "BGP specific commands\n"
1879 "Change the default bestpath selection\n"
1880 "Compare router-id for identical EBGP paths\n")
1882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1883 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
1884 bgp_recalculate_all_bestpaths(bgp
);
1889 /* "bgp bestpath as-path ignore" configuration. */
1890 DEFUN (bgp_bestpath_aspath_ignore
,
1891 bgp_bestpath_aspath_ignore_cmd
,
1892 "bgp bestpath as-path ignore",
1893 "BGP specific commands\n"
1894 "Change the default bestpath selection\n"
1895 "AS-path attribute\n"
1896 "Ignore as-path length in selecting a route\n")
1898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1899 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
1900 bgp_recalculate_all_bestpaths(bgp
);
1905 DEFUN (no_bgp_bestpath_aspath_ignore
,
1906 no_bgp_bestpath_aspath_ignore_cmd
,
1907 "no bgp bestpath as-path ignore",
1909 "BGP specific commands\n"
1910 "Change the default bestpath selection\n"
1911 "AS-path attribute\n"
1912 "Ignore as-path length in selecting a route\n")
1914 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1915 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
1916 bgp_recalculate_all_bestpaths(bgp
);
1921 /* "bgp bestpath as-path confed" configuration. */
1922 DEFUN (bgp_bestpath_aspath_confed
,
1923 bgp_bestpath_aspath_confed_cmd
,
1924 "bgp bestpath as-path confed",
1925 "BGP specific commands\n"
1926 "Change the default bestpath selection\n"
1927 "AS-path attribute\n"
1928 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1930 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1931 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
1932 bgp_recalculate_all_bestpaths(bgp
);
1937 DEFUN (no_bgp_bestpath_aspath_confed
,
1938 no_bgp_bestpath_aspath_confed_cmd
,
1939 "no bgp bestpath as-path confed",
1941 "BGP specific commands\n"
1942 "Change the default bestpath selection\n"
1943 "AS-path attribute\n"
1944 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1947 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
1948 bgp_recalculate_all_bestpaths(bgp
);
1953 /* "bgp bestpath as-path multipath-relax" configuration. */
1954 DEFUN (bgp_bestpath_aspath_multipath_relax
,
1955 bgp_bestpath_aspath_multipath_relax_cmd
,
1956 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
1957 "BGP specific commands\n"
1958 "Change the default bestpath selection\n"
1959 "AS-path attribute\n"
1960 "Allow load sharing across routes that have different AS paths (but same length)\n"
1961 "Generate an AS_SET\n"
1962 "Do not generate an AS_SET\n")
1964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1966 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
1968 /* no-as-set is now the default behavior so we can silently
1970 if (argv_find(argv
, argc
, "as-set", &idx
))
1971 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
1973 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
1975 bgp_recalculate_all_bestpaths(bgp
);
1980 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
1981 no_bgp_bestpath_aspath_multipath_relax_cmd
,
1982 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
1984 "BGP specific commands\n"
1985 "Change the default bestpath selection\n"
1986 "AS-path attribute\n"
1987 "Allow load sharing across routes that have different AS paths (but same length)\n"
1988 "Generate an AS_SET\n"
1989 "Do not generate an AS_SET\n")
1991 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1992 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
1993 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
1994 bgp_recalculate_all_bestpaths(bgp
);
1999 /* "bgp log-neighbor-changes" configuration. */
2000 DEFUN (bgp_log_neighbor_changes
,
2001 bgp_log_neighbor_changes_cmd
,
2002 "bgp log-neighbor-changes",
2003 "BGP specific commands\n"
2004 "Log neighbor up/down and reset reason\n")
2006 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2007 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2011 DEFUN (no_bgp_log_neighbor_changes
,
2012 no_bgp_log_neighbor_changes_cmd
,
2013 "no bgp log-neighbor-changes",
2015 "BGP specific commands\n"
2016 "Log neighbor up/down and reset reason\n")
2018 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2019 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2023 /* "bgp bestpath med" configuration. */
2024 DEFUN (bgp_bestpath_med
,
2025 bgp_bestpath_med_cmd
,
2026 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2027 "BGP specific commands\n"
2028 "Change the default bestpath selection\n"
2030 "Compare MED among confederation paths\n"
2031 "Treat missing MED as the least preferred one\n"
2032 "Treat missing MED as the least preferred one\n"
2033 "Compare MED among confederation paths\n")
2035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2038 if (argv_find(argv
, argc
, "confed", &idx
))
2039 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2041 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2042 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2044 bgp_recalculate_all_bestpaths(bgp
);
2049 DEFUN (no_bgp_bestpath_med
,
2050 no_bgp_bestpath_med_cmd
,
2051 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2053 "BGP specific commands\n"
2054 "Change the default bestpath selection\n"
2056 "Compare MED among confederation paths\n"
2057 "Treat missing MED as the least preferred one\n"
2058 "Treat missing MED as the least preferred one\n"
2059 "Compare MED among confederation paths\n")
2061 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2064 if (argv_find(argv
, argc
, "confed", &idx
))
2065 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2067 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2068 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2070 bgp_recalculate_all_bestpaths(bgp
);
2075 /* "no bgp default ipv4-unicast". */
2076 DEFUN (no_bgp_default_ipv4_unicast
,
2077 no_bgp_default_ipv4_unicast_cmd
,
2078 "no bgp default ipv4-unicast",
2080 "BGP specific commands\n"
2081 "Configure BGP defaults\n"
2082 "Activate ipv4-unicast for a peer by default\n")
2084 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2085 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2089 DEFUN (bgp_default_ipv4_unicast
,
2090 bgp_default_ipv4_unicast_cmd
,
2091 "bgp default ipv4-unicast",
2092 "BGP specific commands\n"
2093 "Configure BGP defaults\n"
2094 "Activate ipv4-unicast for a peer by default\n")
2096 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2097 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2101 /* Display hostname in certain command outputs */
2102 DEFUN (bgp_default_show_hostname
,
2103 bgp_default_show_hostname_cmd
,
2104 "bgp default show-hostname",
2105 "BGP specific commands\n"
2106 "Configure BGP defaults\n"
2107 "Show hostname in certain command ouputs\n")
2109 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2110 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2114 DEFUN (no_bgp_default_show_hostname
,
2115 no_bgp_default_show_hostname_cmd
,
2116 "no bgp default show-hostname",
2118 "BGP specific commands\n"
2119 "Configure BGP defaults\n"
2120 "Show hostname in certain command ouputs\n")
2122 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2123 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2127 /* "bgp network import-check" configuration. */
2128 DEFUN (bgp_network_import_check
,
2129 bgp_network_import_check_cmd
,
2130 "bgp network import-check",
2131 "BGP specific commands\n"
2132 "BGP network command\n"
2133 "Check BGP network route exists in IGP\n")
2135 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2136 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2137 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2138 bgp_static_redo_import_check(bgp
);
2144 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2145 "bgp network import-check exact",
2146 "BGP specific commands\n"
2147 "BGP network command\n"
2148 "Check BGP network route exists in IGP\n"
2149 "Match route precisely\n")
2151 DEFUN (no_bgp_network_import_check
,
2152 no_bgp_network_import_check_cmd
,
2153 "no bgp network import-check",
2155 "BGP specific commands\n"
2156 "BGP network command\n"
2157 "Check BGP network route exists in IGP\n")
2159 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2160 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2161 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2162 bgp_static_redo_import_check(bgp
);
2168 DEFUN (bgp_default_local_preference
,
2169 bgp_default_local_preference_cmd
,
2170 "bgp default local-preference (0-4294967295)",
2171 "BGP specific commands\n"
2172 "Configure BGP defaults\n"
2173 "local preference (higher=more preferred)\n"
2174 "Configure default local preference value\n")
2176 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2178 u_int32_t local_pref
;
2180 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2182 bgp_default_local_preference_set(bgp
, local_pref
);
2183 bgp_clear_star_soft_in(vty
, bgp
->name
);
2188 DEFUN (no_bgp_default_local_preference
,
2189 no_bgp_default_local_preference_cmd
,
2190 "no bgp default local-preference [(0-4294967295)]",
2192 "BGP specific commands\n"
2193 "Configure BGP defaults\n"
2194 "local preference (higher=more preferred)\n"
2195 "Configure default local preference value\n")
2197 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2198 bgp_default_local_preference_unset(bgp
);
2199 bgp_clear_star_soft_in(vty
, bgp
->name
);
2205 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2206 bgp_default_subgroup_pkt_queue_max_cmd
,
2207 "bgp default subgroup-pkt-queue-max (20-100)",
2208 "BGP specific commands\n"
2209 "Configure BGP defaults\n"
2210 "subgroup-pkt-queue-max\n"
2211 "Configure subgroup packet queue max\n")
2213 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2217 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2219 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2224 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2225 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2226 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2228 "BGP specific commands\n"
2229 "Configure BGP defaults\n"
2230 "subgroup-pkt-queue-max\n"
2231 "Configure subgroup packet queue max\n")
2233 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2234 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2239 DEFUN (bgp_rr_allow_outbound_policy
,
2240 bgp_rr_allow_outbound_policy_cmd
,
2241 "bgp route-reflector allow-outbound-policy",
2242 "BGP specific commands\n"
2243 "Allow modifications made by out route-map\n"
2244 "on ibgp neighbors\n")
2246 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2248 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2249 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2250 update_group_announce_rrclients(bgp
);
2251 bgp_clear_star_soft_out(vty
, bgp
->name
);
2257 DEFUN (no_bgp_rr_allow_outbound_policy
,
2258 no_bgp_rr_allow_outbound_policy_cmd
,
2259 "no bgp route-reflector allow-outbound-policy",
2261 "BGP specific commands\n"
2262 "Allow modifications made by out route-map\n"
2263 "on ibgp neighbors\n")
2265 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2267 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2268 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2269 update_group_announce_rrclients(bgp
);
2270 bgp_clear_star_soft_out(vty
, bgp
->name
);
2276 DEFUN (bgp_listen_limit
,
2277 bgp_listen_limit_cmd
,
2278 "bgp listen limit (1-5000)",
2279 "BGP specific commands\n"
2280 "Configure BGP defaults\n"
2281 "maximum number of BGP Dynamic Neighbors that can be created\n"
2282 "Configure Dynamic Neighbors listen limit value\n")
2284 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2288 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2290 bgp_listen_limit_set(bgp
, listen_limit
);
2295 DEFUN (no_bgp_listen_limit
,
2296 no_bgp_listen_limit_cmd
,
2297 "no bgp listen limit [(1-5000)]",
2298 "BGP specific commands\n"
2299 "Configure BGP defaults\n"
2300 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2301 "Configure Dynamic Neighbors listen limit value to default\n"
2302 "Configure Dynamic Neighbors listen limit value\n")
2304 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2305 bgp_listen_limit_unset(bgp
);
2311 * Check if this listen range is already configured. Check for exact
2312 * match or overlap based on input.
2314 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2315 struct prefix
*range
, int exact
)
2317 struct listnode
*node
, *nnode
;
2318 struct listnode
*node1
, *nnode1
;
2319 struct peer_group
*group
;
2324 afi
= family2afi(range
->family
);
2325 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2326 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2329 match
= prefix_same(range
, lr
);
2331 match
= (prefix_match(range
, lr
)
2332 || prefix_match(lr
, range
));
2341 DEFUN (bgp_listen_range
,
2342 bgp_listen_range_cmd
,
2343 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2344 "BGP specific commands\n"
2345 "Configure BGP dynamic neighbors listen range\n"
2346 "Configure BGP dynamic neighbors listen range\n"
2348 "Member of the peer-group\n"
2349 "Peer-group name\n")
2351 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2352 struct prefix range
;
2353 struct peer_group
*group
, *existing_group
;
2358 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2359 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2360 char *prefix
= argv
[idx
]->arg
;
2361 argv_find(argv
, argc
, "WORD", &idx
);
2362 char *peergroup
= argv
[idx
]->arg
;
2364 /* Convert IP prefix string to struct prefix. */
2365 ret
= str2prefix(prefix
, &range
);
2367 vty_out(vty
, "%% Malformed listen range\n");
2368 return CMD_WARNING_CONFIG_FAILED
;
2371 afi
= family2afi(range
.family
);
2373 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2375 "%% Malformed listen range (link-local address)\n");
2376 return CMD_WARNING_CONFIG_FAILED
;
2381 /* Check if same listen range is already configured. */
2382 existing_group
= listen_range_exists(bgp
, &range
, 1);
2383 if (existing_group
) {
2384 if (strcmp(existing_group
->name
, peergroup
) == 0)
2388 "%% Same listen range is attached to peer-group %s\n",
2389 existing_group
->name
);
2390 return CMD_WARNING_CONFIG_FAILED
;
2394 /* Check if an overlapping listen range exists. */
2395 if (listen_range_exists(bgp
, &range
, 0)) {
2397 "%% Listen range overlaps with existing listen range\n");
2398 return CMD_WARNING_CONFIG_FAILED
;
2401 group
= peer_group_lookup(bgp
, peergroup
);
2403 vty_out(vty
, "%% Configure the peer-group first\n");
2404 return CMD_WARNING_CONFIG_FAILED
;
2407 ret
= peer_group_listen_range_add(group
, &range
);
2408 return bgp_vty_return(vty
, ret
);
2411 DEFUN (no_bgp_listen_range
,
2412 no_bgp_listen_range_cmd
,
2413 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2415 "BGP specific commands\n"
2416 "Unconfigure BGP dynamic neighbors listen range\n"
2417 "Unconfigure BGP dynamic neighbors listen range\n"
2419 "Member of the peer-group\n"
2420 "Peer-group name\n")
2422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2423 struct prefix range
;
2424 struct peer_group
*group
;
2429 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2430 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2431 char *prefix
= argv
[idx
]->arg
;
2432 argv_find(argv
, argc
, "WORD", &idx
);
2433 char *peergroup
= argv
[idx
]->arg
;
2435 /* Convert IP prefix string to struct prefix. */
2436 ret
= str2prefix(prefix
, &range
);
2438 vty_out(vty
, "%% Malformed listen range\n");
2439 return CMD_WARNING_CONFIG_FAILED
;
2442 afi
= family2afi(range
.family
);
2444 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2446 "%% Malformed listen range (link-local address)\n");
2447 return CMD_WARNING_CONFIG_FAILED
;
2452 group
= peer_group_lookup(bgp
, peergroup
);
2454 vty_out(vty
, "%% Peer-group does not exist\n");
2455 return CMD_WARNING_CONFIG_FAILED
;
2458 ret
= peer_group_listen_range_del(group
, &range
);
2459 return bgp_vty_return(vty
, ret
);
2462 int bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2464 struct peer_group
*group
;
2465 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2466 struct prefix
*range
;
2468 char buf
[PREFIX2STR_BUFFER
];
2470 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2471 vty_out(vty
, " bgp listen limit %d\n",
2472 bgp
->dynamic_neighbors_limit
);
2474 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2475 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2476 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2478 prefix2str(range
, buf
, sizeof(buf
));
2480 " bgp listen range %s peer-group %s\n",
2490 DEFUN (bgp_disable_connected_route_check
,
2491 bgp_disable_connected_route_check_cmd
,
2492 "bgp disable-ebgp-connected-route-check",
2493 "BGP specific commands\n"
2494 "Disable checking if nexthop is connected on ebgp sessions\n")
2496 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2497 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2498 bgp_clear_star_soft_in(vty
, bgp
->name
);
2503 DEFUN (no_bgp_disable_connected_route_check
,
2504 no_bgp_disable_connected_route_check_cmd
,
2505 "no bgp disable-ebgp-connected-route-check",
2507 "BGP specific commands\n"
2508 "Disable checking if nexthop is connected on ebgp sessions\n")
2510 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2511 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2512 bgp_clear_star_soft_in(vty
, bgp
->name
);
2518 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2519 const char *as_str
, afi_t afi
, safi_t safi
)
2521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2524 int as_type
= AS_SPECIFIED
;
2527 if (as_str
[0] == 'i') {
2529 as_type
= AS_INTERNAL
;
2530 } else if (as_str
[0] == 'e') {
2532 as_type
= AS_EXTERNAL
;
2534 /* Get AS number. */
2535 as
= strtoul(as_str
, NULL
, 10);
2538 /* If peer is peer group, call proper function. */
2539 ret
= str2sockunion(peer_str
, &su
);
2541 /* Check for peer by interface */
2542 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2545 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2548 "%% Create the peer-group or interface first\n");
2549 return CMD_WARNING_CONFIG_FAILED
;
2554 if (peer_address_self_check(bgp
, &su
)) {
2556 "%% Can not configure the local system as neighbor\n");
2557 return CMD_WARNING_CONFIG_FAILED
;
2559 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2562 /* This peer belongs to peer group. */
2564 case BGP_ERR_PEER_GROUP_MEMBER
:
2566 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2568 return CMD_WARNING_CONFIG_FAILED
;
2569 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2571 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2573 return CMD_WARNING_CONFIG_FAILED
;
2575 return bgp_vty_return(vty
, ret
);
2578 DEFUN (neighbor_remote_as
,
2579 neighbor_remote_as_cmd
,
2580 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2583 "Specify a BGP neighbor\n"
2585 "Internal BGP peer\n"
2586 "External BGP peer\n")
2589 int idx_remote_as
= 3;
2590 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2591 argv
[idx_remote_as
]->arg
, AFI_IP
,
2595 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2596 afi_t afi
, safi_t safi
, int v6only
,
2597 const char *peer_group_name
,
2600 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2602 int as_type
= AS_UNSPECIFIED
;
2604 struct peer_group
*group
;
2608 group
= peer_group_lookup(bgp
, conf_if
);
2611 vty_out(vty
, "%% Name conflict with peer-group \n");
2612 return CMD_WARNING_CONFIG_FAILED
;
2616 if (as_str
[0] == 'i') {
2617 as_type
= AS_INTERNAL
;
2618 } else if (as_str
[0] == 'e') {
2619 as_type
= AS_EXTERNAL
;
2621 /* Get AS number. */
2622 as
= strtoul(as_str
, NULL
, 10);
2623 as_type
= AS_SPECIFIED
;
2627 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2630 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2633 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2634 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2635 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2636 as_type
, 0, 0, NULL
);
2638 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2639 as_type
, afi
, safi
, NULL
);
2642 vty_out(vty
, "%% BGP failed to create peer\n");
2643 return CMD_WARNING_CONFIG_FAILED
;
2647 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2649 /* Request zebra to initiate IPv6 RAs on this interface. We do
2651 * any unnumbered peer in order to not worry about run-time
2653 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2655 * gets deleted later etc.)
2658 bgp_zebra_initiate_radv(bgp
, peer
);
2661 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2662 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2664 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2666 UNSET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2668 /* v6only flag changed. Reset bgp seesion */
2669 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2670 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2671 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2672 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2674 bgp_session_reset(peer
);
2677 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
2678 peer_flag_set(peer
, PEER_FLAG_CAPABILITY_ENHE
);
2680 if (peer_group_name
) {
2681 group
= peer_group_lookup(bgp
, peer_group_name
);
2683 vty_out(vty
, "%% Configure the peer-group first\n");
2684 return CMD_WARNING_CONFIG_FAILED
;
2687 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2690 return bgp_vty_return(vty
, ret
);
2693 DEFUN (neighbor_interface_config
,
2694 neighbor_interface_config_cmd
,
2695 "neighbor WORD interface [peer-group WORD]",
2697 "Interface name or neighbor tag\n"
2698 "Enable BGP on interface\n"
2699 "Member of the peer-group\n"
2700 "Peer-group name\n")
2703 int idx_peer_group_word
= 4;
2705 if (argc
> idx_peer_group_word
)
2706 return peer_conf_interface_get(
2707 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2708 argv
[idx_peer_group_word
]->arg
, NULL
);
2710 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2711 SAFI_UNICAST
, 0, NULL
, NULL
);
2714 DEFUN (neighbor_interface_config_v6only
,
2715 neighbor_interface_config_v6only_cmd
,
2716 "neighbor WORD interface v6only [peer-group WORD]",
2718 "Interface name or neighbor tag\n"
2719 "Enable BGP on interface\n"
2720 "Enable BGP with v6 link-local only\n"
2721 "Member of the peer-group\n"
2722 "Peer-group name\n")
2725 int idx_peer_group_word
= 5;
2727 if (argc
> idx_peer_group_word
)
2728 return peer_conf_interface_get(
2729 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2730 argv
[idx_peer_group_word
]->arg
, NULL
);
2732 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2733 SAFI_UNICAST
, 1, NULL
, NULL
);
2737 DEFUN (neighbor_interface_config_remote_as
,
2738 neighbor_interface_config_remote_as_cmd
,
2739 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2741 "Interface name or neighbor tag\n"
2742 "Enable BGP on interface\n"
2743 "Specify a BGP neighbor\n"
2745 "Internal BGP peer\n"
2746 "External BGP peer\n")
2749 int idx_remote_as
= 4;
2750 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2751 SAFI_UNICAST
, 0, NULL
,
2752 argv
[idx_remote_as
]->arg
);
2755 DEFUN (neighbor_interface_v6only_config_remote_as
,
2756 neighbor_interface_v6only_config_remote_as_cmd
,
2757 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2759 "Interface name or neighbor tag\n"
2760 "Enable BGP with v6 link-local only\n"
2761 "Enable BGP on interface\n"
2762 "Specify a BGP neighbor\n"
2764 "Internal BGP peer\n"
2765 "External BGP peer\n")
2768 int idx_remote_as
= 5;
2769 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2770 SAFI_UNICAST
, 1, NULL
,
2771 argv
[idx_remote_as
]->arg
);
2774 DEFUN (neighbor_peer_group
,
2775 neighbor_peer_group_cmd
,
2776 "neighbor WORD peer-group",
2778 "Interface name or neighbor tag\n"
2779 "Configure peer-group\n")
2781 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2784 struct peer_group
*group
;
2786 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2788 vty_out(vty
, "%% Name conflict with interface: \n");
2789 return CMD_WARNING_CONFIG_FAILED
;
2792 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2794 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2795 return CMD_WARNING_CONFIG_FAILED
;
2803 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
2807 "Specify a BGP neighbor\n"
2809 "Internal BGP peer\n"
2810 "External BGP peer\n")
2812 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2816 struct peer_group
*group
;
2820 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
2822 /* look up for neighbor by interface name config. */
2823 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
2825 /* Request zebra to terminate IPv6 RAs on this
2828 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
2833 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
2835 peer_group_delete(group
);
2837 vty_out(vty
, "%% Create the peer-group first\n");
2838 return CMD_WARNING_CONFIG_FAILED
;
2841 peer
= peer_lookup(bgp
, &su
);
2843 if (peer_dynamic_neighbor(peer
)) {
2845 "%% Operation not allowed on a dynamic neighbor\n");
2846 return CMD_WARNING_CONFIG_FAILED
;
2849 other
= peer
->doppelganger
;
2851 if (other
&& other
->status
!= Deleted
)
2859 DEFUN (no_neighbor_interface_config
,
2860 no_neighbor_interface_config_cmd
,
2861 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
2865 "Configure BGP on interface\n"
2866 "Enable BGP with v6 link-local only\n"
2867 "Member of the peer-group\n"
2869 "Specify a BGP neighbor\n"
2871 "Internal BGP peer\n"
2872 "External BGP peer\n")
2874 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2878 /* look up for neighbor by interface name config. */
2879 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2881 /* Request zebra to terminate IPv6 RAs on this interface. */
2883 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
2886 vty_out(vty
, "%% Create the bgp interface first\n");
2887 return CMD_WARNING_CONFIG_FAILED
;
2892 DEFUN (no_neighbor_peer_group
,
2893 no_neighbor_peer_group_cmd
,
2894 "no neighbor WORD peer-group",
2898 "Configure peer-group\n")
2900 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2902 struct peer_group
*group
;
2904 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
2906 peer_group_delete(group
);
2908 vty_out(vty
, "%% Create the peer-group first\n");
2909 return CMD_WARNING_CONFIG_FAILED
;
2914 DEFUN (no_neighbor_interface_peer_group_remote_as
,
2915 no_neighbor_interface_peer_group_remote_as_cmd
,
2916 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
2919 "Interface name or neighbor tag\n"
2920 "Specify a BGP neighbor\n"
2922 "Internal BGP peer\n"
2923 "External BGP peer\n")
2925 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2927 struct peer_group
*group
;
2930 /* look up for neighbor by interface name config. */
2931 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2933 peer_as_change(peer
, 0, AS_SPECIFIED
);
2937 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
2939 peer_group_remote_as_delete(group
);
2941 vty_out(vty
, "%% Create the peer-group or interface first\n");
2942 return CMD_WARNING_CONFIG_FAILED
;
2947 DEFUN (neighbor_local_as
,
2948 neighbor_local_as_cmd
,
2949 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
2952 "Specify a local-as number\n"
2953 "AS number used as local AS\n")
2961 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2963 return CMD_WARNING_CONFIG_FAILED
;
2965 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2966 ret
= peer_local_as_set(peer
, as
, 0, 0);
2967 return bgp_vty_return(vty
, ret
);
2970 DEFUN (neighbor_local_as_no_prepend
,
2971 neighbor_local_as_no_prepend_cmd
,
2972 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
2975 "Specify a local-as number\n"
2976 "AS number used as local AS\n"
2977 "Do not prepend local-as to updates from ebgp peers\n")
2985 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2987 return CMD_WARNING_CONFIG_FAILED
;
2989 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2990 ret
= peer_local_as_set(peer
, as
, 1, 0);
2991 return bgp_vty_return(vty
, ret
);
2994 DEFUN (neighbor_local_as_no_prepend_replace_as
,
2995 neighbor_local_as_no_prepend_replace_as_cmd
,
2996 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
2999 "Specify a local-as number\n"
3000 "AS number used as local AS\n"
3001 "Do not prepend local-as to updates from ebgp peers\n"
3002 "Do not prepend local-as to updates from ibgp peers\n")
3010 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3012 return CMD_WARNING_CONFIG_FAILED
;
3014 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3015 ret
= peer_local_as_set(peer
, as
, 1, 1);
3016 return bgp_vty_return(vty
, ret
);
3019 DEFUN (no_neighbor_local_as
,
3020 no_neighbor_local_as_cmd
,
3021 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3025 "Specify a local-as number\n"
3026 "AS number used as local AS\n"
3027 "Do not prepend local-as to updates from ebgp peers\n"
3028 "Do not prepend local-as to updates from ibgp peers\n")
3034 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3036 return CMD_WARNING_CONFIG_FAILED
;
3038 ret
= peer_local_as_unset(peer
);
3039 return bgp_vty_return(vty
, ret
);
3043 DEFUN (neighbor_solo
,
3045 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3048 "Solo peer - part of its own update group\n")
3054 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3056 return CMD_WARNING_CONFIG_FAILED
;
3058 ret
= update_group_adjust_soloness(peer
, 1);
3059 return bgp_vty_return(vty
, ret
);
3062 DEFUN (no_neighbor_solo
,
3063 no_neighbor_solo_cmd
,
3064 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3068 "Solo peer - part of its own update group\n")
3074 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3076 return CMD_WARNING_CONFIG_FAILED
;
3078 ret
= update_group_adjust_soloness(peer
, 0);
3079 return bgp_vty_return(vty
, ret
);
3082 DEFUN (neighbor_password
,
3083 neighbor_password_cmd
,
3084 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3095 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3097 return CMD_WARNING_CONFIG_FAILED
;
3099 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3100 return bgp_vty_return(vty
, ret
);
3103 DEFUN (no_neighbor_password
,
3104 no_neighbor_password_cmd
,
3105 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3116 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3118 return CMD_WARNING_CONFIG_FAILED
;
3120 ret
= peer_password_unset(peer
);
3121 return bgp_vty_return(vty
, ret
);
3125 DEFUN (neighbor_activate
,
3126 neighbor_activate_cmd
,
3127 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3130 "Enable the Address Family for this Neighbor\n")
3136 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3138 return CMD_WARNING_CONFIG_FAILED
;
3140 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3141 return bgp_vty_return(vty
, ret
);
3144 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3145 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3146 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3147 "Enable the Address Family for this Neighbor\n")
3149 DEFUN (no_neighbor_activate
,
3150 no_neighbor_activate_cmd
,
3151 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3155 "Enable the Address Family for this Neighbor\n")
3162 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3164 return CMD_WARNING_CONFIG_FAILED
;
3166 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3167 return bgp_vty_return(vty
, ret
);
3170 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3171 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3172 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3173 "Enable the Address Family for this Neighbor\n")
3175 DEFUN (neighbor_set_peer_group
,
3176 neighbor_set_peer_group_cmd
,
3177 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3180 "Member of the peer-group\n"
3181 "Peer-group name\n")
3183 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3190 struct peer_group
*group
;
3194 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3196 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3198 vty_out(vty
, "%% Malformed address or name: %s\n",
3199 argv
[idx_peer
]->arg
);
3200 return CMD_WARNING_CONFIG_FAILED
;
3203 if (peer_address_self_check(bgp
, &su
)) {
3205 "%% Can not configure the local system as neighbor\n");
3206 return CMD_WARNING_CONFIG_FAILED
;
3209 /* Disallow for dynamic neighbor. */
3210 peer
= peer_lookup(bgp
, &su
);
3211 if (peer
&& peer_dynamic_neighbor(peer
)) {
3213 "%% Operation not allowed on a dynamic neighbor\n");
3214 return CMD_WARNING_CONFIG_FAILED
;
3218 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3220 vty_out(vty
, "%% Configure the peer-group first\n");
3221 return CMD_WARNING_CONFIG_FAILED
;
3224 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3226 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3228 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3230 return CMD_WARNING_CONFIG_FAILED
;
3233 return bgp_vty_return(vty
, ret
);
3236 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3237 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3238 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3239 "Member of the peer-group\n"
3240 "Peer-group name\n")
3242 DEFUN (no_neighbor_set_peer_group
,
3243 no_neighbor_set_peer_group_cmd
,
3244 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3248 "Member of the peer-group\n"
3249 "Peer-group name\n")
3251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3256 struct peer_group
*group
;
3258 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3260 return CMD_WARNING_CONFIG_FAILED
;
3262 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3264 vty_out(vty
, "%% Configure the peer-group first\n");
3265 return CMD_WARNING_CONFIG_FAILED
;
3268 ret
= peer_group_unbind(bgp
, peer
, group
);
3270 return bgp_vty_return(vty
, ret
);
3273 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3274 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3275 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3276 "Member of the peer-group\n"
3277 "Peer-group name\n")
3279 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3280 u_int16_t flag
, int set
)
3285 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3287 return CMD_WARNING_CONFIG_FAILED
;
3290 * If 'neighbor <interface>', then this is for directly connected peers,
3291 * we should not accept disable-connected-check.
3293 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3295 "%s is directly connected peer, cannot accept disable-"
3296 "connected-check\n",
3298 return CMD_WARNING_CONFIG_FAILED
;
3301 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3302 peer_tx_shutdown_message_unset(peer
);
3305 ret
= peer_flag_set(peer
, flag
);
3307 ret
= peer_flag_unset(peer
, flag
);
3309 return bgp_vty_return(vty
, ret
);
3312 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
,
3315 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3318 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3321 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3324 /* neighbor passive. */
3325 DEFUN (neighbor_passive
,
3326 neighbor_passive_cmd
,
3327 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3330 "Don't send open messages to this neighbor\n")
3333 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3336 DEFUN (no_neighbor_passive
,
3337 no_neighbor_passive_cmd
,
3338 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3342 "Don't send open messages to this neighbor\n")
3345 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3348 /* neighbor shutdown. */
3349 DEFUN (neighbor_shutdown_msg
,
3350 neighbor_shutdown_msg_cmd
,
3351 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3354 "Administratively shut down this neighbor\n"
3355 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3356 "Shutdown message\n")
3362 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3366 return CMD_WARNING_CONFIG_FAILED
;
3367 message
= argv_concat(argv
, argc
, 4);
3368 peer_tx_shutdown_message_set(peer
, message
);
3369 XFREE(MTYPE_TMP
, message
);
3372 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3375 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3376 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3377 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3378 "Administratively shut down this neighbor\n")
3380 DEFUN (no_neighbor_shutdown_msg
,
3381 no_neighbor_shutdown_msg_cmd
,
3382 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3386 "Administratively shut down this neighbor\n"
3387 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3388 "Shutdown message\n")
3392 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3393 PEER_FLAG_SHUTDOWN
);
3396 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3397 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3398 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3399 "Administratively shut down this neighbor\n")
3401 /* neighbor capability dynamic. */
3402 DEFUN (neighbor_capability_dynamic
,
3403 neighbor_capability_dynamic_cmd
,
3404 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3407 "Advertise capability to the peer\n"
3408 "Advertise dynamic capability to this neighbor\n")
3411 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3412 PEER_FLAG_DYNAMIC_CAPABILITY
);
3415 DEFUN (no_neighbor_capability_dynamic
,
3416 no_neighbor_capability_dynamic_cmd
,
3417 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3421 "Advertise capability to the peer\n"
3422 "Advertise dynamic capability to this neighbor\n")
3425 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3426 PEER_FLAG_DYNAMIC_CAPABILITY
);
3429 /* neighbor dont-capability-negotiate */
3430 DEFUN (neighbor_dont_capability_negotiate
,
3431 neighbor_dont_capability_negotiate_cmd
,
3432 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3435 "Do not perform capability negotiation\n")
3438 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3439 PEER_FLAG_DONT_CAPABILITY
);
3442 DEFUN (no_neighbor_dont_capability_negotiate
,
3443 no_neighbor_dont_capability_negotiate_cmd
,
3444 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3448 "Do not perform capability negotiation\n")
3451 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3452 PEER_FLAG_DONT_CAPABILITY
);
3455 /* neighbor capability extended next hop encoding */
3456 DEFUN (neighbor_capability_enhe
,
3457 neighbor_capability_enhe_cmd
,
3458 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3461 "Advertise capability to the peer\n"
3462 "Advertise extended next-hop capability to the peer\n")
3465 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3466 PEER_FLAG_CAPABILITY_ENHE
);
3469 DEFUN (no_neighbor_capability_enhe
,
3470 no_neighbor_capability_enhe_cmd
,
3471 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3475 "Advertise capability to the peer\n"
3476 "Advertise extended next-hop capability to the peer\n")
3479 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3480 PEER_FLAG_CAPABILITY_ENHE
);
3483 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3484 afi_t afi
, safi_t safi
, u_int32_t flag
,
3490 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3492 return CMD_WARNING_CONFIG_FAILED
;
3495 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3497 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3499 return bgp_vty_return(vty
, ret
);
3502 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3503 afi_t afi
, safi_t safi
, u_int32_t flag
)
3505 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3508 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3509 afi_t afi
, safi_t safi
, u_int32_t flag
)
3511 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3514 /* neighbor capability orf prefix-list. */
3515 DEFUN (neighbor_capability_orf_prefix
,
3516 neighbor_capability_orf_prefix_cmd
,
3517 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3520 "Advertise capability to the peer\n"
3521 "Advertise ORF capability to the peer\n"
3522 "Advertise prefixlist ORF capability to this neighbor\n"
3523 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3524 "Capability to RECEIVE the ORF from this neighbor\n"
3525 "Capability to SEND the ORF to this neighbor\n")
3528 int idx_send_recv
= 5;
3531 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3532 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3533 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3534 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3535 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3536 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3538 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3539 return CMD_WARNING_CONFIG_FAILED
;
3542 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3543 bgp_node_safi(vty
), flag
);
3547 neighbor_capability_orf_prefix
,
3548 neighbor_capability_orf_prefix_hidden_cmd
,
3549 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3550 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3551 "Advertise capability to the peer\n"
3552 "Advertise ORF capability to the peer\n"
3553 "Advertise prefixlist ORF capability to this neighbor\n"
3554 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3555 "Capability to RECEIVE the ORF from this neighbor\n"
3556 "Capability to SEND the ORF to this neighbor\n")
3558 DEFUN (no_neighbor_capability_orf_prefix
,
3559 no_neighbor_capability_orf_prefix_cmd
,
3560 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3564 "Advertise capability to the peer\n"
3565 "Advertise ORF capability to the peer\n"
3566 "Advertise prefixlist ORF capability to this neighbor\n"
3567 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3568 "Capability to RECEIVE the ORF from this neighbor\n"
3569 "Capability to SEND the ORF to this neighbor\n")
3572 int idx_send_recv
= 6;
3575 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3576 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3577 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3578 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3579 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3580 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3582 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3583 return CMD_WARNING_CONFIG_FAILED
;
3586 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3587 bgp_node_afi(vty
), bgp_node_safi(vty
),
3592 no_neighbor_capability_orf_prefix
,
3593 no_neighbor_capability_orf_prefix_hidden_cmd
,
3594 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3595 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3596 "Advertise capability to the peer\n"
3597 "Advertise ORF capability to the peer\n"
3598 "Advertise prefixlist ORF capability to this neighbor\n"
3599 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3600 "Capability to RECEIVE the ORF from this neighbor\n"
3601 "Capability to SEND the ORF to this neighbor\n")
3603 /* neighbor next-hop-self. */
3604 DEFUN (neighbor_nexthop_self
,
3605 neighbor_nexthop_self_cmd
,
3606 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3609 "Disable the next hop calculation for this neighbor\n")
3612 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3613 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3616 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3617 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3618 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3619 "Disable the next hop calculation for this neighbor\n")
3621 /* neighbor next-hop-self. */
3622 DEFUN (neighbor_nexthop_self_force
,
3623 neighbor_nexthop_self_force_cmd
,
3624 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3627 "Disable the next hop calculation for this neighbor\n"
3628 "Set the next hop to self for reflected routes\n")
3631 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3633 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3636 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3637 neighbor_nexthop_self_force_hidden_cmd
,
3638 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3639 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3640 "Disable the next hop calculation for this neighbor\n"
3641 "Set the next hop to self for reflected routes\n")
3643 DEFUN (no_neighbor_nexthop_self
,
3644 no_neighbor_nexthop_self_cmd
,
3645 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3649 "Disable the next hop calculation for this neighbor\n")
3652 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3653 bgp_node_afi(vty
), bgp_node_safi(vty
),
3654 PEER_FLAG_NEXTHOP_SELF
);
3657 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3658 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3659 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3660 "Disable the next hop calculation for this neighbor\n")
3662 DEFUN (no_neighbor_nexthop_self_force
,
3663 no_neighbor_nexthop_self_force_cmd
,
3664 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3668 "Disable the next hop calculation for this neighbor\n"
3669 "Set the next hop to self for reflected routes\n")
3672 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3673 bgp_node_afi(vty
), bgp_node_safi(vty
),
3674 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3677 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3678 no_neighbor_nexthop_self_force_hidden_cmd
,
3679 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3680 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3681 "Disable the next hop calculation for this neighbor\n"
3682 "Set the next hop to self for reflected routes\n")
3684 /* neighbor as-override */
3685 DEFUN (neighbor_as_override
,
3686 neighbor_as_override_cmd
,
3687 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3690 "Override ASNs in outbound updates if aspath equals remote-as\n")
3693 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3694 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3697 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3698 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3699 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3700 "Override ASNs in outbound updates if aspath equals remote-as\n")
3702 DEFUN (no_neighbor_as_override
,
3703 no_neighbor_as_override_cmd
,
3704 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3708 "Override ASNs in outbound updates if aspath equals remote-as\n")
3711 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3712 bgp_node_afi(vty
), bgp_node_safi(vty
),
3713 PEER_FLAG_AS_OVERRIDE
);
3716 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3717 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3718 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3719 "Override ASNs in outbound updates if aspath equals remote-as\n")
3721 /* neighbor remove-private-AS. */
3722 DEFUN (neighbor_remove_private_as
,
3723 neighbor_remove_private_as_cmd
,
3724 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3727 "Remove private ASNs in outbound updates\n")
3730 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3732 PEER_FLAG_REMOVE_PRIVATE_AS
);
3735 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3736 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3737 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3738 "Remove private ASNs in outbound updates\n")
3740 DEFUN (neighbor_remove_private_as_all
,
3741 neighbor_remove_private_as_all_cmd
,
3742 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3745 "Remove private ASNs in outbound updates\n"
3746 "Apply to all AS numbers")
3749 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3751 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3754 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3755 neighbor_remove_private_as_all_hidden_cmd
,
3756 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3757 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3758 "Remove private ASNs in outbound updates\n"
3759 "Apply to all AS numbers")
3761 DEFUN (neighbor_remove_private_as_replace_as
,
3762 neighbor_remove_private_as_replace_as_cmd
,
3763 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3766 "Remove private ASNs in outbound updates\n"
3767 "Replace private ASNs with our ASN in outbound updates\n")
3770 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3772 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3775 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3776 neighbor_remove_private_as_replace_as_hidden_cmd
,
3777 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3778 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3779 "Remove private ASNs in outbound updates\n"
3780 "Replace private ASNs with our ASN in outbound updates\n")
3782 DEFUN (neighbor_remove_private_as_all_replace_as
,
3783 neighbor_remove_private_as_all_replace_as_cmd
,
3784 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3787 "Remove private ASNs in outbound updates\n"
3788 "Apply to all AS numbers\n"
3789 "Replace private ASNs with our ASN in outbound updates\n")
3792 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3794 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3798 neighbor_remove_private_as_all_replace_as
,
3799 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3800 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3801 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3802 "Remove private ASNs in outbound updates\n"
3803 "Apply to all AS numbers\n"
3804 "Replace private ASNs with our ASN in outbound updates\n")
3806 DEFUN (no_neighbor_remove_private_as
,
3807 no_neighbor_remove_private_as_cmd
,
3808 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3812 "Remove private ASNs in outbound updates\n")
3815 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3816 bgp_node_afi(vty
), bgp_node_safi(vty
),
3817 PEER_FLAG_REMOVE_PRIVATE_AS
);
3820 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
3821 no_neighbor_remove_private_as_hidden_cmd
,
3822 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3823 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3824 "Remove private ASNs in outbound updates\n")
3826 DEFUN (no_neighbor_remove_private_as_all
,
3827 no_neighbor_remove_private_as_all_cmd
,
3828 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3832 "Remove private ASNs in outbound updates\n"
3833 "Apply to all AS numbers\n")
3836 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3837 bgp_node_afi(vty
), bgp_node_safi(vty
),
3838 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3841 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
3842 no_neighbor_remove_private_as_all_hidden_cmd
,
3843 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3844 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3845 "Remove private ASNs in outbound updates\n"
3846 "Apply to all AS numbers\n")
3848 DEFUN (no_neighbor_remove_private_as_replace_as
,
3849 no_neighbor_remove_private_as_replace_as_cmd
,
3850 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3854 "Remove private ASNs in outbound updates\n"
3855 "Replace private ASNs with our ASN in outbound updates\n")
3858 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3859 bgp_node_afi(vty
), bgp_node_safi(vty
),
3860 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3863 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
3864 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
3865 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3866 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3867 "Remove private ASNs in outbound updates\n"
3868 "Replace private ASNs with our ASN in outbound updates\n")
3870 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
3871 no_neighbor_remove_private_as_all_replace_as_cmd
,
3872 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3876 "Remove private ASNs in outbound updates\n"
3877 "Apply to all AS numbers\n"
3878 "Replace private ASNs with our ASN in outbound updates\n")
3881 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3882 bgp_node_afi(vty
), bgp_node_safi(vty
),
3883 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3887 no_neighbor_remove_private_as_all_replace_as
,
3888 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3889 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3890 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3891 "Remove private ASNs in outbound updates\n"
3892 "Apply to all AS numbers\n"
3893 "Replace private ASNs with our ASN in outbound updates\n")
3896 /* neighbor send-community. */
3897 DEFUN (neighbor_send_community
,
3898 neighbor_send_community_cmd
,
3899 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
3902 "Send Community attribute to this neighbor\n")
3905 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3907 PEER_FLAG_SEND_COMMUNITY
);
3910 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
3911 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
3912 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3913 "Send Community attribute to this neighbor\n")
3915 DEFUN (no_neighbor_send_community
,
3916 no_neighbor_send_community_cmd
,
3917 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
3921 "Send Community attribute to this neighbor\n")
3924 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3925 bgp_node_afi(vty
), bgp_node_safi(vty
),
3926 PEER_FLAG_SEND_COMMUNITY
);
3929 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
3930 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
3931 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3932 "Send Community attribute to this neighbor\n")
3934 /* neighbor send-community extended. */
3935 DEFUN (neighbor_send_community_type
,
3936 neighbor_send_community_type_cmd
,
3937 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
3940 "Send Community attribute to this neighbor\n"
3941 "Send Standard and Extended Community attributes\n"
3942 "Send Standard, Large and Extended Community attributes\n"
3943 "Send Extended Community attributes\n"
3944 "Send Standard Community attributes\n"
3945 "Send Large Community attributes\n")
3950 char *peer
= argv
[1]->arg
;
3952 if (argv_find(argv
, argc
, "standard", &idx
))
3953 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
3954 else if (argv_find(argv
, argc
, "extended", &idx
))
3955 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
3956 else if (argv_find(argv
, argc
, "large", &idx
))
3957 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
3958 else if (argv_find(argv
, argc
, "both", &idx
)) {
3959 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
3960 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
3962 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
3963 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
3964 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
3967 return peer_af_flag_set_vty(vty
, peer
, bgp_node_afi(vty
),
3968 bgp_node_safi(vty
), flag
);
3972 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
3973 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
3974 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3975 "Send Community attribute to this neighbor\n"
3976 "Send Standard and Extended Community attributes\n"
3977 "Send Standard, Large and Extended Community attributes\n"
3978 "Send Extended Community attributes\n"
3979 "Send Standard Community attributes\n"
3980 "Send Large Community attributes\n")
3982 DEFUN (no_neighbor_send_community_type
,
3983 no_neighbor_send_community_type_cmd
,
3984 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
3988 "Send Community attribute to this neighbor\n"
3989 "Send Standard and Extended Community attributes\n"
3990 "Send Standard, Large and Extended Community attributes\n"
3991 "Send Extended Community attributes\n"
3992 "Send Standard Community attributes\n"
3993 "Send Large Community attributes\n")
3997 const char *type
= argv
[argc
- 1]->text
;
3999 if (strmatch(type
, "standard"))
4000 return peer_af_flag_unset_vty(
4001 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4002 bgp_node_safi(vty
), PEER_FLAG_SEND_COMMUNITY
);
4003 if (strmatch(type
, "extended"))
4004 return peer_af_flag_unset_vty(
4005 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4006 bgp_node_safi(vty
), PEER_FLAG_SEND_EXT_COMMUNITY
);
4007 if (strmatch(type
, "large"))
4008 return peer_af_flag_unset_vty(
4009 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4010 bgp_node_safi(vty
), PEER_FLAG_SEND_LARGE_COMMUNITY
);
4011 if (strmatch(type
, "both"))
4012 return peer_af_flag_unset_vty(
4013 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4015 PEER_FLAG_SEND_COMMUNITY
4016 | PEER_FLAG_SEND_EXT_COMMUNITY
);
4018 /* if (strmatch (type, "all")) */
4019 return peer_af_flag_unset_vty(
4020 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4021 (PEER_FLAG_SEND_COMMUNITY
| PEER_FLAG_SEND_EXT_COMMUNITY
4022 | PEER_FLAG_SEND_LARGE_COMMUNITY
));
4026 no_neighbor_send_community_type
,
4027 no_neighbor_send_community_type_hidden_cmd
,
4028 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4029 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4030 "Send Community attribute to this neighbor\n"
4031 "Send Standard and Extended Community attributes\n"
4032 "Send Standard, Large and Extended Community attributes\n"
4033 "Send Extended Community attributes\n"
4034 "Send Standard Community attributes\n"
4035 "Send Large Community attributes\n")
4037 /* neighbor soft-reconfig. */
4038 DEFUN (neighbor_soft_reconfiguration
,
4039 neighbor_soft_reconfiguration_cmd
,
4040 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4043 "Per neighbor soft reconfiguration\n"
4044 "Allow inbound soft reconfiguration for this neighbor\n")
4047 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4049 PEER_FLAG_SOFT_RECONFIG
);
4052 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4053 neighbor_soft_reconfiguration_hidden_cmd
,
4054 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4055 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4056 "Per neighbor soft reconfiguration\n"
4057 "Allow inbound soft reconfiguration for this neighbor\n")
4059 DEFUN (no_neighbor_soft_reconfiguration
,
4060 no_neighbor_soft_reconfiguration_cmd
,
4061 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4065 "Per neighbor soft reconfiguration\n"
4066 "Allow inbound soft reconfiguration for this neighbor\n")
4069 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4070 bgp_node_afi(vty
), bgp_node_safi(vty
),
4071 PEER_FLAG_SOFT_RECONFIG
);
4074 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4075 no_neighbor_soft_reconfiguration_hidden_cmd
,
4076 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4077 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4078 "Per neighbor soft reconfiguration\n"
4079 "Allow inbound soft reconfiguration for this neighbor\n")
4081 DEFUN (neighbor_route_reflector_client
,
4082 neighbor_route_reflector_client_cmd
,
4083 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4086 "Configure a neighbor as Route Reflector client\n")
4092 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4094 return CMD_WARNING_CONFIG_FAILED
;
4096 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4098 PEER_FLAG_REFLECTOR_CLIENT
);
4101 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4102 neighbor_route_reflector_client_hidden_cmd
,
4103 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4104 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4105 "Configure a neighbor as Route Reflector client\n")
4107 DEFUN (no_neighbor_route_reflector_client
,
4108 no_neighbor_route_reflector_client_cmd
,
4109 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4113 "Configure a neighbor as Route Reflector client\n")
4116 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4117 bgp_node_afi(vty
), bgp_node_safi(vty
),
4118 PEER_FLAG_REFLECTOR_CLIENT
);
4121 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4122 no_neighbor_route_reflector_client_hidden_cmd
,
4123 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4124 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4125 "Configure a neighbor as Route Reflector client\n")
4127 /* neighbor route-server-client. */
4128 DEFUN (neighbor_route_server_client
,
4129 neighbor_route_server_client_cmd
,
4130 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4133 "Configure a neighbor as Route Server client\n")
4138 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4140 return CMD_WARNING_CONFIG_FAILED
;
4141 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4143 PEER_FLAG_RSERVER_CLIENT
);
4146 ALIAS_HIDDEN(neighbor_route_server_client
,
4147 neighbor_route_server_client_hidden_cmd
,
4148 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4149 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4150 "Configure a neighbor as Route Server client\n")
4152 DEFUN (no_neighbor_route_server_client
,
4153 no_neighbor_route_server_client_cmd
,
4154 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4158 "Configure a neighbor as Route Server client\n")
4161 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4162 bgp_node_afi(vty
), bgp_node_safi(vty
),
4163 PEER_FLAG_RSERVER_CLIENT
);
4166 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4167 no_neighbor_route_server_client_hidden_cmd
,
4168 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4169 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4170 "Configure a neighbor as Route Server client\n")
4172 DEFUN (neighbor_nexthop_local_unchanged
,
4173 neighbor_nexthop_local_unchanged_cmd
,
4174 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4177 "Configure treatment of outgoing link-local nexthop attribute\n"
4178 "Leave link-local nexthop unchanged for this peer\n")
4181 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4183 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4186 DEFUN (no_neighbor_nexthop_local_unchanged
,
4187 no_neighbor_nexthop_local_unchanged_cmd
,
4188 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4192 "Configure treatment of outgoing link-local-nexthop attribute\n"
4193 "Leave link-local nexthop unchanged for this peer\n")
4196 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4197 bgp_node_afi(vty
), bgp_node_safi(vty
),
4198 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4201 DEFUN (neighbor_attr_unchanged
,
4202 neighbor_attr_unchanged_cmd
,
4203 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4206 "BGP attribute is propagated unchanged to this neighbor\n"
4207 "As-path attribute\n"
4208 "Nexthop attribute\n"
4212 char *peer_str
= argv
[1]->arg
;
4214 u_int16_t flags
= 0;
4215 afi_t afi
= bgp_node_afi(vty
);
4216 safi_t safi
= bgp_node_safi(vty
);
4218 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4220 return CMD_WARNING_CONFIG_FAILED
;
4222 if (argv_find(argv
, argc
, "as-path", &idx
))
4223 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4225 if (argv_find(argv
, argc
, "next-hop", &idx
))
4226 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4228 if (argv_find(argv
, argc
, "med", &idx
))
4229 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4231 /* no flags means all of them! */
4233 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4234 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4235 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4237 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
) &&
4238 peer_af_flag_check(peer
, afi
, safi
,
4239 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4240 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4241 PEER_FLAG_AS_PATH_UNCHANGED
);
4244 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
) &&
4245 peer_af_flag_check(peer
, afi
, safi
,
4246 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4247 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4248 PEER_FLAG_NEXTHOP_UNCHANGED
);
4251 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
) &&
4252 peer_af_flag_check(peer
, afi
, safi
,
4253 PEER_FLAG_MED_UNCHANGED
)) {
4254 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4255 PEER_FLAG_MED_UNCHANGED
);
4259 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4263 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4264 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4265 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4266 "BGP attribute is propagated unchanged to this neighbor\n"
4267 "As-path attribute\n"
4268 "Nexthop attribute\n"
4271 DEFUN (no_neighbor_attr_unchanged
,
4272 no_neighbor_attr_unchanged_cmd
,
4273 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4277 "BGP attribute is propagated unchanged to this neighbor\n"
4278 "As-path attribute\n"
4279 "Nexthop attribute\n"
4283 char *peer
= argv
[2]->arg
;
4284 u_int16_t flags
= 0;
4286 if (argv_find(argv
, argc
, "as-path", &idx
))
4287 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4289 if (argv_find(argv
, argc
, "next-hop", &idx
))
4290 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4292 if (argv_find(argv
, argc
, "med", &idx
))
4293 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4295 if (!flags
) // no flags means all of them!
4297 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4298 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4299 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4302 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4303 bgp_node_safi(vty
), flags
);
4307 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4308 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4309 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4310 "BGP attribute is propagated unchanged to this neighbor\n"
4311 "As-path attribute\n"
4312 "Nexthop attribute\n"
4315 /* EBGP multihop configuration. */
4316 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4317 const char *ttl_str
)
4322 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4324 return CMD_WARNING_CONFIG_FAILED
;
4327 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4332 ttl
= strtoul(ttl_str
, NULL
, 10);
4334 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4337 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4341 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4343 return CMD_WARNING_CONFIG_FAILED
;
4345 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4348 /* neighbor ebgp-multihop. */
4349 DEFUN (neighbor_ebgp_multihop
,
4350 neighbor_ebgp_multihop_cmd
,
4351 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4354 "Allow EBGP neighbors not on directly connected networks\n")
4357 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4360 DEFUN (neighbor_ebgp_multihop_ttl
,
4361 neighbor_ebgp_multihop_ttl_cmd
,
4362 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4365 "Allow EBGP neighbors not on directly connected networks\n"
4366 "maximum hop count\n")
4370 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4371 argv
[idx_number
]->arg
);
4374 DEFUN (no_neighbor_ebgp_multihop
,
4375 no_neighbor_ebgp_multihop_cmd
,
4376 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4380 "Allow EBGP neighbors not on directly connected networks\n"
4381 "maximum hop count\n")
4384 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4388 /* disable-connected-check */
4389 DEFUN (neighbor_disable_connected_check
,
4390 neighbor_disable_connected_check_cmd
,
4391 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4394 "one-hop away EBGP peer using loopback address\n"
4395 "Enforce EBGP neighbors perform multihop\n")
4398 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4399 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4402 DEFUN (no_neighbor_disable_connected_check
,
4403 no_neighbor_disable_connected_check_cmd
,
4404 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4408 "one-hop away EBGP peer using loopback address\n"
4409 "Enforce EBGP neighbors perform multihop\n")
4412 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4413 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4416 DEFUN (neighbor_description
,
4417 neighbor_description_cmd
,
4418 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4421 "Neighbor specific description\n"
4422 "Up to 80 characters describing this neighbor\n")
4429 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4431 return CMD_WARNING_CONFIG_FAILED
;
4433 str
= argv_concat(argv
, argc
, idx_line
);
4435 peer_description_set(peer
, str
);
4437 XFREE(MTYPE_TMP
, str
);
4442 DEFUN (no_neighbor_description
,
4443 no_neighbor_description_cmd
,
4444 "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]",
4448 "Neighbor specific description\n"
4449 "Up to 80 characters describing this neighbor\n")
4454 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4456 return CMD_WARNING_CONFIG_FAILED
;
4458 peer_description_unset(peer
);
4464 /* Neighbor update-source. */
4465 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4466 const char *source_str
)
4471 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4473 return CMD_WARNING_CONFIG_FAILED
;
4480 int ret
= str2sockunion(source_str
, &su
);
4483 peer_update_source_addr_set(peer
, &su
);
4485 if (str2prefix(source_str
, &p
)) {
4487 "%% Invalid update-source, remove prefix length \n");
4488 return CMD_WARNING_CONFIG_FAILED
;
4490 peer_update_source_if_set(peer
, source_str
);
4493 peer_update_source_unset(peer
);
4498 #define BGP_UPDATE_SOURCE_HELP_STR \
4501 "Interface name (requires zebra to be running)\n"
4503 DEFUN (neighbor_update_source
,
4504 neighbor_update_source_cmd
,
4505 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4508 "Source of routing updates\n"
4509 BGP_UPDATE_SOURCE_HELP_STR
)
4513 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4514 argv
[idx_peer_2
]->arg
);
4517 DEFUN (no_neighbor_update_source
,
4518 no_neighbor_update_source_cmd
,
4519 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4523 "Source of routing updates\n"
4524 BGP_UPDATE_SOURCE_HELP_STR
)
4527 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4530 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4531 afi_t afi
, safi_t safi
,
4532 const char *rmap
, int set
)
4537 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4539 return CMD_WARNING_CONFIG_FAILED
;
4542 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4544 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4546 return bgp_vty_return(vty
, ret
);
4549 /* neighbor default-originate. */
4550 DEFUN (neighbor_default_originate
,
4551 neighbor_default_originate_cmd
,
4552 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4555 "Originate default route to this neighbor\n")
4558 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4560 bgp_node_safi(vty
), NULL
, 1);
4563 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4564 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4565 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4566 "Originate default route to this neighbor\n")
4568 DEFUN (neighbor_default_originate_rmap
,
4569 neighbor_default_originate_rmap_cmd
,
4570 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4573 "Originate default route to this neighbor\n"
4574 "Route-map to specify criteria to originate default\n"
4579 return peer_default_originate_set_vty(
4580 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4581 argv
[idx_word
]->arg
, 1);
4585 neighbor_default_originate_rmap
,
4586 neighbor_default_originate_rmap_hidden_cmd
,
4587 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4588 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4589 "Originate default route to this neighbor\n"
4590 "Route-map to specify criteria to originate default\n"
4593 DEFUN (no_neighbor_default_originate
,
4594 no_neighbor_default_originate_cmd
,
4595 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4599 "Originate default route to this neighbor\n"
4600 "Route-map to specify criteria to originate default\n"
4604 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4606 bgp_node_safi(vty
), NULL
, 0);
4610 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4611 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4612 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4613 "Originate default route to this neighbor\n"
4614 "Route-map to specify criteria to originate default\n"
4618 /* Set neighbor's BGP port. */
4619 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4620 const char *port_str
)
4626 peer
= peer_lookup_vty(vty
, ip_str
);
4628 return CMD_WARNING_CONFIG_FAILED
;
4631 sp
= getservbyname("bgp", "tcp");
4632 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4634 port
= strtoul(port_str
, NULL
, 10);
4637 peer_port_set(peer
, port
);
4642 /* Set specified peer's BGP port. */
4643 DEFUN (neighbor_port
,
4645 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4648 "Neighbor's BGP port\n"
4649 "TCP port number\n")
4653 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4654 argv
[idx_number
]->arg
);
4657 DEFUN (no_neighbor_port
,
4658 no_neighbor_port_cmd
,
4659 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4663 "Neighbor's BGP port\n"
4664 "TCP port number\n")
4667 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4671 /* neighbor weight. */
4672 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4673 safi_t safi
, const char *weight_str
)
4677 unsigned long weight
;
4679 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4681 return CMD_WARNING_CONFIG_FAILED
;
4683 weight
= strtoul(weight_str
, NULL
, 10);
4685 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4686 return bgp_vty_return(vty
, ret
);
4689 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4695 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4697 return CMD_WARNING_CONFIG_FAILED
;
4699 ret
= peer_weight_unset(peer
, afi
, safi
);
4700 return bgp_vty_return(vty
, ret
);
4703 DEFUN (neighbor_weight
,
4704 neighbor_weight_cmd
,
4705 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4708 "Set default weight for routes from this neighbor\n"
4713 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4714 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4717 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4718 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4719 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4720 "Set default weight for routes from this neighbor\n"
4723 DEFUN (no_neighbor_weight
,
4724 no_neighbor_weight_cmd
,
4725 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4729 "Set default weight for routes from this neighbor\n"
4733 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4734 bgp_node_afi(vty
), bgp_node_safi(vty
));
4737 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4738 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4739 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4740 "Set default weight for routes from this neighbor\n"
4744 /* Override capability negotiation. */
4745 DEFUN (neighbor_override_capability
,
4746 neighbor_override_capability_cmd
,
4747 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4750 "Override capability negotiation result\n")
4753 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4754 PEER_FLAG_OVERRIDE_CAPABILITY
);
4757 DEFUN (no_neighbor_override_capability
,
4758 no_neighbor_override_capability_cmd
,
4759 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4763 "Override capability negotiation result\n")
4766 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4767 PEER_FLAG_OVERRIDE_CAPABILITY
);
4770 DEFUN (neighbor_strict_capability
,
4771 neighbor_strict_capability_cmd
,
4772 "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4775 "Strict capability negotiation match\n")
4778 return peer_flag_set_vty(vty
, argv
[idx_ip
]->arg
,
4779 PEER_FLAG_STRICT_CAP_MATCH
);
4782 DEFUN (no_neighbor_strict_capability
,
4783 no_neighbor_strict_capability_cmd
,
4784 "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4788 "Strict capability negotiation match\n")
4791 return peer_flag_unset_vty(vty
, argv
[idx_ip
]->arg
,
4792 PEER_FLAG_STRICT_CAP_MATCH
);
4795 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
4796 const char *keep_str
, const char *hold_str
)
4800 u_int32_t keepalive
;
4803 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4805 return CMD_WARNING_CONFIG_FAILED
;
4807 keepalive
= strtoul(keep_str
, NULL
, 10);
4808 holdtime
= strtoul(hold_str
, NULL
, 10);
4810 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
4812 return bgp_vty_return(vty
, ret
);
4815 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
4820 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4822 return CMD_WARNING_CONFIG_FAILED
;
4824 ret
= peer_timers_unset(peer
);
4826 return bgp_vty_return(vty
, ret
);
4829 DEFUN (neighbor_timers
,
4830 neighbor_timers_cmd
,
4831 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
4834 "BGP per neighbor timers\n"
4835 "Keepalive interval\n"
4840 int idx_number_2
= 4;
4841 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
4842 argv
[idx_number
]->arg
,
4843 argv
[idx_number_2
]->arg
);
4846 DEFUN (no_neighbor_timers
,
4847 no_neighbor_timers_cmd
,
4848 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
4852 "BGP per neighbor timers\n"
4853 "Keepalive interval\n"
4857 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
4861 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
4862 const char *time_str
)
4868 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4870 return CMD_WARNING_CONFIG_FAILED
;
4872 connect
= strtoul(time_str
, NULL
, 10);
4874 ret
= peer_timers_connect_set(peer
, connect
);
4876 return bgp_vty_return(vty
, ret
);
4879 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
4884 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4886 return CMD_WARNING_CONFIG_FAILED
;
4888 ret
= peer_timers_connect_unset(peer
);
4890 return bgp_vty_return(vty
, ret
);
4893 DEFUN (neighbor_timers_connect
,
4894 neighbor_timers_connect_cmd
,
4895 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
4898 "BGP per neighbor timers\n"
4899 "BGP connect timer\n"
4904 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
4905 argv
[idx_number
]->arg
);
4908 DEFUN (no_neighbor_timers_connect
,
4909 no_neighbor_timers_connect_cmd
,
4910 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
4914 "BGP per neighbor timers\n"
4915 "BGP connect timer\n"
4919 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
4923 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
4924 const char *time_str
, int set
)
4928 u_int32_t routeadv
= 0;
4930 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4932 return CMD_WARNING_CONFIG_FAILED
;
4935 routeadv
= strtoul(time_str
, NULL
, 10);
4938 ret
= peer_advertise_interval_set(peer
, routeadv
);
4940 ret
= peer_advertise_interval_unset(peer
);
4942 return bgp_vty_return(vty
, ret
);
4945 DEFUN (neighbor_advertise_interval
,
4946 neighbor_advertise_interval_cmd
,
4947 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
4950 "Minimum interval between sending BGP routing updates\n"
4951 "time in seconds\n")
4955 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
4956 argv
[idx_number
]->arg
, 1);
4959 DEFUN (no_neighbor_advertise_interval
,
4960 no_neighbor_advertise_interval_cmd
,
4961 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
4965 "Minimum interval between sending BGP routing updates\n"
4966 "time in seconds\n")
4969 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
4973 /* Time to wait before processing route-map updates */
4974 DEFUN (bgp_set_route_map_delay_timer
,
4975 bgp_set_route_map_delay_timer_cmd
,
4976 "bgp route-map delay-timer (0-600)",
4978 "BGP route-map delay timer\n"
4979 "Time in secs to wait before processing route-map changes\n"
4980 "0 disables the timer, no route updates happen when route-maps change\n")
4983 u_int32_t rmap_delay_timer
;
4985 if (argv
[idx_number
]->arg
) {
4986 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4987 bm
->rmap_update_timer
= rmap_delay_timer
;
4989 /* if the dynamic update handling is being disabled, and a timer
4991 * running, stop the timer and act as if the timer has already
4994 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
4995 BGP_TIMER_OFF(bm
->t_rmap_update
);
4996 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5001 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5002 return CMD_WARNING_CONFIG_FAILED
;
5006 DEFUN (no_bgp_set_route_map_delay_timer
,
5007 no_bgp_set_route_map_delay_timer_cmd
,
5008 "no bgp route-map delay-timer [(0-600)]",
5011 "Default BGP route-map delay timer\n"
5012 "Reset to default time to wait for processing route-map changes\n"
5013 "0 disables the timer, no route updates happen when route-maps change\n")
5016 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5022 /* neighbor interface */
5023 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5028 peer
= peer_lookup_vty(vty
, ip_str
);
5029 if (!peer
|| peer
->conf_if
) {
5030 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5031 return CMD_WARNING_CONFIG_FAILED
;
5035 peer_interface_set(peer
, str
);
5037 peer_interface_unset(peer
);
5042 DEFUN (neighbor_interface
,
5043 neighbor_interface_cmd
,
5044 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5052 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5055 DEFUN (no_neighbor_interface
,
5056 no_neighbor_interface_cmd
,
5057 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5065 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5068 DEFUN (neighbor_distribute_list
,
5069 neighbor_distribute_list_cmd
,
5070 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5073 "Filter updates to/from this neighbor\n"
5074 "IP access-list number\n"
5075 "IP access-list number (expanded range)\n"
5076 "IP Access-list name\n"
5077 "Filter incoming updates\n"
5078 "Filter outgoing updates\n")
5085 const char *pstr
= argv
[idx_peer
]->arg
;
5086 const char *acl
= argv
[idx_acl
]->arg
;
5087 const char *inout
= argv
[argc
- 1]->text
;
5089 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5091 return CMD_WARNING_CONFIG_FAILED
;
5093 /* Check filter direction. */
5094 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5095 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5098 return bgp_vty_return(vty
, ret
);
5102 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5103 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5104 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5105 "Filter updates to/from this neighbor\n"
5106 "IP access-list number\n"
5107 "IP access-list number (expanded range)\n"
5108 "IP Access-list name\n"
5109 "Filter incoming updates\n"
5110 "Filter outgoing updates\n")
5112 DEFUN (no_neighbor_distribute_list
,
5113 no_neighbor_distribute_list_cmd
,
5114 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5118 "Filter updates to/from this neighbor\n"
5119 "IP access-list number\n"
5120 "IP access-list number (expanded range)\n"
5121 "IP Access-list name\n"
5122 "Filter incoming updates\n"
5123 "Filter outgoing updates\n")
5129 const char *pstr
= argv
[idx_peer
]->arg
;
5130 const char *inout
= argv
[argc
- 1]->text
;
5132 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5134 return CMD_WARNING_CONFIG_FAILED
;
5136 /* Check filter direction. */
5137 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5138 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5141 return bgp_vty_return(vty
, ret
);
5145 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5146 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5147 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5148 "Filter updates to/from this neighbor\n"
5149 "IP access-list number\n"
5150 "IP access-list number (expanded range)\n"
5151 "IP Access-list name\n"
5152 "Filter incoming updates\n"
5153 "Filter outgoing updates\n")
5155 /* Set prefix list to the peer. */
5156 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5157 afi_t afi
, safi_t safi
,
5158 const char *name_str
,
5159 const char *direct_str
)
5163 int direct
= FILTER_IN
;
5165 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5167 return CMD_WARNING_CONFIG_FAILED
;
5169 /* Check filter direction. */
5170 if (strncmp(direct_str
, "i", 1) == 0)
5172 else if (strncmp(direct_str
, "o", 1) == 0)
5173 direct
= FILTER_OUT
;
5175 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5177 return bgp_vty_return(vty
, ret
);
5180 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5181 afi_t afi
, safi_t safi
,
5182 const char *direct_str
)
5186 int direct
= FILTER_IN
;
5188 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5190 return CMD_WARNING_CONFIG_FAILED
;
5192 /* Check filter direction. */
5193 if (strncmp(direct_str
, "i", 1) == 0)
5195 else if (strncmp(direct_str
, "o", 1) == 0)
5196 direct
= FILTER_OUT
;
5198 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5200 return bgp_vty_return(vty
, ret
);
5203 DEFUN (neighbor_prefix_list
,
5204 neighbor_prefix_list_cmd
,
5205 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5208 "Filter updates to/from this neighbor\n"
5209 "Name of a prefix list\n"
5210 "Filter incoming updates\n"
5211 "Filter outgoing updates\n")
5216 return peer_prefix_list_set_vty(
5217 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5218 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5221 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5222 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5223 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5224 "Filter updates to/from this neighbor\n"
5225 "Name of a prefix list\n"
5226 "Filter incoming updates\n"
5227 "Filter outgoing updates\n")
5229 DEFUN (no_neighbor_prefix_list
,
5230 no_neighbor_prefix_list_cmd
,
5231 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5235 "Filter updates to/from this neighbor\n"
5236 "Name of a prefix list\n"
5237 "Filter incoming updates\n"
5238 "Filter outgoing updates\n")
5242 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5243 bgp_node_afi(vty
), bgp_node_safi(vty
),
5244 argv
[idx_in_out
]->arg
);
5247 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5248 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5249 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5250 "Filter updates to/from this neighbor\n"
5251 "Name of a prefix list\n"
5252 "Filter incoming updates\n"
5253 "Filter outgoing updates\n")
5255 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5256 safi_t safi
, const char *name_str
,
5257 const char *direct_str
)
5261 int direct
= FILTER_IN
;
5263 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5265 return CMD_WARNING_CONFIG_FAILED
;
5267 /* Check filter direction. */
5268 if (strncmp(direct_str
, "i", 1) == 0)
5270 else if (strncmp(direct_str
, "o", 1) == 0)
5271 direct
= FILTER_OUT
;
5273 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5275 return bgp_vty_return(vty
, ret
);
5278 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5279 safi_t safi
, const char *direct_str
)
5283 int direct
= FILTER_IN
;
5285 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5287 return CMD_WARNING_CONFIG_FAILED
;
5289 /* Check filter direction. */
5290 if (strncmp(direct_str
, "i", 1) == 0)
5292 else if (strncmp(direct_str
, "o", 1) == 0)
5293 direct
= FILTER_OUT
;
5295 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5297 return bgp_vty_return(vty
, ret
);
5300 DEFUN (neighbor_filter_list
,
5301 neighbor_filter_list_cmd
,
5302 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5305 "Establish BGP filters\n"
5306 "AS path access-list name\n"
5307 "Filter incoming routes\n"
5308 "Filter outgoing routes\n")
5313 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5314 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5315 argv
[idx_in_out
]->arg
);
5318 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5319 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5320 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5321 "Establish BGP filters\n"
5322 "AS path access-list name\n"
5323 "Filter incoming routes\n"
5324 "Filter outgoing routes\n")
5326 DEFUN (no_neighbor_filter_list
,
5327 no_neighbor_filter_list_cmd
,
5328 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5332 "Establish BGP filters\n"
5333 "AS path access-list name\n"
5334 "Filter incoming routes\n"
5335 "Filter outgoing routes\n")
5339 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5340 bgp_node_afi(vty
), bgp_node_safi(vty
),
5341 argv
[idx_in_out
]->arg
);
5344 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5345 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5346 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5347 "Establish BGP filters\n"
5348 "AS path access-list name\n"
5349 "Filter incoming routes\n"
5350 "Filter outgoing routes\n")
5352 /* Set route-map to the peer. */
5353 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5354 afi_t afi
, safi_t safi
, const char *name_str
,
5355 const char *direct_str
)
5359 int direct
= RMAP_IN
;
5361 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5363 return CMD_WARNING_CONFIG_FAILED
;
5365 /* Check filter direction. */
5366 if (strncmp(direct_str
, "in", 2) == 0)
5368 else if (strncmp(direct_str
, "o", 1) == 0)
5371 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5373 return bgp_vty_return(vty
, ret
);
5376 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5377 afi_t afi
, safi_t safi
,
5378 const char *direct_str
)
5382 int direct
= RMAP_IN
;
5384 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5386 return CMD_WARNING_CONFIG_FAILED
;
5388 /* Check filter direction. */
5389 if (strncmp(direct_str
, "in", 2) == 0)
5391 else if (strncmp(direct_str
, "o", 1) == 0)
5394 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5396 return bgp_vty_return(vty
, ret
);
5399 DEFUN (neighbor_route_map
,
5400 neighbor_route_map_cmd
,
5401 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5404 "Apply route map to neighbor\n"
5405 "Name of route map\n"
5406 "Apply map to incoming routes\n"
5407 "Apply map to outbound routes\n")
5412 return peer_route_map_set_vty(
5413 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5414 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5417 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5418 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5419 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5420 "Apply route map to neighbor\n"
5421 "Name of route map\n"
5422 "Apply map to incoming routes\n"
5423 "Apply map to outbound routes\n")
5425 DEFUN (no_neighbor_route_map
,
5426 no_neighbor_route_map_cmd
,
5427 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5431 "Apply route map to neighbor\n"
5432 "Name of route map\n"
5433 "Apply map to incoming routes\n"
5434 "Apply map to outbound routes\n")
5438 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5439 bgp_node_afi(vty
), bgp_node_safi(vty
),
5440 argv
[idx_in_out
]->arg
);
5443 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5444 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5445 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5446 "Apply route map to neighbor\n"
5447 "Name of route map\n"
5448 "Apply map to incoming routes\n"
5449 "Apply map to outbound routes\n")
5451 /* Set unsuppress-map to the peer. */
5452 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5453 afi_t afi
, safi_t safi
,
5454 const char *name_str
)
5459 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5461 return CMD_WARNING_CONFIG_FAILED
;
5463 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5465 return bgp_vty_return(vty
, ret
);
5468 /* Unset route-map from the peer. */
5469 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5470 afi_t afi
, safi_t safi
)
5475 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5477 return CMD_WARNING_CONFIG_FAILED
;
5479 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5481 return bgp_vty_return(vty
, ret
);
5484 DEFUN (neighbor_unsuppress_map
,
5485 neighbor_unsuppress_map_cmd
,
5486 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5489 "Route-map to selectively unsuppress suppressed routes\n"
5490 "Name of route map\n")
5494 return peer_unsuppress_map_set_vty(
5495 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5496 argv
[idx_word
]->arg
);
5499 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5500 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5501 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5502 "Route-map to selectively unsuppress suppressed routes\n"
5503 "Name of route map\n")
5505 DEFUN (no_neighbor_unsuppress_map
,
5506 no_neighbor_unsuppress_map_cmd
,
5507 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5511 "Route-map to selectively unsuppress suppressed routes\n"
5512 "Name of route map\n")
5515 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5517 bgp_node_safi(vty
));
5520 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5521 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5522 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5523 "Route-map to selectively unsuppress suppressed routes\n"
5524 "Name of route map\n")
5526 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5527 afi_t afi
, safi_t safi
,
5528 const char *num_str
,
5529 const char *threshold_str
, int warning
,
5530 const char *restart_str
)
5538 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5540 return CMD_WARNING_CONFIG_FAILED
;
5542 max
= strtoul(num_str
, NULL
, 10);
5544 threshold
= atoi(threshold_str
);
5546 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5549 restart
= atoi(restart_str
);
5553 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5556 return bgp_vty_return(vty
, ret
);
5559 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5560 afi_t afi
, safi_t safi
)
5565 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5567 return CMD_WARNING_CONFIG_FAILED
;
5569 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5571 return bgp_vty_return(vty
, ret
);
5574 /* Maximum number of prefix configuration. prefix count is different
5575 for each peer configuration. So this configuration can be set for
5576 each peer configuration. */
5577 DEFUN (neighbor_maximum_prefix
,
5578 neighbor_maximum_prefix_cmd
,
5579 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5582 "Maximum number of prefix accept from this peer\n"
5583 "maximum no. of prefix limit\n")
5587 return peer_maximum_prefix_set_vty(
5588 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5589 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5592 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5593 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5594 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5595 "Maximum number of prefix accept from this peer\n"
5596 "maximum no. of prefix limit\n")
5598 DEFUN (neighbor_maximum_prefix_threshold
,
5599 neighbor_maximum_prefix_threshold_cmd
,
5600 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5603 "Maximum number of prefix accept from this peer\n"
5604 "maximum no. of prefix limit\n"
5605 "Threshold value (%) at which to generate a warning msg\n")
5609 int idx_number_2
= 4;
5610 return peer_maximum_prefix_set_vty(
5611 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5612 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5616 neighbor_maximum_prefix_threshold
,
5617 neighbor_maximum_prefix_threshold_hidden_cmd
,
5618 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5619 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5620 "Maximum number of prefix accept from this peer\n"
5621 "maximum no. of prefix limit\n"
5622 "Threshold value (%) at which to generate a warning msg\n")
5624 DEFUN (neighbor_maximum_prefix_warning
,
5625 neighbor_maximum_prefix_warning_cmd
,
5626 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5629 "Maximum number of prefix accept from this peer\n"
5630 "maximum no. of prefix limit\n"
5631 "Only give warning message when limit is exceeded\n")
5635 return peer_maximum_prefix_set_vty(
5636 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5637 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5641 neighbor_maximum_prefix_warning
,
5642 neighbor_maximum_prefix_warning_hidden_cmd
,
5643 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5644 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5645 "Maximum number of prefix accept from this peer\n"
5646 "maximum no. of prefix limit\n"
5647 "Only give warning message when limit is exceeded\n")
5649 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5650 neighbor_maximum_prefix_threshold_warning_cmd
,
5651 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5654 "Maximum number of prefix accept from this peer\n"
5655 "maximum no. of prefix limit\n"
5656 "Threshold value (%) at which to generate a warning msg\n"
5657 "Only give warning message when limit is exceeded\n")
5661 int idx_number_2
= 4;
5662 return peer_maximum_prefix_set_vty(
5663 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5664 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5668 neighbor_maximum_prefix_threshold_warning
,
5669 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5670 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5671 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5672 "Maximum number of prefix accept from this peer\n"
5673 "maximum no. of prefix limit\n"
5674 "Threshold value (%) at which to generate a warning msg\n"
5675 "Only give warning message when limit is exceeded\n")
5677 DEFUN (neighbor_maximum_prefix_restart
,
5678 neighbor_maximum_prefix_restart_cmd
,
5679 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5682 "Maximum number of prefix accept from this peer\n"
5683 "maximum no. of prefix limit\n"
5684 "Restart bgp connection after limit is exceeded\n"
5685 "Restart interval in minutes")
5689 int idx_number_2
= 5;
5690 return peer_maximum_prefix_set_vty(
5691 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5692 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5696 neighbor_maximum_prefix_restart
,
5697 neighbor_maximum_prefix_restart_hidden_cmd
,
5698 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5699 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5700 "Maximum number of prefix accept from this peer\n"
5701 "maximum no. of prefix limit\n"
5702 "Restart bgp connection after limit is exceeded\n"
5703 "Restart interval in minutes")
5705 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5706 neighbor_maximum_prefix_threshold_restart_cmd
,
5707 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5710 "Maximum number of prefixes to accept from this peer\n"
5711 "maximum no. of prefix limit\n"
5712 "Threshold value (%) at which to generate a warning msg\n"
5713 "Restart bgp connection after limit is exceeded\n"
5714 "Restart interval in minutes\n")
5718 int idx_number_2
= 4;
5719 int idx_number_3
= 6;
5720 return peer_maximum_prefix_set_vty(
5721 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5722 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5723 argv
[idx_number_3
]->arg
);
5727 neighbor_maximum_prefix_threshold_restart
,
5728 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5729 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5730 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5731 "Maximum number of prefixes to accept from this peer\n"
5732 "maximum no. of prefix limit\n"
5733 "Threshold value (%) at which to generate a warning msg\n"
5734 "Restart bgp connection after limit is exceeded\n"
5735 "Restart interval in minutes\n")
5737 DEFUN (no_neighbor_maximum_prefix
,
5738 no_neighbor_maximum_prefix_cmd
,
5739 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5743 "Maximum number of prefixes to accept from this peer\n"
5744 "maximum no. of prefix limit\n"
5745 "Threshold value (%) at which to generate a warning msg\n"
5746 "Restart bgp connection after limit is exceeded\n"
5747 "Restart interval in minutes\n"
5748 "Only give warning message when limit is exceeded\n")
5751 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5753 bgp_node_safi(vty
));
5757 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5758 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5759 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5760 "Maximum number of prefixes to accept from this peer\n"
5761 "maximum no. of prefix limit\n"
5762 "Threshold value (%) at which to generate a warning msg\n"
5763 "Restart bgp connection after limit is exceeded\n"
5764 "Restart interval in minutes\n"
5765 "Only give warning message when limit is exceeded\n")
5768 /* "neighbor allowas-in" */
5769 DEFUN (neighbor_allowas_in
,
5770 neighbor_allowas_in_cmd
,
5771 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5774 "Accept as-path with my AS present in it\n"
5775 "Number of occurances of AS number\n"
5776 "Only accept my AS in the as-path if the route was originated in my AS\n")
5779 int idx_number_origin
= 3;
5785 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5787 return CMD_WARNING_CONFIG_FAILED
;
5789 if (argc
<= idx_number_origin
)
5792 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
5795 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
5798 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5801 return bgp_vty_return(vty
, ret
);
5805 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
5806 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5807 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5808 "Accept as-path with my AS present in it\n"
5809 "Number of occurances of AS number\n"
5810 "Only accept my AS in the as-path if the route was originated in my AS\n")
5812 DEFUN (no_neighbor_allowas_in
,
5813 no_neighbor_allowas_in_cmd
,
5814 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5818 "allow local ASN appears in aspath attribute\n"
5819 "Number of occurances of AS number\n"
5820 "Only accept my AS in the as-path if the route was originated in my AS\n")
5826 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5828 return CMD_WARNING_CONFIG_FAILED
;
5830 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
5831 bgp_node_safi(vty
));
5833 return bgp_vty_return(vty
, ret
);
5837 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
5838 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5839 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5840 "allow local ASN appears in aspath attribute\n"
5841 "Number of occurances of AS number\n"
5842 "Only accept my AS in the as-path if the route was originated in my AS\n")
5844 DEFUN (neighbor_ttl_security
,
5845 neighbor_ttl_security_cmd
,
5846 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
5849 "BGP ttl-security parameters\n"
5850 "Specify the maximum number of hops to the BGP peer\n"
5851 "Number of hops to BGP peer\n")
5858 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5860 return CMD_WARNING_CONFIG_FAILED
;
5862 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5865 * If 'neighbor swpX', then this is for directly connected peers,
5866 * we should not accept a ttl-security hops value greater than 1.
5868 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
5870 "%s is directly connected peer, hops cannot exceed 1\n",
5871 argv
[idx_peer
]->arg
);
5872 return CMD_WARNING_CONFIG_FAILED
;
5875 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
5878 DEFUN (no_neighbor_ttl_security
,
5879 no_neighbor_ttl_security_cmd
,
5880 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
5884 "BGP ttl-security parameters\n"
5885 "Specify the maximum number of hops to the BGP peer\n"
5886 "Number of hops to BGP peer\n")
5891 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5893 return CMD_WARNING_CONFIG_FAILED
;
5895 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
5898 DEFUN (neighbor_addpath_tx_all_paths
,
5899 neighbor_addpath_tx_all_paths_cmd
,
5900 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
5903 "Use addpath to advertise all paths to a neighbor\n")
5908 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5910 return CMD_WARNING_CONFIG_FAILED
;
5912 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5914 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
5917 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
5918 neighbor_addpath_tx_all_paths_hidden_cmd
,
5919 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
5920 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5921 "Use addpath to advertise all paths to a neighbor\n")
5923 DEFUN (no_neighbor_addpath_tx_all_paths
,
5924 no_neighbor_addpath_tx_all_paths_cmd
,
5925 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
5929 "Use addpath to advertise all paths to a neighbor\n")
5932 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5933 bgp_node_afi(vty
), bgp_node_safi(vty
),
5934 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
5937 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
5938 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
5939 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
5940 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5941 "Use addpath to advertise all paths to a neighbor\n")
5943 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
5944 neighbor_addpath_tx_bestpath_per_as_cmd
,
5945 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
5948 "Use addpath to advertise the bestpath per each neighboring AS\n")
5953 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5955 return CMD_WARNING_CONFIG_FAILED
;
5957 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5959 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
5962 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
5963 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
5964 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
5965 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5966 "Use addpath to advertise the bestpath per each neighboring AS\n")
5968 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
5969 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
5970 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
5974 "Use addpath to advertise the bestpath per each neighboring AS\n")
5977 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5978 bgp_node_afi(vty
), bgp_node_safi(vty
),
5979 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
5982 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
5983 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
5984 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
5985 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5986 "Use addpath to advertise the bestpath per each neighboring AS\n")
5988 DEFUN_NOSH (address_family_ipv4_safi
,
5989 address_family_ipv4_safi_cmd
,
5990 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]",
5991 "Enter Address Family command mode\n"
5993 BGP_SAFI_WITH_LABEL_HELP_STR
)
5997 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
5998 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6000 vty
->node
= BGP_IPV4_NODE
;
6005 DEFUN_NOSH (address_family_ipv6_safi
,
6006 address_family_ipv6_safi_cmd
,
6007 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]",
6008 "Enter Address Family command mode\n"
6010 BGP_SAFI_WITH_LABEL_HELP_STR
)
6013 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6014 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6016 vty
->node
= BGP_IPV6_NODE
;
6021 #ifdef KEEP_OLD_VPN_COMMANDS
6022 DEFUN_NOSH (address_family_vpnv4
,
6023 address_family_vpnv4_cmd
,
6024 "address-family vpnv4 [unicast]",
6025 "Enter Address Family command mode\n"
6027 "Address Family modifier\n")
6029 vty
->node
= BGP_VPNV4_NODE
;
6033 DEFUN_NOSH (address_family_vpnv6
,
6034 address_family_vpnv6_cmd
,
6035 "address-family vpnv6 [unicast]",
6036 "Enter Address Family command mode\n"
6038 "Address Family modifier\n")
6040 vty
->node
= BGP_VPNV6_NODE
;
6045 DEFUN_NOSH (address_family_evpn
,
6046 address_family_evpn_cmd
,
6047 "address-family l2vpn evpn",
6048 "Enter Address Family command mode\n"
6050 "Address Family modifier\n")
6052 vty
->node
= BGP_EVPN_NODE
;
6056 DEFUN_NOSH (exit_address_family
,
6057 exit_address_family_cmd
,
6058 "exit-address-family",
6059 "Exit from Address Family configuration mode\n")
6061 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
6062 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
6063 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
6064 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
6065 || vty
->node
== BGP_EVPN_NODE
)
6066 vty
->node
= BGP_NODE
;
6070 /* Recalculate bestpath and re-advertise a prefix */
6071 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
6072 const char *ip_str
, afi_t afi
, safi_t safi
,
6073 struct prefix_rd
*prd
)
6076 struct prefix match
;
6077 struct bgp_node
*rn
;
6078 struct bgp_node
*rm
;
6080 struct bgp_table
*table
;
6081 struct bgp_table
*rib
;
6083 /* BGP structure lookup. */
6085 bgp
= bgp_lookup_by_name(view_name
);
6087 vty_out(vty
, "%% Can't find BGP instance %s\n",
6092 bgp
= bgp_get_default();
6094 vty_out(vty
, "%% No BGP process is configured\n");
6099 /* Check IP address argument. */
6100 ret
= str2prefix(ip_str
, &match
);
6102 vty_out(vty
, "%% address is malformed\n");
6106 match
.family
= afi2family(afi
);
6107 rib
= bgp
->rib
[afi
][safi
];
6109 if (safi
== SAFI_MPLS_VPN
) {
6110 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
6111 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
6114 if ((table
= rn
->info
) != NULL
) {
6115 if ((rm
= bgp_node_match(table
, &match
))
6118 == match
.prefixlen
) {
6120 BGP_NODE_USER_CLEAR
);
6121 bgp_process(bgp
, rm
, afi
, safi
);
6123 bgp_unlock_node(rm
);
6128 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
6129 if (rn
->p
.prefixlen
== match
.prefixlen
) {
6130 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
6131 bgp_process(bgp
, rn
, afi
, safi
);
6133 bgp_unlock_node(rn
);
6140 /* one clear bgp command to rule them all */
6141 DEFUN (clear_ip_bgp_all
,
6142 clear_ip_bgp_all_cmd
,
6143 "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>]",
6147 BGP_INSTANCE_HELP_STR
6149 "BGP neighbor address to clear\n"
6150 "BGP IPv6 neighbor to clear\n"
6151 "BGP neighbor on interface to clear\n"
6152 "Clear peers with the AS number\n"
6153 "Clear all external peers\n"
6154 "Clear all members of peer-group\n"
6155 "BGP peer-group name\n"
6157 BGP_SAFI_WITH_LABEL_HELP_STR
6162 "Push out prefix-list ORF and do inbound soft reconfig\n"
6167 afi_t afi
= AFI_IP6
;
6168 safi_t safi
= SAFI_UNICAST
;
6169 enum clear_sort clr_sort
= clear_peer
;
6170 enum bgp_clear_type clr_type
;
6171 char *clr_arg
= NULL
;
6175 /* clear [ip] bgp */
6176 if (argv_find(argv
, argc
, "ip", &idx
))
6179 /* [<view|vrf> VIEWVRFNAME] */
6180 if (argv_find(argv
, argc
, "view", &idx
)
6181 || argv_find(argv
, argc
, "vrf", &idx
)) {
6182 vrf
= argv
[idx
+ 1]->arg
;
6186 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
6187 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
6188 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
6190 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
6191 if (argv_find(argv
, argc
, "*", &idx
)) {
6192 clr_sort
= clear_all
;
6193 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6194 clr_sort
= clear_peer
;
6195 clr_arg
= argv
[idx
]->arg
;
6196 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
6197 clr_sort
= clear_peer
;
6198 clr_arg
= argv
[idx
]->arg
;
6199 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
6200 clr_sort
= clear_group
;
6202 clr_arg
= argv
[idx
]->arg
;
6203 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
6204 clr_sort
= clear_peer
;
6205 clr_arg
= argv
[idx
]->arg
;
6206 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
6207 clr_sort
= clear_as
;
6208 clr_arg
= argv
[idx
]->arg
;
6209 } else if (argv_find(argv
, argc
, "external", &idx
)) {
6210 clr_sort
= clear_external
;
6213 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
6214 if (argv_find(argv
, argc
, "soft", &idx
)) {
6215 if (argv_find(argv
, argc
, "in", &idx
)
6216 || argv_find(argv
, argc
, "out", &idx
))
6217 clr_type
= strmatch(argv
[idx
]->text
, "in")
6219 : BGP_CLEAR_SOFT_OUT
;
6221 clr_type
= BGP_CLEAR_SOFT_BOTH
;
6222 } else if (argv_find(argv
, argc
, "in", &idx
)) {
6223 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
6224 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
6225 : BGP_CLEAR_SOFT_IN
;
6226 } else if (argv_find(argv
, argc
, "out", &idx
)) {
6227 clr_type
= BGP_CLEAR_SOFT_OUT
;
6229 clr_type
= BGP_CLEAR_SOFT_NONE
;
6231 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
6234 DEFUN (clear_ip_bgp_prefix
,
6235 clear_ip_bgp_prefix_cmd
,
6236 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
6240 BGP_INSTANCE_HELP_STR
6241 "Clear bestpath and re-advertise\n"
6245 char *prefix
= NULL
;
6249 /* [<view|vrf> VIEWVRFNAME] */
6250 if (argv_find(argv
, argc
, "WORD", &idx
))
6251 vrf
= argv
[idx
]->arg
;
6253 prefix
= argv
[argc
- 1]->arg
;
6255 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
6258 DEFUN (clear_bgp_ipv6_safi_prefix
,
6259 clear_bgp_ipv6_safi_prefix_cmd
,
6260 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
6266 "Clear bestpath and re-advertise\n"
6270 int idx_ipv6_prefixlen
= 5;
6271 return bgp_clear_prefix(
6272 vty
, NULL
, argv
[idx_ipv6_prefixlen
]->arg
, AFI_IP6
,
6273 bgp_vty_safi_from_str(argv
[idx_safi
]->text
), NULL
);
6276 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
6277 clear_bgp_instance_ipv6_safi_prefix_cmd
,
6278 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
6282 BGP_INSTANCE_HELP_STR
6285 "Clear bestpath and re-advertise\n"
6290 int idx_ipv6_prefixlen
= 7;
6291 return bgp_clear_prefix(
6292 vty
, argv
[idx_word
]->arg
, argv
[idx_ipv6_prefixlen
]->arg
,
6293 AFI_IP6
, bgp_vty_safi_from_str(argv
[idx_safi
]->text
), NULL
);
6296 DEFUN (show_bgp_views
,
6298 "show [ip] bgp views",
6302 "Show the defined BGP views\n")
6304 struct list
*inst
= bm
->bgp
;
6305 struct listnode
*node
;
6308 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
6309 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
6313 vty_out(vty
, "Defined BGP views:\n");
6314 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
6316 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
6318 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
6325 DEFUN (show_bgp_vrfs
,
6327 "show [ip] bgp vrfs [json]",
6334 struct list
*inst
= bm
->bgp
;
6335 struct listnode
*node
;
6337 u_char uj
= use_json(argc
, argv
);
6338 json_object
*json
= NULL
;
6339 json_object
*json_vrfs
= NULL
;
6341 static char header
[] =
6342 "Type Id RouterId #PeersCfg #PeersEstb Name";
6344 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
6345 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
6350 json
= json_object_new_object();
6351 json_vrfs
= json_object_new_object();
6354 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
6355 const char *name
, *type
;
6357 struct listnode
*node
, *nnode
;
6358 int peers_cfg
, peers_estb
;
6359 json_object
*json_vrf
= NULL
;
6363 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
6367 if (!uj
&& count
== 1)
6368 vty_out(vty
, "%s\n", header
);
6370 peers_cfg
= peers_estb
= 0;
6372 json_vrf
= json_object_new_object();
6375 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
6376 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
6379 if (peer
->status
== Established
)
6383 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
6391 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
) ? -1 : bgp
->vrf_id
;
6393 json_object_string_add(json_vrf
, "type", type
);
6394 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
6395 json_object_string_add(json_vrf
, "routerId",
6396 inet_ntoa(bgp
->router_id
));
6397 json_object_int_add(json_vrf
, "numConfiguredPeers",
6399 json_object_int_add(json_vrf
, "numEstablishedPeers",
6402 json_object_object_add(json_vrfs
, name
, json_vrf
);
6404 vty_out(vty
, "%4s %-5d %-16s %9u %10u %s\n", type
,
6405 vrf_id_ui
, inet_ntoa(bgp
->router_id
), peers_cfg
,
6410 json_object_object_add(json
, "vrfs", json_vrfs
);
6412 json_object_int_add(json
, "totalVrfs", count
);
6414 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
6415 json
, JSON_C_TO_STRING_PRETTY
));
6416 json_object_free(json
);
6420 "\nTotal number of VRFs (including default): %d\n",
6427 DEFUN (show_bgp_memory
,
6428 show_bgp_memory_cmd
,
6429 "show [ip] bgp memory",
6433 "Global BGP memory statistics\n")
6435 char memstrbuf
[MTYPE_MEMSTR_LEN
];
6436 unsigned long count
;
6438 /* RIB related usage stats */
6439 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
6440 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
6441 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6442 count
* sizeof(struct bgp_node
)));
6444 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
6445 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
6446 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6447 count
* sizeof(struct bgp_info
)));
6448 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
6449 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
6451 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6452 count
* sizeof(struct bgp_info_extra
)));
6454 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
6455 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
6456 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6457 count
* sizeof(struct bgp_static
)));
6459 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
6460 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
6461 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6462 count
* sizeof(struct bpacket
)));
6465 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
6466 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
6467 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6468 count
* sizeof(struct bgp_adj_in
)));
6469 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
6470 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
6471 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6472 count
* sizeof(struct bgp_adj_out
)));
6474 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
6475 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
6477 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6478 count
* sizeof(struct bgp_nexthop_cache
)));
6480 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
6481 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
6483 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6484 count
* sizeof(struct bgp_damp_info
)));
6487 count
= attr_count();
6488 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
6489 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6490 count
* sizeof(struct attr
)));
6492 if ((count
= attr_unknown_count()))
6493 vty_out(vty
, "%ld unknown attributes\n", count
);
6495 /* AS_PATH attributes */
6496 count
= aspath_count();
6497 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
6498 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6499 count
* sizeof(struct aspath
)));
6501 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
6502 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
6503 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6504 count
* sizeof(struct assegment
)));
6506 /* Other attributes */
6507 if ((count
= community_count()))
6508 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
6509 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6510 count
* sizeof(struct community
)));
6511 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
6512 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
6513 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6514 count
* sizeof(struct ecommunity
)));
6515 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
6517 "%ld BGP large-community entries, using %s of memory\n",
6518 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6519 count
* sizeof(struct lcommunity
)));
6521 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
6522 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
6523 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6524 count
* sizeof(struct cluster_list
)));
6526 /* Peer related usage */
6527 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
6528 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
6529 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6530 count
* sizeof(struct peer
)));
6532 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
6533 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
6534 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6535 count
* sizeof(struct peer_group
)));
6538 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
6539 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
6540 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6541 count
* sizeof(struct hash
)));
6542 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
6543 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
6544 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6545 count
* sizeof(struct hash_backet
)));
6546 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
6547 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
6548 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6549 count
* sizeof(regex_t
)));
6553 /* Show BGP peer's summary information. */
6554 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
6555 u_char use_json
, json_object
*json
)
6558 struct listnode
*node
, *nnode
;
6559 unsigned int count
= 0, dn_count
= 0;
6560 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
6561 char neighbor_buf
[VTY_BUFSIZ
];
6562 int neighbor_col_default_width
= 16;
6564 int max_neighbor_width
= 0;
6566 json_object
*json_peer
= NULL
;
6567 json_object
*json_peers
= NULL
;
6569 /* labeled-unicast routes are installed in the unicast table so in order
6571 * display the correct PfxRcd value we must look at SAFI_UNICAST
6573 if (safi
== SAFI_LABELED_UNICAST
)
6574 pfx_rcd_safi
= SAFI_UNICAST
;
6576 pfx_rcd_safi
= safi
;
6580 json
= json_object_new_object();
6582 json_peers
= json_object_new_object();
6584 /* Loop over all neighbors that will be displayed to determine
6586 * characters are needed for the Neighbor column
6588 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
6589 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
6592 if (peer
->afc
[afi
][safi
]) {
6593 memset(dn_flag
, '\0', sizeof(dn_flag
));
6594 if (peer_dynamic_neighbor(peer
))
6598 && bgp_flag_check(bgp
,
6599 BGP_FLAG_SHOW_HOSTNAME
))
6600 sprintf(neighbor_buf
, "%s%s(%s) ",
6601 dn_flag
, peer
->hostname
,
6604 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
6607 len
= strlen(neighbor_buf
);
6609 if (len
> max_neighbor_width
)
6610 max_neighbor_width
= len
;
6614 /* Originally we displayed the Neighbor column as 16
6615 * characters wide so make that the default
6617 if (max_neighbor_width
< neighbor_col_default_width
)
6618 max_neighbor_width
= neighbor_col_default_width
;
6621 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
6622 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
6625 if (peer
->afc
[afi
][safi
]) {
6628 char memstrbuf
[MTYPE_MEMSTR_LEN
];
6631 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
6635 /* Usage summary and header */
6637 json_object_string_add(
6639 inet_ntoa(bgp
->router_id
));
6640 json_object_int_add(json
, "as",
6642 json_object_int_add(json
, "vrfId",
6644 json_object_string_add(
6647 == BGP_INSTANCE_TYPE_DEFAULT
)
6652 "BGP router identifier %s, local AS number %u vrf-id %d",
6653 inet_ntoa(bgp
->router_id
),
6654 bgp
->as
, vrf_id_ui
);
6658 if (bgp_update_delay_configured(bgp
)) {
6660 json_object_int_add(
6663 bgp
->v_update_delay
);
6665 if (bgp
->v_update_delay
6666 != bgp
->v_establish_wait
)
6667 json_object_int_add(
6669 "updateDelayEstablishWait",
6670 bgp
->v_establish_wait
);
6672 if (bgp_update_delay_active(
6674 json_object_string_add(
6676 "updateDelayFirstNeighbor",
6677 bgp
->update_delay_begin_time
);
6678 json_object_boolean_true_add(
6680 "updateDelayInProgress");
6682 if (bgp
->update_delay_over
) {
6683 json_object_string_add(
6685 "updateDelayFirstNeighbor",
6686 bgp
->update_delay_begin_time
);
6687 json_object_string_add(
6689 "updateDelayBestpathResumed",
6690 bgp
->update_delay_end_time
);
6691 json_object_string_add(
6693 "updateDelayZebraUpdateResume",
6694 bgp
->update_delay_zebra_resume_time
);
6695 json_object_string_add(
6697 "updateDelayPeerUpdateResume",
6698 bgp
->update_delay_peers_resume_time
);
6703 "Read-only mode update-delay limit: %d seconds\n",
6704 bgp
->v_update_delay
);
6705 if (bgp
->v_update_delay
6706 != bgp
->v_establish_wait
)
6708 " Establish wait: %d seconds\n",
6709 bgp
->v_establish_wait
);
6711 if (bgp_update_delay_active(
6714 " First neighbor established: %s\n",
6715 bgp
->update_delay_begin_time
);
6717 " Delay in progress\n");
6719 if (bgp
->update_delay_over
) {
6721 " First neighbor established: %s\n",
6722 bgp
->update_delay_begin_time
);
6724 " Best-paths resumed: %s\n",
6725 bgp
->update_delay_end_time
);
6727 " zebra update resumed: %s\n",
6728 bgp
->update_delay_zebra_resume_time
);
6730 " peers update resumed: %s\n",
6731 bgp
->update_delay_peers_resume_time
);
6738 if (bgp_maxmed_onstartup_configured(bgp
)
6739 && bgp
->maxmed_active
)
6740 json_object_boolean_true_add(
6743 if (bgp
->v_maxmed_admin
)
6744 json_object_boolean_true_add(
6746 "maxMedAdministrative");
6748 json_object_int_add(
6749 json
, "tableVersion",
6751 bgp
->rib
[afi
][safi
]));
6753 ents
= bgp_table_count(
6754 bgp
->rib
[afi
][safi
]);
6755 json_object_int_add(json
, "ribCount",
6757 json_object_int_add(
6759 ents
* sizeof(struct bgp_node
));
6761 ents
= listcount(bgp
->peer
);
6762 json_object_int_add(json
, "peerCount",
6764 json_object_int_add(
6766 ents
* sizeof(struct peer
));
6768 if ((ents
= listcount(bgp
->group
))) {
6769 json_object_int_add(
6770 json
, "peerGroupCount",
6772 json_object_int_add(
6773 json
, "peerGroupMemory",
6774 ents
* sizeof(struct
6778 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
6779 BGP_CONFIG_DAMPENING
))
6780 json_object_boolean_true_add(
6782 "dampeningEnabled");
6784 if (bgp_maxmed_onstartup_configured(bgp
)
6785 && bgp
->maxmed_active
)
6787 "Max-med on-startup active\n");
6788 if (bgp
->v_maxmed_admin
)
6790 "Max-med administrative active\n");
6793 "BGP table version %" PRIu64
6796 bgp
->rib
[afi
][safi
]));
6798 ents
= bgp_table_count(
6799 bgp
->rib
[afi
][safi
]);
6801 "RIB entries %ld, using %s of memory\n",
6806 ents
* sizeof(struct
6809 /* Peer related usage */
6810 ents
= listcount(bgp
->peer
);
6812 "Peers %ld, using %s of memory\n",
6817 ents
* sizeof(struct
6820 if ((ents
= listcount(bgp
->group
)))
6822 "Peer groups %ld, using %s of memory\n",
6827 ents
* sizeof(struct
6830 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
6831 BGP_CONFIG_DAMPENING
))
6833 "Dampening enabled.\n");
6836 /* Subtract 8 here because 'Neighbor' is
6838 vty_out(vty
, "Neighbor");
6840 max_neighbor_width
- 8, " ");
6842 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
6849 json_peer
= json_object_new_object();
6851 if (peer_dynamic_neighbor(peer
))
6852 json_object_boolean_true_add(
6853 json_peer
, "dynamicPeer");
6856 json_object_string_add(json_peer
,
6860 if (peer
->domainname
)
6861 json_object_string_add(
6862 json_peer
, "domainname",
6865 json_object_int_add(json_peer
, "remoteAs",
6867 json_object_int_add(json_peer
, "version", 4);
6868 json_object_int_add(
6869 json_peer
, "msgRcvd",
6870 peer
->open_in
+ peer
->update_in
6871 + peer
->keepalive_in
6874 + peer
->dynamic_cap_in
);
6875 json_object_int_add(
6876 json_peer
, "msgSent",
6877 peer
->open_out
+ peer
->update_out
6878 + peer
->keepalive_out
6881 + peer
->dynamic_cap_out
);
6883 json_object_int_add(json_peer
, "tableVersion",
6884 peer
->version
[afi
][safi
]);
6885 json_object_int_add(json_peer
, "outq",
6887 json_object_int_add(json_peer
, "inq", 0);
6888 peer_uptime(peer
->uptime
, timebuf
,
6889 BGP_UPTIME_LEN
, use_json
,
6891 json_object_int_add(
6892 json_peer
, "prefixReceivedCount",
6893 peer
->pcount
[afi
][pfx_rcd_safi
]);
6895 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
6896 json_object_string_add(json_peer
,
6899 else if (CHECK_FLAG(
6901 PEER_STATUS_PREFIX_OVERFLOW
))
6902 json_object_string_add(json_peer
,
6906 json_object_string_add(
6908 lookup_msg(bgp_status_msg
,
6909 peer
->status
, NULL
));
6912 json_object_string_add(json_peer
,
6915 else if (peer
->su
.sa
.sa_family
== AF_INET
)
6916 json_object_string_add(
6917 json_peer
, "idType", "ipv4");
6918 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
6919 json_object_string_add(
6920 json_peer
, "idType", "ipv6");
6922 json_object_object_add(json_peers
, peer
->host
,
6925 memset(dn_flag
, '\0', sizeof(dn_flag
));
6926 if (peer_dynamic_neighbor(peer
)) {
6932 && bgp_flag_check(bgp
,
6933 BGP_FLAG_SHOW_HOSTNAME
))
6934 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
6938 len
= vty_out(vty
, "%s%s", dn_flag
,
6941 /* pad the neighbor column with spaces */
6942 if (len
< max_neighbor_width
)
6944 max_neighbor_width
- len
, " ");
6946 vty_out(vty
, "4 %10u %7d %7d %8" PRIu64
6949 peer
->open_in
+ peer
->update_in
6950 + peer
->keepalive_in
6953 + peer
->dynamic_cap_in
,
6954 peer
->open_out
+ peer
->update_out
6955 + peer
->keepalive_out
6958 + peer
->dynamic_cap_out
,
6959 peer
->version
[afi
][safi
], 0,
6961 peer_uptime(peer
->uptime
, timebuf
,
6962 BGP_UPTIME_LEN
, 0, NULL
));
6964 if (peer
->status
== Established
)
6965 vty_out(vty
, " %12ld",
6969 if (CHECK_FLAG(peer
->flags
,
6970 PEER_FLAG_SHUTDOWN
))
6971 vty_out(vty
, " Idle (Admin)");
6975 PEER_STATUS_PREFIX_OVERFLOW
))
6976 vty_out(vty
, " Idle (PfxCt)");
6978 vty_out(vty
, " %12s",
6990 json_object_object_add(json
, "peers", json_peers
);
6992 json_object_int_add(json
, "totalPeers", count
);
6993 json_object_int_add(json
, "dynamicPeers", dn_count
);
6995 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
6996 json
, JSON_C_TO_STRING_PRETTY
));
6997 json_object_free(json
);
7000 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
7004 "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n",
7005 afi_safi_print(afi
, safi
));
7007 vty_out(vty
, "No %s neighbor is configured\n",
7008 afi_safi_print(afi
, safi
));
7011 if (dn_count
&& !use_json
) {
7012 vty_out(vty
, "* - dynamic neighbor\n");
7013 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
7014 dn_count
, bgp
->dynamic_neighbors_limit
);
7022 * Return if we have a peer configured to use this afi/safi
7024 static int bgp_show_summary_afi_safi_peer_exists(struct bgp
*bgp
, int afi
,
7027 struct listnode
*node
;
7030 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
)) {
7031 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7034 if (peer
->afc
[afi
][safi
])
7041 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
7042 int safi
, u_char use_json
,
7046 int afi_wildcard
= (afi
== AFI_MAX
);
7047 int safi_wildcard
= (safi
== SAFI_MAX
);
7048 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
7049 bool json_output
= false;
7051 if (use_json
&& is_wildcard
)
7052 vty_out(vty
, "{\n");
7054 afi
= 1; /* AFI_IP */
7055 while (afi
< AFI_MAX
) {
7057 safi
= 1; /* SAFI_UNICAST */
7058 while (safi
< SAFI_MAX
) {
7059 if (bgp_show_summary_afi_safi_peer_exists(bgp
, afi
,
7064 * So limit output to those afi/safi
7066 * actualy have something interesting in
7070 json
= json_object_new_object();
7073 vty_out(vty
, ",\n");
7077 vty_out(vty
, "\"%s\":",
7081 vty_out(vty
, "\n%s Summary:\n",
7086 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
7095 || afi
== AFI_L2VPN
) /* special case, not handled yet */
7099 if (use_json
&& is_wildcard
)
7100 vty_out(vty
, "}\n");
7101 else if (use_json
&& !json_output
)
7102 vty_out(vty
, "{}\n");
7105 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
7106 safi_t safi
, u_char use_json
)
7108 struct listnode
*node
, *nnode
;
7110 json_object
*json
= NULL
;
7114 vty_out(vty
, "{\n");
7116 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
7118 json
= json_object_new_object();
7121 vty_out(vty
, ",\n");
7125 vty_out(vty
, "\"%s\":",
7126 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7130 vty_out(vty
, "\nInstance %s:\n",
7131 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7135 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
7139 vty_out(vty
, "}\n");
7142 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
7143 safi_t safi
, u_char use_json
)
7148 if (strmatch(name
, "all")) {
7149 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
7153 bgp
= bgp_lookup_by_name(name
);
7157 vty_out(vty
, "{}\n");
7160 "%% No such BGP instance exist\n");
7164 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
7170 bgp
= bgp_get_default();
7173 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
7178 /* `show [ip] bgp summary' commands. */
7179 DEFUN (show_ip_bgp_summary
,
7180 show_ip_bgp_summary_cmd
,
7181 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
7185 BGP_INSTANCE_HELP_STR
7187 BGP_SAFI_WITH_LABEL_HELP_STR
7188 "Summary of BGP neighbor status\n"
7192 afi_t afi
= AFI_MAX
;
7193 safi_t safi
= SAFI_MAX
;
7198 if (argv_find(argv
, argc
, "ip", &idx
))
7200 /* [<view|vrf> VIEWVRFNAME] */
7201 if (argv_find(argv
, argc
, "view", &idx
)
7202 || argv_find(argv
, argc
, "vrf", &idx
))
7203 vrf
= argv
[++idx
]->arg
;
7204 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7205 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
7206 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7209 int uj
= use_json(argc
, argv
);
7211 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
7214 const char *afi_safi_print(afi_t afi
, safi_t safi
)
7216 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
7217 return "IPv4 Unicast";
7218 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
7219 return "IPv4 Multicast";
7220 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
7221 return "IPv4 Labeled Unicast";
7222 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7224 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
7225 return "IPv4 Encap";
7226 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
7227 return "IPv6 Unicast";
7228 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
7229 return "IPv6 Multicast";
7230 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
7231 return "IPv6 Labeled Unicast";
7232 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
7234 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
7235 return "IPv6 Encap";
7236 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
7237 return "L2VPN EVPN";
7243 * Please note that we have intentionally camelCased
7244 * the return strings here. So if you want
7245 * to use this function, please ensure you
7246 * are doing this within json output
7248 const char *afi_safi_json(afi_t afi
, safi_t safi
)
7250 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
7251 return "ipv4Unicast";
7252 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
7253 return "ipv4Multicast";
7254 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
7255 return "ipv4LabeledUnicast";
7256 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7258 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
7260 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
7261 return "ipv6Unicast";
7262 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
7263 return "ipv6Multicast";
7264 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
7265 return "ipv6LabeledUnicast";
7266 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
7268 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
7270 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
7276 /* Show BGP peer's information. */
7277 enum show_type
{ show_all
, show_peer
};
7279 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
7280 afi_t afi
, safi_t safi
,
7281 u_int16_t adv_smcap
, u_int16_t adv_rmcap
,
7282 u_int16_t rcv_smcap
, u_int16_t rcv_rmcap
,
7283 u_char use_json
, json_object
*json_pref
)
7286 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
7287 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
7289 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
7290 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7291 json_object_string_add(json_pref
, "sendMode",
7292 "advertisedAndReceived");
7293 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
7294 json_object_string_add(json_pref
, "sendMode",
7296 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7297 json_object_string_add(json_pref
, "sendMode",
7300 vty_out(vty
, " Send-mode: ");
7301 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
7302 vty_out(vty
, "advertised");
7303 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7304 vty_out(vty
, "%sreceived",
7305 CHECK_FLAG(p
->af_cap
[afi
][safi
],
7314 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
7315 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
7317 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
7318 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7319 json_object_string_add(json_pref
, "recvMode",
7320 "advertisedAndReceived");
7321 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
7322 json_object_string_add(json_pref
, "recvMode",
7324 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7325 json_object_string_add(json_pref
, "recvMode",
7328 vty_out(vty
, " Receive-mode: ");
7329 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
7330 vty_out(vty
, "advertised");
7331 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7332 vty_out(vty
, "%sreceived",
7333 CHECK_FLAG(p
->af_cap
[afi
][safi
],
7342 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
7343 safi_t safi
, u_char use_json
,
7344 json_object
*json_neigh
)
7346 struct bgp_filter
*filter
;
7347 struct peer_af
*paf
;
7348 char orf_pfx_name
[BUFSIZ
];
7350 json_object
*json_af
= NULL
;
7351 json_object
*json_prefA
= NULL
;
7352 json_object
*json_prefB
= NULL
;
7353 json_object
*json_addr
= NULL
;
7356 json_addr
= json_object_new_object();
7357 json_af
= json_object_new_object();
7358 filter
= &p
->filter
[afi
][safi
];
7360 if (peer_group_active(p
))
7361 json_object_string_add(json_addr
, "peerGroupMember",
7364 paf
= peer_af_find(p
, afi
, safi
);
7365 if (paf
&& PAF_SUBGRP(paf
)) {
7366 json_object_int_add(json_addr
, "updateGroupId",
7367 PAF_UPDGRP(paf
)->id
);
7368 json_object_int_add(json_addr
, "subGroupId",
7369 PAF_SUBGRP(paf
)->id
);
7370 json_object_int_add(json_addr
, "packetQueueLength",
7371 bpacket_queue_virtual_length(paf
));
7374 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7375 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7376 PEER_CAP_ORF_PREFIX_SM_RCV
)
7377 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7378 PEER_CAP_ORF_PREFIX_RM_ADV
)
7379 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7380 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
7381 json_object_int_add(json_af
, "orfType",
7383 json_prefA
= json_object_new_object();
7384 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
7385 PEER_CAP_ORF_PREFIX_SM_ADV
,
7386 PEER_CAP_ORF_PREFIX_RM_ADV
,
7387 PEER_CAP_ORF_PREFIX_SM_RCV
,
7388 PEER_CAP_ORF_PREFIX_RM_RCV
,
7389 use_json
, json_prefA
);
7390 json_object_object_add(json_af
, "orfPrefixList",
7394 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7395 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7396 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7397 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7398 PEER_CAP_ORF_PREFIX_RM_ADV
)
7399 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7400 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
7401 json_object_int_add(json_af
, "orfOldType",
7402 ORF_TYPE_PREFIX_OLD
);
7403 json_prefB
= json_object_new_object();
7404 bgp_show_peer_afi_orf_cap(
7405 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
7406 PEER_CAP_ORF_PREFIX_RM_ADV
,
7407 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
7408 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
7410 json_object_object_add(json_af
, "orfOldPrefixList",
7414 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7415 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7416 PEER_CAP_ORF_PREFIX_SM_RCV
)
7417 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7418 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7419 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7420 PEER_CAP_ORF_PREFIX_RM_ADV
)
7421 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7422 PEER_CAP_ORF_PREFIX_RM_RCV
)
7423 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7424 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
7425 json_object_object_add(json_addr
, "afDependentCap",
7428 json_object_free(json_af
);
7430 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
7431 orf_pfx_count
= prefix_bgp_show_prefix_list(
7432 NULL
, afi
, orf_pfx_name
, use_json
);
7434 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7435 PEER_STATUS_ORF_PREFIX_SEND
)
7437 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7438 PEER_STATUS_ORF_PREFIX_SEND
))
7439 json_object_boolean_true_add(json_neigh
,
7442 json_object_int_add(json_addr
, "orfRecvCounter",
7445 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7446 PEER_STATUS_ORF_WAIT_REFRESH
))
7447 json_object_string_add(
7448 json_addr
, "orfFirstUpdate",
7449 "deferredUntilORFOrRouteRefreshRecvd");
7451 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7452 PEER_FLAG_REFLECTOR_CLIENT
))
7453 json_object_boolean_true_add(json_addr
,
7454 "routeReflectorClient");
7455 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7456 PEER_FLAG_RSERVER_CLIENT
))
7457 json_object_boolean_true_add(json_addr
,
7458 "routeServerClient");
7459 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
7460 json_object_boolean_true_add(json_addr
,
7461 "inboundSoftConfigPermit");
7463 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7464 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
7465 json_object_boolean_true_add(
7467 "privateAsNumsAllReplacedInUpdatesToNbr");
7468 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7469 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
7470 json_object_boolean_true_add(
7472 "privateAsNumsReplacedInUpdatesToNbr");
7473 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7474 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
7475 json_object_boolean_true_add(
7477 "privateAsNumsAllRemovedInUpdatesToNbr");
7478 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7479 PEER_FLAG_REMOVE_PRIVATE_AS
))
7480 json_object_boolean_true_add(
7482 "privateAsNumsRemovedInUpdatesToNbr");
7484 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7485 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
7486 json_object_boolean_true_add(json_addr
,
7487 "addpathTxAllPaths");
7489 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7490 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
7491 json_object_boolean_true_add(json_addr
,
7492 "addpathTxBestpathPerAS");
7494 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
7495 json_object_string_add(json_addr
,
7496 "overrideASNsInOutboundUpdates",
7497 "ifAspathEqualRemoteAs");
7499 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
7500 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7501 PEER_FLAG_FORCE_NEXTHOP_SELF
))
7502 json_object_boolean_true_add(json_addr
,
7503 "routerAlwaysNextHop");
7504 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7505 PEER_FLAG_AS_PATH_UNCHANGED
))
7506 json_object_boolean_true_add(
7507 json_addr
, "unchangedAsPathPropogatedToNbr");
7508 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7509 PEER_FLAG_NEXTHOP_UNCHANGED
))
7510 json_object_boolean_true_add(
7511 json_addr
, "unchangedNextHopPropogatedToNbr");
7512 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
7513 json_object_boolean_true_add(
7514 json_addr
, "unchangedMedPropogatedToNbr");
7515 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
7516 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7517 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
7518 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7519 PEER_FLAG_SEND_COMMUNITY
)
7520 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
7521 PEER_FLAG_SEND_EXT_COMMUNITY
))
7522 json_object_string_add(json_addr
,
7523 "commAttriSentToNbr",
7524 "extendedAndStandard");
7525 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7526 PEER_FLAG_SEND_EXT_COMMUNITY
))
7527 json_object_string_add(json_addr
,
7528 "commAttriSentToNbr",
7531 json_object_string_add(json_addr
,
7532 "commAttriSentToNbr",
7535 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7536 PEER_FLAG_DEFAULT_ORIGINATE
)) {
7537 if (p
->default_rmap
[afi
][safi
].name
)
7538 json_object_string_add(
7539 json_addr
, "defaultRouteMap",
7540 p
->default_rmap
[afi
][safi
].name
);
7542 if (paf
&& PAF_SUBGRP(paf
)
7543 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
7544 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
7545 json_object_boolean_true_add(json_addr
,
7548 json_object_boolean_true_add(json_addr
,
7552 if (filter
->plist
[FILTER_IN
].name
7553 || filter
->dlist
[FILTER_IN
].name
7554 || filter
->aslist
[FILTER_IN
].name
7555 || filter
->map
[RMAP_IN
].name
)
7556 json_object_boolean_true_add(json_addr
,
7557 "inboundPathPolicyConfig");
7558 if (filter
->plist
[FILTER_OUT
].name
7559 || filter
->dlist
[FILTER_OUT
].name
7560 || filter
->aslist
[FILTER_OUT
].name
7561 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
7562 json_object_boolean_true_add(
7563 json_addr
, "outboundPathPolicyConfig");
7566 if (filter
->plist
[FILTER_IN
].name
)
7567 json_object_string_add(json_addr
,
7568 "incomingUpdatePrefixFilterList",
7569 filter
->plist
[FILTER_IN
].name
);
7570 if (filter
->plist
[FILTER_OUT
].name
)
7571 json_object_string_add(json_addr
,
7572 "outgoingUpdatePrefixFilterList",
7573 filter
->plist
[FILTER_OUT
].name
);
7575 /* distribute-list */
7576 if (filter
->dlist
[FILTER_IN
].name
)
7577 json_object_string_add(
7578 json_addr
, "incomingUpdateNetworkFilterList",
7579 filter
->dlist
[FILTER_IN
].name
);
7580 if (filter
->dlist
[FILTER_OUT
].name
)
7581 json_object_string_add(
7582 json_addr
, "outgoingUpdateNetworkFilterList",
7583 filter
->dlist
[FILTER_OUT
].name
);
7586 if (filter
->aslist
[FILTER_IN
].name
)
7587 json_object_string_add(json_addr
,
7588 "incomingUpdateAsPathFilterList",
7589 filter
->aslist
[FILTER_IN
].name
);
7590 if (filter
->aslist
[FILTER_OUT
].name
)
7591 json_object_string_add(json_addr
,
7592 "outgoingUpdateAsPathFilterList",
7593 filter
->aslist
[FILTER_OUT
].name
);
7596 if (filter
->map
[RMAP_IN
].name
)
7597 json_object_string_add(
7598 json_addr
, "routeMapForIncomingAdvertisements",
7599 filter
->map
[RMAP_IN
].name
);
7600 if (filter
->map
[RMAP_OUT
].name
)
7601 json_object_string_add(
7602 json_addr
, "routeMapForOutgoingAdvertisements",
7603 filter
->map
[RMAP_OUT
].name
);
7605 /* unsuppress-map */
7606 if (filter
->usmap
.name
)
7607 json_object_string_add(json_addr
,
7608 "selectiveUnsuppressRouteMap",
7609 filter
->usmap
.name
);
7611 /* Receive prefix count */
7612 json_object_int_add(json_addr
, "acceptedPrefixCounter",
7613 p
->pcount
[afi
][safi
]);
7615 /* Maximum prefix */
7616 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
7617 json_object_int_add(json_addr
, "prefixAllowedMax",
7618 p
->pmax
[afi
][safi
]);
7619 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7620 PEER_FLAG_MAX_PREFIX_WARNING
))
7621 json_object_boolean_true_add(
7622 json_addr
, "prefixAllowedMaxWarning");
7623 json_object_int_add(json_addr
,
7624 "prefixAllowedWarningThresh",
7625 p
->pmax_threshold
[afi
][safi
]);
7626 if (p
->pmax_restart
[afi
][safi
])
7627 json_object_int_add(
7629 "prefixAllowedRestartIntervalMsecs",
7630 p
->pmax_restart
[afi
][safi
] * 60000);
7632 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
7636 filter
= &p
->filter
[afi
][safi
];
7638 vty_out(vty
, " For address family: %s\n",
7639 afi_safi_print(afi
, safi
));
7641 if (peer_group_active(p
))
7642 vty_out(vty
, " %s peer-group member\n",
7645 paf
= peer_af_find(p
, afi
, safi
);
7646 if (paf
&& PAF_SUBGRP(paf
)) {
7647 vty_out(vty
, " Update group %" PRIu64
7648 ", subgroup %" PRIu64
"\n",
7649 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
7650 vty_out(vty
, " Packet Queue length %d\n",
7651 bpacket_queue_virtual_length(paf
));
7653 vty_out(vty
, " Not part of any update group\n");
7655 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7656 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7657 PEER_CAP_ORF_PREFIX_SM_RCV
)
7658 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7659 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7660 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7661 PEER_CAP_ORF_PREFIX_RM_ADV
)
7662 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7663 PEER_CAP_ORF_PREFIX_RM_RCV
)
7664 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7665 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
7666 vty_out(vty
, " AF-dependant capabilities:\n");
7668 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7669 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7670 PEER_CAP_ORF_PREFIX_SM_RCV
)
7671 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7672 PEER_CAP_ORF_PREFIX_RM_ADV
)
7673 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7674 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
7676 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
7678 bgp_show_peer_afi_orf_cap(
7679 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
7680 PEER_CAP_ORF_PREFIX_RM_ADV
,
7681 PEER_CAP_ORF_PREFIX_SM_RCV
,
7682 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
7684 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7685 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7686 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7687 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7688 PEER_CAP_ORF_PREFIX_RM_ADV
)
7689 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7690 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
7692 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
7693 ORF_TYPE_PREFIX_OLD
);
7694 bgp_show_peer_afi_orf_cap(
7695 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
7696 PEER_CAP_ORF_PREFIX_RM_ADV
,
7697 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
7698 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
7701 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
7702 orf_pfx_count
= prefix_bgp_show_prefix_list(
7703 NULL
, afi
, orf_pfx_name
, use_json
);
7705 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7706 PEER_STATUS_ORF_PREFIX_SEND
)
7708 vty_out(vty
, " Outbound Route Filter (ORF):");
7709 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7710 PEER_STATUS_ORF_PREFIX_SEND
))
7711 vty_out(vty
, " sent;");
7713 vty_out(vty
, " received (%d entries)",
7717 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7718 PEER_STATUS_ORF_WAIT_REFRESH
))
7720 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
7722 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7723 PEER_FLAG_REFLECTOR_CLIENT
))
7724 vty_out(vty
, " Route-Reflector Client\n");
7725 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7726 PEER_FLAG_RSERVER_CLIENT
))
7727 vty_out(vty
, " Route-Server Client\n");
7728 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
7730 " Inbound soft reconfiguration allowed\n");
7732 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7733 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
7735 " Private AS numbers (all) replaced in updates to this neighbor\n");
7736 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7737 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
7739 " Private AS numbers replaced in updates to this neighbor\n");
7740 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7741 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
7743 " Private AS numbers (all) removed in updates to this neighbor\n");
7744 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7745 PEER_FLAG_REMOVE_PRIVATE_AS
))
7747 " Private AS numbers removed in updates to this neighbor\n");
7749 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7750 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
7751 vty_out(vty
, " Advertise all paths via addpath\n");
7753 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7754 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
7756 " Advertise bestpath per AS via addpath\n");
7758 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
7760 " Override ASNs in outbound updates if aspath equals remote-as\n");
7762 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
7763 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7764 PEER_FLAG_FORCE_NEXTHOP_SELF
))
7765 vty_out(vty
, " NEXT_HOP is always this router\n");
7766 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7767 PEER_FLAG_AS_PATH_UNCHANGED
))
7769 " AS_PATH is propagated unchanged to this neighbor\n");
7770 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7771 PEER_FLAG_NEXTHOP_UNCHANGED
))
7773 " NEXT_HOP is propagated unchanged to this neighbor\n");
7774 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
7776 " MED is propagated unchanged to this neighbor\n");
7777 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
7778 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7779 PEER_FLAG_SEND_EXT_COMMUNITY
)
7780 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7781 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
7783 " Community attribute sent to this neighbor");
7784 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7785 PEER_FLAG_SEND_COMMUNITY
)
7786 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
7787 PEER_FLAG_SEND_EXT_COMMUNITY
)
7788 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
7789 PEER_FLAG_SEND_LARGE_COMMUNITY
))
7790 vty_out(vty
, "(all)\n");
7791 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7792 PEER_FLAG_SEND_LARGE_COMMUNITY
))
7793 vty_out(vty
, "(large)\n");
7794 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7795 PEER_FLAG_SEND_EXT_COMMUNITY
))
7796 vty_out(vty
, "(extended)\n");
7798 vty_out(vty
, "(standard)\n");
7800 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7801 PEER_FLAG_DEFAULT_ORIGINATE
)) {
7802 vty_out(vty
, " Default information originate,");
7804 if (p
->default_rmap
[afi
][safi
].name
)
7805 vty_out(vty
, " default route-map %s%s,",
7806 p
->default_rmap
[afi
][safi
].map
? "*"
7808 p
->default_rmap
[afi
][safi
].name
);
7809 if (paf
&& PAF_SUBGRP(paf
)
7810 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
7811 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
7812 vty_out(vty
, " default sent\n");
7814 vty_out(vty
, " default not sent\n");
7817 if (filter
->plist
[FILTER_IN
].name
7818 || filter
->dlist
[FILTER_IN
].name
7819 || filter
->aslist
[FILTER_IN
].name
7820 || filter
->map
[RMAP_IN
].name
)
7821 vty_out(vty
, " Inbound path policy configured\n");
7822 if (filter
->plist
[FILTER_OUT
].name
7823 || filter
->dlist
[FILTER_OUT
].name
7824 || filter
->aslist
[FILTER_OUT
].name
7825 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
7826 vty_out(vty
, " Outbound path policy configured\n");
7829 if (filter
->plist
[FILTER_IN
].name
)
7831 " Incoming update prefix filter list is %s%s\n",
7832 filter
->plist
[FILTER_IN
].plist
? "*" : "",
7833 filter
->plist
[FILTER_IN
].name
);
7834 if (filter
->plist
[FILTER_OUT
].name
)
7836 " Outgoing update prefix filter list is %s%s\n",
7837 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
7838 filter
->plist
[FILTER_OUT
].name
);
7840 /* distribute-list */
7841 if (filter
->dlist
[FILTER_IN
].name
)
7843 " Incoming update network filter list is %s%s\n",
7844 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
7845 filter
->dlist
[FILTER_IN
].name
);
7846 if (filter
->dlist
[FILTER_OUT
].name
)
7848 " Outgoing update network filter list is %s%s\n",
7849 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
7850 filter
->dlist
[FILTER_OUT
].name
);
7853 if (filter
->aslist
[FILTER_IN
].name
)
7855 " Incoming update AS path filter list is %s%s\n",
7856 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
7857 filter
->aslist
[FILTER_IN
].name
);
7858 if (filter
->aslist
[FILTER_OUT
].name
)
7860 " Outgoing update AS path filter list is %s%s\n",
7861 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
7862 filter
->aslist
[FILTER_OUT
].name
);
7865 if (filter
->map
[RMAP_IN
].name
)
7867 " Route map for incoming advertisements is %s%s\n",
7868 filter
->map
[RMAP_IN
].map
? "*" : "",
7869 filter
->map
[RMAP_IN
].name
);
7870 if (filter
->map
[RMAP_OUT
].name
)
7872 " Route map for outgoing advertisements is %s%s\n",
7873 filter
->map
[RMAP_OUT
].map
? "*" : "",
7874 filter
->map
[RMAP_OUT
].name
);
7876 /* unsuppress-map */
7877 if (filter
->usmap
.name
)
7879 " Route map for selective unsuppress is %s%s\n",
7880 filter
->usmap
.map
? "*" : "",
7881 filter
->usmap
.name
);
7883 /* Receive prefix count */
7884 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
7886 /* Maximum prefix */
7887 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
7888 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
7890 CHECK_FLAG(p
->af_flags
[afi
][safi
],
7891 PEER_FLAG_MAX_PREFIX_WARNING
)
7894 vty_out(vty
, " Threshold for warning message %d%%",
7895 p
->pmax_threshold
[afi
][safi
]);
7896 if (p
->pmax_restart
[afi
][safi
])
7897 vty_out(vty
, ", restart interval %d min",
7898 p
->pmax_restart
[afi
][safi
]);
7906 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, u_char use_json
,
7910 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
7911 char timebuf
[BGP_UPTIME_LEN
];
7913 const char *subcode_str
;
7914 const char *code_str
;
7919 json_object
*json_neigh
= NULL
;
7925 json_neigh
= json_object_new_object();
7927 memset(dn_flag
, '\0', sizeof(dn_flag
));
7928 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
7932 if (p
->conf_if
) /* Configured interface name. */
7933 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
7934 BGP_PEER_SU_UNSPEC(p
)
7936 : sockunion2str(&p
->su
, buf
,
7938 else /* Configured IP address. */
7939 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
7944 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
7945 json_object_string_add(json_neigh
, "bgpNeighborAddr",
7947 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
7948 json_object_string_add(
7949 json_neigh
, "bgpNeighborAddr",
7950 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
7952 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
7954 if (p
->change_local_as
)
7955 json_object_int_add(json_neigh
, "localAs",
7956 p
->change_local_as
);
7958 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
7960 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
7961 json_object_boolean_true_add(json_neigh
,
7962 "localAsNoPrepend");
7964 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
7965 json_object_boolean_true_add(json_neigh
,
7966 "localAsReplaceAs");
7968 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
7969 || (p
->as_type
== AS_INTERNAL
))
7970 vty_out(vty
, "remote AS %u, ", p
->as
);
7972 vty_out(vty
, "remote AS Unspecified, ");
7973 vty_out(vty
, "local AS %u%s%s, ",
7974 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
7975 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
7978 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
7982 /* peer type internal, external, confed-internal or confed-external */
7983 if (p
->as
== p
->local_as
) {
7985 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
7986 json_object_boolean_true_add(
7987 json_neigh
, "nbrConfedInternalLink");
7989 json_object_boolean_true_add(json_neigh
,
7992 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
7993 vty_out(vty
, "confed-internal link\n");
7995 vty_out(vty
, "internal link\n");
7999 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8000 json_object_boolean_true_add(
8001 json_neigh
, "nbrConfedExternalLink");
8003 json_object_boolean_true_add(json_neigh
,
8006 if (bgp_confederation_peers_check(bgp
, p
->as
))
8007 vty_out(vty
, "confed-external link\n");
8009 vty_out(vty
, "external link\n");
8016 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
8018 vty_out(vty
, " Description: %s\n", p
->desc
);
8024 json_object_string_add(json_neigh
, "hostname",
8028 json_object_string_add(json_neigh
, "domainname",
8031 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
8032 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
8035 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
8042 json_object_string_add(json_neigh
, "peerGroup",
8046 struct prefix prefix
, *range
= NULL
;
8048 sockunion2hostprefix(&(p
->su
), &prefix
);
8049 range
= peer_group_lookup_dynamic_neighbor_range(
8053 prefix2str(range
, buf1
, sizeof(buf1
));
8054 json_object_string_add(
8056 "peerSubnetRangeGroup", buf1
);
8061 " Member of peer-group %s for session parameters\n",
8065 struct prefix prefix
, *range
= NULL
;
8067 sockunion2hostprefix(&(p
->su
), &prefix
);
8068 range
= peer_group_lookup_dynamic_neighbor_range(
8072 prefix2str(range
, buf1
, sizeof(buf1
));
8074 " Belongs to the subnet range group: %s\n",
8082 /* Administrative shutdown. */
8083 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8084 json_object_boolean_true_add(json_neigh
,
8088 json_object_int_add(json_neigh
, "bgpVersion", 4);
8089 json_object_string_add(
8090 json_neigh
, "remoteRouterId",
8091 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
8094 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
8095 && bgp_confederation_peers_check(bgp
, p
->as
))
8096 json_object_boolean_true_add(json_neigh
,
8100 json_object_string_add(
8101 json_neigh
, "bgpState",
8102 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
8104 if (p
->status
== Established
) {
8108 uptime
= bgp_clock();
8109 uptime
-= p
->uptime
;
8110 tm
= gmtime(&uptime
);
8111 epoch_tbuf
= time(NULL
) - uptime
;
8113 json_object_int_add(json_neigh
, "bgpTimerUp",
8115 + (tm
->tm_min
* 60000)
8116 + (tm
->tm_hour
* 3600000));
8117 json_object_string_add(json_neigh
, "bgpTimerUpString",
8118 peer_uptime(p
->uptime
, timebuf
,
8121 json_object_int_add(json_neigh
,
8122 "bgpTimerUpEstablishedEpoch",
8126 else if (p
->status
== Active
) {
8127 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
8128 json_object_string_add(json_neigh
, "bgpStateIs",
8130 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
8131 json_object_string_add(json_neigh
, "bgpStateIs",
8139 uptime
= bgp_clock();
8140 uptime
-= p
->readtime
;
8141 tm
= gmtime(&uptime
);
8142 json_object_int_add(json_neigh
, "bgpTimerLastRead",
8143 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8144 + (tm
->tm_hour
* 3600000));
8146 uptime
= bgp_clock();
8147 uptime
-= p
->last_write
;
8148 tm
= gmtime(&uptime
);
8149 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
8150 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8151 + (tm
->tm_hour
* 3600000));
8153 uptime
= bgp_clock();
8154 uptime
-= p
->update_time
;
8155 tm
= gmtime(&uptime
);
8156 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
8157 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8158 + (tm
->tm_hour
* 3600000));
8160 /* Configured timer values. */
8161 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
8162 p
->v_holdtime
* 1000);
8163 json_object_int_add(json_neigh
,
8164 "bgpTimerKeepAliveIntervalMsecs",
8165 p
->v_keepalive
* 1000);
8167 if (CHECK_FLAG(p
->config
, PEER_CONFIG_TIMER
)) {
8168 json_object_int_add(json_neigh
,
8169 "bgpTimerConfiguredHoldTimeMsecs",
8170 p
->holdtime
* 1000);
8171 json_object_int_add(
8173 "bgpTimerConfiguredKeepAliveIntervalMsecs",
8174 p
->keepalive
* 1000);
8177 /* Administrative shutdown. */
8178 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8179 vty_out(vty
, " Administratively shut down\n");
8182 vty_out(vty
, " BGP version 4");
8183 vty_out(vty
, ", remote router ID %s\n",
8184 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
8187 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
8188 && bgp_confederation_peers_check(bgp
, p
->as
))
8190 " Neighbor under common administration\n");
8193 vty_out(vty
, " BGP state = %s",
8194 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
8196 if (p
->status
== Established
)
8197 vty_out(vty
, ", up for %8s",
8198 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8201 else if (p
->status
== Active
) {
8202 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
8203 vty_out(vty
, " (passive)");
8204 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
8205 vty_out(vty
, " (NSF passive)");
8210 vty_out(vty
, " Last read %s",
8211 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
8213 vty_out(vty
, ", Last write %s\n",
8214 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
8217 /* Configured timer values. */
8219 " Hold time is %d, keepalive interval is %d seconds\n",
8220 p
->v_holdtime
, p
->v_keepalive
);
8221 if (CHECK_FLAG(p
->config
, PEER_CONFIG_TIMER
)) {
8222 vty_out(vty
, " Configured hold time is %d",
8224 vty_out(vty
, ", keepalive interval is %d seconds\n",
8229 if (p
->status
== Established
) {
8230 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
8231 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
8232 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
8233 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
8234 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
8235 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
8236 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
8237 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
8238 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
8239 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
8240 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
8241 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
8242 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
8243 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
8244 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
8245 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
8247 json_object
*json_cap
= NULL
;
8249 json_cap
= json_object_new_object();
8252 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
8253 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
8254 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
8255 && CHECK_FLAG(p
->cap
,
8257 json_object_string_add(
8258 json_cap
, "4byteAs",
8259 "advertisedAndReceived");
8260 else if (CHECK_FLAG(p
->cap
,
8262 json_object_string_add(
8263 json_cap
, "4byteAs",
8265 else if (CHECK_FLAG(p
->cap
,
8267 json_object_string_add(
8268 json_cap
, "4byteAs",
8273 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
8274 || CHECK_FLAG(p
->cap
,
8275 PEER_CAP_ADDPATH_ADV
)) {
8276 json_object
*json_add
= NULL
;
8277 const char *print_store
;
8279 json_add
= json_object_new_object();
8281 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
8282 for (safi
= SAFI_UNICAST
;
8283 safi
< SAFI_MAX
; safi
++) {
8284 json_object
*json_sub
=
8287 json_object_new_object();
8297 PEER_CAP_ADDPATH_AF_TX_ADV
)
8302 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
8307 PEER_CAP_ADDPATH_AF_TX_ADV
)
8312 PEER_CAP_ADDPATH_AF_TX_RCV
))
8313 json_object_boolean_true_add(
8315 "txAdvertisedAndReceived");
8321 PEER_CAP_ADDPATH_AF_TX_ADV
))
8322 json_object_boolean_true_add(
8330 PEER_CAP_ADDPATH_AF_TX_RCV
))
8331 json_object_boolean_true_add(
8340 PEER_CAP_ADDPATH_AF_RX_ADV
)
8345 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
8350 PEER_CAP_ADDPATH_AF_RX_ADV
)
8355 PEER_CAP_ADDPATH_AF_RX_RCV
))
8356 json_object_boolean_true_add(
8358 "rxAdvertisedAndReceived");
8364 PEER_CAP_ADDPATH_AF_RX_ADV
))
8365 json_object_boolean_true_add(
8373 PEER_CAP_ADDPATH_AF_RX_RCV
))
8374 json_object_boolean_true_add(
8383 PEER_CAP_ADDPATH_AF_TX_ADV
)
8388 PEER_CAP_ADDPATH_AF_TX_RCV
)
8393 PEER_CAP_ADDPATH_AF_RX_ADV
)
8398 PEER_CAP_ADDPATH_AF_RX_RCV
))
8399 json_object_object_add(
8408 json_object_object_add(
8409 json_cap
, "addPath", json_add
);
8413 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
8414 || CHECK_FLAG(p
->cap
,
8415 PEER_CAP_DYNAMIC_ADV
)) {
8416 if (CHECK_FLAG(p
->cap
,
8417 PEER_CAP_DYNAMIC_ADV
)
8418 && CHECK_FLAG(p
->cap
,
8419 PEER_CAP_DYNAMIC_RCV
))
8420 json_object_string_add(
8421 json_cap
, "dynamic",
8422 "advertisedAndReceived");
8423 else if (CHECK_FLAG(
8425 PEER_CAP_DYNAMIC_ADV
))
8426 json_object_string_add(
8427 json_cap
, "dynamic",
8429 else if (CHECK_FLAG(
8431 PEER_CAP_DYNAMIC_RCV
))
8432 json_object_string_add(
8433 json_cap
, "dynamic",
8437 /* Extended nexthop */
8438 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
8439 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
8440 json_object
*json_nxt
= NULL
;
8441 const char *print_store
;
8444 if (CHECK_FLAG(p
->cap
,
8446 && CHECK_FLAG(p
->cap
,
8448 json_object_string_add(
8451 "advertisedAndReceived");
8452 else if (CHECK_FLAG(p
->cap
,
8454 json_object_string_add(
8458 else if (CHECK_FLAG(p
->cap
,
8460 json_object_string_add(
8465 if (CHECK_FLAG(p
->cap
,
8466 PEER_CAP_ENHE_RCV
)) {
8468 json_object_new_object();
8470 for (safi
= SAFI_UNICAST
;
8471 safi
< SAFI_MAX
; safi
++) {
8476 PEER_CAP_ENHE_AF_RCV
)) {
8477 print_store
= afi_safi_print(
8480 json_object_string_add(
8486 json_object_object_add(
8488 "extendedNexthopFamililesByPeer",
8494 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
8495 || CHECK_FLAG(p
->cap
,
8496 PEER_CAP_REFRESH_NEW_RCV
)
8497 || CHECK_FLAG(p
->cap
,
8498 PEER_CAP_REFRESH_OLD_RCV
)) {
8499 if (CHECK_FLAG(p
->cap
,
8500 PEER_CAP_REFRESH_ADV
)
8503 PEER_CAP_REFRESH_NEW_RCV
)
8506 PEER_CAP_REFRESH_OLD_RCV
))) {
8509 PEER_CAP_REFRESH_OLD_RCV
)
8512 PEER_CAP_REFRESH_NEW_RCV
))
8513 json_object_string_add(
8516 "advertisedAndReceivedOldNew");
8520 PEER_CAP_REFRESH_OLD_RCV
))
8521 json_object_string_add(
8524 "advertisedAndReceivedOld");
8526 json_object_string_add(
8529 "advertisedAndReceivedNew");
8534 PEER_CAP_REFRESH_ADV
))
8535 json_object_string_add(
8542 PEER_CAP_REFRESH_NEW_RCV
)
8545 PEER_CAP_REFRESH_OLD_RCV
))
8546 json_object_string_add(
8552 /* Multiprotocol Extensions */
8553 json_object
*json_multi
= NULL
;
8554 json_multi
= json_object_new_object();
8556 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
8557 for (safi
= SAFI_UNICAST
;
8558 safi
< SAFI_MAX
; safi
++) {
8559 if (p
->afc_adv
[afi
][safi
]
8560 || p
->afc_recv
[afi
][safi
]) {
8565 json_object_new_object();
8572 json_object_boolean_true_add(
8574 "advertisedAndReceived");
8578 json_object_boolean_true_add(
8581 else if (p
->afc_recv
8584 json_object_boolean_true_add(
8588 json_object_object_add(
8597 json_object_object_add(
8598 json_cap
, "multiprotocolExtensions",
8601 /* Gracefull Restart */
8602 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
8603 || CHECK_FLAG(p
->cap
,
8604 PEER_CAP_RESTART_ADV
)) {
8605 if (CHECK_FLAG(p
->cap
,
8606 PEER_CAP_RESTART_ADV
)
8607 && CHECK_FLAG(p
->cap
,
8608 PEER_CAP_RESTART_RCV
))
8609 json_object_string_add(
8612 "advertisedAndReceived");
8613 else if (CHECK_FLAG(
8615 PEER_CAP_RESTART_ADV
))
8616 json_object_string_add(
8618 "gracefulRestartCapability",
8620 else if (CHECK_FLAG(
8622 PEER_CAP_RESTART_RCV
))
8623 json_object_string_add(
8625 "gracefulRestartCapability",
8628 if (CHECK_FLAG(p
->cap
,
8629 PEER_CAP_RESTART_RCV
)) {
8630 int restart_af_count
= 0;
8631 json_object
*json_restart
=
8634 json_object_new_object();
8636 json_object_int_add(
8638 "gracefulRestartRemoteTimerMsecs",
8639 p
->v_gr_restart
* 1000);
8642 afi
< AFI_MAX
; afi
++) {
8643 for (safi
= SAFI_UNICAST
;
8650 PEER_CAP_RESTART_AF_RCV
)) {
8651 json_object
*json_sub
=
8654 json_object_new_object();
8660 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
8661 json_object_boolean_true_add(
8665 json_object_object_add(
8674 if (!restart_af_count
) {
8675 json_object_string_add(
8677 "addressFamiliesByPeer",
8682 json_object_object_add(
8684 "addressFamiliesByPeer",
8688 json_object_object_add(json_neigh
,
8689 "neighborCapabilities",
8692 vty_out(vty
, " Neighbor capabilities:\n");
8695 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
8696 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
8697 vty_out(vty
, " 4 Byte AS:");
8698 if (CHECK_FLAG(p
->cap
,
8700 vty_out(vty
, " advertised");
8701 if (CHECK_FLAG(p
->cap
,
8703 vty_out(vty
, " %sreceived",
8713 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
8714 || CHECK_FLAG(p
->cap
,
8715 PEER_CAP_ADDPATH_ADV
)) {
8716 vty_out(vty
, " AddPath:\n");
8718 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
8719 for (safi
= SAFI_UNICAST
;
8720 safi
< SAFI_MAX
; safi
++) {
8725 PEER_CAP_ADDPATH_AF_TX_ADV
)
8730 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
8741 PEER_CAP_ADDPATH_AF_TX_ADV
))
8752 PEER_CAP_ADDPATH_AF_TX_RCV
))
8759 PEER_CAP_ADDPATH_AF_TX_ADV
)
8771 PEER_CAP_ADDPATH_AF_RX_ADV
)
8776 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
8787 PEER_CAP_ADDPATH_AF_RX_ADV
))
8798 PEER_CAP_ADDPATH_AF_RX_RCV
))
8805 PEER_CAP_ADDPATH_AF_RX_ADV
)
8816 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
8817 || CHECK_FLAG(p
->cap
,
8818 PEER_CAP_DYNAMIC_ADV
)) {
8819 vty_out(vty
, " Dynamic:");
8820 if (CHECK_FLAG(p
->cap
,
8821 PEER_CAP_DYNAMIC_ADV
))
8822 vty_out(vty
, " advertised");
8823 if (CHECK_FLAG(p
->cap
,
8824 PEER_CAP_DYNAMIC_RCV
))
8825 vty_out(vty
, " %sreceived",
8828 PEER_CAP_DYNAMIC_ADV
)
8834 /* Extended nexthop */
8835 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
8836 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
8837 vty_out(vty
, " Extended nexthop:");
8838 if (CHECK_FLAG(p
->cap
,
8840 vty_out(vty
, " advertised");
8841 if (CHECK_FLAG(p
->cap
,
8843 vty_out(vty
, " %sreceived",
8851 if (CHECK_FLAG(p
->cap
,
8852 PEER_CAP_ENHE_RCV
)) {
8854 " Address families by peer:\n ");
8855 for (safi
= SAFI_UNICAST
;
8856 safi
< SAFI_MAX
; safi
++)
8861 PEER_CAP_ENHE_AF_RCV
))
8871 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
8872 || CHECK_FLAG(p
->cap
,
8873 PEER_CAP_REFRESH_NEW_RCV
)
8874 || CHECK_FLAG(p
->cap
,
8875 PEER_CAP_REFRESH_OLD_RCV
)) {
8876 vty_out(vty
, " Route refresh:");
8877 if (CHECK_FLAG(p
->cap
,
8878 PEER_CAP_REFRESH_ADV
))
8879 vty_out(vty
, " advertised");
8880 if (CHECK_FLAG(p
->cap
,
8881 PEER_CAP_REFRESH_NEW_RCV
)
8884 PEER_CAP_REFRESH_OLD_RCV
))
8885 vty_out(vty
, " %sreceived(%s)",
8888 PEER_CAP_REFRESH_ADV
)
8893 PEER_CAP_REFRESH_OLD_RCV
)
8896 PEER_CAP_REFRESH_NEW_RCV
))
8900 PEER_CAP_REFRESH_OLD_RCV
)
8907 /* Multiprotocol Extensions */
8908 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
8909 for (safi
= SAFI_UNICAST
;
8910 safi
< SAFI_MAX
; safi
++)
8911 if (p
->afc_adv
[afi
][safi
]
8912 || p
->afc_recv
[afi
][safi
]) {
8914 " Address Family %s:",
8922 if (p
->afc_recv
[afi
]
8933 /* Hostname capability */
8934 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)
8935 || CHECK_FLAG(p
->cap
,
8936 PEER_CAP_HOSTNAME_RCV
)) {
8938 " Hostname Capability:");
8939 if (CHECK_FLAG(p
->cap
,
8940 PEER_CAP_HOSTNAME_ADV
))
8941 vty_out(vty
, " advertised");
8942 if (CHECK_FLAG(p
->cap
,
8943 PEER_CAP_HOSTNAME_RCV
))
8944 vty_out(vty
, " %sreceived",
8947 PEER_CAP_HOSTNAME_ADV
)
8953 /* Gracefull Restart */
8954 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
8955 || CHECK_FLAG(p
->cap
,
8956 PEER_CAP_RESTART_ADV
)) {
8958 " Graceful Restart Capabilty:");
8959 if (CHECK_FLAG(p
->cap
,
8960 PEER_CAP_RESTART_ADV
))
8961 vty_out(vty
, " advertised");
8962 if (CHECK_FLAG(p
->cap
,
8963 PEER_CAP_RESTART_RCV
))
8964 vty_out(vty
, " %sreceived",
8967 PEER_CAP_RESTART_ADV
)
8972 if (CHECK_FLAG(p
->cap
,
8973 PEER_CAP_RESTART_RCV
)) {
8974 int restart_af_count
= 0;
8977 " Remote Restart timer is %d seconds\n",
8980 " Address families by peer:\n ");
8983 afi
< AFI_MAX
; afi
++)
8984 for (safi
= SAFI_UNICAST
;
8991 PEER_CAP_RESTART_AF_RCV
)) {
9004 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
9009 if (!restart_af_count
)
9010 vty_out(vty
, "none");
9018 /* graceful restart information */
9019 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
9021 json_object
*json_grace
= NULL
;
9022 json_object
*json_grace_send
= NULL
;
9023 json_object
*json_grace_recv
= NULL
;
9024 int eor_send_af_count
= 0;
9025 int eor_receive_af_count
= 0;
9028 json_grace
= json_object_new_object();
9029 json_grace_send
= json_object_new_object();
9030 json_grace_recv
= json_object_new_object();
9032 if (p
->status
== Established
) {
9033 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9034 for (safi
= SAFI_UNICAST
;
9035 safi
< SAFI_MAX
; safi
++) {
9039 PEER_STATUS_EOR_SEND
)) {
9040 json_object_boolean_true_add(
9045 eor_send_af_count
++;
9049 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9050 for (safi
= SAFI_UNICAST
;
9051 safi
< SAFI_MAX
; safi
++) {
9055 PEER_STATUS_EOR_RECEIVED
)) {
9056 json_object_boolean_true_add(
9061 eor_receive_af_count
++;
9067 json_object_object_add(json_grace
, "endOfRibSend",
9069 json_object_object_add(json_grace
, "endOfRibRecv",
9072 if (p
->t_gr_restart
)
9073 json_object_int_add(json_grace
,
9074 "gracefulRestartTimerMsecs",
9075 thread_timer_remain_second(
9080 json_object_int_add(
9082 "gracefulStalepathTimerMsecs",
9083 thread_timer_remain_second(
9087 json_object_object_add(
9088 json_neigh
, "gracefulRestartInfo", json_grace
);
9090 vty_out(vty
, " Graceful restart informations:\n");
9091 if (p
->status
== Established
) {
9092 vty_out(vty
, " End-of-RIB send: ");
9093 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9094 for (safi
= SAFI_UNICAST
;
9095 safi
< SAFI_MAX
; safi
++) {
9099 PEER_STATUS_EOR_SEND
)) {
9100 vty_out(vty
, "%s%s",
9107 eor_send_af_count
++;
9112 vty_out(vty
, " End-of-RIB received: ");
9113 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9114 for (safi
= SAFI_UNICAST
;
9115 safi
< SAFI_MAX
; safi
++) {
9119 PEER_STATUS_EOR_RECEIVED
)) {
9120 vty_out(vty
, "%s%s",
9121 eor_receive_af_count
9127 eor_receive_af_count
++;
9134 if (p
->t_gr_restart
)
9136 " The remaining time of restart timer is %ld\n",
9137 thread_timer_remain_second(
9142 " The remaining time of stalepath timer is %ld\n",
9143 thread_timer_remain_second(
9148 json_object
*json_stat
= NULL
;
9149 json_stat
= json_object_new_object();
9150 /* Packet counts. */
9151 json_object_int_add(json_stat
, "depthInq", 0);
9152 json_object_int_add(json_stat
, "depthOutq",
9153 (unsigned long)p
->obuf
->count
);
9154 json_object_int_add(json_stat
, "opensSent", p
->open_out
);
9155 json_object_int_add(json_stat
, "opensRecv", p
->open_in
);
9156 json_object_int_add(json_stat
, "notificationsSent",
9158 json_object_int_add(json_stat
, "notificationsRecv",
9160 json_object_int_add(json_stat
, "updatesSent", p
->update_out
);
9161 json_object_int_add(json_stat
, "updatesRecv", p
->update_in
);
9162 json_object_int_add(json_stat
, "keepalivesSent",
9164 json_object_int_add(json_stat
, "keepalivesRecv",
9166 json_object_int_add(json_stat
, "routeRefreshSent",
9168 json_object_int_add(json_stat
, "routeRefreshRecv",
9170 json_object_int_add(json_stat
, "capabilitySent",
9171 p
->dynamic_cap_out
);
9172 json_object_int_add(json_stat
, "capabilityRecv",
9174 json_object_int_add(json_stat
, "totalSent",
9175 p
->open_out
+ p
->notify_out
+ p
->update_out
9176 + p
->keepalive_out
+ p
->refresh_out
9177 + p
->dynamic_cap_out
);
9178 json_object_int_add(json_stat
, "totalRecv",
9179 p
->open_in
+ p
->notify_in
+ p
->update_in
9180 + p
->keepalive_in
+ p
->refresh_in
9181 + p
->dynamic_cap_in
);
9182 json_object_object_add(json_neigh
, "messageStats", json_stat
);
9184 /* Packet counts. */
9185 vty_out(vty
, " Message statistics:\n");
9186 vty_out(vty
, " Inq depth is 0\n");
9187 vty_out(vty
, " Outq depth is %lu\n",
9188 (unsigned long)p
->obuf
->count
);
9189 vty_out(vty
, " Sent Rcvd\n");
9190 vty_out(vty
, " Opens: %10d %10d\n", p
->open_out
,
9192 vty_out(vty
, " Notifications: %10d %10d\n", p
->notify_out
,
9194 vty_out(vty
, " Updates: %10d %10d\n", p
->update_out
,
9196 vty_out(vty
, " Keepalives: %10d %10d\n", p
->keepalive_out
,
9198 vty_out(vty
, " Route Refresh: %10d %10d\n", p
->refresh_out
,
9200 vty_out(vty
, " Capability: %10d %10d\n",
9201 p
->dynamic_cap_out
, p
->dynamic_cap_in
);
9202 vty_out(vty
, " Total: %10d %10d\n",
9203 p
->open_out
+ p
->notify_out
+ p
->update_out
9204 + p
->keepalive_out
+ p
->refresh_out
9205 + p
->dynamic_cap_out
,
9206 p
->open_in
+ p
->notify_in
+ p
->update_in
9207 + p
->keepalive_in
+ p
->refresh_in
9208 + p
->dynamic_cap_in
);
9212 /* advertisement-interval */
9213 json_object_int_add(json_neigh
,
9214 "minBtwnAdvertisementRunsTimerMsecs",
9215 p
->v_routeadv
* 1000);
9217 /* Update-source. */
9218 if (p
->update_if
|| p
->update_source
) {
9220 json_object_string_add(json_neigh
,
9223 else if (p
->update_source
)
9224 json_object_string_add(
9225 json_neigh
, "updateSource",
9226 sockunion2str(p
->update_source
, buf1
,
9230 /* advertisement-interval */
9232 " Minimum time between advertisement runs is %d seconds\n",
9235 /* Update-source. */
9236 if (p
->update_if
|| p
->update_source
) {
9237 vty_out(vty
, " Update source is ");
9239 vty_out(vty
, "%s", p
->update_if
);
9240 else if (p
->update_source
)
9242 sockunion2str(p
->update_source
, buf1
,
9250 /* Address Family Information */
9251 json_object
*json_hold
= NULL
;
9254 json_hold
= json_object_new_object();
9256 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
9257 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
9258 if (p
->afc
[afi
][safi
])
9259 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
9263 json_object_object_add(json_neigh
, "addressFamilyInfo",
9265 json_object_int_add(json_neigh
, "connectionsEstablished",
9267 json_object_int_add(json_neigh
, "connectionsDropped",
9270 vty_out(vty
, " Connections established %d; dropped %d\n",
9271 p
->established
, p
->dropped
);
9273 if (!p
->last_reset
) {
9275 json_object_string_add(json_neigh
, "lastReset",
9278 vty_out(vty
, " Last reset never\n");
9284 uptime
= bgp_clock();
9285 uptime
-= p
->resettime
;
9286 tm
= gmtime(&uptime
);
9287 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
9289 + (tm
->tm_min
* 60000)
9290 + (tm
->tm_hour
* 3600000));
9291 json_object_string_add(
9292 json_neigh
, "lastResetDueTo",
9293 peer_down_str
[(int)p
->last_reset
]);
9294 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9295 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9296 char errorcodesubcode_hexstr
[5];
9297 char errorcodesubcode_str
[256];
9299 code_str
= bgp_notify_code_str(p
->notify
.code
);
9300 subcode_str
= bgp_notify_subcode_str(
9301 p
->notify
.code
, p
->notify
.subcode
);
9303 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
9304 p
->notify
.code
, p
->notify
.subcode
);
9305 json_object_string_add(json_neigh
,
9306 "lastErrorCodeSubcode",
9307 errorcodesubcode_hexstr
);
9308 snprintf(errorcodesubcode_str
, 255, "%s%s",
9309 code_str
, subcode_str
);
9310 json_object_string_add(json_neigh
,
9311 "lastNotificationReason",
9312 errorcodesubcode_str
);
9313 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
9314 && p
->notify
.code
== BGP_NOTIFY_CEASE
9315 && (p
->notify
.subcode
9316 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9317 || p
->notify
.subcode
9318 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
9319 && p
->notify
.length
) {
9321 const char *msg_str
;
9323 msg_str
= bgp_notify_admin_message(
9324 msgbuf
, sizeof(msgbuf
),
9325 (u_char
*)p
->notify
.data
,
9328 json_object_string_add(
9330 "lastShutdownDescription",
9335 vty_out(vty
, " Last reset %s, ",
9336 peer_uptime(p
->resettime
, timebuf
,
9337 BGP_UPTIME_LEN
, 0, NULL
));
9339 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9340 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9341 code_str
= bgp_notify_code_str(p
->notify
.code
);
9342 subcode_str
= bgp_notify_subcode_str(
9343 p
->notify
.code
, p
->notify
.subcode
);
9344 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
9345 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9348 code_str
, subcode_str
);
9349 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
9350 && p
->notify
.code
== BGP_NOTIFY_CEASE
9351 && (p
->notify
.subcode
9352 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9353 || p
->notify
.subcode
9354 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
9355 && p
->notify
.length
) {
9357 const char *msg_str
;
9359 msg_str
= bgp_notify_admin_message(
9360 msgbuf
, sizeof(msgbuf
),
9361 (u_char
*)p
->notify
.data
,
9365 " Message: \"%s\"\n",
9369 vty_out(vty
, "due to %s\n",
9370 peer_down_str
[(int)p
->last_reset
]);
9373 if (p
->last_reset_cause_size
) {
9374 msg
= p
->last_reset_cause
;
9376 " Message received that caused BGP to send a NOTIFICATION:\n ");
9377 for (i
= 1; i
<= p
->last_reset_cause_size
;
9379 vty_out(vty
, "%02X", *msg
++);
9381 if (i
!= p
->last_reset_cause_size
) {
9383 vty_out(vty
, "\n ");
9384 } else if (i
% 4 == 0) {
9394 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
9396 json_object_boolean_true_add(json_neigh
,
9397 "prefixesConfigExceedMax");
9400 " Peer had exceeded the max. no. of prefixes configured.\n");
9402 if (p
->t_pmax_restart
) {
9404 json_object_boolean_true_add(
9405 json_neigh
, "reducePrefixNumFrom");
9406 json_object_int_add(json_neigh
,
9407 "restartInTimerMsec",
9408 thread_timer_remain_second(
9413 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
9414 p
->host
, thread_timer_remain_second(
9415 p
->t_pmax_restart
));
9418 json_object_boolean_true_add(
9420 "reducePrefixNumAndClearIpBgp");
9423 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
9428 /* EBGP Multihop and GTSM */
9429 if (p
->sort
!= BGP_PEER_IBGP
) {
9431 if (p
->gtsm_hops
> 0)
9432 json_object_int_add(json_neigh
,
9433 "externalBgpNbrMaxHopsAway",
9435 else if (p
->ttl
> 1)
9436 json_object_int_add(json_neigh
,
9437 "externalBgpNbrMaxHopsAway",
9440 if (p
->gtsm_hops
> 0)
9442 " External BGP neighbor may be up to %d hops away.\n",
9444 else if (p
->ttl
> 1)
9446 " External BGP neighbor may be up to %d hops away.\n",
9450 if (p
->gtsm_hops
> 0) {
9452 json_object_int_add(json_neigh
,
9453 "internalBgpNbrMaxHopsAway",
9457 " Internal BGP neighbor may be up to %d hops away.\n",
9462 /* Local address. */
9465 json_object_string_add(json_neigh
, "hostLocal",
9466 sockunion2str(p
->su_local
, buf1
,
9468 json_object_int_add(json_neigh
, "portLocal",
9469 ntohs(p
->su_local
->sin
.sin_port
));
9471 vty_out(vty
, "Local host: %s, Local port: %d\n",
9472 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
9473 ntohs(p
->su_local
->sin
.sin_port
));
9476 /* Remote address. */
9479 json_object_string_add(json_neigh
, "hostForeign",
9480 sockunion2str(p
->su_remote
, buf1
,
9482 json_object_int_add(json_neigh
, "portForeign",
9483 ntohs(p
->su_remote
->sin
.sin_port
));
9485 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
9486 sockunion2str(p
->su_remote
, buf1
,
9488 ntohs(p
->su_remote
->sin
.sin_port
));
9491 /* Nexthop display. */
9494 json_object_string_add(json_neigh
, "nexthop",
9496 &p
->nexthop
.v4
, buf1
,
9498 json_object_string_add(json_neigh
, "nexthopGlobal",
9500 &p
->nexthop
.v6_global
,
9501 buf1
, sizeof(buf1
)));
9502 json_object_string_add(json_neigh
, "nexthopLocal",
9504 &p
->nexthop
.v6_local
,
9505 buf1
, sizeof(buf1
)));
9506 if (p
->shared_network
)
9507 json_object_string_add(json_neigh
,
9511 json_object_string_add(json_neigh
,
9513 "nonSharedNetwork");
9515 vty_out(vty
, "Nexthop: %s\n",
9516 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
9518 vty_out(vty
, "Nexthop global: %s\n",
9519 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
9521 vty_out(vty
, "Nexthop local: %s\n",
9522 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
9524 vty_out(vty
, "BGP connection: %s\n",
9525 p
->shared_network
? "shared network"
9526 : "non shared network");
9530 /* Timer information. */
9532 json_object_int_add(json_neigh
, "connectRetryTimer",
9534 if (p
->status
== Established
&& p
->rtt
)
9535 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
9538 json_object_int_add(
9539 json_neigh
, "nextStartTimerDueInMsecs",
9540 thread_timer_remain_second(p
->t_start
) * 1000);
9542 json_object_int_add(
9543 json_neigh
, "nextConnectTimerDueInMsecs",
9544 thread_timer_remain_second(p
->t_connect
)
9546 if (p
->t_routeadv
) {
9547 json_object_int_add(json_neigh
, "mraiInterval",
9549 json_object_int_add(
9550 json_neigh
, "mraiTimerExpireInMsecs",
9551 thread_timer_remain_second(p
->t_routeadv
)
9555 json_object_int_add(json_neigh
, "authenticationEnabled",
9559 json_object_string_add(json_neigh
, "readThread", "on");
9561 json_object_string_add(json_neigh
, "readThread", "off");
9563 json_object_string_add(json_neigh
, "writeThread", "on");
9565 json_object_string_add(json_neigh
, "writeThread",
9568 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
9570 if (p
->status
== Established
&& p
->rtt
)
9571 vty_out(vty
, "Estimated round trip time: %d ms\n",
9574 vty_out(vty
, "Next start timer due in %ld seconds\n",
9575 thread_timer_remain_second(p
->t_start
));
9577 vty_out(vty
, "Next connect timer due in %ld seconds\n",
9578 thread_timer_remain_second(p
->t_connect
));
9581 "MRAI (interval %u) timer expires in %ld seconds\n",
9583 thread_timer_remain_second(p
->t_routeadv
));
9585 vty_out(vty
, "Peer Authentication Enabled\n");
9587 vty_out(vty
, "Read thread: %s Write thread: %s\n",
9588 p
->t_read
? "on" : "off", p
->t_write
? "on" : "off");
9591 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
9592 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
9593 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
9598 /* BFD information. */
9599 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
9602 if (p
->conf_if
) /* Configured interface name. */
9603 json_object_object_add(json
, p
->conf_if
, json_neigh
);
9604 else /* Configured IP address. */
9605 json_object_object_add(json
, p
->host
, json_neigh
);
9609 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
9610 enum show_type type
, union sockunion
*su
,
9611 const char *conf_if
, u_char use_json
,
9614 struct listnode
*node
, *nnode
;
9618 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9619 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9624 bgp_show_peer(vty
, peer
, use_json
, json
);
9629 && !strcmp(peer
->conf_if
, conf_if
))
9631 && !strcmp(peer
->hostname
, conf_if
))) {
9633 bgp_show_peer(vty
, peer
, use_json
,
9637 if (sockunion_same(&peer
->su
, su
)) {
9639 bgp_show_peer(vty
, peer
, use_json
,
9647 if (type
== show_peer
&& !find
) {
9649 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
9651 vty_out(vty
, "%% No such neighbor\n");
9655 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9656 json
, JSON_C_TO_STRING_PRETTY
));
9657 json_object_free(json
);
9665 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
9668 struct listnode
*node
, *nnode
;
9670 json_object
*json
= NULL
;
9674 vty_out(vty
, "{\n");
9676 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
9678 if (!(json
= json_object_new_object())) {
9680 "Unable to allocate memory for JSON object");
9682 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
9686 json_object_int_add(json
, "vrfId",
9687 (bgp
->vrf_id
== VRF_UNKNOWN
)
9690 json_object_string_add(
9692 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9697 vty_out(vty
, ",\n");
9701 vty_out(vty
, "\"%s\":",
9702 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9706 vty_out(vty
, "\nInstance %s:\n",
9707 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9711 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
, use_json
,
9716 vty_out(vty
, "}\n");
9719 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
9720 enum show_type type
, const char *ip_str
,
9726 json_object
*json
= NULL
;
9729 if (strmatch(name
, "all")) {
9730 bgp_show_all_instances_neighbors_vty(vty
, use_json
);
9733 bgp
= bgp_lookup_by_name(name
);
9736 json
= json_object_new_object();
9737 json_object_boolean_true_add(
9738 json
, "bgpNoSuchInstance");
9739 vty_out(vty
, "%s\n",
9740 json_object_to_json_string_ext(
9742 JSON_C_TO_STRING_PRETTY
));
9743 json_object_free(json
);
9746 "%% No such BGP instance exist\n");
9752 bgp
= bgp_get_default();
9756 json
= json_object_new_object();
9758 ret
= str2sockunion(ip_str
, &su
);
9760 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
9763 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
9766 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
9769 json_object_free(json
);
9775 /* "show [ip] bgp neighbors" commands. */
9776 DEFUN (show_ip_bgp_neighbors
,
9777 show_ip_bgp_neighbors_cmd
,
9778 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|vpnv4 <all|rd ASN:nn_or_IP-address:nn>>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
9782 BGP_INSTANCE_HELP_STR
9786 "Display information about all VPNv4 NLRIs\n"
9787 "Display information for a route distinguisher\n"
9788 "VPN Route Distinguisher\n"
9789 "Detailed information on TCP and BGP neighbor connections\n"
9790 "Neighbor to display information about\n"
9791 "Neighbor to display information about\n"
9792 "Neighbor on BGP configured interface\n"
9796 char *sh_arg
= NULL
;
9797 enum show_type sh_type
;
9799 u_char uj
= use_json(argc
, argv
);
9803 if (argv_find(argv
, argc
, "view", &idx
)
9804 || argv_find(argv
, argc
, "vrf", &idx
))
9805 vrf
= argv
[idx
+ 1]->arg
;
9808 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
9809 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
9810 || argv_find(argv
, argc
, "WORD", &idx
)) {
9811 sh_type
= show_peer
;
9812 sh_arg
= argv
[idx
]->arg
;
9816 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
9819 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
9820 paths' and `show ip mbgp paths'. Those functions results are the
9822 DEFUN (show_ip_bgp_paths
,
9823 show_ip_bgp_paths_cmd
,
9824 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
9829 "Path information\n")
9831 vty_out(vty
, "Address Refcnt Path\n");
9832 aspath_print_all_vty(vty
);
9838 static void community_show_all_iterator(struct hash_backet
*backet
,
9841 struct community
*com
;
9843 com
= (struct community
*)backet
->data
;
9844 vty_out(vty
, "[%p] (%ld) %s\n", (void *)backet
, com
->refcnt
,
9845 community_str(com
));
9848 /* Show BGP's community internal data. */
9849 DEFUN (show_ip_bgp_community_info
,
9850 show_ip_bgp_community_info_cmd
,
9851 "show [ip] bgp community-info",
9855 "List all bgp community information\n")
9857 vty_out(vty
, "Address Refcnt Community\n");
9859 hash_iterate(community_hash(),
9860 (void (*)(struct hash_backet
*,
9861 void *))community_show_all_iterator
,
9867 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
9870 struct lcommunity
*lcom
;
9872 lcom
= (struct lcommunity
*)backet
->data
;
9873 vty_out(vty
, "[%p] (%ld) %s\n", (void *)backet
, lcom
->refcnt
,
9874 lcommunity_str(lcom
));
9877 /* Show BGP's community internal data. */
9878 DEFUN (show_ip_bgp_lcommunity_info
,
9879 show_ip_bgp_lcommunity_info_cmd
,
9880 "show ip bgp large-community-info",
9884 "List all bgp large-community information\n")
9886 vty_out(vty
, "Address Refcnt Large-community\n");
9888 hash_iterate(lcommunity_hash(),
9889 (void (*)(struct hash_backet
*,
9890 void *))lcommunity_show_all_iterator
,
9897 DEFUN (show_ip_bgp_attr_info
,
9898 show_ip_bgp_attr_info_cmd
,
9899 "show [ip] bgp attribute-info",
9903 "List all bgp attribute information\n")
9909 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
9912 struct listnode
*node
, *nnode
;
9915 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
9916 vty_out(vty
, "\nInstance %s:\n",
9917 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9920 update_group_show(bgp
, afi
, safi
, vty
, 0);
9924 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
9925 int safi
, uint64_t subgrp_id
)
9930 if (strmatch(name
, "all")) {
9931 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
9934 bgp
= bgp_lookup_by_name(name
);
9937 bgp
= bgp_get_default();
9941 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
9945 DEFUN (show_ip_bgp_updgrps
,
9946 show_ip_bgp_updgrps_cmd
,
9947 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
9951 BGP_INSTANCE_HELP_STR
9953 BGP_SAFI_WITH_LABEL_HELP_STR
9954 "Detailed info about dynamic update groups\n"
9955 "Specific subgroup to display detailed info for\n")
9958 afi_t afi
= AFI_IP6
;
9959 safi_t safi
= SAFI_UNICAST
;
9960 uint64_t subgrp_id
= 0;
9965 if (argv_find(argv
, argc
, "ip", &idx
))
9967 /* [<view|vrf> VIEWVRFNAME] */
9968 if (argv_find(argv
, argc
, "view", &idx
)
9969 || argv_find(argv
, argc
, "vrf", &idx
))
9970 vrf
= argv
[++idx
]->arg
;
9971 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9972 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
9973 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9976 /* get subgroup id, if provided */
9978 if (argv
[idx
]->type
== VARIABLE_TKN
)
9979 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
9981 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
9984 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
9985 show_bgp_instance_all_ipv6_updgrps_cmd
,
9986 "show [ip] bgp <view|vrf> all update-groups",
9990 BGP_INSTANCE_ALL_HELP_STR
9991 "Detailed info about dynamic update groups\n")
9993 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
9997 DEFUN (show_bgp_updgrps_stats
,
9998 show_bgp_updgrps_stats_cmd
,
9999 "show [ip] bgp update-groups statistics",
10003 "Detailed info about dynamic update groups\n"
10008 bgp
= bgp_get_default();
10010 update_group_show_stats(bgp
, vty
);
10012 return CMD_SUCCESS
;
10015 DEFUN (show_bgp_instance_updgrps_stats
,
10016 show_bgp_instance_updgrps_stats_cmd
,
10017 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
10021 BGP_INSTANCE_HELP_STR
10022 "Detailed info about dynamic update groups\n"
10028 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
10030 update_group_show_stats(bgp
, vty
);
10032 return CMD_SUCCESS
;
10035 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
10036 afi_t afi
, safi_t safi
,
10037 const char *what
, uint64_t subgrp_id
)
10042 bgp
= bgp_lookup_by_name(name
);
10044 bgp
= bgp_get_default();
10047 if (!strcmp(what
, "advertise-queue"))
10048 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
10050 else if (!strcmp(what
, "advertised-routes"))
10051 update_group_show_advertised(bgp
, afi
, safi
, vty
,
10053 else if (!strcmp(what
, "packet-queue"))
10054 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
10059 DEFUN (show_ip_bgp_updgrps_adj
,
10060 show_ip_bgp_updgrps_adj_cmd
,
10061 "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
10065 "Detailed info about dynamic update groups\n"
10066 "Advertisement queue\n"
10067 "Announced routes\n"
10071 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10072 argv
[idx_type
]->arg
, 0);
10073 return CMD_SUCCESS
;
10076 DEFUN (show_ip_bgp_instance_updgrps_adj
,
10077 show_ip_bgp_instance_updgrps_adj_cmd
,
10078 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>",
10082 BGP_INSTANCE_HELP_STR
10083 "Detailed info about dynamic update groups\n"
10084 "Advertisement queue\n"
10085 "Announced routes\n"
10090 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_word
]->arg
, AFI_IP
,
10091 SAFI_UNICAST
, argv
[idx_type
]->arg
, 0);
10092 return CMD_SUCCESS
;
10095 DEFUN (show_bgp_updgrps_afi_adj
,
10096 show_bgp_updgrps_afi_adj_cmd
,
10097 "show [ip] bgp "BGP_AFI_SAFI_CMD_STR
" update-groups <advertise-queue|advertised-routes|packet-queue>",
10101 BGP_AFI_SAFI_HELP_STR
10102 "Detailed info about dynamic update groups\n"
10103 "Advertisement queue\n"
10104 "Announced routes\n"
10110 show_bgp_updgrps_adj_info_aux(
10111 vty
, NULL
, bgp_vty_afi_from_str(argv
[idx_afi
]->text
),
10112 bgp_vty_safi_from_str(argv
[idx_safi
]->text
),
10113 argv
[idx_type
]->arg
, 0);
10114 return CMD_SUCCESS
;
10117 DEFUN (show_bgp_updgrps_adj
,
10118 show_bgp_updgrps_adj_cmd
,
10119 "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
10123 "Detailed info about dynamic update groups\n"
10124 "Advertisement queue\n"
10125 "Announced routes\n"
10129 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10130 argv
[idx_type
]->arg
, 0);
10131 return CMD_SUCCESS
;
10134 DEFUN (show_bgp_instance_updgrps_adj
,
10135 show_bgp_instance_updgrps_adj_cmd
,
10136 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>",
10140 BGP_INSTANCE_HELP_STR
10141 "Detailed info about dynamic update groups\n"
10142 "Advertisement queue\n"
10143 "Announced routes\n"
10148 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_word
]->arg
, AFI_IP6
,
10149 SAFI_UNICAST
, argv
[idx_type
]->arg
, 0);
10150 return CMD_SUCCESS
;
10153 DEFUN (show_ip_bgp_updgrps_adj_s
,
10154 show_ip_bgp_updgrps_adj_s_cmd
,
10155 "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10159 "Detailed info about dynamic update groups\n"
10160 "Specific subgroup to display info for\n"
10161 "Advertisement queue\n"
10162 "Announced routes\n"
10165 int idx_subgroup_id
= 4;
10167 uint64_t subgrp_id
;
10169 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10171 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10172 argv
[idx_type
]->arg
, subgrp_id
);
10173 return CMD_SUCCESS
;
10176 DEFUN (show_ip_bgp_instance_updgrps_adj_s
,
10177 show_ip_bgp_instance_updgrps_adj_s_cmd
,
10178 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10182 BGP_INSTANCE_HELP_STR
10183 "Detailed info about dynamic update groups\n"
10184 "Specific subgroup to display info for\n"
10185 "Advertisement queue\n"
10186 "Announced routes\n"
10190 int idx_subgroup_id
= 6;
10192 uint64_t subgrp_id
;
10194 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10196 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_vrf
]->arg
, AFI_IP
,
10197 SAFI_UNICAST
, argv
[idx_type
]->arg
,
10199 return CMD_SUCCESS
;
10202 DEFUN (show_bgp_updgrps_afi_adj_s
,
10203 show_bgp_updgrps_afi_adj_s_cmd
,
10204 "show [ip] bgp "BGP_AFI_SAFI_CMD_STR
" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10208 BGP_AFI_SAFI_HELP_STR
10209 "Detailed info about dynamic update groups\n"
10210 "Specific subgroup to display info for\n"
10211 "Advertisement queue\n"
10212 "Announced routes\n"
10217 int idx_subgroup_id
= 5;
10219 uint64_t subgrp_id
;
10221 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10223 show_bgp_updgrps_adj_info_aux(
10224 vty
, NULL
, bgp_vty_afi_from_str(argv
[idx_afi
]->text
),
10225 bgp_vty_safi_from_str(argv
[idx_safi
]->text
),
10226 argv
[idx_type
]->arg
, subgrp_id
);
10227 return CMD_SUCCESS
;
10230 DEFUN (show_bgp_updgrps_adj_s
,
10231 show_bgp_updgrps_adj_s_cmd
,
10232 "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10236 "Detailed info about dynamic update groups\n"
10237 "Specific subgroup to display info for\n"
10238 "Advertisement queue\n"
10239 "Announced routes\n"
10242 int idx_subgroup_id
= 3;
10244 uint64_t subgrp_id
;
10246 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10248 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10249 argv
[idx_type
]->arg
, subgrp_id
);
10250 return CMD_SUCCESS
;
10253 DEFUN (show_bgp_instance_updgrps_adj_s
,
10254 show_bgp_instance_updgrps_adj_s_cmd
,
10255 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10259 BGP_INSTANCE_HELP_STR
10260 "Detailed info about dynamic update groups\n"
10261 "Specific subgroup to display info for\n"
10262 "Advertisement queue\n"
10263 "Announced routes\n"
10267 int idx_subgroup_id
= 5;
10269 uint64_t subgrp_id
;
10271 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10273 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_vrf
]->arg
, AFI_IP6
,
10274 SAFI_UNICAST
, argv
[idx_type
]->arg
,
10276 return CMD_SUCCESS
;
10280 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
10282 struct listnode
*node
, *nnode
;
10283 struct prefix
*range
;
10286 char buf
[PREFIX2STR_BUFFER
];
10289 const char *peer_status
;
10290 const char *af_str
;
10295 conf
= group
->conf
;
10297 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
10298 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10300 } else if (conf
->as_type
== AS_INTERNAL
) {
10301 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10304 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
10307 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
10308 vty_out(vty
, " Peer-group type is internal\n");
10310 vty_out(vty
, " Peer-group type is external\n");
10312 /* Display AFs configured. */
10313 vty_out(vty
, " Configured address-families:");
10314 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
10315 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++) {
10316 if (conf
->afc
[afi
][safi
]) {
10318 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
10322 vty_out(vty
, " none\n");
10324 vty_out(vty
, "\n");
10326 /* Display listen ranges (for dynamic neighbors), if any */
10327 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
10330 else if (afi
== AFI_IP6
)
10334 lr_count
= listcount(group
->listen_range
[afi
]);
10336 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
10340 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
10342 prefix2str(range
, buf
, sizeof(buf
));
10343 vty_out(vty
, " %s\n", buf
);
10348 /* Display group members and their status */
10349 if (listcount(group
->peer
)) {
10350 vty_out(vty
, " Peer-group members:\n");
10351 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
10352 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
10353 peer_status
= "Idle (Admin)";
10354 else if (CHECK_FLAG(peer
->sflags
,
10355 PEER_STATUS_PREFIX_OVERFLOW
))
10356 peer_status
= "Idle (PfxCt)";
10358 peer_status
= lookup_msg(bgp_status_msg
,
10359 peer
->status
, NULL
);
10361 dynamic
= peer_dynamic_neighbor(peer
);
10362 vty_out(vty
, " %s %s %s \n", peer
->host
,
10363 dynamic
? "(dynamic)" : "", peer_status
);
10367 return CMD_SUCCESS
;
10370 /* Show BGP peer group's information. */
10371 enum show_group_type
{ show_all_groups
, show_peer_group
};
10373 static int bgp_show_peer_group(struct vty
*vty
, struct bgp
*bgp
,
10374 enum show_group_type type
,
10375 const char *group_name
)
10377 struct listnode
*node
, *nnode
;
10378 struct peer_group
*group
;
10381 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
10383 case show_all_groups
:
10384 bgp_show_one_peer_group(vty
, group
);
10386 case show_peer_group
:
10388 && (strcmp(group
->name
, group_name
) == 0)) {
10390 bgp_show_one_peer_group(vty
, group
);
10396 if (type
== show_peer_group
&& !find
)
10397 vty_out(vty
, "%% No such peer-group\n");
10399 return CMD_SUCCESS
;
10402 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
10403 enum show_group_type type
,
10404 const char *group_name
)
10407 int ret
= CMD_SUCCESS
;
10410 bgp
= bgp_lookup_by_name(name
);
10412 bgp
= bgp_get_default();
10415 vty_out(vty
, "%% No such BGP instance exist\n");
10416 return CMD_WARNING
;
10419 ret
= bgp_show_peer_group(vty
, bgp
, type
, group_name
);
10424 DEFUN (show_ip_bgp_peer_groups
,
10425 show_ip_bgp_peer_groups_cmd
,
10426 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
10430 BGP_INSTANCE_HELP_STR
10431 "Detailed information on BGP peer groups\n"
10432 "Peer group name\n")
10438 vrf
= argv_find(argv
, argc
, "WORD", &idx
) ? argv
[idx
]->arg
: NULL
;
10439 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
10441 return bgp_show_peer_group_vty(vty
, vrf
, show_all_groups
, pg
);
10445 /* Redistribute VTY commands. */
10447 DEFUN (bgp_redistribute_ipv4
,
10448 bgp_redistribute_ipv4_cmd
,
10449 "redistribute " FRR_IP_REDIST_STR_BGPD
,
10450 "Redistribute information from another routing protocol\n"
10451 FRR_IP_REDIST_HELP_STR_BGPD
)
10453 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10454 int idx_protocol
= 1;
10457 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10459 vty_out(vty
, "%% Invalid route type\n");
10460 return CMD_WARNING_CONFIG_FAILED
;
10462 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10463 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10467 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
10468 "redistribute " FRR_IP_REDIST_STR_BGPD
,
10469 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
10471 DEFUN (bgp_redistribute_ipv4_rmap
,
10472 bgp_redistribute_ipv4_rmap_cmd
,
10473 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
10474 "Redistribute information from another routing protocol\n"
10475 FRR_IP_REDIST_HELP_STR_BGPD
10476 "Route map reference\n"
10477 "Pointer to route-map entries\n")
10479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10480 int idx_protocol
= 1;
10483 struct bgp_redist
*red
;
10485 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10487 vty_out(vty
, "%% Invalid route type\n");
10488 return CMD_WARNING_CONFIG_FAILED
;
10491 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10492 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10493 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10497 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
10498 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
10499 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10500 "Route map reference\n"
10501 "Pointer to route-map entries\n")
10503 DEFUN (bgp_redistribute_ipv4_metric
,
10504 bgp_redistribute_ipv4_metric_cmd
,
10505 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
10506 "Redistribute information from another routing protocol\n"
10507 FRR_IP_REDIST_HELP_STR_BGPD
10508 "Metric for redistributed routes\n"
10509 "Default metric\n")
10511 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10512 int idx_protocol
= 1;
10513 int idx_number
= 3;
10516 struct bgp_redist
*red
;
10518 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10520 vty_out(vty
, "%% Invalid route type\n");
10521 return CMD_WARNING_CONFIG_FAILED
;
10523 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10525 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10526 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
10527 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10531 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
10532 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
10533 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10534 "Metric for redistributed routes\n"
10535 "Default metric\n")
10537 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
10538 bgp_redistribute_ipv4_rmap_metric_cmd
,
10539 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
10540 "Redistribute information from another routing protocol\n"
10541 FRR_IP_REDIST_HELP_STR_BGPD
10542 "Route map reference\n"
10543 "Pointer to route-map entries\n"
10544 "Metric for redistributed routes\n"
10545 "Default metric\n")
10547 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10548 int idx_protocol
= 1;
10550 int idx_number
= 5;
10553 struct bgp_redist
*red
;
10555 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10557 vty_out(vty
, "%% Invalid route type\n");
10558 return CMD_WARNING_CONFIG_FAILED
;
10560 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10562 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10563 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10564 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
10565 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10569 bgp_redistribute_ipv4_rmap_metric
,
10570 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
10571 "redistribute " FRR_IP_REDIST_STR_BGPD
10572 " route-map WORD metric (0-4294967295)",
10573 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10574 "Route map reference\n"
10575 "Pointer to route-map entries\n"
10576 "Metric for redistributed routes\n"
10577 "Default metric\n")
10579 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
10580 bgp_redistribute_ipv4_metric_rmap_cmd
,
10581 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
10582 "Redistribute information from another routing protocol\n"
10583 FRR_IP_REDIST_HELP_STR_BGPD
10584 "Metric for redistributed routes\n"
10586 "Route map reference\n"
10587 "Pointer to route-map entries\n")
10589 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10590 int idx_protocol
= 1;
10591 int idx_number
= 3;
10595 struct bgp_redist
*red
;
10597 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10599 vty_out(vty
, "%% Invalid route type\n");
10600 return CMD_WARNING_CONFIG_FAILED
;
10602 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10604 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10605 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
10606 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10607 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10611 bgp_redistribute_ipv4_metric_rmap
,
10612 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
10613 "redistribute " FRR_IP_REDIST_STR_BGPD
10614 " metric (0-4294967295) route-map WORD",
10615 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10616 "Metric for redistributed routes\n"
10618 "Route map reference\n"
10619 "Pointer to route-map entries\n")
10621 DEFUN (bgp_redistribute_ipv4_ospf
,
10622 bgp_redistribute_ipv4_ospf_cmd
,
10623 "redistribute <ospf|table> (1-65535)",
10624 "Redistribute information from another routing protocol\n"
10625 "Open Shortest Path First (OSPFv2)\n"
10626 "Non-main Kernel Routing Table\n"
10627 "Instance ID/Table ID\n")
10629 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10630 int idx_ospf_table
= 1;
10631 int idx_number
= 2;
10635 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10637 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10638 protocol
= ZEBRA_ROUTE_OSPF
;
10640 protocol
= ZEBRA_ROUTE_TABLE
;
10642 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10643 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10646 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
10647 "redistribute <ospf|table> (1-65535)",
10648 "Redistribute information from another routing protocol\n"
10649 "Open Shortest Path First (OSPFv2)\n"
10650 "Non-main Kernel Routing Table\n"
10651 "Instance ID/Table ID\n")
10653 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
10654 bgp_redistribute_ipv4_ospf_rmap_cmd
,
10655 "redistribute <ospf|table> (1-65535) route-map WORD",
10656 "Redistribute information from another routing protocol\n"
10657 "Open Shortest Path First (OSPFv2)\n"
10658 "Non-main Kernel Routing Table\n"
10659 "Instance ID/Table ID\n"
10660 "Route map reference\n"
10661 "Pointer to route-map entries\n")
10663 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10664 int idx_ospf_table
= 1;
10665 int idx_number
= 2;
10667 struct bgp_redist
*red
;
10671 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10672 protocol
= ZEBRA_ROUTE_OSPF
;
10674 protocol
= ZEBRA_ROUTE_TABLE
;
10676 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10677 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10678 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10679 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10682 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
10683 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
10684 "redistribute <ospf|table> (1-65535) route-map WORD",
10685 "Redistribute information from another routing protocol\n"
10686 "Open Shortest Path First (OSPFv2)\n"
10687 "Non-main Kernel Routing Table\n"
10688 "Instance ID/Table ID\n"
10689 "Route map reference\n"
10690 "Pointer to route-map entries\n")
10692 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
10693 bgp_redistribute_ipv4_ospf_metric_cmd
,
10694 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
10695 "Redistribute information from another routing protocol\n"
10696 "Open Shortest Path First (OSPFv2)\n"
10697 "Non-main Kernel Routing Table\n"
10698 "Instance ID/Table ID\n"
10699 "Metric for redistributed routes\n"
10700 "Default metric\n")
10702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10703 int idx_ospf_table
= 1;
10704 int idx_number
= 2;
10705 int idx_number_2
= 4;
10707 struct bgp_redist
*red
;
10711 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10712 protocol
= ZEBRA_ROUTE_OSPF
;
10714 protocol
= ZEBRA_ROUTE_TABLE
;
10716 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10717 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
10719 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10720 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
10721 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10724 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
10725 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
10726 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
10727 "Redistribute information from another routing protocol\n"
10728 "Open Shortest Path First (OSPFv2)\n"
10729 "Non-main Kernel Routing Table\n"
10730 "Instance ID/Table ID\n"
10731 "Metric for redistributed routes\n"
10732 "Default metric\n")
10734 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
10735 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
10736 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
10737 "Redistribute information from another routing protocol\n"
10738 "Open Shortest Path First (OSPFv2)\n"
10739 "Non-main Kernel Routing Table\n"
10740 "Instance ID/Table ID\n"
10741 "Route map reference\n"
10742 "Pointer to route-map entries\n"
10743 "Metric for redistributed routes\n"
10744 "Default metric\n")
10746 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10747 int idx_ospf_table
= 1;
10748 int idx_number
= 2;
10750 int idx_number_2
= 6;
10752 struct bgp_redist
*red
;
10756 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10757 protocol
= ZEBRA_ROUTE_OSPF
;
10759 protocol
= ZEBRA_ROUTE_TABLE
;
10761 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10762 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
10764 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10765 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10766 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
10767 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10771 bgp_redistribute_ipv4_ospf_rmap_metric
,
10772 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
10773 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
10774 "Redistribute information from another routing protocol\n"
10775 "Open Shortest Path First (OSPFv2)\n"
10776 "Non-main Kernel Routing Table\n"
10777 "Instance ID/Table ID\n"
10778 "Route map reference\n"
10779 "Pointer to route-map entries\n"
10780 "Metric for redistributed routes\n"
10781 "Default metric\n")
10783 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
10784 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
10785 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
10786 "Redistribute information from another routing protocol\n"
10787 "Open Shortest Path First (OSPFv2)\n"
10788 "Non-main Kernel Routing Table\n"
10789 "Instance ID/Table ID\n"
10790 "Metric for redistributed routes\n"
10792 "Route map reference\n"
10793 "Pointer to route-map entries\n")
10795 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10796 int idx_ospf_table
= 1;
10797 int idx_number
= 2;
10798 int idx_number_2
= 4;
10801 struct bgp_redist
*red
;
10805 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10806 protocol
= ZEBRA_ROUTE_OSPF
;
10808 protocol
= ZEBRA_ROUTE_TABLE
;
10810 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10811 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
10813 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10814 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
10815 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10816 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10820 bgp_redistribute_ipv4_ospf_metric_rmap
,
10821 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
10822 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
10823 "Redistribute information from another routing protocol\n"
10824 "Open Shortest Path First (OSPFv2)\n"
10825 "Non-main Kernel Routing Table\n"
10826 "Instance ID/Table ID\n"
10827 "Metric for redistributed routes\n"
10829 "Route map reference\n"
10830 "Pointer to route-map entries\n")
10832 DEFUN (no_bgp_redistribute_ipv4_ospf
,
10833 no_bgp_redistribute_ipv4_ospf_cmd
,
10834 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
10836 "Redistribute information from another routing protocol\n"
10837 "Open Shortest Path First (OSPFv2)\n"
10838 "Non-main Kernel Routing Table\n"
10839 "Instance ID/Table ID\n"
10840 "Metric for redistributed routes\n"
10842 "Route map reference\n"
10843 "Pointer to route-map entries\n")
10845 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10846 int idx_ospf_table
= 2;
10847 int idx_number
= 3;
10851 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10852 protocol
= ZEBRA_ROUTE_OSPF
;
10854 protocol
= ZEBRA_ROUTE_TABLE
;
10856 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10857 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
10861 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
10862 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
10864 "Redistribute information from another routing protocol\n"
10865 "Open Shortest Path First (OSPFv2)\n"
10866 "Non-main Kernel Routing Table\n"
10867 "Instance ID/Table ID\n"
10868 "Metric for redistributed routes\n"
10870 "Route map reference\n"
10871 "Pointer to route-map entries\n")
10873 DEFUN (no_bgp_redistribute_ipv4
,
10874 no_bgp_redistribute_ipv4_cmd
,
10875 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
10877 "Redistribute information from another routing protocol\n"
10878 FRR_IP_REDIST_HELP_STR_BGPD
10879 "Metric for redistributed routes\n"
10881 "Route map reference\n"
10882 "Pointer to route-map entries\n")
10884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10885 int idx_protocol
= 2;
10888 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10890 vty_out(vty
, "%% Invalid route type\n");
10891 return CMD_WARNING_CONFIG_FAILED
;
10893 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
10897 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
10898 "no redistribute " FRR_IP_REDIST_STR_BGPD
10899 " [metric (0-4294967295)] [route-map WORD]",
10901 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10902 "Metric for redistributed routes\n"
10904 "Route map reference\n"
10905 "Pointer to route-map entries\n")
10907 DEFUN (bgp_redistribute_ipv6
,
10908 bgp_redistribute_ipv6_cmd
,
10909 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
10910 "Redistribute information from another routing protocol\n"
10911 FRR_IP6_REDIST_HELP_STR_BGPD
)
10913 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10914 int idx_protocol
= 1;
10917 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
10919 vty_out(vty
, "%% Invalid route type\n");
10920 return CMD_WARNING_CONFIG_FAILED
;
10923 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
10924 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
10927 DEFUN (bgp_redistribute_ipv6_rmap
,
10928 bgp_redistribute_ipv6_rmap_cmd
,
10929 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
10930 "Redistribute information from another routing protocol\n"
10931 FRR_IP6_REDIST_HELP_STR_BGPD
10932 "Route map reference\n"
10933 "Pointer to route-map entries\n")
10935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10936 int idx_protocol
= 1;
10939 struct bgp_redist
*red
;
10941 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
10943 vty_out(vty
, "%% Invalid route type\n");
10944 return CMD_WARNING_CONFIG_FAILED
;
10947 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
10948 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10949 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
10952 DEFUN (bgp_redistribute_ipv6_metric
,
10953 bgp_redistribute_ipv6_metric_cmd
,
10954 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
10955 "Redistribute information from another routing protocol\n"
10956 FRR_IP6_REDIST_HELP_STR_BGPD
10957 "Metric for redistributed routes\n"
10958 "Default metric\n")
10960 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10961 int idx_protocol
= 1;
10962 int idx_number
= 3;
10965 struct bgp_redist
*red
;
10967 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
10969 vty_out(vty
, "%% Invalid route type\n");
10970 return CMD_WARNING_CONFIG_FAILED
;
10972 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10974 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
10975 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
10976 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
10979 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
10980 bgp_redistribute_ipv6_rmap_metric_cmd
,
10981 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
10982 "Redistribute information from another routing protocol\n"
10983 FRR_IP6_REDIST_HELP_STR_BGPD
10984 "Route map reference\n"
10985 "Pointer to route-map entries\n"
10986 "Metric for redistributed routes\n"
10987 "Default metric\n")
10989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10990 int idx_protocol
= 1;
10992 int idx_number
= 5;
10995 struct bgp_redist
*red
;
10997 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
10999 vty_out(vty
, "%% Invalid route type\n");
11000 return CMD_WARNING_CONFIG_FAILED
;
11002 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11004 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11005 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11006 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11007 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11010 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
11011 bgp_redistribute_ipv6_metric_rmap_cmd
,
11012 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11013 "Redistribute information from another routing protocol\n"
11014 FRR_IP6_REDIST_HELP_STR_BGPD
11015 "Metric for redistributed routes\n"
11017 "Route map reference\n"
11018 "Pointer to route-map entries\n")
11020 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11021 int idx_protocol
= 1;
11022 int idx_number
= 3;
11026 struct bgp_redist
*red
;
11028 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11030 vty_out(vty
, "%% Invalid route type\n");
11031 return CMD_WARNING_CONFIG_FAILED
;
11033 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11035 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11036 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
11037 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11038 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11041 DEFUN (no_bgp_redistribute_ipv6
,
11042 no_bgp_redistribute_ipv6_cmd
,
11043 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11045 "Redistribute information from another routing protocol\n"
11046 FRR_IP6_REDIST_HELP_STR_BGPD
11047 "Metric for redistributed routes\n"
11049 "Route map reference\n"
11050 "Pointer to route-map entries\n")
11052 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11053 int idx_protocol
= 2;
11056 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11058 vty_out(vty
, "%% Invalid route type\n");
11059 return CMD_WARNING_CONFIG_FAILED
;
11062 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
11065 int bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
11066 safi_t safi
, int *write
)
11070 /* Unicast redistribution only. */
11071 if (safi
!= SAFI_UNICAST
)
11074 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
11075 /* Redistribute BGP does not make sense. */
11076 if (i
!= ZEBRA_ROUTE_BGP
) {
11077 struct list
*red_list
;
11078 struct listnode
*node
;
11079 struct bgp_redist
*red
;
11081 red_list
= bgp
->redist
[afi
][i
];
11085 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
11086 /* Display "address-family" when it is not yet
11088 bgp_config_write_family_header(vty
, afi
, safi
,
11091 /* "redistribute" configuration. */
11092 vty_out(vty
, " redistribute %s",
11093 zebra_route_string(i
));
11095 vty_out(vty
, " %d", red
->instance
);
11096 if (red
->redist_metric_flag
)
11097 vty_out(vty
, " metric %u",
11098 red
->redist_metric
);
11099 if (red
->rmap
.name
)
11100 vty_out(vty
, " route-map %s",
11102 vty_out(vty
, "\n");
11109 /* BGP node structure. */
11110 static struct cmd_node bgp_node
= {
11111 BGP_NODE
, "%s(config-router)# ", 1,
11114 static struct cmd_node bgp_ipv4_unicast_node
= {
11115 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
11118 static struct cmd_node bgp_ipv4_multicast_node
= {
11119 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
11122 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
11123 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
11126 static struct cmd_node bgp_ipv6_unicast_node
= {
11127 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
11130 static struct cmd_node bgp_ipv6_multicast_node
= {
11131 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
11134 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
11135 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
11138 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
11139 "%s(config-router-af)# ", 1};
11141 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
11142 "%s(config-router-af-vpnv6)# ", 1};
11144 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
11145 "%s(config-router-evpn)# ", 1};
11147 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
11148 "%s(config-router-af-vni)# ", 1};
11150 static void community_list_vty(void);
11152 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
11156 struct peer_group
*group
;
11157 struct listnode
*lnbgp
, *lnpeer
;
11159 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
11160 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
11161 /* only provide suggestions on the appropriate input
11163 * they'll otherwise show up multiple times */
11164 enum cmd_token_type match_type
;
11165 char *name
= peer
->host
;
11167 if (peer
->conf_if
) {
11168 match_type
= VARIABLE_TKN
;
11169 name
= peer
->conf_if
;
11170 } else if (strchr(peer
->host
, ':'))
11171 match_type
= IPV6_TKN
;
11173 match_type
= IPV4_TKN
;
11175 if (token
->type
!= match_type
)
11178 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
11181 if (token
->type
== VARIABLE_TKN
)
11182 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
11183 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
11188 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
11189 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
11190 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
11191 {.completions
= NULL
}};
11193 void bgp_vty_init(void)
11195 cmd_variable_handler_register(bgp_var_neighbor
);
11197 /* Install bgp top node. */
11198 install_node(&bgp_node
, bgp_config_write
);
11199 install_node(&bgp_ipv4_unicast_node
, NULL
);
11200 install_node(&bgp_ipv4_multicast_node
, NULL
);
11201 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
11202 install_node(&bgp_ipv6_unicast_node
, NULL
);
11203 install_node(&bgp_ipv6_multicast_node
, NULL
);
11204 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
11205 install_node(&bgp_vpnv4_node
, NULL
);
11206 install_node(&bgp_vpnv6_node
, NULL
);
11207 install_node(&bgp_evpn_node
, NULL
);
11208 install_node(&bgp_evpn_vni_node
, NULL
);
11210 /* Install default VTY commands to new nodes. */
11211 install_default(BGP_NODE
);
11212 install_default(BGP_IPV4_NODE
);
11213 install_default(BGP_IPV4M_NODE
);
11214 install_default(BGP_IPV4L_NODE
);
11215 install_default(BGP_IPV6_NODE
);
11216 install_default(BGP_IPV6M_NODE
);
11217 install_default(BGP_IPV6L_NODE
);
11218 install_default(BGP_VPNV4_NODE
);
11219 install_default(BGP_VPNV6_NODE
);
11220 install_default(BGP_EVPN_NODE
);
11221 install_default(BGP_EVPN_VNI_NODE
);
11223 /* "bgp multiple-instance" commands. */
11224 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
11225 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
11227 /* "bgp config-type" commands. */
11228 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
11229 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
11231 /* bgp route-map delay-timer commands. */
11232 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
11233 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
11235 /* Dummy commands (Currently not supported) */
11236 install_element(BGP_NODE
, &no_synchronization_cmd
);
11237 install_element(BGP_NODE
, &no_auto_summary_cmd
);
11239 /* "router bgp" commands. */
11240 install_element(CONFIG_NODE
, &router_bgp_cmd
);
11242 /* "no router bgp" commands. */
11243 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
11245 /* "bgp router-id" commands. */
11246 install_element(BGP_NODE
, &bgp_router_id_cmd
);
11247 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
11249 /* "bgp cluster-id" commands. */
11250 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
11251 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
11253 /* "bgp confederation" commands. */
11254 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
11255 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
11257 /* "bgp confederation peers" commands. */
11258 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
11259 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
11261 /* bgp max-med command */
11262 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
11263 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
11264 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
11265 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
11266 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
11268 /* bgp disable-ebgp-connected-nh-check */
11269 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
11270 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
11272 /* bgp update-delay command */
11273 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
11274 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
11275 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
11277 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
11278 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
11280 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
11281 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
11283 /* "maximum-paths" commands. */
11284 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
11285 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
11286 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
11287 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
11288 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
11289 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
11290 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
11291 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
11292 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
11293 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
11294 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11295 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11296 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
11297 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11298 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11300 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
11301 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
11302 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
11303 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11304 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11306 /* "timers bgp" commands. */
11307 install_element(BGP_NODE
, &bgp_timers_cmd
);
11308 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
11310 /* route-map delay-timer commands - per instance for backwards compat.
11312 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
11313 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
11315 /* "bgp client-to-client reflection" commands */
11316 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
11317 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
11319 /* "bgp always-compare-med" commands */
11320 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
11321 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
11323 /* "bgp deterministic-med" commands */
11324 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
11325 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
11327 /* "bgp graceful-restart" commands */
11328 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
11329 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
11330 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
11331 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
11332 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
11333 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
11335 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
11336 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
11338 /* "bgp fast-external-failover" commands */
11339 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
11340 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
11342 /* "bgp enforce-first-as" commands */
11343 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
11344 install_element(BGP_NODE
, &no_bgp_enforce_first_as_cmd
);
11346 /* "bgp bestpath compare-routerid" commands */
11347 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
11348 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
11350 /* "bgp bestpath as-path ignore" commands */
11351 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
11352 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
11354 /* "bgp bestpath as-path confed" commands */
11355 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
11356 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
11358 /* "bgp bestpath as-path multipath-relax" commands */
11359 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
11360 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
11362 /* "bgp log-neighbor-changes" commands */
11363 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
11364 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
11366 /* "bgp bestpath med" commands */
11367 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
11368 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
11370 /* "no bgp default ipv4-unicast" commands. */
11371 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
11372 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
11374 /* "bgp network import-check" commands. */
11375 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
11376 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
11377 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
11379 /* "bgp default local-preference" commands. */
11380 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
11381 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
11383 /* bgp default show-hostname */
11384 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
11385 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
11387 /* "bgp default subgroup-pkt-queue-max" commands. */
11388 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
11389 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
11391 /* bgp ibgp-allow-policy-mods command */
11392 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
11393 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
11395 /* "bgp listen limit" commands. */
11396 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
11397 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
11399 /* "bgp listen range" commands. */
11400 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
11401 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
11403 /* "neighbor remote-as" commands. */
11404 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
11405 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
11406 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
11407 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
11408 install_element(BGP_NODE
,
11409 &neighbor_interface_v6only_config_remote_as_cmd
);
11410 install_element(BGP_NODE
, &no_neighbor_cmd
);
11411 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
11413 /* "neighbor peer-group" commands. */
11414 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
11415 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
11416 install_element(BGP_NODE
,
11417 &no_neighbor_interface_peer_group_remote_as_cmd
);
11419 /* "neighbor local-as" commands. */
11420 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
11421 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
11422 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
11423 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
11425 /* "neighbor solo" commands. */
11426 install_element(BGP_NODE
, &neighbor_solo_cmd
);
11427 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
11429 /* "neighbor password" commands. */
11430 install_element(BGP_NODE
, &neighbor_password_cmd
);
11431 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
11433 /* "neighbor activate" commands. */
11434 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
11435 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
11436 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
11437 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
11438 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
11439 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
11440 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
11441 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
11442 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
11443 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
11445 /* "no neighbor activate" commands. */
11446 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
11447 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
11448 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
11449 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
11450 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
11451 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
11452 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
11453 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
11454 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
11455 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
11457 /* "neighbor peer-group" set commands. */
11458 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
11459 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11460 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11461 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11462 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11463 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11464 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11465 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11467 /* "no neighbor peer-group unset" commands. */
11468 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
11469 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11470 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11471 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11472 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11473 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11474 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11475 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11477 /* "neighbor softreconfiguration inbound" commands.*/
11478 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
11479 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
11480 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
11481 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11482 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
11483 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11484 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
11485 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11486 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
11487 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11488 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
11489 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11490 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
11491 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11492 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
11493 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11494 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
11495 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11497 /* "neighbor attribute-unchanged" commands. */
11498 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
11499 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
11500 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
11501 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
11502 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
11503 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
11504 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
11505 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
11506 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
11507 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
11508 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
11509 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
11510 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
11511 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
11512 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
11513 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
11514 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
11515 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
11517 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
11518 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
11520 /* "nexthop-local unchanged" commands */
11521 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
11522 install_element(BGP_IPV6_NODE
,
11523 &no_neighbor_nexthop_local_unchanged_cmd
);
11525 /* "neighbor next-hop-self" commands. */
11526 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
11527 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
11528 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
11529 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
11530 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
11531 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
11532 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
11533 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
11534 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
11535 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
11536 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
11537 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
11538 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
11539 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
11540 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
11541 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
11542 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
11543 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
11545 /* "neighbor next-hop-self force" commands. */
11546 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
11547 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
11548 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
11549 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11550 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
11551 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11552 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
11553 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11554 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
11555 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11556 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
11557 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11558 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
11559 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11560 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
11561 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11562 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
11563 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11565 /* "neighbor as-override" commands. */
11566 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
11567 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
11568 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
11569 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
11570 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
11571 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
11572 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
11573 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
11574 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
11575 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
11576 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
11577 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
11578 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
11579 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
11580 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
11581 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
11582 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
11583 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
11585 /* "neighbor remove-private-AS" commands. */
11586 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
11587 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
11588 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
11589 install_element(BGP_NODE
,
11590 &no_neighbor_remove_private_as_all_hidden_cmd
);
11591 install_element(BGP_NODE
,
11592 &neighbor_remove_private_as_replace_as_hidden_cmd
);
11593 install_element(BGP_NODE
,
11594 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
11595 install_element(BGP_NODE
,
11596 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
11599 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
11600 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
11601 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
11602 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
11603 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11604 install_element(BGP_IPV4_NODE
,
11605 &neighbor_remove_private_as_replace_as_cmd
);
11606 install_element(BGP_IPV4_NODE
,
11607 &no_neighbor_remove_private_as_replace_as_cmd
);
11608 install_element(BGP_IPV4_NODE
,
11609 &neighbor_remove_private_as_all_replace_as_cmd
);
11610 install_element(BGP_IPV4_NODE
,
11611 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11612 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
11613 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
11614 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
11615 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11616 install_element(BGP_IPV4M_NODE
,
11617 &neighbor_remove_private_as_replace_as_cmd
);
11618 install_element(BGP_IPV4M_NODE
,
11619 &no_neighbor_remove_private_as_replace_as_cmd
);
11620 install_element(BGP_IPV4M_NODE
,
11621 &neighbor_remove_private_as_all_replace_as_cmd
);
11622 install_element(BGP_IPV4M_NODE
,
11623 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11624 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
11625 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
11626 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
11627 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11628 install_element(BGP_IPV4L_NODE
,
11629 &neighbor_remove_private_as_replace_as_cmd
);
11630 install_element(BGP_IPV4L_NODE
,
11631 &no_neighbor_remove_private_as_replace_as_cmd
);
11632 install_element(BGP_IPV4L_NODE
,
11633 &neighbor_remove_private_as_all_replace_as_cmd
);
11634 install_element(BGP_IPV4L_NODE
,
11635 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11636 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
11637 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
11638 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
11639 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11640 install_element(BGP_IPV6_NODE
,
11641 &neighbor_remove_private_as_replace_as_cmd
);
11642 install_element(BGP_IPV6_NODE
,
11643 &no_neighbor_remove_private_as_replace_as_cmd
);
11644 install_element(BGP_IPV6_NODE
,
11645 &neighbor_remove_private_as_all_replace_as_cmd
);
11646 install_element(BGP_IPV6_NODE
,
11647 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11648 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
11649 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
11650 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
11651 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11652 install_element(BGP_IPV6M_NODE
,
11653 &neighbor_remove_private_as_replace_as_cmd
);
11654 install_element(BGP_IPV6M_NODE
,
11655 &no_neighbor_remove_private_as_replace_as_cmd
);
11656 install_element(BGP_IPV6M_NODE
,
11657 &neighbor_remove_private_as_all_replace_as_cmd
);
11658 install_element(BGP_IPV6M_NODE
,
11659 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11660 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
11661 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
11662 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
11663 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11664 install_element(BGP_IPV6L_NODE
,
11665 &neighbor_remove_private_as_replace_as_cmd
);
11666 install_element(BGP_IPV6L_NODE
,
11667 &no_neighbor_remove_private_as_replace_as_cmd
);
11668 install_element(BGP_IPV6L_NODE
,
11669 &neighbor_remove_private_as_all_replace_as_cmd
);
11670 install_element(BGP_IPV6L_NODE
,
11671 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11672 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
11673 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
11674 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
11675 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11676 install_element(BGP_VPNV4_NODE
,
11677 &neighbor_remove_private_as_replace_as_cmd
);
11678 install_element(BGP_VPNV4_NODE
,
11679 &no_neighbor_remove_private_as_replace_as_cmd
);
11680 install_element(BGP_VPNV4_NODE
,
11681 &neighbor_remove_private_as_all_replace_as_cmd
);
11682 install_element(BGP_VPNV4_NODE
,
11683 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11684 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
11685 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
11686 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
11687 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11688 install_element(BGP_VPNV6_NODE
,
11689 &neighbor_remove_private_as_replace_as_cmd
);
11690 install_element(BGP_VPNV6_NODE
,
11691 &no_neighbor_remove_private_as_replace_as_cmd
);
11692 install_element(BGP_VPNV6_NODE
,
11693 &neighbor_remove_private_as_all_replace_as_cmd
);
11694 install_element(BGP_VPNV6_NODE
,
11695 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11697 /* "neighbor send-community" commands.*/
11698 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
11699 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
11700 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
11701 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
11702 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
11703 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
11704 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
11705 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
11706 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
11707 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
11708 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
11709 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
11710 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
11711 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
11712 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
11713 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
11714 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
11715 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
11716 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
11717 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
11718 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
11719 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
11720 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
11721 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
11722 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
11723 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
11724 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
11725 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
11726 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
11727 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
11728 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
11729 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
11730 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
11731 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
11732 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
11733 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
11735 /* "neighbor route-reflector" commands.*/
11736 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
11737 install_element(BGP_NODE
,
11738 &no_neighbor_route_reflector_client_hidden_cmd
);
11739 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
11740 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
11741 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
11742 install_element(BGP_IPV4M_NODE
,
11743 &no_neighbor_route_reflector_client_cmd
);
11744 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
11745 install_element(BGP_IPV4L_NODE
,
11746 &no_neighbor_route_reflector_client_cmd
);
11747 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
11748 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
11749 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
11750 install_element(BGP_IPV6M_NODE
,
11751 &no_neighbor_route_reflector_client_cmd
);
11752 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
11753 install_element(BGP_IPV6L_NODE
,
11754 &no_neighbor_route_reflector_client_cmd
);
11755 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
11756 install_element(BGP_VPNV4_NODE
,
11757 &no_neighbor_route_reflector_client_cmd
);
11758 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
11759 install_element(BGP_VPNV6_NODE
,
11760 &no_neighbor_route_reflector_client_cmd
);
11761 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
11762 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
11764 /* "neighbor route-server" commands.*/
11765 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
11766 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
11767 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
11768 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
11769 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
11770 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
11771 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
11772 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
11773 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
11774 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
11775 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
11776 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
11777 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
11778 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
11779 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
11780 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
11781 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
11782 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
11784 /* "neighbor addpath-tx-all-paths" commands.*/
11785 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
11786 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
11787 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11788 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11789 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11790 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11791 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11792 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11793 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11794 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11795 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11796 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11797 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11798 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11799 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11800 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11801 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11802 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11804 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
11805 install_element(BGP_NODE
,
11806 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
11807 install_element(BGP_NODE
,
11808 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
11809 install_element(BGP_IPV4_NODE
,
11810 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11811 install_element(BGP_IPV4_NODE
,
11812 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11813 install_element(BGP_IPV4M_NODE
,
11814 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11815 install_element(BGP_IPV4M_NODE
,
11816 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11817 install_element(BGP_IPV4L_NODE
,
11818 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11819 install_element(BGP_IPV4L_NODE
,
11820 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11821 install_element(BGP_IPV6_NODE
,
11822 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11823 install_element(BGP_IPV6_NODE
,
11824 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11825 install_element(BGP_IPV6M_NODE
,
11826 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11827 install_element(BGP_IPV6M_NODE
,
11828 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11829 install_element(BGP_IPV6L_NODE
,
11830 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11831 install_element(BGP_IPV6L_NODE
,
11832 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11833 install_element(BGP_VPNV4_NODE
,
11834 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11835 install_element(BGP_VPNV4_NODE
,
11836 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11837 install_element(BGP_VPNV6_NODE
,
11838 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11839 install_element(BGP_VPNV6_NODE
,
11840 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11842 /* "neighbor passive" commands. */
11843 install_element(BGP_NODE
, &neighbor_passive_cmd
);
11844 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
11847 /* "neighbor shutdown" commands. */
11848 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
11849 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
11850 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
11851 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
11853 /* "neighbor capability extended-nexthop" commands.*/
11854 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
11855 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
11857 /* "neighbor capability orf prefix-list" commands.*/
11858 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
11859 install_element(BGP_NODE
,
11860 &no_neighbor_capability_orf_prefix_hidden_cmd
);
11861 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
11862 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11863 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
11864 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11865 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
11866 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11867 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
11868 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11869 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
11870 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11871 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
11872 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11874 /* "neighbor capability dynamic" commands.*/
11875 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
11876 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
11878 /* "neighbor dont-capability-negotiate" commands. */
11879 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
11880 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
11882 /* "neighbor ebgp-multihop" commands. */
11883 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
11884 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
11885 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
11887 /* "neighbor disable-connected-check" commands. */
11888 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
11889 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
11891 /* "neighbor description" commands. */
11892 install_element(BGP_NODE
, &neighbor_description_cmd
);
11893 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
11895 /* "neighbor update-source" commands. "*/
11896 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
11897 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
11899 /* "neighbor default-originate" commands. */
11900 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
11901 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
11902 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
11903 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
11904 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
11905 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
11906 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
11907 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
11908 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
11909 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
11910 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
11911 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
11912 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
11913 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
11914 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
11915 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
11916 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
11917 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
11918 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
11919 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
11920 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
11922 /* "neighbor port" commands. */
11923 install_element(BGP_NODE
, &neighbor_port_cmd
);
11924 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
11926 /* "neighbor weight" commands. */
11927 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
11928 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
11930 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
11931 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
11932 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
11933 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
11934 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
11935 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
11936 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
11937 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
11938 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
11939 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
11940 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
11941 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
11942 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
11943 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
11944 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
11945 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
11947 /* "neighbor override-capability" commands. */
11948 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
11949 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
11951 /* "neighbor strict-capability-match" commands. */
11952 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
11953 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
11955 /* "neighbor timers" commands. */
11956 install_element(BGP_NODE
, &neighbor_timers_cmd
);
11957 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
11959 /* "neighbor timers connect" commands. */
11960 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
11961 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
11963 /* "neighbor advertisement-interval" commands. */
11964 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
11965 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
11967 /* "neighbor interface" commands. */
11968 install_element(BGP_NODE
, &neighbor_interface_cmd
);
11969 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
11971 /* "neighbor distribute" commands. */
11972 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
11973 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
11974 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
11975 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
11976 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
11977 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
11978 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
11979 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
11980 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
11981 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
11982 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
11983 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
11984 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
11985 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
11986 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
11987 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
11988 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
11989 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
11991 /* "neighbor prefix-list" commands. */
11992 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
11993 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
11994 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
11995 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
11996 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
11997 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
11998 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
11999 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
12000 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
12001 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
12002 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
12003 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
12004 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
12005 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
12006 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
12007 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
12008 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
12009 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
12011 /* "neighbor filter-list" commands. */
12012 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
12013 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
12014 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
12015 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
12016 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
12017 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
12018 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
12019 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
12020 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
12021 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
12022 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
12023 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
12024 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
12025 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
12026 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
12027 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
12028 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
12029 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
12031 /* "neighbor route-map" commands. */
12032 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
12033 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
12034 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
12035 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
12036 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
12037 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
12038 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
12039 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
12040 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
12041 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
12042 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
12043 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
12044 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
12045 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
12046 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
12047 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
12048 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
12049 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
12051 /* "neighbor unsuppress-map" commands. */
12052 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
12053 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
12054 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
12055 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12056 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
12057 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12058 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
12059 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12060 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
12061 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12062 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
12063 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12064 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
12065 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12066 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
12067 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12068 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
12069 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12071 /* "neighbor maximum-prefix" commands. */
12072 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
12073 install_element(BGP_NODE
,
12074 &neighbor_maximum_prefix_threshold_hidden_cmd
);
12075 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
12076 install_element(BGP_NODE
,
12077 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
12078 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
12079 install_element(BGP_NODE
,
12080 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
12081 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
12082 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
12083 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12084 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12085 install_element(BGP_IPV4_NODE
,
12086 &neighbor_maximum_prefix_threshold_warning_cmd
);
12087 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12088 install_element(BGP_IPV4_NODE
,
12089 &neighbor_maximum_prefix_threshold_restart_cmd
);
12090 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12091 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
12092 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12093 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12094 install_element(BGP_IPV4M_NODE
,
12095 &neighbor_maximum_prefix_threshold_warning_cmd
);
12096 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12097 install_element(BGP_IPV4M_NODE
,
12098 &neighbor_maximum_prefix_threshold_restart_cmd
);
12099 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12100 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
12101 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12102 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12103 install_element(BGP_IPV4L_NODE
,
12104 &neighbor_maximum_prefix_threshold_warning_cmd
);
12105 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12106 install_element(BGP_IPV4L_NODE
,
12107 &neighbor_maximum_prefix_threshold_restart_cmd
);
12108 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12109 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
12110 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12111 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12112 install_element(BGP_IPV6_NODE
,
12113 &neighbor_maximum_prefix_threshold_warning_cmd
);
12114 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12115 install_element(BGP_IPV6_NODE
,
12116 &neighbor_maximum_prefix_threshold_restart_cmd
);
12117 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12118 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
12119 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12120 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12121 install_element(BGP_IPV6M_NODE
,
12122 &neighbor_maximum_prefix_threshold_warning_cmd
);
12123 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12124 install_element(BGP_IPV6M_NODE
,
12125 &neighbor_maximum_prefix_threshold_restart_cmd
);
12126 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12127 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
12128 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12129 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12130 install_element(BGP_IPV6L_NODE
,
12131 &neighbor_maximum_prefix_threshold_warning_cmd
);
12132 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12133 install_element(BGP_IPV6L_NODE
,
12134 &neighbor_maximum_prefix_threshold_restart_cmd
);
12135 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12136 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
12137 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12138 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12139 install_element(BGP_VPNV4_NODE
,
12140 &neighbor_maximum_prefix_threshold_warning_cmd
);
12141 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12142 install_element(BGP_VPNV4_NODE
,
12143 &neighbor_maximum_prefix_threshold_restart_cmd
);
12144 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12145 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
12146 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12147 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12148 install_element(BGP_VPNV6_NODE
,
12149 &neighbor_maximum_prefix_threshold_warning_cmd
);
12150 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12151 install_element(BGP_VPNV6_NODE
,
12152 &neighbor_maximum_prefix_threshold_restart_cmd
);
12153 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12155 /* "neighbor allowas-in" */
12156 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
12157 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
12158 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
12159 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
12160 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
12161 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
12162 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
12163 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
12164 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
12165 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
12166 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
12167 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
12168 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
12169 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
12170 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
12171 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
12172 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
12173 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
12174 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
12175 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
12177 /* address-family commands. */
12178 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
12179 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
12180 #ifdef KEEP_OLD_VPN_COMMANDS
12181 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
12182 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
12183 #endif /* KEEP_OLD_VPN_COMMANDS */
12185 install_element(BGP_NODE
, &address_family_evpn_cmd
);
12187 /* "exit-address-family" command. */
12188 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
12189 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
12190 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
12191 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
12192 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
12193 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
12194 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
12195 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
12196 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
12198 /* "clear ip bgp commands" */
12199 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
12201 /* clear ip bgp prefix */
12202 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
12203 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
12204 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
12206 /* "show [ip] bgp summary" commands. */
12207 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
12208 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_adj_cmd
);
12209 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_adj_s_cmd
);
12210 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
12211 install_element(VIEW_NODE
, &show_bgp_updgrps_adj_cmd
);
12212 install_element(VIEW_NODE
, &show_bgp_updgrps_adj_s_cmd
);
12213 install_element(VIEW_NODE
, &show_bgp_updgrps_afi_adj_cmd
);
12214 install_element(VIEW_NODE
, &show_bgp_updgrps_afi_adj_s_cmd
);
12215 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
12216 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_cmd
);
12217 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
12218 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
12219 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_adj_cmd
);
12220 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_adj_s_cmd
);
12221 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
12223 /* "show [ip] bgp neighbors" commands. */
12224 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
12226 /* "show [ip] bgp peer-group" commands. */
12227 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
12229 /* "show [ip] bgp paths" commands. */
12230 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
12232 /* "show [ip] bgp community" commands. */
12233 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
12235 /* "show ip bgp large-community" commands. */
12236 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
12237 /* "show [ip] bgp attribute-info" commands. */
12238 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
12240 /* "redistribute" commands. */
12241 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
12242 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
12243 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
12244 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
12245 install_element(BGP_NODE
,
12246 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
12247 install_element(BGP_NODE
,
12248 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
12249 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
12250 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
12251 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
12252 install_element(BGP_NODE
,
12253 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
12254 install_element(BGP_NODE
,
12255 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
12256 install_element(BGP_NODE
,
12257 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
12258 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
12259 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
12260 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
12261 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
12262 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
12263 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
12264 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
12265 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
12266 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
12267 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
12268 install_element(BGP_IPV4_NODE
,
12269 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
12270 install_element(BGP_IPV4_NODE
,
12271 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
12272 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
12273 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
12274 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
12275 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
12276 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
12277 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
12279 /* ttl_security commands */
12280 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
12281 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
12283 /* "show [ip] bgp memory" commands. */
12284 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
12286 /* "show [ip] bgp views" commands. */
12287 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
12289 /* "show [ip] bgp vrfs" commands. */
12290 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
12292 /* Community-list. */
12293 community_list_vty();
12296 #include "memory.h"
12297 #include "bgp_regex.h"
12298 #include "bgp_clist.h"
12299 #include "bgp_ecommunity.h"
12301 /* VTY functions. */
12303 /* Direction value to string conversion. */
12304 static const char *community_direct_str(int direct
)
12307 case COMMUNITY_DENY
:
12309 case COMMUNITY_PERMIT
:
12316 /* Display error string. */
12317 static void community_list_perror(struct vty
*vty
, int ret
)
12320 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
12321 vty_out(vty
, "%% Can't find community-list\n");
12323 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
12324 vty_out(vty
, "%% Malformed community-list value\n");
12326 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
12328 "%% Community name conflict, previously defined as standard community\n");
12330 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
12332 "%% Community name conflict, previously defined as expanded community\n");
12337 /* "community-list" keyword help string. */
12338 #define COMMUNITY_LIST_STR "Add a community list entry\n"
12340 /* ip community-list standard */
12341 DEFUN (ip_community_list_standard
,
12342 ip_community_list_standard_cmd
,
12343 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
12346 "Community list number (standard)\n"
12347 "Add an standard community-list entry\n"
12348 "Community list name\n"
12349 "Specify community to reject\n"
12350 "Specify community to accept\n"
12353 char *cl_name_or_number
= NULL
;
12355 int style
= COMMUNITY_LIST_STANDARD
;
12358 argv_find(argv
, argc
, "(1-99)", &idx
);
12359 argv_find(argv
, argc
, "WORD", &idx
);
12360 cl_name_or_number
= argv
[idx
]->arg
;
12361 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12363 argv_find(argv
, argc
, "AA:NN", &idx
);
12364 char *str
= argv_concat(argv
, argc
, idx
);
12366 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
12369 XFREE(MTYPE_TMP
, str
);
12372 /* Display error string. */
12373 community_list_perror(vty
, ret
);
12374 return CMD_WARNING_CONFIG_FAILED
;
12377 return CMD_SUCCESS
;
12380 DEFUN (no_ip_community_list_standard_all
,
12381 no_ip_community_list_standard_all_cmd
,
12382 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
12386 "Community list number (standard)\n"
12387 "Add an standard community-list entry\n"
12388 "Community list name\n"
12389 "Specify community to reject\n"
12390 "Specify community to accept\n"
12393 int delete_all
= 0;
12395 char *cl_name_or_number
= NULL
;
12397 int style
= COMMUNITY_LIST_STANDARD
;
12400 argv_find(argv
, argc
, "(1-99)", &idx
);
12401 argv_find(argv
, argc
, "WORD", &idx
);
12402 cl_name_or_number
= argv
[idx
]->arg
;
12403 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12405 argv_find(argv
, argc
, "AA:NN", &idx
);
12406 char *str
= argv_concat(argv
, argc
, idx
);
12408 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
12409 direct
, style
, delete_all
);
12411 XFREE(MTYPE_TMP
, str
);
12414 community_list_perror(vty
, ret
);
12415 return CMD_WARNING_CONFIG_FAILED
;
12418 return CMD_SUCCESS
;
12421 /* ip community-list expanded */
12422 DEFUN (ip_community_list_expanded_all
,
12423 ip_community_list_expanded_all_cmd
,
12424 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
12427 "Community list number (expanded)\n"
12428 "Add an expanded community-list entry\n"
12429 "Community list name\n"
12430 "Specify community to reject\n"
12431 "Specify community to accept\n"
12434 char *cl_name_or_number
= NULL
;
12436 int style
= COMMUNITY_LIST_EXPANDED
;
12439 argv_find(argv
, argc
, "(100-500)", &idx
);
12440 argv_find(argv
, argc
, "WORD", &idx
);
12441 cl_name_or_number
= argv
[idx
]->arg
;
12442 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12444 argv_find(argv
, argc
, "AA:NN", &idx
);
12445 char *str
= argv_concat(argv
, argc
, idx
);
12447 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
12450 XFREE(MTYPE_TMP
, str
);
12453 /* Display error string. */
12454 community_list_perror(vty
, ret
);
12455 return CMD_WARNING_CONFIG_FAILED
;
12458 return CMD_SUCCESS
;
12461 DEFUN (no_ip_community_list_expanded_all
,
12462 no_ip_community_list_expanded_all_cmd
,
12463 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
12467 "Community list number (expanded)\n"
12468 "Add an expanded community-list entry\n"
12469 "Community list name\n"
12470 "Specify community to reject\n"
12471 "Specify community to accept\n"
12474 int delete_all
= 0;
12476 char *cl_name_or_number
= NULL
;
12478 int style
= COMMUNITY_LIST_EXPANDED
;
12481 argv_find(argv
, argc
, "(100-500)", &idx
);
12482 argv_find(argv
, argc
, "WORD", &idx
);
12483 cl_name_or_number
= argv
[idx
]->arg
;
12484 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12486 argv_find(argv
, argc
, "AA:NN", &idx
);
12487 char *str
= argv_concat(argv
, argc
, idx
);
12489 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
12490 direct
, style
, delete_all
);
12492 XFREE(MTYPE_TMP
, str
);
12495 community_list_perror(vty
, ret
);
12496 return CMD_WARNING_CONFIG_FAILED
;
12499 return CMD_SUCCESS
;
12502 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
12504 struct community_entry
*entry
;
12506 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
12507 if (entry
== list
->head
) {
12508 if (all_digit(list
->name
))
12509 vty_out(vty
, "Community %s list %s\n",
12510 entry
->style
== COMMUNITY_LIST_STANDARD
12512 : "(expanded) access",
12515 vty_out(vty
, "Named Community %s list %s\n",
12516 entry
->style
== COMMUNITY_LIST_STANDARD
12522 vty_out(vty
, " %s\n",
12523 community_direct_str(entry
->direct
));
12525 vty_out(vty
, " %s %s\n",
12526 community_direct_str(entry
->direct
),
12527 entry
->style
== COMMUNITY_LIST_STANDARD
12528 ? community_str(entry
->u
.com
)
12533 DEFUN (show_ip_community_list
,
12534 show_ip_community_list_cmd
,
12535 "show ip community-list",
12538 "List community-list\n")
12540 struct community_list
*list
;
12541 struct community_list_master
*cm
;
12543 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
12545 return CMD_SUCCESS
;
12547 for (list
= cm
->num
.head
; list
; list
= list
->next
)
12548 community_list_show(vty
, list
);
12550 for (list
= cm
->str
.head
; list
; list
= list
->next
)
12551 community_list_show(vty
, list
);
12553 return CMD_SUCCESS
;
12556 DEFUN (show_ip_community_list_arg
,
12557 show_ip_community_list_arg_cmd
,
12558 "show ip community-list <(1-500)|WORD>",
12561 "List community-list\n"
12562 "Community-list number\n"
12563 "Community-list name\n")
12565 int idx_comm_list
= 3;
12566 struct community_list
*list
;
12568 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
12569 COMMUNITY_LIST_MASTER
);
12571 vty_out(vty
, "%% Can't find community-list\n");
12572 return CMD_WARNING
;
12575 community_list_show(vty
, list
);
12577 return CMD_SUCCESS
;
12581 * Large Community code.
12583 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
12584 struct cmd_token
**argv
, int style
,
12585 int reject_all_digit_name
)
12593 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12596 /* All digit name check. */
12598 argv_find(argv
, argc
, "WORD", &idx
);
12599 argv_find(argv
, argc
, "(1-99)", &idx
);
12600 argv_find(argv
, argc
, "(100-500)", &idx
);
12601 cl_name
= argv
[idx
]->arg
;
12602 if (reject_all_digit_name
&& all_digit(cl_name
)) {
12603 vty_out(vty
, "%% Community name cannot have all digits\n");
12604 return CMD_WARNING_CONFIG_FAILED
;
12608 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
12609 argv_find(argv
, argc
, "LINE", &idx
);
12610 /* Concat community string argument. */
12612 str
= argv_concat(argv
, argc
, idx
);
12616 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
12618 /* Free temporary community list string allocated by
12621 XFREE(MTYPE_TMP
, str
);
12624 community_list_perror(vty
, ret
);
12625 return CMD_WARNING_CONFIG_FAILED
;
12627 return CMD_SUCCESS
;
12630 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
12631 struct cmd_token
**argv
, int style
)
12638 argv_find(argv
, argc
, "permit", &idx
);
12639 argv_find(argv
, argc
, "deny", &idx
);
12642 /* Check the list direct. */
12643 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
12644 direct
= COMMUNITY_PERMIT
;
12646 direct
= COMMUNITY_DENY
;
12649 argv_find(argv
, argc
, "LINE", &idx
);
12650 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
12651 /* Concat community string argument. */
12652 str
= argv_concat(argv
, argc
, idx
);
12656 argv_find(argv
, argc
, "(1-99)", &idx
);
12657 argv_find(argv
, argc
, "(100-500)", &idx
);
12658 argv_find(argv
, argc
, "WORD", &idx
);
12660 /* Unset community list. */
12661 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
12664 /* Free temporary community list string allocated by
12667 XFREE(MTYPE_TMP
, str
);
12670 community_list_perror(vty
, ret
);
12671 return CMD_WARNING_CONFIG_FAILED
;
12674 return CMD_SUCCESS
;
12677 /* "large-community-list" keyword help string. */
12678 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
12679 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
12681 DEFUN (ip_lcommunity_list_standard
,
12682 ip_lcommunity_list_standard_cmd
,
12683 "ip large-community-list (1-99) <deny|permit>",
12685 LCOMMUNITY_LIST_STR
12686 "Large Community list number (standard)\n"
12687 "Specify large community to reject\n"
12688 "Specify large community to accept\n")
12690 return lcommunity_list_set_vty(vty
, argc
, argv
,
12691 LARGE_COMMUNITY_LIST_STANDARD
, 0);
12694 DEFUN (ip_lcommunity_list_standard1
,
12695 ip_lcommunity_list_standard1_cmd
,
12696 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
12698 LCOMMUNITY_LIST_STR
12699 "Large Community list number (standard)\n"
12700 "Specify large community to reject\n"
12701 "Specify large community to accept\n"
12702 LCOMMUNITY_VAL_STR
)
12704 return lcommunity_list_set_vty(vty
, argc
, argv
,
12705 LARGE_COMMUNITY_LIST_STANDARD
, 0);
12708 DEFUN (ip_lcommunity_list_expanded
,
12709 ip_lcommunity_list_expanded_cmd
,
12710 "ip large-community-list (100-500) <deny|permit> LINE...",
12712 LCOMMUNITY_LIST_STR
12713 "Large Community list number (expanded)\n"
12714 "Specify large community to reject\n"
12715 "Specify large community to accept\n"
12716 "An ordered list as a regular-expression\n")
12718 return lcommunity_list_set_vty(vty
, argc
, argv
,
12719 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
12722 DEFUN (ip_lcommunity_list_name_standard
,
12723 ip_lcommunity_list_name_standard_cmd
,
12724 "ip large-community-list standard WORD <deny|permit>",
12726 LCOMMUNITY_LIST_STR
12727 "Specify standard large-community-list\n"
12728 "Large Community list name\n"
12729 "Specify large community to reject\n"
12730 "Specify large community to accept\n")
12732 return lcommunity_list_set_vty(vty
, argc
, argv
,
12733 LARGE_COMMUNITY_LIST_STANDARD
, 1);
12736 DEFUN (ip_lcommunity_list_name_standard1
,
12737 ip_lcommunity_list_name_standard1_cmd
,
12738 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
12740 LCOMMUNITY_LIST_STR
12741 "Specify standard large-community-list\n"
12742 "Large Community list name\n"
12743 "Specify large community to reject\n"
12744 "Specify large community to accept\n"
12745 LCOMMUNITY_VAL_STR
)
12747 return lcommunity_list_set_vty(vty
, argc
, argv
,
12748 LARGE_COMMUNITY_LIST_STANDARD
, 1);
12751 DEFUN (ip_lcommunity_list_name_expanded
,
12752 ip_lcommunity_list_name_expanded_cmd
,
12753 "ip large-community-list expanded WORD <deny|permit> LINE...",
12755 LCOMMUNITY_LIST_STR
12756 "Specify expanded large-community-list\n"
12757 "Large Community list name\n"
12758 "Specify large community to reject\n"
12759 "Specify large community to accept\n"
12760 "An ordered list as a regular-expression\n")
12762 return lcommunity_list_set_vty(vty
, argc
, argv
,
12763 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
12766 DEFUN (no_ip_lcommunity_list_standard_all
,
12767 no_ip_lcommunity_list_standard_all_cmd
,
12768 "no ip large-community-list <(1-99)|(100-500)|WORD>",
12771 LCOMMUNITY_LIST_STR
12772 "Large Community list number (standard)\n"
12773 "Large Community list number (expanded)\n"
12774 "Large Community list name\n")
12776 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12777 LARGE_COMMUNITY_LIST_STANDARD
);
12780 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
12781 no_ip_lcommunity_list_name_expanded_all_cmd
,
12782 "no ip large-community-list expanded WORD",
12785 LCOMMUNITY_LIST_STR
12786 "Specify expanded large-community-list\n"
12787 "Large Community list name\n")
12789 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12790 LARGE_COMMUNITY_LIST_EXPANDED
);
12793 DEFUN (no_ip_lcommunity_list_standard
,
12794 no_ip_lcommunity_list_standard_cmd
,
12795 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
12798 LCOMMUNITY_LIST_STR
12799 "Large Community list number (standard)\n"
12800 "Specify large community to reject\n"
12801 "Specify large community to accept\n"
12802 LCOMMUNITY_VAL_STR
)
12804 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12805 LARGE_COMMUNITY_LIST_STANDARD
);
12808 DEFUN (no_ip_lcommunity_list_expanded
,
12809 no_ip_lcommunity_list_expanded_cmd
,
12810 "no ip large-community-list (100-500) <deny|permit> LINE...",
12813 LCOMMUNITY_LIST_STR
12814 "Large Community list number (expanded)\n"
12815 "Specify large community to reject\n"
12816 "Specify large community to accept\n"
12817 "An ordered list as a regular-expression\n")
12819 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12820 LARGE_COMMUNITY_LIST_EXPANDED
);
12823 DEFUN (no_ip_lcommunity_list_name_standard
,
12824 no_ip_lcommunity_list_name_standard_cmd
,
12825 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
12828 LCOMMUNITY_LIST_STR
12829 "Specify standard large-community-list\n"
12830 "Large Community list name\n"
12831 "Specify large community to reject\n"
12832 "Specify large community to accept\n"
12833 LCOMMUNITY_VAL_STR
)
12835 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12836 LARGE_COMMUNITY_LIST_STANDARD
);
12839 DEFUN (no_ip_lcommunity_list_name_expanded
,
12840 no_ip_lcommunity_list_name_expanded_cmd
,
12841 "no ip large-community-list expanded WORD <deny|permit> LINE...",
12844 LCOMMUNITY_LIST_STR
12845 "Specify expanded large-community-list\n"
12846 "Large community list name\n"
12847 "Specify large community to reject\n"
12848 "Specify large community to accept\n"
12849 "An ordered list as a regular-expression\n")
12851 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12852 LARGE_COMMUNITY_LIST_EXPANDED
);
12855 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
12857 struct community_entry
*entry
;
12859 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
12860 if (entry
== list
->head
) {
12861 if (all_digit(list
->name
))
12862 vty_out(vty
, "Large community %s list %s\n",
12863 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
12865 : "(expanded) access",
12869 "Named large community %s list %s\n",
12870 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
12876 vty_out(vty
, " %s\n",
12877 community_direct_str(entry
->direct
));
12879 vty_out(vty
, " %s %s\n",
12880 community_direct_str(entry
->direct
),
12881 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
12882 ? entry
->u
.ecom
->str
12887 DEFUN (show_ip_lcommunity_list
,
12888 show_ip_lcommunity_list_cmd
,
12889 "show ip large-community-list",
12892 "List large-community list\n")
12894 struct community_list
*list
;
12895 struct community_list_master
*cm
;
12897 cm
= community_list_master_lookup(bgp_clist
,
12898 LARGE_COMMUNITY_LIST_MASTER
);
12900 return CMD_SUCCESS
;
12902 for (list
= cm
->num
.head
; list
; list
= list
->next
)
12903 lcommunity_list_show(vty
, list
);
12905 for (list
= cm
->str
.head
; list
; list
= list
->next
)
12906 lcommunity_list_show(vty
, list
);
12908 return CMD_SUCCESS
;
12911 DEFUN (show_ip_lcommunity_list_arg
,
12912 show_ip_lcommunity_list_arg_cmd
,
12913 "show ip large-community-list <(1-500)|WORD>",
12916 "List large-community list\n"
12917 "large-community-list number\n"
12918 "large-community-list name\n")
12920 struct community_list
*list
;
12922 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
12923 LARGE_COMMUNITY_LIST_MASTER
);
12925 vty_out(vty
, "%% Can't find extcommunity-list\n");
12926 return CMD_WARNING
;
12929 lcommunity_list_show(vty
, list
);
12931 return CMD_SUCCESS
;
12934 /* "extcommunity-list" keyword help string. */
12935 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
12936 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
12938 DEFUN (ip_extcommunity_list_standard
,
12939 ip_extcommunity_list_standard_cmd
,
12940 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
12942 EXTCOMMUNITY_LIST_STR
12943 "Extended Community list number (standard)\n"
12944 "Specify standard extcommunity-list\n"
12945 "Community list name\n"
12946 "Specify community to reject\n"
12947 "Specify community to accept\n"
12948 EXTCOMMUNITY_VAL_STR
)
12950 int style
= EXTCOMMUNITY_LIST_STANDARD
;
12952 char *cl_number_or_name
= NULL
;
12955 argv_find(argv
, argc
, "(1-99)", &idx
);
12956 argv_find(argv
, argc
, "WORD", &idx
);
12957 cl_number_or_name
= argv
[idx
]->arg
;
12958 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12960 argv_find(argv
, argc
, "AA:NN", &idx
);
12961 char *str
= argv_concat(argv
, argc
, idx
);
12963 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
12966 XFREE(MTYPE_TMP
, str
);
12969 community_list_perror(vty
, ret
);
12970 return CMD_WARNING_CONFIG_FAILED
;
12973 return CMD_SUCCESS
;
12976 DEFUN (ip_extcommunity_list_name_expanded
,
12977 ip_extcommunity_list_name_expanded_cmd
,
12978 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
12980 EXTCOMMUNITY_LIST_STR
12981 "Extended Community list number (expanded)\n"
12982 "Specify expanded extcommunity-list\n"
12983 "Extended Community list name\n"
12984 "Specify community to reject\n"
12985 "Specify community to accept\n"
12986 "An ordered list as a regular-expression\n")
12988 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
12990 char *cl_number_or_name
= NULL
;
12993 argv_find(argv
, argc
, "(100-500)", &idx
);
12994 argv_find(argv
, argc
, "WORD", &idx
);
12995 cl_number_or_name
= argv
[idx
]->arg
;
12996 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12998 argv_find(argv
, argc
, "LINE", &idx
);
12999 char *str
= argv_concat(argv
, argc
, idx
);
13001 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
13004 XFREE(MTYPE_TMP
, str
);
13007 community_list_perror(vty
, ret
);
13008 return CMD_WARNING_CONFIG_FAILED
;
13011 return CMD_SUCCESS
;
13014 DEFUN (no_ip_extcommunity_list_standard_all
,
13015 no_ip_extcommunity_list_standard_all_cmd
,
13016 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13019 EXTCOMMUNITY_LIST_STR
13020 "Extended Community list number (standard)\n"
13021 "Specify standard extcommunity-list\n"
13022 "Community list name\n"
13023 "Specify community to reject\n"
13024 "Specify community to accept\n"
13025 EXTCOMMUNITY_VAL_STR
)
13029 int style
= EXTCOMMUNITY_LIST_STANDARD
;
13031 char *cl_number_or_name
= NULL
;
13034 argv_find(argv
, argc
, "(1-99)", &idx
);
13035 argv_find(argv
, argc
, "WORD", &idx
);
13036 cl_number_or_name
= argv
[idx
]->arg
;
13037 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13039 argv_find(argv
, argc
, "AA:NN", &idx
);
13040 char *str
= argv_concat(argv
, argc
, idx
);
13042 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13043 direct
, style
, deleteall
);
13045 XFREE(MTYPE_TMP
, str
);
13048 community_list_perror(vty
, ret
);
13049 return CMD_WARNING_CONFIG_FAILED
;
13052 return CMD_SUCCESS
;
13055 DEFUN (no_ip_extcommunity_list_expanded_all
,
13056 no_ip_extcommunity_list_expanded_all_cmd
,
13057 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
13060 EXTCOMMUNITY_LIST_STR
13061 "Extended Community list number (expanded)\n"
13062 "Specify expanded extcommunity-list\n"
13063 "Extended Community list name\n"
13064 "Specify community to reject\n"
13065 "Specify community to accept\n"
13066 "An ordered list as a regular-expression\n")
13070 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
13072 char *cl_number_or_name
= NULL
;
13075 argv_find(argv
, argc
, "(100-500)", &idx
);
13076 argv_find(argv
, argc
, "WORD", &idx
);
13077 cl_number_or_name
= argv
[idx
]->arg
;
13078 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13080 argv_find(argv
, argc
, "LINE", &idx
);
13081 char *str
= argv_concat(argv
, argc
, idx
);
13083 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13084 direct
, style
, deleteall
);
13086 XFREE(MTYPE_TMP
, str
);
13089 community_list_perror(vty
, ret
);
13090 return CMD_WARNING_CONFIG_FAILED
;
13093 return CMD_SUCCESS
;
13096 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
13098 struct community_entry
*entry
;
13100 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13101 if (entry
== list
->head
) {
13102 if (all_digit(list
->name
))
13103 vty_out(vty
, "Extended community %s list %s\n",
13104 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13106 : "(expanded) access",
13110 "Named extended community %s list %s\n",
13111 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13117 vty_out(vty
, " %s\n",
13118 community_direct_str(entry
->direct
));
13120 vty_out(vty
, " %s %s\n",
13121 community_direct_str(entry
->direct
),
13122 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13123 ? entry
->u
.ecom
->str
13128 DEFUN (show_ip_extcommunity_list
,
13129 show_ip_extcommunity_list_cmd
,
13130 "show ip extcommunity-list",
13133 "List extended-community list\n")
13135 struct community_list
*list
;
13136 struct community_list_master
*cm
;
13138 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
13140 return CMD_SUCCESS
;
13142 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13143 extcommunity_list_show(vty
, list
);
13145 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13146 extcommunity_list_show(vty
, list
);
13148 return CMD_SUCCESS
;
13151 DEFUN (show_ip_extcommunity_list_arg
,
13152 show_ip_extcommunity_list_arg_cmd
,
13153 "show ip extcommunity-list <(1-500)|WORD>",
13156 "List extended-community list\n"
13157 "Extcommunity-list number\n"
13158 "Extcommunity-list name\n")
13160 int idx_comm_list
= 3;
13161 struct community_list
*list
;
13163 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13164 EXTCOMMUNITY_LIST_MASTER
);
13166 vty_out(vty
, "%% Can't find extcommunity-list\n");
13167 return CMD_WARNING
;
13170 extcommunity_list_show(vty
, list
);
13172 return CMD_SUCCESS
;
13175 /* Return configuration string of community-list entry. */
13176 static const char *community_list_config_str(struct community_entry
*entry
)
13183 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13184 str
= community_str(entry
->u
.com
);
13186 str
= entry
->config
;
13191 /* Display community-list and extcommunity-list configuration. */
13192 static int community_list_config_write(struct vty
*vty
)
13194 struct community_list
*list
;
13195 struct community_entry
*entry
;
13196 struct community_list_master
*cm
;
13199 /* Community-list. */
13200 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13202 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13203 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13204 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
13205 community_direct_str(entry
->direct
),
13206 community_list_config_str(entry
));
13209 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13210 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13211 vty_out(vty
, "ip community-list %s %s %s %s\n",
13212 entry
->style
== COMMUNITY_LIST_STANDARD
13215 list
->name
, community_direct_str(entry
->direct
),
13216 community_list_config_str(entry
));
13220 /* Extcommunity-list. */
13221 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
13223 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13224 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13225 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
13226 list
->name
, community_direct_str(entry
->direct
),
13227 community_list_config_str(entry
));
13230 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13231 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13232 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
13233 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13236 list
->name
, community_direct_str(entry
->direct
),
13237 community_list_config_str(entry
));
13242 /* lcommunity-list. */
13243 cm
= community_list_master_lookup(bgp_clist
,
13244 LARGE_COMMUNITY_LIST_MASTER
);
13246 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13247 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13248 vty_out(vty
, "ip large-community-list %s %s %s\n",
13249 list
->name
, community_direct_str(entry
->direct
),
13250 community_list_config_str(entry
));
13253 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13254 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13255 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
13256 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
13259 list
->name
, community_direct_str(entry
->direct
),
13260 community_list_config_str(entry
));
13267 static struct cmd_node community_list_node
= {
13268 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
13271 static void community_list_vty(void)
13273 install_node(&community_list_node
, community_list_config_write
);
13275 /* Community-list. */
13276 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
13277 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
13278 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
13279 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
13280 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
13281 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
13283 /* Extcommunity-list. */
13284 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
13285 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
13286 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
13287 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
13288 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
13289 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
13291 /* Large Community List */
13292 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
13293 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
13294 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
13295 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
13296 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
13297 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
13298 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
13299 install_element(CONFIG_NODE
,
13300 &no_ip_lcommunity_list_name_expanded_all_cmd
);
13301 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
13302 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
13303 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
13304 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
13305 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
13306 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);