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 void 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
);
1293 /* Update-delay configuration */
1294 DEFUN (bgp_update_delay
,
1295 bgp_update_delay_cmd
,
1296 "update-delay (0-3600)",
1297 "Force initial delay for best-path and updates\n"
1301 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1304 DEFUN (bgp_update_delay_establish_wait
,
1305 bgp_update_delay_establish_wait_cmd
,
1306 "update-delay (0-3600) (1-3600)",
1307 "Force initial delay for best-path and updates\n"
1312 int idx_number_2
= 2;
1313 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1314 argv
[idx_number_2
]->arg
);
1317 /* Update-delay deconfiguration */
1318 DEFUN (no_bgp_update_delay
,
1319 no_bgp_update_delay_cmd
,
1320 "no update-delay [(0-3600) [(1-3600)]]",
1322 "Force initial delay for best-path and updates\n"
1326 return bgp_update_delay_deconfig_vty(vty
);
1330 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1333 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1336 bgp
->wpkt_quanta
= strtoul(num
, NULL
, 10);
1338 bgp
->wpkt_quanta
= BGP_WRITE_PACKET_MAX
;
1343 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1345 if (bgp
->wpkt_quanta
!= BGP_WRITE_PACKET_MAX
)
1346 vty_out(vty
, " write-quanta %d\n", bgp
->wpkt_quanta
);
1350 /* Update-delay configuration */
1351 DEFUN (bgp_wpkt_quanta
,
1352 bgp_wpkt_quanta_cmd
,
1353 "write-quanta (1-10000)",
1354 "How many packets to write to peer socket per run\n"
1355 "Number of packets\n")
1358 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1361 /* Update-delay deconfiguration */
1362 DEFUN (no_bgp_wpkt_quanta
,
1363 no_bgp_wpkt_quanta_cmd
,
1364 "no write-quanta (1-10000)",
1366 "How many packets to write to peer socket per run\n"
1367 "Number of packets\n")
1370 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1373 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1375 if (bgp
->coalesce_time
!= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
)
1376 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1380 DEFUN (bgp_coalesce_time
,
1381 bgp_coalesce_time_cmd
,
1382 "coalesce-time (0-4294967295)",
1383 "Subgroup coalesce timer\n"
1384 "Subgroup coalesce timer value (in ms)\n")
1386 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1389 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1390 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1394 DEFUN (no_bgp_coalesce_time
,
1395 no_bgp_coalesce_time_cmd
,
1396 "no coalesce-time (0-4294967295)",
1398 "Subgroup coalesce timer\n"
1399 "Subgroup coalesce timer value (in ms)\n")
1401 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1403 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1407 /* Maximum-paths configuration */
1408 DEFUN (bgp_maxpaths
,
1410 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1411 "Forward packets over multiple paths\n"
1412 "Number of paths\n")
1415 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1416 argv
[idx_number
]->arg
, 0, 1);
1419 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1420 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1421 "Forward packets over multiple paths\n"
1422 "Number of paths\n")
1424 DEFUN (bgp_maxpaths_ibgp
,
1425 bgp_maxpaths_ibgp_cmd
,
1426 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1427 "Forward packets over multiple paths\n"
1429 "Number of paths\n")
1432 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1433 argv
[idx_number
]->arg
, 0, 1);
1436 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1437 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1438 "Forward packets over multiple paths\n"
1440 "Number of paths\n")
1442 DEFUN (bgp_maxpaths_ibgp_cluster
,
1443 bgp_maxpaths_ibgp_cluster_cmd
,
1444 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1445 "Forward packets over multiple paths\n"
1448 "Match the cluster length\n")
1451 return bgp_maxpaths_config_vty(
1452 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1453 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1456 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1457 "maximum-paths ibgp " CMD_RANGE_STR(
1458 1, MULTIPATH_NUM
) " equal-cluster-length",
1459 "Forward packets over multiple paths\n"
1462 "Match the cluster length\n")
1464 DEFUN (no_bgp_maxpaths
,
1465 no_bgp_maxpaths_cmd
,
1466 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1468 "Forward packets over multiple paths\n"
1469 "Number of paths\n")
1471 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1474 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1475 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1476 "Forward packets over multiple paths\n"
1477 "Number of paths\n")
1479 DEFUN (no_bgp_maxpaths_ibgp
,
1480 no_bgp_maxpaths_ibgp_cmd
,
1481 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1483 "Forward packets over multiple paths\n"
1486 "Match the cluster length\n")
1488 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1491 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1492 "no maximum-paths ibgp [" CMD_RANGE_STR(
1493 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1495 "Forward packets over multiple paths\n"
1498 "Match the cluster length\n")
1500 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1503 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1504 vty_out(vty
, " maximum-paths %d\n",
1505 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1508 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1509 vty_out(vty
, " maximum-paths ibgp %d",
1510 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1511 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1512 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1513 vty_out(vty
, " equal-cluster-length");
1522 "timers bgp (0-65535) (0-65535)",
1523 "Adjust routing timers\n"
1525 "Keepalive interval\n"
1528 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1530 int idx_number_2
= 3;
1531 unsigned long keepalive
= 0;
1532 unsigned long holdtime
= 0;
1534 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1535 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1537 /* Holdtime value check. */
1538 if (holdtime
< 3 && holdtime
!= 0) {
1540 "%% hold time value must be either 0 or greater than 3\n");
1541 return CMD_WARNING_CONFIG_FAILED
;
1544 bgp_timers_set(bgp
, keepalive
, holdtime
);
1549 DEFUN (no_bgp_timers
,
1551 "no timers bgp [(0-65535) (0-65535)]",
1553 "Adjust routing timers\n"
1555 "Keepalive interval\n"
1558 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1559 bgp_timers_unset(bgp
);
1565 DEFUN (bgp_client_to_client_reflection
,
1566 bgp_client_to_client_reflection_cmd
,
1567 "bgp client-to-client reflection",
1568 "BGP specific commands\n"
1569 "Configure client to client route reflection\n"
1570 "reflection of routes allowed\n")
1572 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1573 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1574 bgp_clear_star_soft_out(vty
, bgp
->name
);
1579 DEFUN (no_bgp_client_to_client_reflection
,
1580 no_bgp_client_to_client_reflection_cmd
,
1581 "no bgp client-to-client reflection",
1583 "BGP specific commands\n"
1584 "Configure client to client route reflection\n"
1585 "reflection of routes allowed\n")
1587 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1588 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1589 bgp_clear_star_soft_out(vty
, bgp
->name
);
1594 /* "bgp always-compare-med" configuration. */
1595 DEFUN (bgp_always_compare_med
,
1596 bgp_always_compare_med_cmd
,
1597 "bgp always-compare-med",
1598 "BGP specific commands\n"
1599 "Allow comparing MED from different neighbors\n")
1601 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1602 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1603 bgp_recalculate_all_bestpaths(bgp
);
1608 DEFUN (no_bgp_always_compare_med
,
1609 no_bgp_always_compare_med_cmd
,
1610 "no bgp always-compare-med",
1612 "BGP specific commands\n"
1613 "Allow comparing MED from different neighbors\n")
1615 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1616 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1617 bgp_recalculate_all_bestpaths(bgp
);
1622 /* "bgp deterministic-med" configuration. */
1623 DEFUN (bgp_deterministic_med
,
1624 bgp_deterministic_med_cmd
,
1625 "bgp deterministic-med",
1626 "BGP specific commands\n"
1627 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1629 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1631 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1632 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1633 bgp_recalculate_all_bestpaths(bgp
);
1639 DEFUN (no_bgp_deterministic_med
,
1640 no_bgp_deterministic_med_cmd
,
1641 "no bgp deterministic-med",
1643 "BGP specific commands\n"
1644 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1646 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1647 int bestpath_per_as_used
;
1651 struct listnode
*node
, *nnode
;
1653 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1654 bestpath_per_as_used
= 0;
1656 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1657 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1658 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
;
1661 peer
->af_flags
[afi
][safi
],
1662 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1663 bestpath_per_as_used
= 1;
1667 if (bestpath_per_as_used
)
1671 if (bestpath_per_as_used
) {
1673 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1674 return CMD_WARNING_CONFIG_FAILED
;
1676 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1677 bgp_recalculate_all_bestpaths(bgp
);
1684 /* "bgp graceful-restart" configuration. */
1685 DEFUN (bgp_graceful_restart
,
1686 bgp_graceful_restart_cmd
,
1687 "bgp graceful-restart",
1688 "BGP specific commands\n"
1689 "Graceful restart capability parameters\n")
1691 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1692 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1696 DEFUN (no_bgp_graceful_restart
,
1697 no_bgp_graceful_restart_cmd
,
1698 "no bgp graceful-restart",
1700 "BGP specific commands\n"
1701 "Graceful restart capability parameters\n")
1703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1704 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1708 DEFUN (bgp_graceful_restart_stalepath_time
,
1709 bgp_graceful_restart_stalepath_time_cmd
,
1710 "bgp graceful-restart stalepath-time (1-3600)",
1711 "BGP specific commands\n"
1712 "Graceful restart capability parameters\n"
1713 "Set the max time to hold onto restarting peer's stale paths\n"
1714 "Delay value (seconds)\n")
1716 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1718 u_int32_t stalepath
;
1720 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1721 bgp
->stalepath_time
= stalepath
;
1725 DEFUN (bgp_graceful_restart_restart_time
,
1726 bgp_graceful_restart_restart_time_cmd
,
1727 "bgp graceful-restart restart-time (1-3600)",
1728 "BGP specific commands\n"
1729 "Graceful restart capability parameters\n"
1730 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1731 "Delay value (seconds)\n")
1733 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1737 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1738 bgp
->restart_time
= restart
;
1742 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1743 no_bgp_graceful_restart_stalepath_time_cmd
,
1744 "no bgp graceful-restart stalepath-time [(1-3600)]",
1746 "BGP specific commands\n"
1747 "Graceful restart capability parameters\n"
1748 "Set the max time to hold onto restarting peer's stale paths\n"
1749 "Delay value (seconds)\n")
1751 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1753 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1757 DEFUN (no_bgp_graceful_restart_restart_time
,
1758 no_bgp_graceful_restart_restart_time_cmd
,
1759 "no bgp graceful-restart restart-time [(1-3600)]",
1761 "BGP specific commands\n"
1762 "Graceful restart capability parameters\n"
1763 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1764 "Delay value (seconds)\n")
1766 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1768 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1772 DEFUN (bgp_graceful_restart_preserve_fw
,
1773 bgp_graceful_restart_preserve_fw_cmd
,
1774 "bgp graceful-restart preserve-fw-state",
1775 "BGP specific commands\n"
1776 "Graceful restart capability parameters\n"
1777 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1779 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1780 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1784 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1785 no_bgp_graceful_restart_preserve_fw_cmd
,
1786 "no bgp graceful-restart preserve-fw-state",
1788 "BGP specific commands\n"
1789 "Graceful restart capability parameters\n"
1790 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1792 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1793 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1797 static void bgp_redistribute_redo(struct bgp
*bgp
)
1801 struct list
*red_list
;
1802 struct listnode
*node
;
1803 struct bgp_redist
*red
;
1805 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1806 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1808 red_list
= bgp
->redist
[afi
][i
];
1812 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1813 bgp_redistribute_resend(bgp
, afi
, i
,
1820 /* "bgp graceful-shutdown" configuration */
1821 DEFUN (bgp_graceful_shutdown
,
1822 bgp_graceful_shutdown_cmd
,
1823 "bgp graceful-shutdown",
1825 "Graceful shutdown parameters\n")
1827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1829 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1830 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1831 bgp_static_redo_import_check(bgp
);
1832 bgp_redistribute_redo(bgp
);
1833 bgp_clear_star_soft_out(vty
, bgp
->name
);
1834 bgp_clear_star_soft_in(vty
, bgp
->name
);
1840 DEFUN (no_bgp_graceful_shutdown
,
1841 no_bgp_graceful_shutdown_cmd
,
1842 "no bgp graceful-shutdown",
1845 "Graceful shutdown parameters\n")
1847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1849 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1850 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1851 bgp_static_redo_import_check(bgp
);
1852 bgp_redistribute_redo(bgp
);
1853 bgp_clear_star_soft_out(vty
, bgp
->name
);
1854 bgp_clear_star_soft_in(vty
, bgp
->name
);
1860 /* "bgp fast-external-failover" configuration. */
1861 DEFUN (bgp_fast_external_failover
,
1862 bgp_fast_external_failover_cmd
,
1863 "bgp fast-external-failover",
1865 "Immediately reset session if a link to a directly connected external peer goes down\n")
1867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1868 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1872 DEFUN (no_bgp_fast_external_failover
,
1873 no_bgp_fast_external_failover_cmd
,
1874 "no bgp fast-external-failover",
1877 "Immediately reset session if a link to a directly connected external peer goes down\n")
1879 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1880 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1884 /* "bgp enforce-first-as" configuration. */
1885 DEFUN (bgp_enforce_first_as
,
1886 bgp_enforce_first_as_cmd
,
1887 "bgp enforce-first-as",
1889 "Enforce the first AS for EBGP routes\n")
1891 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1892 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1893 bgp_clear_star_soft_in(vty
, bgp
->name
);
1898 DEFUN (no_bgp_enforce_first_as
,
1899 no_bgp_enforce_first_as_cmd
,
1900 "no bgp enforce-first-as",
1903 "Enforce the first AS for EBGP routes\n")
1905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1906 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
1907 bgp_clear_star_soft_in(vty
, bgp
->name
);
1912 /* "bgp bestpath compare-routerid" configuration. */
1913 DEFUN (bgp_bestpath_compare_router_id
,
1914 bgp_bestpath_compare_router_id_cmd
,
1915 "bgp bestpath compare-routerid",
1916 "BGP specific commands\n"
1917 "Change the default bestpath selection\n"
1918 "Compare router-id for identical EBGP paths\n")
1920 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1921 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
1922 bgp_recalculate_all_bestpaths(bgp
);
1927 DEFUN (no_bgp_bestpath_compare_router_id
,
1928 no_bgp_bestpath_compare_router_id_cmd
,
1929 "no bgp bestpath compare-routerid",
1931 "BGP specific commands\n"
1932 "Change the default bestpath selection\n"
1933 "Compare router-id for identical EBGP paths\n")
1935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1936 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
1937 bgp_recalculate_all_bestpaths(bgp
);
1942 /* "bgp bestpath as-path ignore" configuration. */
1943 DEFUN (bgp_bestpath_aspath_ignore
,
1944 bgp_bestpath_aspath_ignore_cmd
,
1945 "bgp bestpath as-path ignore",
1946 "BGP specific commands\n"
1947 "Change the default bestpath selection\n"
1948 "AS-path attribute\n"
1949 "Ignore as-path length in selecting a route\n")
1951 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1952 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
1953 bgp_recalculate_all_bestpaths(bgp
);
1958 DEFUN (no_bgp_bestpath_aspath_ignore
,
1959 no_bgp_bestpath_aspath_ignore_cmd
,
1960 "no bgp bestpath as-path ignore",
1962 "BGP specific commands\n"
1963 "Change the default bestpath selection\n"
1964 "AS-path attribute\n"
1965 "Ignore as-path length in selecting a route\n")
1967 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1968 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
1969 bgp_recalculate_all_bestpaths(bgp
);
1974 /* "bgp bestpath as-path confed" configuration. */
1975 DEFUN (bgp_bestpath_aspath_confed
,
1976 bgp_bestpath_aspath_confed_cmd
,
1977 "bgp bestpath as-path confed",
1978 "BGP specific commands\n"
1979 "Change the default bestpath selection\n"
1980 "AS-path attribute\n"
1981 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1983 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1984 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
1985 bgp_recalculate_all_bestpaths(bgp
);
1990 DEFUN (no_bgp_bestpath_aspath_confed
,
1991 no_bgp_bestpath_aspath_confed_cmd
,
1992 "no bgp bestpath as-path confed",
1994 "BGP specific commands\n"
1995 "Change the default bestpath selection\n"
1996 "AS-path attribute\n"
1997 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2000 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2001 bgp_recalculate_all_bestpaths(bgp
);
2006 /* "bgp bestpath as-path multipath-relax" configuration. */
2007 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2008 bgp_bestpath_aspath_multipath_relax_cmd
,
2009 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2010 "BGP specific commands\n"
2011 "Change the default bestpath selection\n"
2012 "AS-path attribute\n"
2013 "Allow load sharing across routes that have different AS paths (but same length)\n"
2014 "Generate an AS_SET\n"
2015 "Do not generate an AS_SET\n")
2017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2019 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2021 /* no-as-set is now the default behavior so we can silently
2023 if (argv_find(argv
, argc
, "as-set", &idx
))
2024 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2026 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2028 bgp_recalculate_all_bestpaths(bgp
);
2033 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2034 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2035 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2037 "BGP specific commands\n"
2038 "Change the default bestpath selection\n"
2039 "AS-path attribute\n"
2040 "Allow load sharing across routes that have different AS paths (but same length)\n"
2041 "Generate an AS_SET\n"
2042 "Do not generate an AS_SET\n")
2044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2045 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2046 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2047 bgp_recalculate_all_bestpaths(bgp
);
2052 /* "bgp log-neighbor-changes" configuration. */
2053 DEFUN (bgp_log_neighbor_changes
,
2054 bgp_log_neighbor_changes_cmd
,
2055 "bgp log-neighbor-changes",
2056 "BGP specific commands\n"
2057 "Log neighbor up/down and reset reason\n")
2059 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2060 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2064 DEFUN (no_bgp_log_neighbor_changes
,
2065 no_bgp_log_neighbor_changes_cmd
,
2066 "no bgp log-neighbor-changes",
2068 "BGP specific commands\n"
2069 "Log neighbor up/down and reset reason\n")
2071 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2072 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2076 /* "bgp bestpath med" configuration. */
2077 DEFUN (bgp_bestpath_med
,
2078 bgp_bestpath_med_cmd
,
2079 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2080 "BGP specific commands\n"
2081 "Change the default bestpath selection\n"
2083 "Compare MED among confederation paths\n"
2084 "Treat missing MED as the least preferred one\n"
2085 "Treat missing MED as the least preferred one\n"
2086 "Compare MED among confederation paths\n")
2088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2091 if (argv_find(argv
, argc
, "confed", &idx
))
2092 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2094 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2095 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2097 bgp_recalculate_all_bestpaths(bgp
);
2102 DEFUN (no_bgp_bestpath_med
,
2103 no_bgp_bestpath_med_cmd
,
2104 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2106 "BGP specific commands\n"
2107 "Change the default bestpath selection\n"
2109 "Compare MED among confederation paths\n"
2110 "Treat missing MED as the least preferred one\n"
2111 "Treat missing MED as the least preferred one\n"
2112 "Compare MED among confederation paths\n")
2114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2117 if (argv_find(argv
, argc
, "confed", &idx
))
2118 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2120 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2121 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2123 bgp_recalculate_all_bestpaths(bgp
);
2128 /* "no bgp default ipv4-unicast". */
2129 DEFUN (no_bgp_default_ipv4_unicast
,
2130 no_bgp_default_ipv4_unicast_cmd
,
2131 "no bgp default ipv4-unicast",
2133 "BGP specific commands\n"
2134 "Configure BGP defaults\n"
2135 "Activate ipv4-unicast for a peer by default\n")
2137 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2138 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2142 DEFUN (bgp_default_ipv4_unicast
,
2143 bgp_default_ipv4_unicast_cmd
,
2144 "bgp default ipv4-unicast",
2145 "BGP specific commands\n"
2146 "Configure BGP defaults\n"
2147 "Activate ipv4-unicast for a peer by default\n")
2149 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2150 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2154 /* Display hostname in certain command outputs */
2155 DEFUN (bgp_default_show_hostname
,
2156 bgp_default_show_hostname_cmd
,
2157 "bgp default show-hostname",
2158 "BGP specific commands\n"
2159 "Configure BGP defaults\n"
2160 "Show hostname in certain command ouputs\n")
2162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2163 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2167 DEFUN (no_bgp_default_show_hostname
,
2168 no_bgp_default_show_hostname_cmd
,
2169 "no bgp default show-hostname",
2171 "BGP specific commands\n"
2172 "Configure BGP defaults\n"
2173 "Show hostname in certain command ouputs\n")
2175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2176 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2180 /* "bgp network import-check" configuration. */
2181 DEFUN (bgp_network_import_check
,
2182 bgp_network_import_check_cmd
,
2183 "bgp network import-check",
2184 "BGP specific commands\n"
2185 "BGP network command\n"
2186 "Check BGP network route exists in IGP\n")
2188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2189 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2190 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2191 bgp_static_redo_import_check(bgp
);
2197 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2198 "bgp network import-check exact",
2199 "BGP specific commands\n"
2200 "BGP network command\n"
2201 "Check BGP network route exists in IGP\n"
2202 "Match route precisely\n")
2204 DEFUN (no_bgp_network_import_check
,
2205 no_bgp_network_import_check_cmd
,
2206 "no bgp network import-check",
2208 "BGP specific commands\n"
2209 "BGP network command\n"
2210 "Check BGP network route exists in IGP\n")
2212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2213 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2214 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2215 bgp_static_redo_import_check(bgp
);
2221 DEFUN (bgp_default_local_preference
,
2222 bgp_default_local_preference_cmd
,
2223 "bgp default local-preference (0-4294967295)",
2224 "BGP specific commands\n"
2225 "Configure BGP defaults\n"
2226 "local preference (higher=more preferred)\n"
2227 "Configure default local preference value\n")
2229 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2231 u_int32_t local_pref
;
2233 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2235 bgp_default_local_preference_set(bgp
, local_pref
);
2236 bgp_clear_star_soft_in(vty
, bgp
->name
);
2241 DEFUN (no_bgp_default_local_preference
,
2242 no_bgp_default_local_preference_cmd
,
2243 "no bgp default local-preference [(0-4294967295)]",
2245 "BGP specific commands\n"
2246 "Configure BGP defaults\n"
2247 "local preference (higher=more preferred)\n"
2248 "Configure default local preference value\n")
2250 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2251 bgp_default_local_preference_unset(bgp
);
2252 bgp_clear_star_soft_in(vty
, bgp
->name
);
2258 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2259 bgp_default_subgroup_pkt_queue_max_cmd
,
2260 "bgp default subgroup-pkt-queue-max (20-100)",
2261 "BGP specific commands\n"
2262 "Configure BGP defaults\n"
2263 "subgroup-pkt-queue-max\n"
2264 "Configure subgroup packet queue max\n")
2266 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2270 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2272 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2277 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2278 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2279 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2281 "BGP specific commands\n"
2282 "Configure BGP defaults\n"
2283 "subgroup-pkt-queue-max\n"
2284 "Configure subgroup packet queue max\n")
2286 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2287 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2292 DEFUN (bgp_rr_allow_outbound_policy
,
2293 bgp_rr_allow_outbound_policy_cmd
,
2294 "bgp route-reflector allow-outbound-policy",
2295 "BGP specific commands\n"
2296 "Allow modifications made by out route-map\n"
2297 "on ibgp neighbors\n")
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2301 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2302 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2303 update_group_announce_rrclients(bgp
);
2304 bgp_clear_star_soft_out(vty
, bgp
->name
);
2310 DEFUN (no_bgp_rr_allow_outbound_policy
,
2311 no_bgp_rr_allow_outbound_policy_cmd
,
2312 "no bgp route-reflector allow-outbound-policy",
2314 "BGP specific commands\n"
2315 "Allow modifications made by out route-map\n"
2316 "on ibgp neighbors\n")
2318 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2320 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2321 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2322 update_group_announce_rrclients(bgp
);
2323 bgp_clear_star_soft_out(vty
, bgp
->name
);
2329 DEFUN (bgp_listen_limit
,
2330 bgp_listen_limit_cmd
,
2331 "bgp listen limit (1-5000)",
2332 "BGP specific commands\n"
2333 "Configure BGP defaults\n"
2334 "maximum number of BGP Dynamic Neighbors that can be created\n"
2335 "Configure Dynamic Neighbors listen limit value\n")
2337 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2341 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2343 bgp_listen_limit_set(bgp
, listen_limit
);
2348 DEFUN (no_bgp_listen_limit
,
2349 no_bgp_listen_limit_cmd
,
2350 "no bgp listen limit [(1-5000)]",
2351 "BGP specific commands\n"
2352 "Configure BGP defaults\n"
2353 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2354 "Configure Dynamic Neighbors listen limit value to default\n"
2355 "Configure Dynamic Neighbors listen limit value\n")
2357 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2358 bgp_listen_limit_unset(bgp
);
2364 * Check if this listen range is already configured. Check for exact
2365 * match or overlap based on input.
2367 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2368 struct prefix
*range
, int exact
)
2370 struct listnode
*node
, *nnode
;
2371 struct listnode
*node1
, *nnode1
;
2372 struct peer_group
*group
;
2377 afi
= family2afi(range
->family
);
2378 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2379 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2382 match
= prefix_same(range
, lr
);
2384 match
= (prefix_match(range
, lr
)
2385 || prefix_match(lr
, range
));
2394 DEFUN (bgp_listen_range
,
2395 bgp_listen_range_cmd
,
2396 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2397 "BGP specific commands\n"
2398 "Configure BGP dynamic neighbors listen range\n"
2399 "Configure BGP dynamic neighbors listen range\n"
2401 "Member of the peer-group\n"
2402 "Peer-group name\n")
2404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2405 struct prefix range
;
2406 struct peer_group
*group
, *existing_group
;
2411 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2412 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2413 char *prefix
= argv
[idx
]->arg
;
2414 argv_find(argv
, argc
, "WORD", &idx
);
2415 char *peergroup
= argv
[idx
]->arg
;
2417 /* Convert IP prefix string to struct prefix. */
2418 ret
= str2prefix(prefix
, &range
);
2420 vty_out(vty
, "%% Malformed listen range\n");
2421 return CMD_WARNING_CONFIG_FAILED
;
2424 afi
= family2afi(range
.family
);
2426 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2428 "%% Malformed listen range (link-local address)\n");
2429 return CMD_WARNING_CONFIG_FAILED
;
2434 /* Check if same listen range is already configured. */
2435 existing_group
= listen_range_exists(bgp
, &range
, 1);
2436 if (existing_group
) {
2437 if (strcmp(existing_group
->name
, peergroup
) == 0)
2441 "%% Same listen range is attached to peer-group %s\n",
2442 existing_group
->name
);
2443 return CMD_WARNING_CONFIG_FAILED
;
2447 /* Check if an overlapping listen range exists. */
2448 if (listen_range_exists(bgp
, &range
, 0)) {
2450 "%% Listen range overlaps with existing listen range\n");
2451 return CMD_WARNING_CONFIG_FAILED
;
2454 group
= peer_group_lookup(bgp
, peergroup
);
2456 vty_out(vty
, "%% Configure the peer-group first\n");
2457 return CMD_WARNING_CONFIG_FAILED
;
2460 ret
= peer_group_listen_range_add(group
, &range
);
2461 return bgp_vty_return(vty
, ret
);
2464 DEFUN (no_bgp_listen_range
,
2465 no_bgp_listen_range_cmd
,
2466 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2468 "BGP specific commands\n"
2469 "Unconfigure BGP dynamic neighbors listen range\n"
2470 "Unconfigure BGP dynamic neighbors listen range\n"
2472 "Member of the peer-group\n"
2473 "Peer-group name\n")
2475 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2476 struct prefix range
;
2477 struct peer_group
*group
;
2482 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2483 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2484 char *prefix
= argv
[idx
]->arg
;
2485 argv_find(argv
, argc
, "WORD", &idx
);
2486 char *peergroup
= argv
[idx
]->arg
;
2488 /* Convert IP prefix string to struct prefix. */
2489 ret
= str2prefix(prefix
, &range
);
2491 vty_out(vty
, "%% Malformed listen range\n");
2492 return CMD_WARNING_CONFIG_FAILED
;
2495 afi
= family2afi(range
.family
);
2497 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2499 "%% Malformed listen range (link-local address)\n");
2500 return CMD_WARNING_CONFIG_FAILED
;
2505 group
= peer_group_lookup(bgp
, peergroup
);
2507 vty_out(vty
, "%% Peer-group does not exist\n");
2508 return CMD_WARNING_CONFIG_FAILED
;
2511 ret
= peer_group_listen_range_del(group
, &range
);
2512 return bgp_vty_return(vty
, ret
);
2515 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2517 struct peer_group
*group
;
2518 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2519 struct prefix
*range
;
2521 char buf
[PREFIX2STR_BUFFER
];
2523 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2524 vty_out(vty
, " bgp listen limit %d\n",
2525 bgp
->dynamic_neighbors_limit
);
2527 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2528 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2529 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2531 prefix2str(range
, buf
, sizeof(buf
));
2533 " bgp listen range %s peer-group %s\n",
2541 DEFUN (bgp_disable_connected_route_check
,
2542 bgp_disable_connected_route_check_cmd
,
2543 "bgp disable-ebgp-connected-route-check",
2544 "BGP specific commands\n"
2545 "Disable checking if nexthop is connected on ebgp sessions\n")
2547 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2548 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2549 bgp_clear_star_soft_in(vty
, bgp
->name
);
2554 DEFUN (no_bgp_disable_connected_route_check
,
2555 no_bgp_disable_connected_route_check_cmd
,
2556 "no bgp disable-ebgp-connected-route-check",
2558 "BGP specific commands\n"
2559 "Disable checking if nexthop is connected on ebgp sessions\n")
2561 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2562 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2563 bgp_clear_star_soft_in(vty
, bgp
->name
);
2569 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2570 const char *as_str
, afi_t afi
, safi_t safi
)
2572 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2575 int as_type
= AS_SPECIFIED
;
2578 if (as_str
[0] == 'i') {
2580 as_type
= AS_INTERNAL
;
2581 } else if (as_str
[0] == 'e') {
2583 as_type
= AS_EXTERNAL
;
2585 /* Get AS number. */
2586 as
= strtoul(as_str
, NULL
, 10);
2589 /* If peer is peer group, call proper function. */
2590 ret
= str2sockunion(peer_str
, &su
);
2592 /* Check for peer by interface */
2593 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2596 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2599 "%% Create the peer-group or interface first\n");
2600 return CMD_WARNING_CONFIG_FAILED
;
2605 if (peer_address_self_check(bgp
, &su
)) {
2607 "%% Can not configure the local system as neighbor\n");
2608 return CMD_WARNING_CONFIG_FAILED
;
2610 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2613 /* This peer belongs to peer group. */
2615 case BGP_ERR_PEER_GROUP_MEMBER
:
2617 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2619 return CMD_WARNING_CONFIG_FAILED
;
2620 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2622 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2624 return CMD_WARNING_CONFIG_FAILED
;
2626 return bgp_vty_return(vty
, ret
);
2629 DEFUN (neighbor_remote_as
,
2630 neighbor_remote_as_cmd
,
2631 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2634 "Specify a BGP neighbor\n"
2636 "Internal BGP peer\n"
2637 "External BGP peer\n")
2640 int idx_remote_as
= 3;
2641 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2642 argv
[idx_remote_as
]->arg
, AFI_IP
,
2646 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2647 afi_t afi
, safi_t safi
, int v6only
,
2648 const char *peer_group_name
,
2651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2653 int as_type
= AS_UNSPECIFIED
;
2655 struct peer_group
*group
;
2659 group
= peer_group_lookup(bgp
, conf_if
);
2662 vty_out(vty
, "%% Name conflict with peer-group \n");
2663 return CMD_WARNING_CONFIG_FAILED
;
2667 if (as_str
[0] == 'i') {
2668 as_type
= AS_INTERNAL
;
2669 } else if (as_str
[0] == 'e') {
2670 as_type
= AS_EXTERNAL
;
2672 /* Get AS number. */
2673 as
= strtoul(as_str
, NULL
, 10);
2674 as_type
= AS_SPECIFIED
;
2678 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2681 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2684 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2685 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2686 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2687 as_type
, 0, 0, NULL
);
2689 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2690 as_type
, afi
, safi
, NULL
);
2693 vty_out(vty
, "%% BGP failed to create peer\n");
2694 return CMD_WARNING_CONFIG_FAILED
;
2698 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2700 /* Request zebra to initiate IPv6 RAs on this interface. We do
2702 * any unnumbered peer in order to not worry about run-time
2704 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2706 * gets deleted later etc.)
2709 bgp_zebra_initiate_radv(bgp
, peer
);
2712 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2713 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2715 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2717 UNSET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2719 /* v6only flag changed. Reset bgp seesion */
2720 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2721 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2722 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2723 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2725 bgp_session_reset(peer
);
2728 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
2729 peer_flag_set(peer
, PEER_FLAG_CAPABILITY_ENHE
);
2731 if (peer_group_name
) {
2732 group
= peer_group_lookup(bgp
, peer_group_name
);
2734 vty_out(vty
, "%% Configure the peer-group first\n");
2735 return CMD_WARNING_CONFIG_FAILED
;
2738 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2741 return bgp_vty_return(vty
, ret
);
2744 DEFUN (neighbor_interface_config
,
2745 neighbor_interface_config_cmd
,
2746 "neighbor WORD interface [peer-group WORD]",
2748 "Interface name or neighbor tag\n"
2749 "Enable BGP on interface\n"
2750 "Member of the peer-group\n"
2751 "Peer-group name\n")
2754 int idx_peer_group_word
= 4;
2756 if (argc
> idx_peer_group_word
)
2757 return peer_conf_interface_get(
2758 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2759 argv
[idx_peer_group_word
]->arg
, NULL
);
2761 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2762 SAFI_UNICAST
, 0, NULL
, NULL
);
2765 DEFUN (neighbor_interface_config_v6only
,
2766 neighbor_interface_config_v6only_cmd
,
2767 "neighbor WORD interface v6only [peer-group WORD]",
2769 "Interface name or neighbor tag\n"
2770 "Enable BGP on interface\n"
2771 "Enable BGP with v6 link-local only\n"
2772 "Member of the peer-group\n"
2773 "Peer-group name\n")
2776 int idx_peer_group_word
= 5;
2778 if (argc
> idx_peer_group_word
)
2779 return peer_conf_interface_get(
2780 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2781 argv
[idx_peer_group_word
]->arg
, NULL
);
2783 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2784 SAFI_UNICAST
, 1, NULL
, NULL
);
2788 DEFUN (neighbor_interface_config_remote_as
,
2789 neighbor_interface_config_remote_as_cmd
,
2790 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2792 "Interface name or neighbor tag\n"
2793 "Enable BGP on interface\n"
2794 "Specify a BGP neighbor\n"
2796 "Internal BGP peer\n"
2797 "External BGP peer\n")
2800 int idx_remote_as
= 4;
2801 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2802 SAFI_UNICAST
, 0, NULL
,
2803 argv
[idx_remote_as
]->arg
);
2806 DEFUN (neighbor_interface_v6only_config_remote_as
,
2807 neighbor_interface_v6only_config_remote_as_cmd
,
2808 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2810 "Interface name or neighbor tag\n"
2811 "Enable BGP with v6 link-local only\n"
2812 "Enable BGP on interface\n"
2813 "Specify a BGP neighbor\n"
2815 "Internal BGP peer\n"
2816 "External BGP peer\n")
2819 int idx_remote_as
= 5;
2820 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2821 SAFI_UNICAST
, 1, NULL
,
2822 argv
[idx_remote_as
]->arg
);
2825 DEFUN (neighbor_peer_group
,
2826 neighbor_peer_group_cmd
,
2827 "neighbor WORD peer-group",
2829 "Interface name or neighbor tag\n"
2830 "Configure peer-group\n")
2832 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2835 struct peer_group
*group
;
2837 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2839 vty_out(vty
, "%% Name conflict with interface: \n");
2840 return CMD_WARNING_CONFIG_FAILED
;
2843 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2845 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2846 return CMD_WARNING_CONFIG_FAILED
;
2854 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
2858 "Specify a BGP neighbor\n"
2860 "Internal BGP peer\n"
2861 "External BGP peer\n")
2863 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2867 struct peer_group
*group
;
2871 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
2873 /* look up for neighbor by interface name config. */
2874 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
2876 /* Request zebra to terminate IPv6 RAs on this
2879 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
2884 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
2886 peer_group_delete(group
);
2888 vty_out(vty
, "%% Create the peer-group first\n");
2889 return CMD_WARNING_CONFIG_FAILED
;
2892 peer
= peer_lookup(bgp
, &su
);
2894 if (peer_dynamic_neighbor(peer
)) {
2896 "%% Operation not allowed on a dynamic neighbor\n");
2897 return CMD_WARNING_CONFIG_FAILED
;
2900 other
= peer
->doppelganger
;
2902 if (other
&& other
->status
!= Deleted
)
2910 DEFUN (no_neighbor_interface_config
,
2911 no_neighbor_interface_config_cmd
,
2912 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
2916 "Configure BGP on interface\n"
2917 "Enable BGP with v6 link-local only\n"
2918 "Member of the peer-group\n"
2920 "Specify a BGP neighbor\n"
2922 "Internal BGP peer\n"
2923 "External BGP peer\n")
2925 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2929 /* look up for neighbor by interface name config. */
2930 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2932 /* Request zebra to terminate IPv6 RAs on this interface. */
2934 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
2937 vty_out(vty
, "%% Create the bgp interface first\n");
2938 return CMD_WARNING_CONFIG_FAILED
;
2943 DEFUN (no_neighbor_peer_group
,
2944 no_neighbor_peer_group_cmd
,
2945 "no neighbor WORD peer-group",
2949 "Configure peer-group\n")
2951 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2953 struct peer_group
*group
;
2955 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
2957 peer_group_delete(group
);
2959 vty_out(vty
, "%% Create the peer-group first\n");
2960 return CMD_WARNING_CONFIG_FAILED
;
2965 DEFUN (no_neighbor_interface_peer_group_remote_as
,
2966 no_neighbor_interface_peer_group_remote_as_cmd
,
2967 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
2970 "Interface name or neighbor tag\n"
2971 "Specify a BGP neighbor\n"
2973 "Internal BGP peer\n"
2974 "External BGP peer\n")
2976 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2978 struct peer_group
*group
;
2981 /* look up for neighbor by interface name config. */
2982 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2984 peer_as_change(peer
, 0, AS_SPECIFIED
);
2988 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
2990 peer_group_remote_as_delete(group
);
2992 vty_out(vty
, "%% Create the peer-group or interface first\n");
2993 return CMD_WARNING_CONFIG_FAILED
;
2998 DEFUN (neighbor_local_as
,
2999 neighbor_local_as_cmd
,
3000 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3003 "Specify a local-as number\n"
3004 "AS number used as local AS\n")
3012 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3014 return CMD_WARNING_CONFIG_FAILED
;
3016 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3017 ret
= peer_local_as_set(peer
, as
, 0, 0);
3018 return bgp_vty_return(vty
, ret
);
3021 DEFUN (neighbor_local_as_no_prepend
,
3022 neighbor_local_as_no_prepend_cmd
,
3023 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3026 "Specify a local-as number\n"
3027 "AS number used as local AS\n"
3028 "Do not prepend local-as to updates from ebgp peers\n")
3036 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3038 return CMD_WARNING_CONFIG_FAILED
;
3040 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3041 ret
= peer_local_as_set(peer
, as
, 1, 0);
3042 return bgp_vty_return(vty
, ret
);
3045 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3046 neighbor_local_as_no_prepend_replace_as_cmd
,
3047 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3050 "Specify a local-as number\n"
3051 "AS number used as local AS\n"
3052 "Do not prepend local-as to updates from ebgp peers\n"
3053 "Do not prepend local-as to updates from ibgp peers\n")
3061 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3063 return CMD_WARNING_CONFIG_FAILED
;
3065 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3066 ret
= peer_local_as_set(peer
, as
, 1, 1);
3067 return bgp_vty_return(vty
, ret
);
3070 DEFUN (no_neighbor_local_as
,
3071 no_neighbor_local_as_cmd
,
3072 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3076 "Specify a local-as number\n"
3077 "AS number used as local AS\n"
3078 "Do not prepend local-as to updates from ebgp peers\n"
3079 "Do not prepend local-as to updates from ibgp peers\n")
3085 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3087 return CMD_WARNING_CONFIG_FAILED
;
3089 ret
= peer_local_as_unset(peer
);
3090 return bgp_vty_return(vty
, ret
);
3094 DEFUN (neighbor_solo
,
3096 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3099 "Solo peer - part of its own update group\n")
3105 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3107 return CMD_WARNING_CONFIG_FAILED
;
3109 ret
= update_group_adjust_soloness(peer
, 1);
3110 return bgp_vty_return(vty
, ret
);
3113 DEFUN (no_neighbor_solo
,
3114 no_neighbor_solo_cmd
,
3115 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3119 "Solo peer - part of its own update group\n")
3125 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3127 return CMD_WARNING_CONFIG_FAILED
;
3129 ret
= update_group_adjust_soloness(peer
, 0);
3130 return bgp_vty_return(vty
, ret
);
3133 DEFUN (neighbor_password
,
3134 neighbor_password_cmd
,
3135 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3146 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3148 return CMD_WARNING_CONFIG_FAILED
;
3150 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3151 return bgp_vty_return(vty
, ret
);
3154 DEFUN (no_neighbor_password
,
3155 no_neighbor_password_cmd
,
3156 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3167 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3169 return CMD_WARNING_CONFIG_FAILED
;
3171 ret
= peer_password_unset(peer
);
3172 return bgp_vty_return(vty
, ret
);
3176 DEFUN (neighbor_activate
,
3177 neighbor_activate_cmd
,
3178 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3181 "Enable the Address Family for this Neighbor\n")
3187 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3189 return CMD_WARNING_CONFIG_FAILED
;
3191 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3192 return bgp_vty_return(vty
, ret
);
3195 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3196 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3197 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3198 "Enable the Address Family for this Neighbor\n")
3200 DEFUN (no_neighbor_activate
,
3201 no_neighbor_activate_cmd
,
3202 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3206 "Enable the Address Family for this Neighbor\n")
3213 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3215 return CMD_WARNING_CONFIG_FAILED
;
3217 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3218 return bgp_vty_return(vty
, ret
);
3221 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3222 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3223 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3224 "Enable the Address Family for this Neighbor\n")
3226 DEFUN (neighbor_set_peer_group
,
3227 neighbor_set_peer_group_cmd
,
3228 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3231 "Member of the peer-group\n"
3232 "Peer-group name\n")
3234 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3241 struct peer_group
*group
;
3245 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3247 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3249 vty_out(vty
, "%% Malformed address or name: %s\n",
3250 argv
[idx_peer
]->arg
);
3251 return CMD_WARNING_CONFIG_FAILED
;
3254 if (peer_address_self_check(bgp
, &su
)) {
3256 "%% Can not configure the local system as neighbor\n");
3257 return CMD_WARNING_CONFIG_FAILED
;
3260 /* Disallow for dynamic neighbor. */
3261 peer
= peer_lookup(bgp
, &su
);
3262 if (peer
&& peer_dynamic_neighbor(peer
)) {
3264 "%% Operation not allowed on a dynamic neighbor\n");
3265 return CMD_WARNING_CONFIG_FAILED
;
3269 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3271 vty_out(vty
, "%% Configure the peer-group first\n");
3272 return CMD_WARNING_CONFIG_FAILED
;
3275 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3277 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3279 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3281 return CMD_WARNING_CONFIG_FAILED
;
3284 return bgp_vty_return(vty
, ret
);
3287 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3288 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3289 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3290 "Member of the peer-group\n"
3291 "Peer-group name\n")
3293 DEFUN (no_neighbor_set_peer_group
,
3294 no_neighbor_set_peer_group_cmd
,
3295 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3299 "Member of the peer-group\n"
3300 "Peer-group name\n")
3302 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3307 struct peer_group
*group
;
3309 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3311 return CMD_WARNING_CONFIG_FAILED
;
3313 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3315 vty_out(vty
, "%% Configure the peer-group first\n");
3316 return CMD_WARNING_CONFIG_FAILED
;
3319 ret
= peer_group_unbind(bgp
, peer
, group
);
3321 return bgp_vty_return(vty
, ret
);
3324 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3325 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3326 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3327 "Member of the peer-group\n"
3328 "Peer-group name\n")
3330 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3331 u_int16_t flag
, int set
)
3336 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3338 return CMD_WARNING_CONFIG_FAILED
;
3341 * If 'neighbor <interface>', then this is for directly connected peers,
3342 * we should not accept disable-connected-check.
3344 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3346 "%s is directly connected peer, cannot accept disable-"
3347 "connected-check\n",
3349 return CMD_WARNING_CONFIG_FAILED
;
3352 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3353 peer_tx_shutdown_message_unset(peer
);
3356 ret
= peer_flag_set(peer
, flag
);
3358 ret
= peer_flag_unset(peer
, flag
);
3360 return bgp_vty_return(vty
, ret
);
3363 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
,
3366 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3369 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3372 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3375 /* neighbor passive. */
3376 DEFUN (neighbor_passive
,
3377 neighbor_passive_cmd
,
3378 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3381 "Don't send open messages to this neighbor\n")
3384 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3387 DEFUN (no_neighbor_passive
,
3388 no_neighbor_passive_cmd
,
3389 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3393 "Don't send open messages to this neighbor\n")
3396 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3399 /* neighbor shutdown. */
3400 DEFUN (neighbor_shutdown_msg
,
3401 neighbor_shutdown_msg_cmd
,
3402 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3405 "Administratively shut down this neighbor\n"
3406 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3407 "Shutdown message\n")
3413 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3417 return CMD_WARNING_CONFIG_FAILED
;
3418 message
= argv_concat(argv
, argc
, 4);
3419 peer_tx_shutdown_message_set(peer
, message
);
3420 XFREE(MTYPE_TMP
, message
);
3423 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3426 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3427 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3428 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3429 "Administratively shut down this neighbor\n")
3431 DEFUN (no_neighbor_shutdown_msg
,
3432 no_neighbor_shutdown_msg_cmd
,
3433 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3437 "Administratively shut down this neighbor\n"
3438 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3439 "Shutdown message\n")
3443 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3444 PEER_FLAG_SHUTDOWN
);
3447 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3448 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3449 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3450 "Administratively shut down this neighbor\n")
3452 /* neighbor capability dynamic. */
3453 DEFUN (neighbor_capability_dynamic
,
3454 neighbor_capability_dynamic_cmd
,
3455 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3458 "Advertise capability to the peer\n"
3459 "Advertise dynamic capability to this neighbor\n")
3462 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3463 PEER_FLAG_DYNAMIC_CAPABILITY
);
3466 DEFUN (no_neighbor_capability_dynamic
,
3467 no_neighbor_capability_dynamic_cmd
,
3468 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3472 "Advertise capability to the peer\n"
3473 "Advertise dynamic capability to this neighbor\n")
3476 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3477 PEER_FLAG_DYNAMIC_CAPABILITY
);
3480 /* neighbor dont-capability-negotiate */
3481 DEFUN (neighbor_dont_capability_negotiate
,
3482 neighbor_dont_capability_negotiate_cmd
,
3483 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3486 "Do not perform capability negotiation\n")
3489 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3490 PEER_FLAG_DONT_CAPABILITY
);
3493 DEFUN (no_neighbor_dont_capability_negotiate
,
3494 no_neighbor_dont_capability_negotiate_cmd
,
3495 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3499 "Do not perform capability negotiation\n")
3502 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3503 PEER_FLAG_DONT_CAPABILITY
);
3506 /* neighbor capability extended next hop encoding */
3507 DEFUN (neighbor_capability_enhe
,
3508 neighbor_capability_enhe_cmd
,
3509 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3512 "Advertise capability to the peer\n"
3513 "Advertise extended next-hop capability to the peer\n")
3516 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3517 PEER_FLAG_CAPABILITY_ENHE
);
3520 DEFUN (no_neighbor_capability_enhe
,
3521 no_neighbor_capability_enhe_cmd
,
3522 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3526 "Advertise capability to the peer\n"
3527 "Advertise extended next-hop capability to the peer\n")
3530 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3531 PEER_FLAG_CAPABILITY_ENHE
);
3534 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3535 afi_t afi
, safi_t safi
, u_int32_t flag
,
3541 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3543 return CMD_WARNING_CONFIG_FAILED
;
3546 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3548 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3550 return bgp_vty_return(vty
, ret
);
3553 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3554 afi_t afi
, safi_t safi
, u_int32_t flag
)
3556 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3559 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3560 afi_t afi
, safi_t safi
, u_int32_t flag
)
3562 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3565 /* neighbor capability orf prefix-list. */
3566 DEFUN (neighbor_capability_orf_prefix
,
3567 neighbor_capability_orf_prefix_cmd
,
3568 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3571 "Advertise capability to the peer\n"
3572 "Advertise ORF capability to the peer\n"
3573 "Advertise prefixlist ORF capability to this neighbor\n"
3574 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3575 "Capability to RECEIVE the ORF from this neighbor\n"
3576 "Capability to SEND the ORF to this neighbor\n")
3579 int idx_send_recv
= 5;
3582 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3583 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3584 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3585 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3586 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3587 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3589 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3590 return CMD_WARNING_CONFIG_FAILED
;
3593 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3594 bgp_node_safi(vty
), flag
);
3598 neighbor_capability_orf_prefix
,
3599 neighbor_capability_orf_prefix_hidden_cmd
,
3600 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3601 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3602 "Advertise capability to the peer\n"
3603 "Advertise ORF capability to the peer\n"
3604 "Advertise prefixlist ORF capability to this neighbor\n"
3605 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3606 "Capability to RECEIVE the ORF from this neighbor\n"
3607 "Capability to SEND the ORF to this neighbor\n")
3609 DEFUN (no_neighbor_capability_orf_prefix
,
3610 no_neighbor_capability_orf_prefix_cmd
,
3611 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3615 "Advertise capability to the peer\n"
3616 "Advertise ORF capability to the peer\n"
3617 "Advertise prefixlist ORF capability to this neighbor\n"
3618 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3619 "Capability to RECEIVE the ORF from this neighbor\n"
3620 "Capability to SEND the ORF to this neighbor\n")
3623 int idx_send_recv
= 6;
3626 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3627 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3628 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3629 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3630 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3631 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3633 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3634 return CMD_WARNING_CONFIG_FAILED
;
3637 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3638 bgp_node_afi(vty
), bgp_node_safi(vty
),
3643 no_neighbor_capability_orf_prefix
,
3644 no_neighbor_capability_orf_prefix_hidden_cmd
,
3645 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3646 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3647 "Advertise capability to the peer\n"
3648 "Advertise ORF capability to the peer\n"
3649 "Advertise prefixlist ORF capability to this neighbor\n"
3650 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3651 "Capability to RECEIVE the ORF from this neighbor\n"
3652 "Capability to SEND the ORF to this neighbor\n")
3654 /* neighbor next-hop-self. */
3655 DEFUN (neighbor_nexthop_self
,
3656 neighbor_nexthop_self_cmd
,
3657 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3660 "Disable the next hop calculation for this neighbor\n")
3663 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3664 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3667 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3668 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3669 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3670 "Disable the next hop calculation for this neighbor\n")
3672 /* neighbor next-hop-self. */
3673 DEFUN (neighbor_nexthop_self_force
,
3674 neighbor_nexthop_self_force_cmd
,
3675 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3678 "Disable the next hop calculation for this neighbor\n"
3679 "Set the next hop to self for reflected routes\n")
3682 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3684 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3687 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3688 neighbor_nexthop_self_force_hidden_cmd
,
3689 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3690 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3691 "Disable the next hop calculation for this neighbor\n"
3692 "Set the next hop to self for reflected routes\n")
3694 DEFUN (no_neighbor_nexthop_self
,
3695 no_neighbor_nexthop_self_cmd
,
3696 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3700 "Disable the next hop calculation for this neighbor\n")
3703 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3704 bgp_node_afi(vty
), bgp_node_safi(vty
),
3705 PEER_FLAG_NEXTHOP_SELF
);
3708 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3709 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3710 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3711 "Disable the next hop calculation for this neighbor\n")
3713 DEFUN (no_neighbor_nexthop_self_force
,
3714 no_neighbor_nexthop_self_force_cmd
,
3715 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3719 "Disable the next hop calculation for this neighbor\n"
3720 "Set the next hop to self for reflected routes\n")
3723 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3724 bgp_node_afi(vty
), bgp_node_safi(vty
),
3725 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3728 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3729 no_neighbor_nexthop_self_force_hidden_cmd
,
3730 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3731 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3732 "Disable the next hop calculation for this neighbor\n"
3733 "Set the next hop to self for reflected routes\n")
3735 /* neighbor as-override */
3736 DEFUN (neighbor_as_override
,
3737 neighbor_as_override_cmd
,
3738 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3741 "Override ASNs in outbound updates if aspath equals remote-as\n")
3744 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3745 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3748 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3749 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3750 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3751 "Override ASNs in outbound updates if aspath equals remote-as\n")
3753 DEFUN (no_neighbor_as_override
,
3754 no_neighbor_as_override_cmd
,
3755 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3759 "Override ASNs in outbound updates if aspath equals remote-as\n")
3762 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3763 bgp_node_afi(vty
), bgp_node_safi(vty
),
3764 PEER_FLAG_AS_OVERRIDE
);
3767 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3768 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3769 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3770 "Override ASNs in outbound updates if aspath equals remote-as\n")
3772 /* neighbor remove-private-AS. */
3773 DEFUN (neighbor_remove_private_as
,
3774 neighbor_remove_private_as_cmd
,
3775 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3778 "Remove private ASNs in outbound updates\n")
3781 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3783 PEER_FLAG_REMOVE_PRIVATE_AS
);
3786 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3787 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3788 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3789 "Remove private ASNs in outbound updates\n")
3791 DEFUN (neighbor_remove_private_as_all
,
3792 neighbor_remove_private_as_all_cmd
,
3793 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3796 "Remove private ASNs in outbound updates\n"
3797 "Apply to all AS numbers")
3800 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3802 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3805 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3806 neighbor_remove_private_as_all_hidden_cmd
,
3807 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3808 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3809 "Remove private ASNs in outbound updates\n"
3810 "Apply to all AS numbers")
3812 DEFUN (neighbor_remove_private_as_replace_as
,
3813 neighbor_remove_private_as_replace_as_cmd
,
3814 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3817 "Remove private ASNs in outbound updates\n"
3818 "Replace private ASNs with our ASN in outbound updates\n")
3821 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3823 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3826 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3827 neighbor_remove_private_as_replace_as_hidden_cmd
,
3828 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3829 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3830 "Remove private ASNs in outbound updates\n"
3831 "Replace private ASNs with our ASN in outbound updates\n")
3833 DEFUN (neighbor_remove_private_as_all_replace_as
,
3834 neighbor_remove_private_as_all_replace_as_cmd
,
3835 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3838 "Remove private ASNs in outbound updates\n"
3839 "Apply to all AS numbers\n"
3840 "Replace private ASNs with our ASN in outbound updates\n")
3843 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3845 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3849 neighbor_remove_private_as_all_replace_as
,
3850 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3851 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3852 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3853 "Remove private ASNs in outbound updates\n"
3854 "Apply to all AS numbers\n"
3855 "Replace private ASNs with our ASN in outbound updates\n")
3857 DEFUN (no_neighbor_remove_private_as
,
3858 no_neighbor_remove_private_as_cmd
,
3859 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3863 "Remove private ASNs in outbound updates\n")
3866 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3867 bgp_node_afi(vty
), bgp_node_safi(vty
),
3868 PEER_FLAG_REMOVE_PRIVATE_AS
);
3871 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
3872 no_neighbor_remove_private_as_hidden_cmd
,
3873 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3874 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3875 "Remove private ASNs in outbound updates\n")
3877 DEFUN (no_neighbor_remove_private_as_all
,
3878 no_neighbor_remove_private_as_all_cmd
,
3879 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3883 "Remove private ASNs in outbound updates\n"
3884 "Apply to all AS numbers\n")
3887 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3888 bgp_node_afi(vty
), bgp_node_safi(vty
),
3889 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3892 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
3893 no_neighbor_remove_private_as_all_hidden_cmd
,
3894 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3895 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3896 "Remove private ASNs in outbound updates\n"
3897 "Apply to all AS numbers\n")
3899 DEFUN (no_neighbor_remove_private_as_replace_as
,
3900 no_neighbor_remove_private_as_replace_as_cmd
,
3901 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3905 "Remove private ASNs in outbound updates\n"
3906 "Replace private ASNs with our ASN in outbound updates\n")
3909 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3910 bgp_node_afi(vty
), bgp_node_safi(vty
),
3911 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3914 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
3915 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
3916 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3917 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3918 "Remove private ASNs in outbound updates\n"
3919 "Replace private ASNs with our ASN in outbound updates\n")
3921 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
3922 no_neighbor_remove_private_as_all_replace_as_cmd
,
3923 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3927 "Remove private ASNs in outbound updates\n"
3928 "Apply to all AS numbers\n"
3929 "Replace private ASNs with our ASN in outbound updates\n")
3932 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3933 bgp_node_afi(vty
), bgp_node_safi(vty
),
3934 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3938 no_neighbor_remove_private_as_all_replace_as
,
3939 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3940 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3941 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3942 "Remove private ASNs in outbound updates\n"
3943 "Apply to all AS numbers\n"
3944 "Replace private ASNs with our ASN in outbound updates\n")
3947 /* neighbor send-community. */
3948 DEFUN (neighbor_send_community
,
3949 neighbor_send_community_cmd
,
3950 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
3953 "Send Community attribute to this neighbor\n")
3956 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3958 PEER_FLAG_SEND_COMMUNITY
);
3961 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
3962 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
3963 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3964 "Send Community attribute to this neighbor\n")
3966 DEFUN (no_neighbor_send_community
,
3967 no_neighbor_send_community_cmd
,
3968 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
3972 "Send Community attribute to this neighbor\n")
3975 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3976 bgp_node_afi(vty
), bgp_node_safi(vty
),
3977 PEER_FLAG_SEND_COMMUNITY
);
3980 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
3981 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
3982 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3983 "Send Community attribute to this neighbor\n")
3985 /* neighbor send-community extended. */
3986 DEFUN (neighbor_send_community_type
,
3987 neighbor_send_community_type_cmd
,
3988 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
3991 "Send Community attribute to this neighbor\n"
3992 "Send Standard and Extended Community attributes\n"
3993 "Send Standard, Large and Extended Community attributes\n"
3994 "Send Extended Community attributes\n"
3995 "Send Standard Community attributes\n"
3996 "Send Large Community attributes\n")
4001 char *peer
= argv
[1]->arg
;
4003 if (argv_find(argv
, argc
, "standard", &idx
))
4004 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4005 else if (argv_find(argv
, argc
, "extended", &idx
))
4006 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4007 else if (argv_find(argv
, argc
, "large", &idx
))
4008 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4009 else if (argv_find(argv
, argc
, "both", &idx
)) {
4010 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4011 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4013 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4014 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4015 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4018 return peer_af_flag_set_vty(vty
, peer
, bgp_node_afi(vty
),
4019 bgp_node_safi(vty
), flag
);
4023 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4024 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4025 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4026 "Send Community attribute to this neighbor\n"
4027 "Send Standard and Extended Community attributes\n"
4028 "Send Standard, Large and Extended Community attributes\n"
4029 "Send Extended Community attributes\n"
4030 "Send Standard Community attributes\n"
4031 "Send Large Community attributes\n")
4033 DEFUN (no_neighbor_send_community_type
,
4034 no_neighbor_send_community_type_cmd
,
4035 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4039 "Send Community attribute to this neighbor\n"
4040 "Send Standard and Extended Community attributes\n"
4041 "Send Standard, Large and Extended Community attributes\n"
4042 "Send Extended Community attributes\n"
4043 "Send Standard Community attributes\n"
4044 "Send Large Community attributes\n")
4048 const char *type
= argv
[argc
- 1]->text
;
4050 if (strmatch(type
, "standard"))
4051 return peer_af_flag_unset_vty(
4052 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4053 bgp_node_safi(vty
), PEER_FLAG_SEND_COMMUNITY
);
4054 if (strmatch(type
, "extended"))
4055 return peer_af_flag_unset_vty(
4056 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4057 bgp_node_safi(vty
), PEER_FLAG_SEND_EXT_COMMUNITY
);
4058 if (strmatch(type
, "large"))
4059 return peer_af_flag_unset_vty(
4060 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4061 bgp_node_safi(vty
), PEER_FLAG_SEND_LARGE_COMMUNITY
);
4062 if (strmatch(type
, "both"))
4063 return peer_af_flag_unset_vty(
4064 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4066 PEER_FLAG_SEND_COMMUNITY
4067 | PEER_FLAG_SEND_EXT_COMMUNITY
);
4069 /* if (strmatch (type, "all")) */
4070 return peer_af_flag_unset_vty(
4071 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4072 (PEER_FLAG_SEND_COMMUNITY
| PEER_FLAG_SEND_EXT_COMMUNITY
4073 | PEER_FLAG_SEND_LARGE_COMMUNITY
));
4077 no_neighbor_send_community_type
,
4078 no_neighbor_send_community_type_hidden_cmd
,
4079 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4080 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4081 "Send Community attribute to this neighbor\n"
4082 "Send Standard and Extended Community attributes\n"
4083 "Send Standard, Large and Extended Community attributes\n"
4084 "Send Extended Community attributes\n"
4085 "Send Standard Community attributes\n"
4086 "Send Large Community attributes\n")
4088 /* neighbor soft-reconfig. */
4089 DEFUN (neighbor_soft_reconfiguration
,
4090 neighbor_soft_reconfiguration_cmd
,
4091 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4094 "Per neighbor soft reconfiguration\n"
4095 "Allow inbound soft reconfiguration for this neighbor\n")
4098 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4100 PEER_FLAG_SOFT_RECONFIG
);
4103 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4104 neighbor_soft_reconfiguration_hidden_cmd
,
4105 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4106 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4107 "Per neighbor soft reconfiguration\n"
4108 "Allow inbound soft reconfiguration for this neighbor\n")
4110 DEFUN (no_neighbor_soft_reconfiguration
,
4111 no_neighbor_soft_reconfiguration_cmd
,
4112 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4116 "Per neighbor soft reconfiguration\n"
4117 "Allow inbound soft reconfiguration for this neighbor\n")
4120 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4121 bgp_node_afi(vty
), bgp_node_safi(vty
),
4122 PEER_FLAG_SOFT_RECONFIG
);
4125 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4126 no_neighbor_soft_reconfiguration_hidden_cmd
,
4127 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4128 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4129 "Per neighbor soft reconfiguration\n"
4130 "Allow inbound soft reconfiguration for this neighbor\n")
4132 DEFUN (neighbor_route_reflector_client
,
4133 neighbor_route_reflector_client_cmd
,
4134 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4137 "Configure a neighbor as Route Reflector client\n")
4143 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4145 return CMD_WARNING_CONFIG_FAILED
;
4147 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4149 PEER_FLAG_REFLECTOR_CLIENT
);
4152 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4153 neighbor_route_reflector_client_hidden_cmd
,
4154 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4155 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4156 "Configure a neighbor as Route Reflector client\n")
4158 DEFUN (no_neighbor_route_reflector_client
,
4159 no_neighbor_route_reflector_client_cmd
,
4160 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4164 "Configure a neighbor as Route Reflector client\n")
4167 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4168 bgp_node_afi(vty
), bgp_node_safi(vty
),
4169 PEER_FLAG_REFLECTOR_CLIENT
);
4172 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4173 no_neighbor_route_reflector_client_hidden_cmd
,
4174 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4175 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4176 "Configure a neighbor as Route Reflector client\n")
4178 /* neighbor route-server-client. */
4179 DEFUN (neighbor_route_server_client
,
4180 neighbor_route_server_client_cmd
,
4181 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4184 "Configure a neighbor as Route Server client\n")
4189 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4191 return CMD_WARNING_CONFIG_FAILED
;
4192 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4194 PEER_FLAG_RSERVER_CLIENT
);
4197 ALIAS_HIDDEN(neighbor_route_server_client
,
4198 neighbor_route_server_client_hidden_cmd
,
4199 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4200 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4201 "Configure a neighbor as Route Server client\n")
4203 DEFUN (no_neighbor_route_server_client
,
4204 no_neighbor_route_server_client_cmd
,
4205 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4209 "Configure a neighbor as Route Server client\n")
4212 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4213 bgp_node_afi(vty
), bgp_node_safi(vty
),
4214 PEER_FLAG_RSERVER_CLIENT
);
4217 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4218 no_neighbor_route_server_client_hidden_cmd
,
4219 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4220 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4221 "Configure a neighbor as Route Server client\n")
4223 DEFUN (neighbor_nexthop_local_unchanged
,
4224 neighbor_nexthop_local_unchanged_cmd
,
4225 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4228 "Configure treatment of outgoing link-local nexthop attribute\n"
4229 "Leave link-local nexthop unchanged for this peer\n")
4232 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4234 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4237 DEFUN (no_neighbor_nexthop_local_unchanged
,
4238 no_neighbor_nexthop_local_unchanged_cmd
,
4239 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4243 "Configure treatment of outgoing link-local-nexthop attribute\n"
4244 "Leave link-local nexthop unchanged for this peer\n")
4247 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4248 bgp_node_afi(vty
), bgp_node_safi(vty
),
4249 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4252 DEFUN (neighbor_attr_unchanged
,
4253 neighbor_attr_unchanged_cmd
,
4254 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4257 "BGP attribute is propagated unchanged to this neighbor\n"
4258 "As-path attribute\n"
4259 "Nexthop attribute\n"
4263 char *peer_str
= argv
[1]->arg
;
4265 u_int16_t flags
= 0;
4266 afi_t afi
= bgp_node_afi(vty
);
4267 safi_t safi
= bgp_node_safi(vty
);
4269 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4271 return CMD_WARNING_CONFIG_FAILED
;
4273 if (argv_find(argv
, argc
, "as-path", &idx
))
4274 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4276 if (argv_find(argv
, argc
, "next-hop", &idx
))
4277 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4279 if (argv_find(argv
, argc
, "med", &idx
))
4280 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4282 /* no flags means all of them! */
4284 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4285 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4286 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4288 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
) &&
4289 peer_af_flag_check(peer
, afi
, safi
,
4290 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4291 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4292 PEER_FLAG_AS_PATH_UNCHANGED
);
4295 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
) &&
4296 peer_af_flag_check(peer
, afi
, safi
,
4297 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4298 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4299 PEER_FLAG_NEXTHOP_UNCHANGED
);
4302 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
) &&
4303 peer_af_flag_check(peer
, afi
, safi
,
4304 PEER_FLAG_MED_UNCHANGED
)) {
4305 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4306 PEER_FLAG_MED_UNCHANGED
);
4310 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4314 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4315 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4316 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4317 "BGP attribute is propagated unchanged to this neighbor\n"
4318 "As-path attribute\n"
4319 "Nexthop attribute\n"
4322 DEFUN (no_neighbor_attr_unchanged
,
4323 no_neighbor_attr_unchanged_cmd
,
4324 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4328 "BGP attribute is propagated unchanged to this neighbor\n"
4329 "As-path attribute\n"
4330 "Nexthop attribute\n"
4334 char *peer
= argv
[2]->arg
;
4335 u_int16_t flags
= 0;
4337 if (argv_find(argv
, argc
, "as-path", &idx
))
4338 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4340 if (argv_find(argv
, argc
, "next-hop", &idx
))
4341 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4343 if (argv_find(argv
, argc
, "med", &idx
))
4344 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4346 if (!flags
) // no flags means all of them!
4348 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4349 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4350 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4353 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4354 bgp_node_safi(vty
), flags
);
4358 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4359 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4360 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4361 "BGP attribute is propagated unchanged to this neighbor\n"
4362 "As-path attribute\n"
4363 "Nexthop attribute\n"
4366 /* EBGP multihop configuration. */
4367 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4368 const char *ttl_str
)
4373 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4375 return CMD_WARNING_CONFIG_FAILED
;
4378 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4383 ttl
= strtoul(ttl_str
, NULL
, 10);
4385 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4388 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4392 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4394 return CMD_WARNING_CONFIG_FAILED
;
4396 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4399 /* neighbor ebgp-multihop. */
4400 DEFUN (neighbor_ebgp_multihop
,
4401 neighbor_ebgp_multihop_cmd
,
4402 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4405 "Allow EBGP neighbors not on directly connected networks\n")
4408 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4411 DEFUN (neighbor_ebgp_multihop_ttl
,
4412 neighbor_ebgp_multihop_ttl_cmd
,
4413 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4416 "Allow EBGP neighbors not on directly connected networks\n"
4417 "maximum hop count\n")
4421 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4422 argv
[idx_number
]->arg
);
4425 DEFUN (no_neighbor_ebgp_multihop
,
4426 no_neighbor_ebgp_multihop_cmd
,
4427 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4431 "Allow EBGP neighbors not on directly connected networks\n"
4432 "maximum hop count\n")
4435 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4439 /* disable-connected-check */
4440 DEFUN (neighbor_disable_connected_check
,
4441 neighbor_disable_connected_check_cmd
,
4442 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4445 "one-hop away EBGP peer using loopback address\n"
4446 "Enforce EBGP neighbors perform multihop\n")
4449 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4450 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4453 DEFUN (no_neighbor_disable_connected_check
,
4454 no_neighbor_disable_connected_check_cmd
,
4455 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4459 "one-hop away EBGP peer using loopback address\n"
4460 "Enforce EBGP neighbors perform multihop\n")
4463 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4464 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4467 DEFUN (neighbor_description
,
4468 neighbor_description_cmd
,
4469 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4472 "Neighbor specific description\n"
4473 "Up to 80 characters describing this neighbor\n")
4480 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4482 return CMD_WARNING_CONFIG_FAILED
;
4484 str
= argv_concat(argv
, argc
, idx_line
);
4486 peer_description_set(peer
, str
);
4488 XFREE(MTYPE_TMP
, str
);
4493 DEFUN (no_neighbor_description
,
4494 no_neighbor_description_cmd
,
4495 "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]",
4499 "Neighbor specific description\n"
4500 "Up to 80 characters describing this neighbor\n")
4505 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4507 return CMD_WARNING_CONFIG_FAILED
;
4509 peer_description_unset(peer
);
4515 /* Neighbor update-source. */
4516 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4517 const char *source_str
)
4522 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4524 return CMD_WARNING_CONFIG_FAILED
;
4531 int ret
= str2sockunion(source_str
, &su
);
4534 peer_update_source_addr_set(peer
, &su
);
4536 if (str2prefix(source_str
, &p
)) {
4538 "%% Invalid update-source, remove prefix length \n");
4539 return CMD_WARNING_CONFIG_FAILED
;
4541 peer_update_source_if_set(peer
, source_str
);
4544 peer_update_source_unset(peer
);
4549 #define BGP_UPDATE_SOURCE_HELP_STR \
4552 "Interface name (requires zebra to be running)\n"
4554 DEFUN (neighbor_update_source
,
4555 neighbor_update_source_cmd
,
4556 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4559 "Source of routing updates\n"
4560 BGP_UPDATE_SOURCE_HELP_STR
)
4564 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4565 argv
[idx_peer_2
]->arg
);
4568 DEFUN (no_neighbor_update_source
,
4569 no_neighbor_update_source_cmd
,
4570 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4574 "Source of routing updates\n"
4575 BGP_UPDATE_SOURCE_HELP_STR
)
4578 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4581 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4582 afi_t afi
, safi_t safi
,
4583 const char *rmap
, int set
)
4588 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4590 return CMD_WARNING_CONFIG_FAILED
;
4593 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4595 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4597 return bgp_vty_return(vty
, ret
);
4600 /* neighbor default-originate. */
4601 DEFUN (neighbor_default_originate
,
4602 neighbor_default_originate_cmd
,
4603 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4606 "Originate default route to this neighbor\n")
4609 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4611 bgp_node_safi(vty
), NULL
, 1);
4614 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4615 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4616 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4617 "Originate default route to this neighbor\n")
4619 DEFUN (neighbor_default_originate_rmap
,
4620 neighbor_default_originate_rmap_cmd
,
4621 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4624 "Originate default route to this neighbor\n"
4625 "Route-map to specify criteria to originate default\n"
4630 return peer_default_originate_set_vty(
4631 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4632 argv
[idx_word
]->arg
, 1);
4636 neighbor_default_originate_rmap
,
4637 neighbor_default_originate_rmap_hidden_cmd
,
4638 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4639 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4640 "Originate default route to this neighbor\n"
4641 "Route-map to specify criteria to originate default\n"
4644 DEFUN (no_neighbor_default_originate
,
4645 no_neighbor_default_originate_cmd
,
4646 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4650 "Originate default route to this neighbor\n"
4651 "Route-map to specify criteria to originate default\n"
4655 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4657 bgp_node_safi(vty
), NULL
, 0);
4661 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4662 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4663 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4664 "Originate default route to this neighbor\n"
4665 "Route-map to specify criteria to originate default\n"
4669 /* Set neighbor's BGP port. */
4670 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4671 const char *port_str
)
4677 peer
= peer_lookup_vty(vty
, ip_str
);
4679 return CMD_WARNING_CONFIG_FAILED
;
4682 sp
= getservbyname("bgp", "tcp");
4683 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4685 port
= strtoul(port_str
, NULL
, 10);
4688 peer_port_set(peer
, port
);
4693 /* Set specified peer's BGP port. */
4694 DEFUN (neighbor_port
,
4696 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4699 "Neighbor's BGP port\n"
4700 "TCP port number\n")
4704 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4705 argv
[idx_number
]->arg
);
4708 DEFUN (no_neighbor_port
,
4709 no_neighbor_port_cmd
,
4710 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4714 "Neighbor's BGP port\n"
4715 "TCP port number\n")
4718 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4722 /* neighbor weight. */
4723 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4724 safi_t safi
, const char *weight_str
)
4728 unsigned long weight
;
4730 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4732 return CMD_WARNING_CONFIG_FAILED
;
4734 weight
= strtoul(weight_str
, NULL
, 10);
4736 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4737 return bgp_vty_return(vty
, ret
);
4740 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4746 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4748 return CMD_WARNING_CONFIG_FAILED
;
4750 ret
= peer_weight_unset(peer
, afi
, safi
);
4751 return bgp_vty_return(vty
, ret
);
4754 DEFUN (neighbor_weight
,
4755 neighbor_weight_cmd
,
4756 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4759 "Set default weight for routes from this neighbor\n"
4764 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4765 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4768 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4769 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4770 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4771 "Set default weight for routes from this neighbor\n"
4774 DEFUN (no_neighbor_weight
,
4775 no_neighbor_weight_cmd
,
4776 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4780 "Set default weight for routes from this neighbor\n"
4784 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4785 bgp_node_afi(vty
), bgp_node_safi(vty
));
4788 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4789 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4790 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4791 "Set default weight for routes from this neighbor\n"
4795 /* Override capability negotiation. */
4796 DEFUN (neighbor_override_capability
,
4797 neighbor_override_capability_cmd
,
4798 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4801 "Override capability negotiation result\n")
4804 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4805 PEER_FLAG_OVERRIDE_CAPABILITY
);
4808 DEFUN (no_neighbor_override_capability
,
4809 no_neighbor_override_capability_cmd
,
4810 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4814 "Override capability negotiation result\n")
4817 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4818 PEER_FLAG_OVERRIDE_CAPABILITY
);
4821 DEFUN (neighbor_strict_capability
,
4822 neighbor_strict_capability_cmd
,
4823 "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4826 "Strict capability negotiation match\n")
4829 return peer_flag_set_vty(vty
, argv
[idx_ip
]->arg
,
4830 PEER_FLAG_STRICT_CAP_MATCH
);
4833 DEFUN (no_neighbor_strict_capability
,
4834 no_neighbor_strict_capability_cmd
,
4835 "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4839 "Strict capability negotiation match\n")
4842 return peer_flag_unset_vty(vty
, argv
[idx_ip
]->arg
,
4843 PEER_FLAG_STRICT_CAP_MATCH
);
4846 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
4847 const char *keep_str
, const char *hold_str
)
4851 u_int32_t keepalive
;
4854 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4856 return CMD_WARNING_CONFIG_FAILED
;
4858 keepalive
= strtoul(keep_str
, NULL
, 10);
4859 holdtime
= strtoul(hold_str
, NULL
, 10);
4861 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
4863 return bgp_vty_return(vty
, ret
);
4866 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
4871 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4873 return CMD_WARNING_CONFIG_FAILED
;
4875 ret
= peer_timers_unset(peer
);
4877 return bgp_vty_return(vty
, ret
);
4880 DEFUN (neighbor_timers
,
4881 neighbor_timers_cmd
,
4882 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
4885 "BGP per neighbor timers\n"
4886 "Keepalive interval\n"
4891 int idx_number_2
= 4;
4892 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
4893 argv
[idx_number
]->arg
,
4894 argv
[idx_number_2
]->arg
);
4897 DEFUN (no_neighbor_timers
,
4898 no_neighbor_timers_cmd
,
4899 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
4903 "BGP per neighbor timers\n"
4904 "Keepalive interval\n"
4908 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
4912 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
4913 const char *time_str
)
4919 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4921 return CMD_WARNING_CONFIG_FAILED
;
4923 connect
= strtoul(time_str
, NULL
, 10);
4925 ret
= peer_timers_connect_set(peer
, connect
);
4927 return bgp_vty_return(vty
, ret
);
4930 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
4935 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4937 return CMD_WARNING_CONFIG_FAILED
;
4939 ret
= peer_timers_connect_unset(peer
);
4941 return bgp_vty_return(vty
, ret
);
4944 DEFUN (neighbor_timers_connect
,
4945 neighbor_timers_connect_cmd
,
4946 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
4949 "BGP per neighbor timers\n"
4950 "BGP connect timer\n"
4955 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
4956 argv
[idx_number
]->arg
);
4959 DEFUN (no_neighbor_timers_connect
,
4960 no_neighbor_timers_connect_cmd
,
4961 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
4965 "BGP per neighbor timers\n"
4966 "BGP connect timer\n"
4970 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
4974 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
4975 const char *time_str
, int set
)
4979 u_int32_t routeadv
= 0;
4981 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4983 return CMD_WARNING_CONFIG_FAILED
;
4986 routeadv
= strtoul(time_str
, NULL
, 10);
4989 ret
= peer_advertise_interval_set(peer
, routeadv
);
4991 ret
= peer_advertise_interval_unset(peer
);
4993 return bgp_vty_return(vty
, ret
);
4996 DEFUN (neighbor_advertise_interval
,
4997 neighbor_advertise_interval_cmd
,
4998 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5001 "Minimum interval between sending BGP routing updates\n"
5002 "time in seconds\n")
5006 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5007 argv
[idx_number
]->arg
, 1);
5010 DEFUN (no_neighbor_advertise_interval
,
5011 no_neighbor_advertise_interval_cmd
,
5012 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5016 "Minimum interval between sending BGP routing updates\n"
5017 "time in seconds\n")
5020 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5024 /* Time to wait before processing route-map updates */
5025 DEFUN (bgp_set_route_map_delay_timer
,
5026 bgp_set_route_map_delay_timer_cmd
,
5027 "bgp route-map delay-timer (0-600)",
5029 "BGP route-map delay timer\n"
5030 "Time in secs to wait before processing route-map changes\n"
5031 "0 disables the timer, no route updates happen when route-maps change\n")
5034 u_int32_t rmap_delay_timer
;
5036 if (argv
[idx_number
]->arg
) {
5037 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5038 bm
->rmap_update_timer
= rmap_delay_timer
;
5040 /* if the dynamic update handling is being disabled, and a timer
5042 * running, stop the timer and act as if the timer has already
5045 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5046 BGP_TIMER_OFF(bm
->t_rmap_update
);
5047 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5052 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5053 return CMD_WARNING_CONFIG_FAILED
;
5057 DEFUN (no_bgp_set_route_map_delay_timer
,
5058 no_bgp_set_route_map_delay_timer_cmd
,
5059 "no bgp route-map delay-timer [(0-600)]",
5062 "Default BGP route-map delay timer\n"
5063 "Reset to default time to wait for processing route-map changes\n"
5064 "0 disables the timer, no route updates happen when route-maps change\n")
5067 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5073 /* neighbor interface */
5074 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5079 peer
= peer_lookup_vty(vty
, ip_str
);
5080 if (!peer
|| peer
->conf_if
) {
5081 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5082 return CMD_WARNING_CONFIG_FAILED
;
5086 peer_interface_set(peer
, str
);
5088 peer_interface_unset(peer
);
5093 DEFUN (neighbor_interface
,
5094 neighbor_interface_cmd
,
5095 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5103 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5106 DEFUN (no_neighbor_interface
,
5107 no_neighbor_interface_cmd
,
5108 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5116 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5119 DEFUN (neighbor_distribute_list
,
5120 neighbor_distribute_list_cmd
,
5121 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5124 "Filter updates to/from this neighbor\n"
5125 "IP access-list number\n"
5126 "IP access-list number (expanded range)\n"
5127 "IP Access-list name\n"
5128 "Filter incoming updates\n"
5129 "Filter outgoing updates\n")
5136 const char *pstr
= argv
[idx_peer
]->arg
;
5137 const char *acl
= argv
[idx_acl
]->arg
;
5138 const char *inout
= argv
[argc
- 1]->text
;
5140 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5142 return CMD_WARNING_CONFIG_FAILED
;
5144 /* Check filter direction. */
5145 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5146 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5149 return bgp_vty_return(vty
, ret
);
5153 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5154 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5155 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5156 "Filter updates to/from this neighbor\n"
5157 "IP access-list number\n"
5158 "IP access-list number (expanded range)\n"
5159 "IP Access-list name\n"
5160 "Filter incoming updates\n"
5161 "Filter outgoing updates\n")
5163 DEFUN (no_neighbor_distribute_list
,
5164 no_neighbor_distribute_list_cmd
,
5165 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5169 "Filter updates to/from this neighbor\n"
5170 "IP access-list number\n"
5171 "IP access-list number (expanded range)\n"
5172 "IP Access-list name\n"
5173 "Filter incoming updates\n"
5174 "Filter outgoing updates\n")
5180 const char *pstr
= argv
[idx_peer
]->arg
;
5181 const char *inout
= argv
[argc
- 1]->text
;
5183 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5185 return CMD_WARNING_CONFIG_FAILED
;
5187 /* Check filter direction. */
5188 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5189 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5192 return bgp_vty_return(vty
, ret
);
5196 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5197 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5198 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5199 "Filter updates to/from this neighbor\n"
5200 "IP access-list number\n"
5201 "IP access-list number (expanded range)\n"
5202 "IP Access-list name\n"
5203 "Filter incoming updates\n"
5204 "Filter outgoing updates\n")
5206 /* Set prefix list to the peer. */
5207 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5208 afi_t afi
, safi_t safi
,
5209 const char *name_str
,
5210 const char *direct_str
)
5214 int direct
= FILTER_IN
;
5216 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5218 return CMD_WARNING_CONFIG_FAILED
;
5220 /* Check filter direction. */
5221 if (strncmp(direct_str
, "i", 1) == 0)
5223 else if (strncmp(direct_str
, "o", 1) == 0)
5224 direct
= FILTER_OUT
;
5226 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5228 return bgp_vty_return(vty
, ret
);
5231 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5232 afi_t afi
, safi_t safi
,
5233 const char *direct_str
)
5237 int direct
= FILTER_IN
;
5239 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5241 return CMD_WARNING_CONFIG_FAILED
;
5243 /* Check filter direction. */
5244 if (strncmp(direct_str
, "i", 1) == 0)
5246 else if (strncmp(direct_str
, "o", 1) == 0)
5247 direct
= FILTER_OUT
;
5249 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5251 return bgp_vty_return(vty
, ret
);
5254 DEFUN (neighbor_prefix_list
,
5255 neighbor_prefix_list_cmd
,
5256 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5259 "Filter updates to/from this neighbor\n"
5260 "Name of a prefix list\n"
5261 "Filter incoming updates\n"
5262 "Filter outgoing updates\n")
5267 return peer_prefix_list_set_vty(
5268 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5269 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5272 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5273 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5274 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5275 "Filter updates to/from this neighbor\n"
5276 "Name of a prefix list\n"
5277 "Filter incoming updates\n"
5278 "Filter outgoing updates\n")
5280 DEFUN (no_neighbor_prefix_list
,
5281 no_neighbor_prefix_list_cmd
,
5282 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5286 "Filter updates to/from this neighbor\n"
5287 "Name of a prefix list\n"
5288 "Filter incoming updates\n"
5289 "Filter outgoing updates\n")
5293 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5294 bgp_node_afi(vty
), bgp_node_safi(vty
),
5295 argv
[idx_in_out
]->arg
);
5298 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5299 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5300 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5301 "Filter updates to/from this neighbor\n"
5302 "Name of a prefix list\n"
5303 "Filter incoming updates\n"
5304 "Filter outgoing updates\n")
5306 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5307 safi_t safi
, const char *name_str
,
5308 const char *direct_str
)
5312 int direct
= FILTER_IN
;
5314 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5316 return CMD_WARNING_CONFIG_FAILED
;
5318 /* Check filter direction. */
5319 if (strncmp(direct_str
, "i", 1) == 0)
5321 else if (strncmp(direct_str
, "o", 1) == 0)
5322 direct
= FILTER_OUT
;
5324 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5326 return bgp_vty_return(vty
, ret
);
5329 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5330 safi_t safi
, const char *direct_str
)
5334 int direct
= FILTER_IN
;
5336 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5338 return CMD_WARNING_CONFIG_FAILED
;
5340 /* Check filter direction. */
5341 if (strncmp(direct_str
, "i", 1) == 0)
5343 else if (strncmp(direct_str
, "o", 1) == 0)
5344 direct
= FILTER_OUT
;
5346 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5348 return bgp_vty_return(vty
, ret
);
5351 DEFUN (neighbor_filter_list
,
5352 neighbor_filter_list_cmd
,
5353 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5356 "Establish BGP filters\n"
5357 "AS path access-list name\n"
5358 "Filter incoming routes\n"
5359 "Filter outgoing routes\n")
5364 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5365 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5366 argv
[idx_in_out
]->arg
);
5369 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5370 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5371 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5372 "Establish BGP filters\n"
5373 "AS path access-list name\n"
5374 "Filter incoming routes\n"
5375 "Filter outgoing routes\n")
5377 DEFUN (no_neighbor_filter_list
,
5378 no_neighbor_filter_list_cmd
,
5379 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5383 "Establish BGP filters\n"
5384 "AS path access-list name\n"
5385 "Filter incoming routes\n"
5386 "Filter outgoing routes\n")
5390 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5391 bgp_node_afi(vty
), bgp_node_safi(vty
),
5392 argv
[idx_in_out
]->arg
);
5395 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5396 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5397 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5398 "Establish BGP filters\n"
5399 "AS path access-list name\n"
5400 "Filter incoming routes\n"
5401 "Filter outgoing routes\n")
5403 /* Set route-map to the peer. */
5404 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5405 afi_t afi
, safi_t safi
, const char *name_str
,
5406 const char *direct_str
)
5410 int direct
= RMAP_IN
;
5412 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5414 return CMD_WARNING_CONFIG_FAILED
;
5416 /* Check filter direction. */
5417 if (strncmp(direct_str
, "in", 2) == 0)
5419 else if (strncmp(direct_str
, "o", 1) == 0)
5422 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5424 return bgp_vty_return(vty
, ret
);
5427 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5428 afi_t afi
, safi_t safi
,
5429 const char *direct_str
)
5433 int direct
= RMAP_IN
;
5435 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5437 return CMD_WARNING_CONFIG_FAILED
;
5439 /* Check filter direction. */
5440 if (strncmp(direct_str
, "in", 2) == 0)
5442 else if (strncmp(direct_str
, "o", 1) == 0)
5445 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5447 return bgp_vty_return(vty
, ret
);
5450 DEFUN (neighbor_route_map
,
5451 neighbor_route_map_cmd
,
5452 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5455 "Apply route map to neighbor\n"
5456 "Name of route map\n"
5457 "Apply map to incoming routes\n"
5458 "Apply map to outbound routes\n")
5463 return peer_route_map_set_vty(
5464 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5465 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5468 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5469 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5470 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5471 "Apply route map to neighbor\n"
5472 "Name of route map\n"
5473 "Apply map to incoming routes\n"
5474 "Apply map to outbound routes\n")
5476 DEFUN (no_neighbor_route_map
,
5477 no_neighbor_route_map_cmd
,
5478 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5482 "Apply route map to neighbor\n"
5483 "Name of route map\n"
5484 "Apply map to incoming routes\n"
5485 "Apply map to outbound routes\n")
5489 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5490 bgp_node_afi(vty
), bgp_node_safi(vty
),
5491 argv
[idx_in_out
]->arg
);
5494 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5495 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5496 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5497 "Apply route map to neighbor\n"
5498 "Name of route map\n"
5499 "Apply map to incoming routes\n"
5500 "Apply map to outbound routes\n")
5502 /* Set unsuppress-map to the peer. */
5503 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5504 afi_t afi
, safi_t safi
,
5505 const char *name_str
)
5510 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5512 return CMD_WARNING_CONFIG_FAILED
;
5514 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5516 return bgp_vty_return(vty
, ret
);
5519 /* Unset route-map from the peer. */
5520 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5521 afi_t afi
, safi_t safi
)
5526 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5528 return CMD_WARNING_CONFIG_FAILED
;
5530 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5532 return bgp_vty_return(vty
, ret
);
5535 DEFUN (neighbor_unsuppress_map
,
5536 neighbor_unsuppress_map_cmd
,
5537 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5540 "Route-map to selectively unsuppress suppressed routes\n"
5541 "Name of route map\n")
5545 return peer_unsuppress_map_set_vty(
5546 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5547 argv
[idx_word
]->arg
);
5550 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5551 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5552 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5553 "Route-map to selectively unsuppress suppressed routes\n"
5554 "Name of route map\n")
5556 DEFUN (no_neighbor_unsuppress_map
,
5557 no_neighbor_unsuppress_map_cmd
,
5558 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5562 "Route-map to selectively unsuppress suppressed routes\n"
5563 "Name of route map\n")
5566 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5568 bgp_node_safi(vty
));
5571 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5572 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5573 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5574 "Route-map to selectively unsuppress suppressed routes\n"
5575 "Name of route map\n")
5577 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5578 afi_t afi
, safi_t safi
,
5579 const char *num_str
,
5580 const char *threshold_str
, int warning
,
5581 const char *restart_str
)
5589 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5591 return CMD_WARNING_CONFIG_FAILED
;
5593 max
= strtoul(num_str
, NULL
, 10);
5595 threshold
= atoi(threshold_str
);
5597 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5600 restart
= atoi(restart_str
);
5604 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5607 return bgp_vty_return(vty
, ret
);
5610 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5611 afi_t afi
, safi_t safi
)
5616 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5618 return CMD_WARNING_CONFIG_FAILED
;
5620 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5622 return bgp_vty_return(vty
, ret
);
5625 /* Maximum number of prefix configuration. prefix count is different
5626 for each peer configuration. So this configuration can be set for
5627 each peer configuration. */
5628 DEFUN (neighbor_maximum_prefix
,
5629 neighbor_maximum_prefix_cmd
,
5630 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5633 "Maximum number of prefix accept from this peer\n"
5634 "maximum no. of prefix limit\n")
5638 return peer_maximum_prefix_set_vty(
5639 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5640 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5643 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5644 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5645 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5646 "Maximum number of prefix accept from this peer\n"
5647 "maximum no. of prefix limit\n")
5649 DEFUN (neighbor_maximum_prefix_threshold
,
5650 neighbor_maximum_prefix_threshold_cmd
,
5651 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
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")
5660 int idx_number_2
= 4;
5661 return peer_maximum_prefix_set_vty(
5662 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5663 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5667 neighbor_maximum_prefix_threshold
,
5668 neighbor_maximum_prefix_threshold_hidden_cmd
,
5669 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5670 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5671 "Maximum number of prefix accept from this peer\n"
5672 "maximum no. of prefix limit\n"
5673 "Threshold value (%) at which to generate a warning msg\n")
5675 DEFUN (neighbor_maximum_prefix_warning
,
5676 neighbor_maximum_prefix_warning_cmd
,
5677 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5680 "Maximum number of prefix accept from this peer\n"
5681 "maximum no. of prefix limit\n"
5682 "Only give warning message when limit is exceeded\n")
5686 return peer_maximum_prefix_set_vty(
5687 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5688 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5692 neighbor_maximum_prefix_warning
,
5693 neighbor_maximum_prefix_warning_hidden_cmd
,
5694 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5695 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5696 "Maximum number of prefix accept from this peer\n"
5697 "maximum no. of prefix limit\n"
5698 "Only give warning message when limit is exceeded\n")
5700 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5701 neighbor_maximum_prefix_threshold_warning_cmd
,
5702 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5705 "Maximum number of prefix accept from this peer\n"
5706 "maximum no. of prefix limit\n"
5707 "Threshold value (%) at which to generate a warning msg\n"
5708 "Only give warning message when limit is exceeded\n")
5712 int idx_number_2
= 4;
5713 return peer_maximum_prefix_set_vty(
5714 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5715 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5719 neighbor_maximum_prefix_threshold_warning
,
5720 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5721 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5722 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5723 "Maximum number of prefix accept from this peer\n"
5724 "maximum no. of prefix limit\n"
5725 "Threshold value (%) at which to generate a warning msg\n"
5726 "Only give warning message when limit is exceeded\n")
5728 DEFUN (neighbor_maximum_prefix_restart
,
5729 neighbor_maximum_prefix_restart_cmd
,
5730 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5733 "Maximum number of prefix accept from this peer\n"
5734 "maximum no. of prefix limit\n"
5735 "Restart bgp connection after limit is exceeded\n"
5736 "Restart interval in minutes")
5740 int idx_number_2
= 5;
5741 return peer_maximum_prefix_set_vty(
5742 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5743 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5747 neighbor_maximum_prefix_restart
,
5748 neighbor_maximum_prefix_restart_hidden_cmd
,
5749 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5750 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5751 "Maximum number of prefix accept from this peer\n"
5752 "maximum no. of prefix limit\n"
5753 "Restart bgp connection after limit is exceeded\n"
5754 "Restart interval in minutes")
5756 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5757 neighbor_maximum_prefix_threshold_restart_cmd
,
5758 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5761 "Maximum number of prefixes to accept from this peer\n"
5762 "maximum no. of prefix limit\n"
5763 "Threshold value (%) at which to generate a warning msg\n"
5764 "Restart bgp connection after limit is exceeded\n"
5765 "Restart interval in minutes\n")
5769 int idx_number_2
= 4;
5770 int idx_number_3
= 6;
5771 return peer_maximum_prefix_set_vty(
5772 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5773 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5774 argv
[idx_number_3
]->arg
);
5778 neighbor_maximum_prefix_threshold_restart
,
5779 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5780 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5781 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5782 "Maximum number of prefixes to accept from this peer\n"
5783 "maximum no. of prefix limit\n"
5784 "Threshold value (%) at which to generate a warning msg\n"
5785 "Restart bgp connection after limit is exceeded\n"
5786 "Restart interval in minutes\n")
5788 DEFUN (no_neighbor_maximum_prefix
,
5789 no_neighbor_maximum_prefix_cmd
,
5790 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5794 "Maximum number of prefixes to accept from this peer\n"
5795 "maximum no. of prefix limit\n"
5796 "Threshold value (%) at which to generate a warning msg\n"
5797 "Restart bgp connection after limit is exceeded\n"
5798 "Restart interval in minutes\n"
5799 "Only give warning message when limit is exceeded\n")
5802 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5804 bgp_node_safi(vty
));
5808 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5809 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5810 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5811 "Maximum number of prefixes to accept from this peer\n"
5812 "maximum no. of prefix limit\n"
5813 "Threshold value (%) at which to generate a warning msg\n"
5814 "Restart bgp connection after limit is exceeded\n"
5815 "Restart interval in minutes\n"
5816 "Only give warning message when limit is exceeded\n")
5819 /* "neighbor allowas-in" */
5820 DEFUN (neighbor_allowas_in
,
5821 neighbor_allowas_in_cmd
,
5822 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5825 "Accept as-path with my AS present in it\n"
5826 "Number of occurances of AS number\n"
5827 "Only accept my AS in the as-path if the route was originated in my AS\n")
5830 int idx_number_origin
= 3;
5836 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5838 return CMD_WARNING_CONFIG_FAILED
;
5840 if (argc
<= idx_number_origin
)
5843 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
5846 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
5849 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5852 return bgp_vty_return(vty
, ret
);
5856 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
5857 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5858 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5859 "Accept as-path with my AS present in it\n"
5860 "Number of occurances of AS number\n"
5861 "Only accept my AS in the as-path if the route was originated in my AS\n")
5863 DEFUN (no_neighbor_allowas_in
,
5864 no_neighbor_allowas_in_cmd
,
5865 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5869 "allow local ASN appears in aspath attribute\n"
5870 "Number of occurances of AS number\n"
5871 "Only accept my AS in the as-path if the route was originated in my AS\n")
5877 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5879 return CMD_WARNING_CONFIG_FAILED
;
5881 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
5882 bgp_node_safi(vty
));
5884 return bgp_vty_return(vty
, ret
);
5888 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
5889 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5890 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5891 "allow local ASN appears in aspath attribute\n"
5892 "Number of occurances of AS number\n"
5893 "Only accept my AS in the as-path if the route was originated in my AS\n")
5895 DEFUN (neighbor_ttl_security
,
5896 neighbor_ttl_security_cmd
,
5897 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
5900 "BGP ttl-security parameters\n"
5901 "Specify the maximum number of hops to the BGP peer\n"
5902 "Number of hops to BGP peer\n")
5909 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5911 return CMD_WARNING_CONFIG_FAILED
;
5913 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5916 * If 'neighbor swpX', then this is for directly connected peers,
5917 * we should not accept a ttl-security hops value greater than 1.
5919 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
5921 "%s is directly connected peer, hops cannot exceed 1\n",
5922 argv
[idx_peer
]->arg
);
5923 return CMD_WARNING_CONFIG_FAILED
;
5926 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
5929 DEFUN (no_neighbor_ttl_security
,
5930 no_neighbor_ttl_security_cmd
,
5931 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
5935 "BGP ttl-security parameters\n"
5936 "Specify the maximum number of hops to the BGP peer\n"
5937 "Number of hops to BGP peer\n")
5942 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5944 return CMD_WARNING_CONFIG_FAILED
;
5946 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
5949 DEFUN (neighbor_addpath_tx_all_paths
,
5950 neighbor_addpath_tx_all_paths_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
5954 "Use addpath to advertise all paths to a neighbor\n")
5959 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5961 return CMD_WARNING_CONFIG_FAILED
;
5963 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5965 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
5968 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
5969 neighbor_addpath_tx_all_paths_hidden_cmd
,
5970 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
5971 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5972 "Use addpath to advertise all paths to a neighbor\n")
5974 DEFUN (no_neighbor_addpath_tx_all_paths
,
5975 no_neighbor_addpath_tx_all_paths_cmd
,
5976 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
5980 "Use addpath to advertise all paths to a neighbor\n")
5983 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5984 bgp_node_afi(vty
), bgp_node_safi(vty
),
5985 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
5988 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
5989 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
5990 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
5991 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5992 "Use addpath to advertise all paths to a neighbor\n")
5994 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
5995 neighbor_addpath_tx_bestpath_per_as_cmd
,
5996 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
5999 "Use addpath to advertise the bestpath per each neighboring AS\n")
6004 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6006 return CMD_WARNING_CONFIG_FAILED
;
6008 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6010 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6013 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6014 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6015 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6017 "Use addpath to advertise the bestpath per each neighboring AS\n")
6019 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6020 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6021 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6025 "Use addpath to advertise the bestpath per each neighboring AS\n")
6028 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6029 bgp_node_afi(vty
), bgp_node_safi(vty
),
6030 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6033 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6034 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6035 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6036 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6037 "Use addpath to advertise the bestpath per each neighboring AS\n")
6039 DEFUN_NOSH (address_family_ipv4_safi
,
6040 address_family_ipv4_safi_cmd
,
6041 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]",
6042 "Enter Address Family command mode\n"
6044 BGP_SAFI_WITH_LABEL_HELP_STR
)
6048 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6049 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6051 vty
->node
= BGP_IPV4_NODE
;
6056 DEFUN_NOSH (address_family_ipv6_safi
,
6057 address_family_ipv6_safi_cmd
,
6058 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]",
6059 "Enter Address Family command mode\n"
6061 BGP_SAFI_WITH_LABEL_HELP_STR
)
6064 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6065 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6067 vty
->node
= BGP_IPV6_NODE
;
6072 #ifdef KEEP_OLD_VPN_COMMANDS
6073 DEFUN_NOSH (address_family_vpnv4
,
6074 address_family_vpnv4_cmd
,
6075 "address-family vpnv4 [unicast]",
6076 "Enter Address Family command mode\n"
6078 "Address Family modifier\n")
6080 vty
->node
= BGP_VPNV4_NODE
;
6084 DEFUN_NOSH (address_family_vpnv6
,
6085 address_family_vpnv6_cmd
,
6086 "address-family vpnv6 [unicast]",
6087 "Enter Address Family command mode\n"
6089 "Address Family modifier\n")
6091 vty
->node
= BGP_VPNV6_NODE
;
6096 DEFUN_NOSH (address_family_evpn
,
6097 address_family_evpn_cmd
,
6098 "address-family l2vpn evpn",
6099 "Enter Address Family command mode\n"
6101 "Address Family modifier\n")
6103 vty
->node
= BGP_EVPN_NODE
;
6107 DEFUN_NOSH (exit_address_family
,
6108 exit_address_family_cmd
,
6109 "exit-address-family",
6110 "Exit from Address Family configuration mode\n")
6112 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
6113 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
6114 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
6115 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
6116 || vty
->node
== BGP_EVPN_NODE
)
6117 vty
->node
= BGP_NODE
;
6121 /* Recalculate bestpath and re-advertise a prefix */
6122 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
6123 const char *ip_str
, afi_t afi
, safi_t safi
,
6124 struct prefix_rd
*prd
)
6127 struct prefix match
;
6128 struct bgp_node
*rn
;
6129 struct bgp_node
*rm
;
6131 struct bgp_table
*table
;
6132 struct bgp_table
*rib
;
6134 /* BGP structure lookup. */
6136 bgp
= bgp_lookup_by_name(view_name
);
6138 vty_out(vty
, "%% Can't find BGP instance %s\n",
6143 bgp
= bgp_get_default();
6145 vty_out(vty
, "%% No BGP process is configured\n");
6150 /* Check IP address argument. */
6151 ret
= str2prefix(ip_str
, &match
);
6153 vty_out(vty
, "%% address is malformed\n");
6157 match
.family
= afi2family(afi
);
6158 rib
= bgp
->rib
[afi
][safi
];
6160 if (safi
== SAFI_MPLS_VPN
) {
6161 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
6162 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
6165 if ((table
= rn
->info
) != NULL
) {
6166 if ((rm
= bgp_node_match(table
, &match
))
6169 == match
.prefixlen
) {
6171 BGP_NODE_USER_CLEAR
);
6172 bgp_process(bgp
, rm
, afi
, safi
);
6174 bgp_unlock_node(rm
);
6179 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
6180 if (rn
->p
.prefixlen
== match
.prefixlen
) {
6181 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
6182 bgp_process(bgp
, rn
, afi
, safi
);
6184 bgp_unlock_node(rn
);
6191 /* one clear bgp command to rule them all */
6192 DEFUN (clear_ip_bgp_all
,
6193 clear_ip_bgp_all_cmd
,
6194 "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>]",
6198 BGP_INSTANCE_HELP_STR
6200 BGP_SAFI_WITH_LABEL_HELP_STR
6202 "BGP neighbor address to clear\n"
6203 "BGP IPv6 neighbor to clear\n"
6204 "BGP neighbor on interface to clear\n"
6205 "Clear peers with the AS number\n"
6206 "Clear all external peers\n"
6207 "Clear all members of peer-group\n"
6208 "BGP peer-group name\n"
6213 "Push out prefix-list ORF and do inbound soft reconfig\n"
6218 afi_t afi
= AFI_IP6
;
6219 safi_t safi
= SAFI_UNICAST
;
6220 enum clear_sort clr_sort
= clear_peer
;
6221 enum bgp_clear_type clr_type
;
6222 char *clr_arg
= NULL
;
6226 /* clear [ip] bgp */
6227 if (argv_find(argv
, argc
, "ip", &idx
))
6230 /* [<view|vrf> VIEWVRFNAME] */
6231 if (argv_find(argv
, argc
, "view", &idx
)
6232 || argv_find(argv
, argc
, "vrf", &idx
)) {
6233 vrf
= argv
[idx
+ 1]->arg
;
6237 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
6238 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
6239 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
6241 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
6242 if (argv_find(argv
, argc
, "*", &idx
)) {
6243 clr_sort
= clear_all
;
6244 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
6245 clr_sort
= clear_peer
;
6246 clr_arg
= argv
[idx
]->arg
;
6247 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
6248 clr_sort
= clear_peer
;
6249 clr_arg
= argv
[idx
]->arg
;
6250 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
6251 clr_sort
= clear_group
;
6253 clr_arg
= argv
[idx
]->arg
;
6254 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
6255 clr_sort
= clear_peer
;
6256 clr_arg
= argv
[idx
]->arg
;
6257 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
6258 clr_sort
= clear_as
;
6259 clr_arg
= argv
[idx
]->arg
;
6260 } else if (argv_find(argv
, argc
, "external", &idx
)) {
6261 clr_sort
= clear_external
;
6264 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
6265 if (argv_find(argv
, argc
, "soft", &idx
)) {
6266 if (argv_find(argv
, argc
, "in", &idx
)
6267 || argv_find(argv
, argc
, "out", &idx
))
6268 clr_type
= strmatch(argv
[idx
]->text
, "in")
6270 : BGP_CLEAR_SOFT_OUT
;
6272 clr_type
= BGP_CLEAR_SOFT_BOTH
;
6273 } else if (argv_find(argv
, argc
, "in", &idx
)) {
6274 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
6275 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
6276 : BGP_CLEAR_SOFT_IN
;
6277 } else if (argv_find(argv
, argc
, "out", &idx
)) {
6278 clr_type
= BGP_CLEAR_SOFT_OUT
;
6280 clr_type
= BGP_CLEAR_SOFT_NONE
;
6282 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
6285 DEFUN (clear_ip_bgp_prefix
,
6286 clear_ip_bgp_prefix_cmd
,
6287 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
6291 BGP_INSTANCE_HELP_STR
6292 "Clear bestpath and re-advertise\n"
6296 char *prefix
= NULL
;
6300 /* [<view|vrf> VIEWVRFNAME] */
6301 if (argv_find(argv
, argc
, "WORD", &idx
))
6302 vrf
= argv
[idx
]->arg
;
6304 prefix
= argv
[argc
- 1]->arg
;
6306 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
6309 DEFUN (clear_bgp_ipv6_safi_prefix
,
6310 clear_bgp_ipv6_safi_prefix_cmd
,
6311 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
6317 "Clear bestpath and re-advertise\n"
6321 int idx_ipv6_prefixlen
= 5;
6322 return bgp_clear_prefix(
6323 vty
, NULL
, argv
[idx_ipv6_prefixlen
]->arg
, AFI_IP6
,
6324 bgp_vty_safi_from_str(argv
[idx_safi
]->text
), NULL
);
6327 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
6328 clear_bgp_instance_ipv6_safi_prefix_cmd
,
6329 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
6333 BGP_INSTANCE_HELP_STR
6336 "Clear bestpath and re-advertise\n"
6341 int idx_ipv6_prefixlen
= 7;
6342 return bgp_clear_prefix(
6343 vty
, argv
[idx_word
]->arg
, argv
[idx_ipv6_prefixlen
]->arg
,
6344 AFI_IP6
, bgp_vty_safi_from_str(argv
[idx_safi
]->text
), NULL
);
6347 DEFUN (show_bgp_views
,
6349 "show [ip] bgp views",
6353 "Show the defined BGP views\n")
6355 struct list
*inst
= bm
->bgp
;
6356 struct listnode
*node
;
6359 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
6360 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
6364 vty_out(vty
, "Defined BGP views:\n");
6365 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
6367 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
6369 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
6376 DEFUN (show_bgp_vrfs
,
6378 "show [ip] bgp vrfs [json]",
6385 struct list
*inst
= bm
->bgp
;
6386 struct listnode
*node
;
6388 u_char uj
= use_json(argc
, argv
);
6389 json_object
*json
= NULL
;
6390 json_object
*json_vrfs
= NULL
;
6392 static char header
[] =
6393 "Type Id RouterId #PeersCfg #PeersEstb Name";
6395 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
6396 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
6401 json
= json_object_new_object();
6402 json_vrfs
= json_object_new_object();
6405 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
6406 const char *name
, *type
;
6408 struct listnode
*node
, *nnode
;
6409 int peers_cfg
, peers_estb
;
6410 json_object
*json_vrf
= NULL
;
6414 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
6418 if (!uj
&& count
== 1)
6419 vty_out(vty
, "%s\n", header
);
6421 peers_cfg
= peers_estb
= 0;
6423 json_vrf
= json_object_new_object();
6426 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
6427 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
6430 if (peer
->status
== Established
)
6434 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
6442 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
) ? -1 : bgp
->vrf_id
;
6444 json_object_string_add(json_vrf
, "type", type
);
6445 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
6446 json_object_string_add(json_vrf
, "routerId",
6447 inet_ntoa(bgp
->router_id
));
6448 json_object_int_add(json_vrf
, "numConfiguredPeers",
6450 json_object_int_add(json_vrf
, "numEstablishedPeers",
6453 json_object_object_add(json_vrfs
, name
, json_vrf
);
6455 vty_out(vty
, "%4s %-5d %-16s %9u %10u %s\n", type
,
6456 vrf_id_ui
, inet_ntoa(bgp
->router_id
), peers_cfg
,
6461 json_object_object_add(json
, "vrfs", json_vrfs
);
6463 json_object_int_add(json
, "totalVrfs", count
);
6465 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
6466 json
, JSON_C_TO_STRING_PRETTY
));
6467 json_object_free(json
);
6471 "\nTotal number of VRFs (including default): %d\n",
6478 static void show_address_entry(struct hash_backet
*backet
, void *args
)
6480 struct vty
*vty
= (struct vty
*)args
;
6481 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
6483 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
6487 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
6489 struct vty
*vty
= (struct vty
*)args
;
6490 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
6492 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
6496 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
6498 vty_out(vty
, "self nexthop database:\n");
6499 hash_iterate(bgp
->address_hash
,
6500 (void (*)(struct hash_backet
*, void *))show_address_entry
,
6503 vty_out(vty
, "Tunnel-ip database:\n");
6504 hash_iterate(bgp
->tip_hash
,
6505 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
6509 DEFUN(show_bgp_martian_nexthop_db
,
6510 show_bgp_martian_nexthop_db_cmd
,
6511 "show bgp martian next-hop",
6514 "martian next-hops\n"
6515 "martian next-hop database\n")
6517 struct bgp
*bgp
= NULL
;
6519 bgp
= bgp_get_default();
6521 vty_out(vty
, "%% No BGP process is configured\n");
6524 bgp_show_martian_nexthops(vty
, bgp
);
6529 DEFUN (show_bgp_memory
,
6530 show_bgp_memory_cmd
,
6531 "show [ip] bgp memory",
6535 "Global BGP memory statistics\n")
6537 char memstrbuf
[MTYPE_MEMSTR_LEN
];
6538 unsigned long count
;
6540 /* RIB related usage stats */
6541 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
6542 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
6543 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6544 count
* sizeof(struct bgp_node
)));
6546 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
6547 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
6548 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6549 count
* sizeof(struct bgp_info
)));
6550 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
6551 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
6553 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6554 count
* sizeof(struct bgp_info_extra
)));
6556 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
6557 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
6558 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6559 count
* sizeof(struct bgp_static
)));
6561 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
6562 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
6563 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6564 count
* sizeof(struct bpacket
)));
6567 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
6568 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
6569 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6570 count
* sizeof(struct bgp_adj_in
)));
6571 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
6572 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
6573 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6574 count
* sizeof(struct bgp_adj_out
)));
6576 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
6577 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
6579 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6580 count
* sizeof(struct bgp_nexthop_cache
)));
6582 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
6583 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
6585 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6586 count
* sizeof(struct bgp_damp_info
)));
6589 count
= attr_count();
6590 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
6591 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6592 count
* sizeof(struct attr
)));
6594 if ((count
= attr_unknown_count()))
6595 vty_out(vty
, "%ld unknown attributes\n", count
);
6597 /* AS_PATH attributes */
6598 count
= aspath_count();
6599 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
6600 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6601 count
* sizeof(struct aspath
)));
6603 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
6604 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
6605 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6606 count
* sizeof(struct assegment
)));
6608 /* Other attributes */
6609 if ((count
= community_count()))
6610 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
6611 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6612 count
* sizeof(struct community
)));
6613 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
6614 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
6615 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6616 count
* sizeof(struct ecommunity
)));
6617 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
6619 "%ld BGP large-community entries, using %s of memory\n",
6620 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6621 count
* sizeof(struct lcommunity
)));
6623 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
6624 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
6625 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6626 count
* sizeof(struct cluster_list
)));
6628 /* Peer related usage */
6629 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
6630 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
6631 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6632 count
* sizeof(struct peer
)));
6634 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
6635 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
6636 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6637 count
* sizeof(struct peer_group
)));
6640 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
6641 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
6642 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6643 count
* sizeof(struct hash
)));
6644 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
6645 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
6646 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6647 count
* sizeof(struct hash_backet
)));
6648 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
6649 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
6650 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
6651 count
* sizeof(regex_t
)));
6655 /* Show BGP peer's summary information. */
6656 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
6657 u_char use_json
, json_object
*json
)
6660 struct listnode
*node
, *nnode
;
6661 unsigned int count
= 0, dn_count
= 0;
6662 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
6663 char neighbor_buf
[VTY_BUFSIZ
];
6664 int neighbor_col_default_width
= 16;
6666 int max_neighbor_width
= 0;
6668 json_object
*json_peer
= NULL
;
6669 json_object
*json_peers
= NULL
;
6671 /* labeled-unicast routes are installed in the unicast table so in order
6673 * display the correct PfxRcd value we must look at SAFI_UNICAST
6675 if (safi
== SAFI_LABELED_UNICAST
)
6676 pfx_rcd_safi
= SAFI_UNICAST
;
6678 pfx_rcd_safi
= safi
;
6682 json
= json_object_new_object();
6684 json_peers
= json_object_new_object();
6686 /* Loop over all neighbors that will be displayed to determine
6688 * characters are needed for the Neighbor column
6690 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
6691 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
6694 if (peer
->afc
[afi
][safi
]) {
6695 memset(dn_flag
, '\0', sizeof(dn_flag
));
6696 if (peer_dynamic_neighbor(peer
))
6700 && bgp_flag_check(bgp
,
6701 BGP_FLAG_SHOW_HOSTNAME
))
6702 sprintf(neighbor_buf
, "%s%s(%s) ",
6703 dn_flag
, peer
->hostname
,
6706 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
6709 len
= strlen(neighbor_buf
);
6711 if (len
> max_neighbor_width
)
6712 max_neighbor_width
= len
;
6716 /* Originally we displayed the Neighbor column as 16
6717 * characters wide so make that the default
6719 if (max_neighbor_width
< neighbor_col_default_width
)
6720 max_neighbor_width
= neighbor_col_default_width
;
6723 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
6724 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
6727 if (!peer
->afc
[afi
][safi
])
6732 char memstrbuf
[MTYPE_MEMSTR_LEN
];
6736 (bgp
->vrf_id
== VRF_UNKNOWN
) ? -1 : bgp
->vrf_id
;
6738 /* Usage summary and header */
6740 json_object_string_add(
6742 inet_ntoa(bgp
->router_id
));
6743 json_object_int_add(json
, "as", bgp
->as
);
6744 json_object_int_add(json
, "vrfId", vrf_id_ui
);
6745 json_object_string_add(
6748 == BGP_INSTANCE_TYPE_DEFAULT
)
6753 "BGP router identifier %s, local AS number %u vrf-id %d",
6754 inet_ntoa(bgp
->router_id
), bgp
->as
,
6759 if (bgp_update_delay_configured(bgp
)) {
6761 json_object_int_add(
6762 json
, "updateDelayLimit",
6763 bgp
->v_update_delay
);
6765 if (bgp
->v_update_delay
6766 != bgp
->v_establish_wait
)
6767 json_object_int_add(
6769 "updateDelayEstablishWait",
6770 bgp
->v_establish_wait
);
6772 if (bgp_update_delay_active(bgp
)) {
6773 json_object_string_add(
6775 "updateDelayFirstNeighbor",
6776 bgp
->update_delay_begin_time
);
6777 json_object_boolean_true_add(
6779 "updateDelayInProgress");
6781 if (bgp
->update_delay_over
) {
6782 json_object_string_add(
6784 "updateDelayFirstNeighbor",
6785 bgp
->update_delay_begin_time
);
6786 json_object_string_add(
6788 "updateDelayBestpathResumed",
6789 bgp
->update_delay_end_time
);
6790 json_object_string_add(
6792 "updateDelayZebraUpdateResume",
6793 bgp
->update_delay_zebra_resume_time
);
6794 json_object_string_add(
6796 "updateDelayPeerUpdateResume",
6797 bgp
->update_delay_peers_resume_time
);
6802 "Read-only mode update-delay limit: %d seconds\n",
6803 bgp
->v_update_delay
);
6804 if (bgp
->v_update_delay
6805 != bgp
->v_establish_wait
)
6807 " Establish wait: %d seconds\n",
6808 bgp
->v_establish_wait
);
6810 if (bgp_update_delay_active(bgp
)) {
6812 " First neighbor established: %s\n",
6813 bgp
->update_delay_begin_time
);
6815 " Delay in progress\n");
6817 if (bgp
->update_delay_over
) {
6819 " First neighbor established: %s\n",
6820 bgp
->update_delay_begin_time
);
6822 " Best-paths resumed: %s\n",
6823 bgp
->update_delay_end_time
);
6825 " zebra update resumed: %s\n",
6826 bgp
->update_delay_zebra_resume_time
);
6828 " peers update resumed: %s\n",
6829 bgp
->update_delay_peers_resume_time
);
6836 if (bgp_maxmed_onstartup_configured(bgp
)
6837 && bgp
->maxmed_active
)
6838 json_object_boolean_true_add(
6839 json
, "maxMedOnStartup");
6840 if (bgp
->v_maxmed_admin
)
6841 json_object_boolean_true_add(
6842 json
, "maxMedAdministrative");
6844 json_object_int_add(
6845 json
, "tableVersion",
6846 bgp_table_version(bgp
->rib
[afi
][safi
]));
6848 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
6849 json_object_int_add(json
, "ribCount", ents
);
6850 json_object_int_add(
6852 ents
* sizeof(struct bgp_node
));
6854 ents
= listcount(bgp
->peer
);
6855 json_object_int_add(json
, "peerCount", ents
);
6856 json_object_int_add(json
, "peerMemory",
6857 ents
* sizeof(struct peer
));
6859 if ((ents
= listcount(bgp
->group
))) {
6860 json_object_int_add(
6861 json
, "peerGroupCount", ents
);
6862 json_object_int_add(
6863 json
, "peerGroupMemory",
6864 ents
* sizeof(struct
6868 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
6869 BGP_CONFIG_DAMPENING
))
6870 json_object_boolean_true_add(
6871 json
, "dampeningEnabled");
6873 if (bgp_maxmed_onstartup_configured(bgp
)
6874 && bgp
->maxmed_active
)
6876 "Max-med on-startup active\n");
6877 if (bgp
->v_maxmed_admin
)
6879 "Max-med administrative active\n");
6881 vty_out(vty
, "BGP table version %" PRIu64
"\n",
6882 bgp_table_version(bgp
->rib
[afi
][safi
]));
6884 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
6886 "RIB entries %ld, using %s of memory\n",
6888 mtype_memstr(memstrbuf
,
6890 ents
* sizeof(struct
6893 /* Peer related usage */
6894 ents
= listcount(bgp
->peer
);
6895 vty_out(vty
, "Peers %ld, using %s of memory\n",
6898 memstrbuf
, sizeof(memstrbuf
),
6899 ents
* sizeof(struct peer
)));
6901 if ((ents
= listcount(bgp
->group
)))
6903 "Peer groups %ld, using %s of memory\n",
6908 ents
* sizeof(struct
6911 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
6912 BGP_CONFIG_DAMPENING
))
6913 vty_out(vty
, "Dampening enabled.\n");
6916 /* Subtract 8 here because 'Neighbor' is
6918 vty_out(vty
, "Neighbor");
6919 vty_out(vty
, "%*s", max_neighbor_width
- 8,
6922 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
6929 json_peer
= json_object_new_object();
6931 if (peer_dynamic_neighbor(peer
))
6932 json_object_boolean_true_add(json_peer
,
6936 json_object_string_add(json_peer
, "hostname",
6939 if (peer
->domainname
)
6940 json_object_string_add(json_peer
, "domainname",
6943 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
6944 json_object_int_add(json_peer
, "version", 4);
6945 json_object_int_add(json_peer
, "msgRcvd",
6946 peer
->open_in
+ peer
->update_in
6947 + peer
->keepalive_in
6950 + peer
->dynamic_cap_in
);
6951 json_object_int_add(json_peer
, "msgSent",
6952 peer
->open_out
+ peer
->update_out
6953 + peer
->keepalive_out
6956 + peer
->dynamic_cap_out
);
6958 json_object_int_add(json_peer
, "tableVersion",
6959 peer
->version
[afi
][safi
]);
6960 json_object_int_add(json_peer
, "outq",
6962 json_object_int_add(json_peer
, "inq", 0);
6963 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
6964 use_json
, json_peer
);
6965 json_object_int_add(json_peer
, "prefixReceivedCount",
6966 peer
->pcount
[afi
][pfx_rcd_safi
]);
6968 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
6969 json_object_string_add(json_peer
, "state",
6971 else if (CHECK_FLAG(peer
->sflags
,
6972 PEER_STATUS_PREFIX_OVERFLOW
))
6973 json_object_string_add(json_peer
, "state",
6976 json_object_string_add(
6978 lookup_msg(bgp_status_msg
, peer
->status
,
6982 json_object_string_add(json_peer
, "idType",
6984 else if (peer
->su
.sa
.sa_family
== AF_INET
)
6985 json_object_string_add(json_peer
, "idType",
6987 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
6988 json_object_string_add(json_peer
, "idType",
6991 json_object_object_add(json_peers
, peer
->host
,
6994 memset(dn_flag
, '\0', sizeof(dn_flag
));
6995 if (peer_dynamic_neighbor(peer
)) {
7001 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7002 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7003 peer
->hostname
, peer
->host
);
7005 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7007 /* pad the neighbor column with spaces */
7008 if (len
< max_neighbor_width
)
7009 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7012 vty_out(vty
, "4 %10u %7d %7d %8" PRIu64
" %4d %4zd %8s",
7014 peer
->open_in
+ peer
->update_in
7015 + peer
->keepalive_in
+ peer
->notify_in
7017 + peer
->dynamic_cap_in
,
7018 peer
->open_out
+ peer
->update_out
7019 + peer
->keepalive_out
+ peer
->notify_out
7021 + peer
->dynamic_cap_out
,
7022 peer
->version
[afi
][safi
], 0, peer
->obuf
->count
,
7023 peer_uptime(peer
->uptime
, timebuf
,
7024 BGP_UPTIME_LEN
, 0, NULL
));
7026 if (peer
->status
== Established
)
7027 vty_out(vty
, " %12ld",
7028 peer
->pcount
[afi
][pfx_rcd_safi
]);
7030 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7031 vty_out(vty
, " Idle (Admin)");
7032 else if (CHECK_FLAG(
7034 PEER_STATUS_PREFIX_OVERFLOW
))
7035 vty_out(vty
, " Idle (PfxCt)");
7037 vty_out(vty
, " %12s",
7038 lookup_msg(bgp_status_msg
,
7039 peer
->status
, NULL
));
7046 json_object_object_add(json
, "peers", json_peers
);
7048 json_object_int_add(json
, "totalPeers", count
);
7049 json_object_int_add(json
, "dynamicPeers", dn_count
);
7051 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7052 json
, JSON_C_TO_STRING_PRETTY
));
7053 json_object_free(json
);
7056 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
7060 "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n",
7061 afi_safi_print(afi
, safi
));
7063 vty_out(vty
, "No %s neighbor is configured\n",
7064 afi_safi_print(afi
, safi
));
7067 if (dn_count
&& !use_json
) {
7068 vty_out(vty
, "* - dynamic neighbor\n");
7069 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
7070 dn_count
, bgp
->dynamic_neighbors_limit
);
7077 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
7078 int safi
, u_char use_json
,
7082 int afi_wildcard
= (afi
== AFI_MAX
);
7083 int safi_wildcard
= (safi
== SAFI_MAX
);
7084 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
7085 bool json_output
= false;
7087 if (use_json
&& is_wildcard
)
7088 vty_out(vty
, "{\n");
7090 afi
= 1; /* AFI_IP */
7091 while (afi
< AFI_MAX
) {
7093 safi
= 1; /* SAFI_UNICAST */
7094 while (safi
< SAFI_MAX
) {
7095 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
7099 * So limit output to those afi/safi
7101 * actualy have something interesting in
7105 json
= json_object_new_object();
7108 vty_out(vty
, ",\n");
7112 vty_out(vty
, "\"%s\":",
7116 vty_out(vty
, "\n%s Summary:\n",
7121 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
7130 || afi
== AFI_L2VPN
) /* special case, not handled yet */
7134 if (use_json
&& is_wildcard
)
7135 vty_out(vty
, "}\n");
7136 else if (use_json
&& !json_output
)
7137 vty_out(vty
, "{}\n");
7140 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
7141 safi_t safi
, u_char use_json
)
7143 struct listnode
*node
, *nnode
;
7145 json_object
*json
= NULL
;
7149 vty_out(vty
, "{\n");
7151 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
7153 json
= json_object_new_object();
7156 vty_out(vty
, ",\n");
7160 vty_out(vty
, "\"%s\":",
7161 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7165 vty_out(vty
, "\nInstance %s:\n",
7166 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7170 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
7174 vty_out(vty
, "}\n");
7177 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
7178 safi_t safi
, u_char use_json
)
7183 if (strmatch(name
, "all")) {
7184 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
7188 bgp
= bgp_lookup_by_name(name
);
7192 vty_out(vty
, "{}\n");
7195 "%% No such BGP instance exist\n");
7199 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
7205 bgp
= bgp_get_default();
7208 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
7213 /* `show [ip] bgp summary' commands. */
7214 DEFUN (show_ip_bgp_summary
,
7215 show_ip_bgp_summary_cmd
,
7216 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
7220 BGP_INSTANCE_HELP_STR
7222 BGP_SAFI_WITH_LABEL_HELP_STR
7223 "Summary of BGP neighbor status\n"
7227 afi_t afi
= AFI_MAX
;
7228 safi_t safi
= SAFI_MAX
;
7233 if (argv_find(argv
, argc
, "ip", &idx
))
7235 /* [<view|vrf> VIEWVRFNAME] */
7236 if (argv_find(argv
, argc
, "view", &idx
)
7237 || argv_find(argv
, argc
, "vrf", &idx
))
7238 vrf
= argv
[++idx
]->arg
;
7239 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7240 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
7241 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7244 int uj
= use_json(argc
, argv
);
7246 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
7249 const char *afi_safi_print(afi_t afi
, safi_t safi
)
7251 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
7252 return "IPv4 Unicast";
7253 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
7254 return "IPv4 Multicast";
7255 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
7256 return "IPv4 Labeled Unicast";
7257 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7259 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
7260 return "IPv4 Encap";
7261 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
7262 return "IPv6 Unicast";
7263 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
7264 return "IPv6 Multicast";
7265 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
7266 return "IPv6 Labeled Unicast";
7267 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
7269 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
7270 return "IPv6 Encap";
7271 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
7272 return "L2VPN EVPN";
7278 * Please note that we have intentionally camelCased
7279 * the return strings here. So if you want
7280 * to use this function, please ensure you
7281 * are doing this within json output
7283 const char *afi_safi_json(afi_t afi
, safi_t safi
)
7285 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
7286 return "ipv4Unicast";
7287 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
7288 return "ipv4Multicast";
7289 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
7290 return "ipv4LabeledUnicast";
7291 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7293 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
7295 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
7296 return "ipv6Unicast";
7297 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
7298 return "ipv6Multicast";
7299 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
7300 return "ipv6LabeledUnicast";
7301 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
7303 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
7305 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
7311 /* Show BGP peer's information. */
7312 enum show_type
{ show_all
, show_peer
};
7314 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
7315 afi_t afi
, safi_t safi
,
7316 u_int16_t adv_smcap
, u_int16_t adv_rmcap
,
7317 u_int16_t rcv_smcap
, u_int16_t rcv_rmcap
,
7318 u_char use_json
, json_object
*json_pref
)
7321 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
7322 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
7324 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
7325 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7326 json_object_string_add(json_pref
, "sendMode",
7327 "advertisedAndReceived");
7328 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
7329 json_object_string_add(json_pref
, "sendMode",
7331 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7332 json_object_string_add(json_pref
, "sendMode",
7335 vty_out(vty
, " Send-mode: ");
7336 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
7337 vty_out(vty
, "advertised");
7338 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
7339 vty_out(vty
, "%sreceived",
7340 CHECK_FLAG(p
->af_cap
[afi
][safi
],
7349 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
7350 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
7352 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
7353 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7354 json_object_string_add(json_pref
, "recvMode",
7355 "advertisedAndReceived");
7356 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
7357 json_object_string_add(json_pref
, "recvMode",
7359 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7360 json_object_string_add(json_pref
, "recvMode",
7363 vty_out(vty
, " Receive-mode: ");
7364 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
7365 vty_out(vty
, "advertised");
7366 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
7367 vty_out(vty
, "%sreceived",
7368 CHECK_FLAG(p
->af_cap
[afi
][safi
],
7377 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
7378 safi_t safi
, u_char use_json
,
7379 json_object
*json_neigh
)
7381 struct bgp_filter
*filter
;
7382 struct peer_af
*paf
;
7383 char orf_pfx_name
[BUFSIZ
];
7385 json_object
*json_af
= NULL
;
7386 json_object
*json_prefA
= NULL
;
7387 json_object
*json_prefB
= NULL
;
7388 json_object
*json_addr
= NULL
;
7391 json_addr
= json_object_new_object();
7392 json_af
= json_object_new_object();
7393 filter
= &p
->filter
[afi
][safi
];
7395 if (peer_group_active(p
))
7396 json_object_string_add(json_addr
, "peerGroupMember",
7399 paf
= peer_af_find(p
, afi
, safi
);
7400 if (paf
&& PAF_SUBGRP(paf
)) {
7401 json_object_int_add(json_addr
, "updateGroupId",
7402 PAF_UPDGRP(paf
)->id
);
7403 json_object_int_add(json_addr
, "subGroupId",
7404 PAF_SUBGRP(paf
)->id
);
7405 json_object_int_add(json_addr
, "packetQueueLength",
7406 bpacket_queue_virtual_length(paf
));
7409 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7410 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7411 PEER_CAP_ORF_PREFIX_SM_RCV
)
7412 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7413 PEER_CAP_ORF_PREFIX_RM_ADV
)
7414 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7415 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
7416 json_object_int_add(json_af
, "orfType",
7418 json_prefA
= json_object_new_object();
7419 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
7420 PEER_CAP_ORF_PREFIX_SM_ADV
,
7421 PEER_CAP_ORF_PREFIX_RM_ADV
,
7422 PEER_CAP_ORF_PREFIX_SM_RCV
,
7423 PEER_CAP_ORF_PREFIX_RM_RCV
,
7424 use_json
, json_prefA
);
7425 json_object_object_add(json_af
, "orfPrefixList",
7429 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7430 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7431 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7432 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7433 PEER_CAP_ORF_PREFIX_RM_ADV
)
7434 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7435 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
7436 json_object_int_add(json_af
, "orfOldType",
7437 ORF_TYPE_PREFIX_OLD
);
7438 json_prefB
= json_object_new_object();
7439 bgp_show_peer_afi_orf_cap(
7440 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
7441 PEER_CAP_ORF_PREFIX_RM_ADV
,
7442 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
7443 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
7445 json_object_object_add(json_af
, "orfOldPrefixList",
7449 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7450 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7451 PEER_CAP_ORF_PREFIX_SM_RCV
)
7452 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7453 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7454 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7455 PEER_CAP_ORF_PREFIX_RM_ADV
)
7456 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7457 PEER_CAP_ORF_PREFIX_RM_RCV
)
7458 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7459 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
7460 json_object_object_add(json_addr
, "afDependentCap",
7463 json_object_free(json_af
);
7465 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
7466 orf_pfx_count
= prefix_bgp_show_prefix_list(
7467 NULL
, afi
, orf_pfx_name
, use_json
);
7469 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7470 PEER_STATUS_ORF_PREFIX_SEND
)
7472 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7473 PEER_STATUS_ORF_PREFIX_SEND
))
7474 json_object_boolean_true_add(json_neigh
,
7477 json_object_int_add(json_addr
, "orfRecvCounter",
7480 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7481 PEER_STATUS_ORF_WAIT_REFRESH
))
7482 json_object_string_add(
7483 json_addr
, "orfFirstUpdate",
7484 "deferredUntilORFOrRouteRefreshRecvd");
7486 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7487 PEER_FLAG_REFLECTOR_CLIENT
))
7488 json_object_boolean_true_add(json_addr
,
7489 "routeReflectorClient");
7490 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7491 PEER_FLAG_RSERVER_CLIENT
))
7492 json_object_boolean_true_add(json_addr
,
7493 "routeServerClient");
7494 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
7495 json_object_boolean_true_add(json_addr
,
7496 "inboundSoftConfigPermit");
7498 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7499 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
7500 json_object_boolean_true_add(
7502 "privateAsNumsAllReplacedInUpdatesToNbr");
7503 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7504 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
7505 json_object_boolean_true_add(
7507 "privateAsNumsReplacedInUpdatesToNbr");
7508 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7509 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
7510 json_object_boolean_true_add(
7512 "privateAsNumsAllRemovedInUpdatesToNbr");
7513 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7514 PEER_FLAG_REMOVE_PRIVATE_AS
))
7515 json_object_boolean_true_add(
7517 "privateAsNumsRemovedInUpdatesToNbr");
7519 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7520 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
7521 json_object_boolean_true_add(json_addr
,
7522 "addpathTxAllPaths");
7524 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7525 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
7526 json_object_boolean_true_add(json_addr
,
7527 "addpathTxBestpathPerAS");
7529 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
7530 json_object_string_add(json_addr
,
7531 "overrideASNsInOutboundUpdates",
7532 "ifAspathEqualRemoteAs");
7534 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
7535 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7536 PEER_FLAG_FORCE_NEXTHOP_SELF
))
7537 json_object_boolean_true_add(json_addr
,
7538 "routerAlwaysNextHop");
7539 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7540 PEER_FLAG_AS_PATH_UNCHANGED
))
7541 json_object_boolean_true_add(
7542 json_addr
, "unchangedAsPathPropogatedToNbr");
7543 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7544 PEER_FLAG_NEXTHOP_UNCHANGED
))
7545 json_object_boolean_true_add(
7546 json_addr
, "unchangedNextHopPropogatedToNbr");
7547 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
7548 json_object_boolean_true_add(
7549 json_addr
, "unchangedMedPropogatedToNbr");
7550 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
7551 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7552 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
7553 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7554 PEER_FLAG_SEND_COMMUNITY
)
7555 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
7556 PEER_FLAG_SEND_EXT_COMMUNITY
))
7557 json_object_string_add(json_addr
,
7558 "commAttriSentToNbr",
7559 "extendedAndStandard");
7560 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7561 PEER_FLAG_SEND_EXT_COMMUNITY
))
7562 json_object_string_add(json_addr
,
7563 "commAttriSentToNbr",
7566 json_object_string_add(json_addr
,
7567 "commAttriSentToNbr",
7570 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7571 PEER_FLAG_DEFAULT_ORIGINATE
)) {
7572 if (p
->default_rmap
[afi
][safi
].name
)
7573 json_object_string_add(
7574 json_addr
, "defaultRouteMap",
7575 p
->default_rmap
[afi
][safi
].name
);
7577 if (paf
&& PAF_SUBGRP(paf
)
7578 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
7579 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
7580 json_object_boolean_true_add(json_addr
,
7583 json_object_boolean_true_add(json_addr
,
7587 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
7588 if (p
->bgp
->advertise_all_vni
)
7589 json_object_boolean_true_add(
7590 json_addr
, "advertiseAllVnis");
7593 if (filter
->plist
[FILTER_IN
].name
7594 || filter
->dlist
[FILTER_IN
].name
7595 || filter
->aslist
[FILTER_IN
].name
7596 || filter
->map
[RMAP_IN
].name
)
7597 json_object_boolean_true_add(json_addr
,
7598 "inboundPathPolicyConfig");
7599 if (filter
->plist
[FILTER_OUT
].name
7600 || filter
->dlist
[FILTER_OUT
].name
7601 || filter
->aslist
[FILTER_OUT
].name
7602 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
7603 json_object_boolean_true_add(
7604 json_addr
, "outboundPathPolicyConfig");
7607 if (filter
->plist
[FILTER_IN
].name
)
7608 json_object_string_add(json_addr
,
7609 "incomingUpdatePrefixFilterList",
7610 filter
->plist
[FILTER_IN
].name
);
7611 if (filter
->plist
[FILTER_OUT
].name
)
7612 json_object_string_add(json_addr
,
7613 "outgoingUpdatePrefixFilterList",
7614 filter
->plist
[FILTER_OUT
].name
);
7616 /* distribute-list */
7617 if (filter
->dlist
[FILTER_IN
].name
)
7618 json_object_string_add(
7619 json_addr
, "incomingUpdateNetworkFilterList",
7620 filter
->dlist
[FILTER_IN
].name
);
7621 if (filter
->dlist
[FILTER_OUT
].name
)
7622 json_object_string_add(
7623 json_addr
, "outgoingUpdateNetworkFilterList",
7624 filter
->dlist
[FILTER_OUT
].name
);
7627 if (filter
->aslist
[FILTER_IN
].name
)
7628 json_object_string_add(json_addr
,
7629 "incomingUpdateAsPathFilterList",
7630 filter
->aslist
[FILTER_IN
].name
);
7631 if (filter
->aslist
[FILTER_OUT
].name
)
7632 json_object_string_add(json_addr
,
7633 "outgoingUpdateAsPathFilterList",
7634 filter
->aslist
[FILTER_OUT
].name
);
7637 if (filter
->map
[RMAP_IN
].name
)
7638 json_object_string_add(
7639 json_addr
, "routeMapForIncomingAdvertisements",
7640 filter
->map
[RMAP_IN
].name
);
7641 if (filter
->map
[RMAP_OUT
].name
)
7642 json_object_string_add(
7643 json_addr
, "routeMapForOutgoingAdvertisements",
7644 filter
->map
[RMAP_OUT
].name
);
7646 /* unsuppress-map */
7647 if (filter
->usmap
.name
)
7648 json_object_string_add(json_addr
,
7649 "selectiveUnsuppressRouteMap",
7650 filter
->usmap
.name
);
7652 /* Receive prefix count */
7653 json_object_int_add(json_addr
, "acceptedPrefixCounter",
7654 p
->pcount
[afi
][safi
]);
7656 /* Maximum prefix */
7657 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
7658 json_object_int_add(json_addr
, "prefixAllowedMax",
7659 p
->pmax
[afi
][safi
]);
7660 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7661 PEER_FLAG_MAX_PREFIX_WARNING
))
7662 json_object_boolean_true_add(
7663 json_addr
, "prefixAllowedMaxWarning");
7664 json_object_int_add(json_addr
,
7665 "prefixAllowedWarningThresh",
7666 p
->pmax_threshold
[afi
][safi
]);
7667 if (p
->pmax_restart
[afi
][safi
])
7668 json_object_int_add(
7670 "prefixAllowedRestartIntervalMsecs",
7671 p
->pmax_restart
[afi
][safi
] * 60000);
7673 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
7677 filter
= &p
->filter
[afi
][safi
];
7679 vty_out(vty
, " For address family: %s\n",
7680 afi_safi_print(afi
, safi
));
7682 if (peer_group_active(p
))
7683 vty_out(vty
, " %s peer-group member\n",
7686 paf
= peer_af_find(p
, afi
, safi
);
7687 if (paf
&& PAF_SUBGRP(paf
)) {
7688 vty_out(vty
, " Update group %" PRIu64
7689 ", subgroup %" PRIu64
"\n",
7690 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
7691 vty_out(vty
, " Packet Queue length %d\n",
7692 bpacket_queue_virtual_length(paf
));
7694 vty_out(vty
, " Not part of any update group\n");
7696 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7697 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7698 PEER_CAP_ORF_PREFIX_SM_RCV
)
7699 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7700 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7701 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7702 PEER_CAP_ORF_PREFIX_RM_ADV
)
7703 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7704 PEER_CAP_ORF_PREFIX_RM_RCV
)
7705 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7706 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
7707 vty_out(vty
, " AF-dependant capabilities:\n");
7709 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7710 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7711 PEER_CAP_ORF_PREFIX_SM_RCV
)
7712 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7713 PEER_CAP_ORF_PREFIX_RM_ADV
)
7714 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7715 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
7717 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
7719 bgp_show_peer_afi_orf_cap(
7720 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
7721 PEER_CAP_ORF_PREFIX_RM_ADV
,
7722 PEER_CAP_ORF_PREFIX_SM_RCV
,
7723 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
7725 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
7726 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7727 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
7728 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7729 PEER_CAP_ORF_PREFIX_RM_ADV
)
7730 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
7731 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
7733 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
7734 ORF_TYPE_PREFIX_OLD
);
7735 bgp_show_peer_afi_orf_cap(
7736 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
7737 PEER_CAP_ORF_PREFIX_RM_ADV
,
7738 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
7739 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
7742 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
7743 orf_pfx_count
= prefix_bgp_show_prefix_list(
7744 NULL
, afi
, orf_pfx_name
, use_json
);
7746 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7747 PEER_STATUS_ORF_PREFIX_SEND
)
7749 vty_out(vty
, " Outbound Route Filter (ORF):");
7750 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7751 PEER_STATUS_ORF_PREFIX_SEND
))
7752 vty_out(vty
, " sent;");
7754 vty_out(vty
, " received (%d entries)",
7758 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
7759 PEER_STATUS_ORF_WAIT_REFRESH
))
7761 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
7763 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7764 PEER_FLAG_REFLECTOR_CLIENT
))
7765 vty_out(vty
, " Route-Reflector Client\n");
7766 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7767 PEER_FLAG_RSERVER_CLIENT
))
7768 vty_out(vty
, " Route-Server Client\n");
7769 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
7771 " Inbound soft reconfiguration allowed\n");
7773 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7774 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
7776 " Private AS numbers (all) replaced in updates to this neighbor\n");
7777 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7778 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
7780 " Private AS numbers replaced in updates to this neighbor\n");
7781 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7782 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
7784 " Private AS numbers (all) removed in updates to this neighbor\n");
7785 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7786 PEER_FLAG_REMOVE_PRIVATE_AS
))
7788 " Private AS numbers removed in updates to this neighbor\n");
7790 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7791 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
7792 vty_out(vty
, " Advertise all paths via addpath\n");
7794 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7795 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
7797 " Advertise bestpath per AS via addpath\n");
7799 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
7801 " Override ASNs in outbound updates if aspath equals remote-as\n");
7803 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
7804 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7805 PEER_FLAG_FORCE_NEXTHOP_SELF
))
7806 vty_out(vty
, " NEXT_HOP is always this router\n");
7807 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7808 PEER_FLAG_AS_PATH_UNCHANGED
))
7810 " AS_PATH is propagated unchanged to this neighbor\n");
7811 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7812 PEER_FLAG_NEXTHOP_UNCHANGED
))
7814 " NEXT_HOP is propagated unchanged to this neighbor\n");
7815 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
7817 " MED is propagated unchanged to this neighbor\n");
7818 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
7819 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7820 PEER_FLAG_SEND_EXT_COMMUNITY
)
7821 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
7822 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
7824 " Community attribute sent to this neighbor");
7825 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7826 PEER_FLAG_SEND_COMMUNITY
)
7827 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
7828 PEER_FLAG_SEND_EXT_COMMUNITY
)
7829 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
7830 PEER_FLAG_SEND_LARGE_COMMUNITY
))
7831 vty_out(vty
, "(all)\n");
7832 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7833 PEER_FLAG_SEND_LARGE_COMMUNITY
))
7834 vty_out(vty
, "(large)\n");
7835 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7836 PEER_FLAG_SEND_EXT_COMMUNITY
))
7837 vty_out(vty
, "(extended)\n");
7839 vty_out(vty
, "(standard)\n");
7841 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
7842 PEER_FLAG_DEFAULT_ORIGINATE
)) {
7843 vty_out(vty
, " Default information originate,");
7845 if (p
->default_rmap
[afi
][safi
].name
)
7846 vty_out(vty
, " default route-map %s%s,",
7847 p
->default_rmap
[afi
][safi
].map
? "*"
7849 p
->default_rmap
[afi
][safi
].name
);
7850 if (paf
&& PAF_SUBGRP(paf
)
7851 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
7852 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
7853 vty_out(vty
, " default sent\n");
7855 vty_out(vty
, " default not sent\n");
7858 /* advertise-vni-all */
7859 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
7860 if (p
->bgp
->advertise_all_vni
)
7861 vty_out(vty
, " advertise-all-vni\n");
7864 if (filter
->plist
[FILTER_IN
].name
7865 || filter
->dlist
[FILTER_IN
].name
7866 || filter
->aslist
[FILTER_IN
].name
7867 || filter
->map
[RMAP_IN
].name
)
7868 vty_out(vty
, " Inbound path policy configured\n");
7869 if (filter
->plist
[FILTER_OUT
].name
7870 || filter
->dlist
[FILTER_OUT
].name
7871 || filter
->aslist
[FILTER_OUT
].name
7872 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
7873 vty_out(vty
, " Outbound path policy configured\n");
7876 if (filter
->plist
[FILTER_IN
].name
)
7878 " Incoming update prefix filter list is %s%s\n",
7879 filter
->plist
[FILTER_IN
].plist
? "*" : "",
7880 filter
->plist
[FILTER_IN
].name
);
7881 if (filter
->plist
[FILTER_OUT
].name
)
7883 " Outgoing update prefix filter list is %s%s\n",
7884 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
7885 filter
->plist
[FILTER_OUT
].name
);
7887 /* distribute-list */
7888 if (filter
->dlist
[FILTER_IN
].name
)
7890 " Incoming update network filter list is %s%s\n",
7891 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
7892 filter
->dlist
[FILTER_IN
].name
);
7893 if (filter
->dlist
[FILTER_OUT
].name
)
7895 " Outgoing update network filter list is %s%s\n",
7896 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
7897 filter
->dlist
[FILTER_OUT
].name
);
7900 if (filter
->aslist
[FILTER_IN
].name
)
7902 " Incoming update AS path filter list is %s%s\n",
7903 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
7904 filter
->aslist
[FILTER_IN
].name
);
7905 if (filter
->aslist
[FILTER_OUT
].name
)
7907 " Outgoing update AS path filter list is %s%s\n",
7908 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
7909 filter
->aslist
[FILTER_OUT
].name
);
7912 if (filter
->map
[RMAP_IN
].name
)
7914 " Route map for incoming advertisements is %s%s\n",
7915 filter
->map
[RMAP_IN
].map
? "*" : "",
7916 filter
->map
[RMAP_IN
].name
);
7917 if (filter
->map
[RMAP_OUT
].name
)
7919 " Route map for outgoing advertisements is %s%s\n",
7920 filter
->map
[RMAP_OUT
].map
? "*" : "",
7921 filter
->map
[RMAP_OUT
].name
);
7923 /* unsuppress-map */
7924 if (filter
->usmap
.name
)
7926 " Route map for selective unsuppress is %s%s\n",
7927 filter
->usmap
.map
? "*" : "",
7928 filter
->usmap
.name
);
7930 /* Receive prefix count */
7931 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
7933 /* Maximum prefix */
7934 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
7935 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
7937 CHECK_FLAG(p
->af_flags
[afi
][safi
],
7938 PEER_FLAG_MAX_PREFIX_WARNING
)
7941 vty_out(vty
, " Threshold for warning message %d%%",
7942 p
->pmax_threshold
[afi
][safi
]);
7943 if (p
->pmax_restart
[afi
][safi
])
7944 vty_out(vty
, ", restart interval %d min",
7945 p
->pmax_restart
[afi
][safi
]);
7953 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, u_char use_json
,
7957 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
7958 char timebuf
[BGP_UPTIME_LEN
];
7960 const char *subcode_str
;
7961 const char *code_str
;
7966 json_object
*json_neigh
= NULL
;
7972 json_neigh
= json_object_new_object();
7974 memset(dn_flag
, '\0', sizeof(dn_flag
));
7975 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
7979 if (p
->conf_if
) /* Configured interface name. */
7980 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
7981 BGP_PEER_SU_UNSPEC(p
)
7983 : sockunion2str(&p
->su
, buf
,
7985 else /* Configured IP address. */
7986 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
7991 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
7992 json_object_string_add(json_neigh
, "bgpNeighborAddr",
7994 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
7995 json_object_string_add(
7996 json_neigh
, "bgpNeighborAddr",
7997 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
7999 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8001 if (p
->change_local_as
)
8002 json_object_int_add(json_neigh
, "localAs",
8003 p
->change_local_as
);
8005 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8007 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8008 json_object_boolean_true_add(json_neigh
,
8009 "localAsNoPrepend");
8011 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8012 json_object_boolean_true_add(json_neigh
,
8013 "localAsReplaceAs");
8015 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
8016 || (p
->as_type
== AS_INTERNAL
))
8017 vty_out(vty
, "remote AS %u, ", p
->as
);
8019 vty_out(vty
, "remote AS Unspecified, ");
8020 vty_out(vty
, "local AS %u%s%s, ",
8021 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
8022 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
8025 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
8029 /* peer type internal, external, confed-internal or confed-external */
8030 if (p
->as
== p
->local_as
) {
8032 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8033 json_object_boolean_true_add(
8034 json_neigh
, "nbrConfedInternalLink");
8036 json_object_boolean_true_add(json_neigh
,
8039 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8040 vty_out(vty
, "confed-internal link\n");
8042 vty_out(vty
, "internal link\n");
8046 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8047 json_object_boolean_true_add(
8048 json_neigh
, "nbrConfedExternalLink");
8050 json_object_boolean_true_add(json_neigh
,
8053 if (bgp_confederation_peers_check(bgp
, p
->as
))
8054 vty_out(vty
, "confed-external link\n");
8056 vty_out(vty
, "external link\n");
8063 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
8065 vty_out(vty
, " Description: %s\n", p
->desc
);
8071 json_object_string_add(json_neigh
, "hostname",
8075 json_object_string_add(json_neigh
, "domainname",
8078 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
8079 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
8082 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
8089 json_object_string_add(json_neigh
, "peerGroup",
8093 struct prefix prefix
, *range
= NULL
;
8095 sockunion2hostprefix(&(p
->su
), &prefix
);
8096 range
= peer_group_lookup_dynamic_neighbor_range(
8100 prefix2str(range
, buf1
, sizeof(buf1
));
8101 json_object_string_add(
8103 "peerSubnetRangeGroup", buf1
);
8108 " Member of peer-group %s for session parameters\n",
8112 struct prefix prefix
, *range
= NULL
;
8114 sockunion2hostprefix(&(p
->su
), &prefix
);
8115 range
= peer_group_lookup_dynamic_neighbor_range(
8119 prefix2str(range
, buf1
, sizeof(buf1
));
8121 " Belongs to the subnet range group: %s\n",
8129 /* Administrative shutdown. */
8130 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8131 json_object_boolean_true_add(json_neigh
,
8135 json_object_int_add(json_neigh
, "bgpVersion", 4);
8136 json_object_string_add(
8137 json_neigh
, "remoteRouterId",
8138 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
8141 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
8142 && bgp_confederation_peers_check(bgp
, p
->as
))
8143 json_object_boolean_true_add(json_neigh
,
8147 json_object_string_add(
8148 json_neigh
, "bgpState",
8149 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
8151 if (p
->status
== Established
) {
8155 uptime
= bgp_clock();
8156 uptime
-= p
->uptime
;
8157 tm
= gmtime(&uptime
);
8158 epoch_tbuf
= time(NULL
) - uptime
;
8160 json_object_int_add(json_neigh
, "bgpTimerUp",
8162 + (tm
->tm_min
* 60000)
8163 + (tm
->tm_hour
* 3600000));
8164 json_object_string_add(json_neigh
, "bgpTimerUpString",
8165 peer_uptime(p
->uptime
, timebuf
,
8168 json_object_int_add(json_neigh
,
8169 "bgpTimerUpEstablishedEpoch",
8173 else if (p
->status
== Active
) {
8174 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
8175 json_object_string_add(json_neigh
, "bgpStateIs",
8177 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
8178 json_object_string_add(json_neigh
, "bgpStateIs",
8186 uptime
= bgp_clock();
8187 uptime
-= p
->readtime
;
8188 tm
= gmtime(&uptime
);
8189 json_object_int_add(json_neigh
, "bgpTimerLastRead",
8190 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8191 + (tm
->tm_hour
* 3600000));
8193 uptime
= bgp_clock();
8194 uptime
-= p
->last_write
;
8195 tm
= gmtime(&uptime
);
8196 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
8197 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8198 + (tm
->tm_hour
* 3600000));
8200 uptime
= bgp_clock();
8201 uptime
-= p
->update_time
;
8202 tm
= gmtime(&uptime
);
8203 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
8204 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
8205 + (tm
->tm_hour
* 3600000));
8207 /* Configured timer values. */
8208 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
8209 p
->v_holdtime
* 1000);
8210 json_object_int_add(json_neigh
,
8211 "bgpTimerKeepAliveIntervalMsecs",
8212 p
->v_keepalive
* 1000);
8214 if (CHECK_FLAG(p
->config
, PEER_CONFIG_TIMER
)) {
8215 json_object_int_add(json_neigh
,
8216 "bgpTimerConfiguredHoldTimeMsecs",
8217 p
->holdtime
* 1000);
8218 json_object_int_add(
8220 "bgpTimerConfiguredKeepAliveIntervalMsecs",
8221 p
->keepalive
* 1000);
8224 /* Administrative shutdown. */
8225 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
8226 vty_out(vty
, " Administratively shut down\n");
8229 vty_out(vty
, " BGP version 4");
8230 vty_out(vty
, ", remote router ID %s\n",
8231 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
8234 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
8235 && bgp_confederation_peers_check(bgp
, p
->as
))
8237 " Neighbor under common administration\n");
8240 vty_out(vty
, " BGP state = %s",
8241 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
8243 if (p
->status
== Established
)
8244 vty_out(vty
, ", up for %8s",
8245 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8248 else if (p
->status
== Active
) {
8249 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
8250 vty_out(vty
, " (passive)");
8251 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
8252 vty_out(vty
, " (NSF passive)");
8257 vty_out(vty
, " Last read %s",
8258 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
8260 vty_out(vty
, ", Last write %s\n",
8261 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
8264 /* Configured timer values. */
8266 " Hold time is %d, keepalive interval is %d seconds\n",
8267 p
->v_holdtime
, p
->v_keepalive
);
8268 if (CHECK_FLAG(p
->config
, PEER_CONFIG_TIMER
)) {
8269 vty_out(vty
, " Configured hold time is %d",
8271 vty_out(vty
, ", keepalive interval is %d seconds\n",
8276 if (p
->status
== Established
) {
8277 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
8278 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
8279 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
8280 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
8281 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
8282 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
8283 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
8284 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
8285 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
8286 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
8287 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
8288 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
8289 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
8290 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
8291 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
8292 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
8294 json_object
*json_cap
= NULL
;
8296 json_cap
= json_object_new_object();
8299 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
8300 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
8301 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
8302 && CHECK_FLAG(p
->cap
,
8304 json_object_string_add(
8305 json_cap
, "4byteAs",
8306 "advertisedAndReceived");
8307 else if (CHECK_FLAG(p
->cap
,
8309 json_object_string_add(
8310 json_cap
, "4byteAs",
8312 else if (CHECK_FLAG(p
->cap
,
8314 json_object_string_add(
8315 json_cap
, "4byteAs",
8320 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
8321 || CHECK_FLAG(p
->cap
,
8322 PEER_CAP_ADDPATH_ADV
)) {
8323 json_object
*json_add
= NULL
;
8324 const char *print_store
;
8326 json_add
= json_object_new_object();
8328 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
8329 for (safi
= SAFI_UNICAST
;
8330 safi
< SAFI_MAX
; safi
++) {
8331 json_object
*json_sub
=
8334 json_object_new_object();
8344 PEER_CAP_ADDPATH_AF_TX_ADV
)
8349 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
8354 PEER_CAP_ADDPATH_AF_TX_ADV
)
8359 PEER_CAP_ADDPATH_AF_TX_RCV
))
8360 json_object_boolean_true_add(
8362 "txAdvertisedAndReceived");
8368 PEER_CAP_ADDPATH_AF_TX_ADV
))
8369 json_object_boolean_true_add(
8377 PEER_CAP_ADDPATH_AF_TX_RCV
))
8378 json_object_boolean_true_add(
8387 PEER_CAP_ADDPATH_AF_RX_ADV
)
8392 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
8397 PEER_CAP_ADDPATH_AF_RX_ADV
)
8402 PEER_CAP_ADDPATH_AF_RX_RCV
))
8403 json_object_boolean_true_add(
8405 "rxAdvertisedAndReceived");
8411 PEER_CAP_ADDPATH_AF_RX_ADV
))
8412 json_object_boolean_true_add(
8420 PEER_CAP_ADDPATH_AF_RX_RCV
))
8421 json_object_boolean_true_add(
8430 PEER_CAP_ADDPATH_AF_TX_ADV
)
8435 PEER_CAP_ADDPATH_AF_TX_RCV
)
8440 PEER_CAP_ADDPATH_AF_RX_ADV
)
8445 PEER_CAP_ADDPATH_AF_RX_RCV
))
8446 json_object_object_add(
8455 json_object_object_add(
8456 json_cap
, "addPath", json_add
);
8460 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
8461 || CHECK_FLAG(p
->cap
,
8462 PEER_CAP_DYNAMIC_ADV
)) {
8463 if (CHECK_FLAG(p
->cap
,
8464 PEER_CAP_DYNAMIC_ADV
)
8465 && CHECK_FLAG(p
->cap
,
8466 PEER_CAP_DYNAMIC_RCV
))
8467 json_object_string_add(
8468 json_cap
, "dynamic",
8469 "advertisedAndReceived");
8470 else if (CHECK_FLAG(
8472 PEER_CAP_DYNAMIC_ADV
))
8473 json_object_string_add(
8474 json_cap
, "dynamic",
8476 else if (CHECK_FLAG(
8478 PEER_CAP_DYNAMIC_RCV
))
8479 json_object_string_add(
8480 json_cap
, "dynamic",
8484 /* Extended nexthop */
8485 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
8486 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
8487 json_object
*json_nxt
= NULL
;
8488 const char *print_store
;
8491 if (CHECK_FLAG(p
->cap
,
8493 && CHECK_FLAG(p
->cap
,
8495 json_object_string_add(
8498 "advertisedAndReceived");
8499 else if (CHECK_FLAG(p
->cap
,
8501 json_object_string_add(
8505 else if (CHECK_FLAG(p
->cap
,
8507 json_object_string_add(
8512 if (CHECK_FLAG(p
->cap
,
8513 PEER_CAP_ENHE_RCV
)) {
8515 json_object_new_object();
8517 for (safi
= SAFI_UNICAST
;
8518 safi
< SAFI_MAX
; safi
++) {
8523 PEER_CAP_ENHE_AF_RCV
)) {
8524 print_store
= afi_safi_print(
8527 json_object_string_add(
8533 json_object_object_add(
8535 "extendedNexthopFamililesByPeer",
8541 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
8542 || CHECK_FLAG(p
->cap
,
8543 PEER_CAP_REFRESH_NEW_RCV
)
8544 || CHECK_FLAG(p
->cap
,
8545 PEER_CAP_REFRESH_OLD_RCV
)) {
8546 if (CHECK_FLAG(p
->cap
,
8547 PEER_CAP_REFRESH_ADV
)
8550 PEER_CAP_REFRESH_NEW_RCV
)
8553 PEER_CAP_REFRESH_OLD_RCV
))) {
8556 PEER_CAP_REFRESH_OLD_RCV
)
8559 PEER_CAP_REFRESH_NEW_RCV
))
8560 json_object_string_add(
8563 "advertisedAndReceivedOldNew");
8567 PEER_CAP_REFRESH_OLD_RCV
))
8568 json_object_string_add(
8571 "advertisedAndReceivedOld");
8573 json_object_string_add(
8576 "advertisedAndReceivedNew");
8581 PEER_CAP_REFRESH_ADV
))
8582 json_object_string_add(
8589 PEER_CAP_REFRESH_NEW_RCV
)
8592 PEER_CAP_REFRESH_OLD_RCV
))
8593 json_object_string_add(
8599 /* Multiprotocol Extensions */
8600 json_object
*json_multi
= NULL
;
8601 json_multi
= json_object_new_object();
8603 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
8604 for (safi
= SAFI_UNICAST
;
8605 safi
< SAFI_MAX
; safi
++) {
8606 if (p
->afc_adv
[afi
][safi
]
8607 || p
->afc_recv
[afi
][safi
]) {
8612 json_object_new_object();
8619 json_object_boolean_true_add(
8621 "advertisedAndReceived");
8625 json_object_boolean_true_add(
8628 else if (p
->afc_recv
8631 json_object_boolean_true_add(
8635 json_object_object_add(
8644 json_object_object_add(
8645 json_cap
, "multiprotocolExtensions",
8648 /* Hostname capabilities */
8649 json_object
*json_hname
= NULL
;
8651 json_hname
= json_object_new_object();
8653 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
8654 json_object_string_add(
8655 json_hname
, "advHostName",
8656 bgp
->peer_self
->hostname
8660 json_object_string_add(
8661 json_hname
, "advDomainName",
8662 bgp
->peer_self
->domainname
8669 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
8670 json_object_string_add(
8671 json_hname
, "rcvHostName",
8672 p
->hostname
? p
->hostname
8674 json_object_string_add(
8675 json_hname
, "rcvDomainName",
8676 p
->domainname
? p
->domainname
8680 json_object_object_add(json_cap
, "hostName",
8683 /* Gracefull Restart */
8684 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
8685 || CHECK_FLAG(p
->cap
,
8686 PEER_CAP_RESTART_ADV
)) {
8687 if (CHECK_FLAG(p
->cap
,
8688 PEER_CAP_RESTART_ADV
)
8689 && CHECK_FLAG(p
->cap
,
8690 PEER_CAP_RESTART_RCV
))
8691 json_object_string_add(
8694 "advertisedAndReceived");
8695 else if (CHECK_FLAG(
8697 PEER_CAP_RESTART_ADV
))
8698 json_object_string_add(
8700 "gracefulRestartCapability",
8702 else if (CHECK_FLAG(
8704 PEER_CAP_RESTART_RCV
))
8705 json_object_string_add(
8707 "gracefulRestartCapability",
8710 if (CHECK_FLAG(p
->cap
,
8711 PEER_CAP_RESTART_RCV
)) {
8712 int restart_af_count
= 0;
8713 json_object
*json_restart
=
8716 json_object_new_object();
8718 json_object_int_add(
8720 "gracefulRestartRemoteTimerMsecs",
8721 p
->v_gr_restart
* 1000);
8724 afi
< AFI_MAX
; afi
++) {
8725 for (safi
= SAFI_UNICAST
;
8732 PEER_CAP_RESTART_AF_RCV
)) {
8733 json_object
*json_sub
=
8736 json_object_new_object();
8742 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
8743 json_object_boolean_true_add(
8747 json_object_object_add(
8756 if (!restart_af_count
) {
8757 json_object_string_add(
8759 "addressFamiliesByPeer",
8764 json_object_object_add(
8766 "addressFamiliesByPeer",
8770 json_object_object_add(json_neigh
,
8771 "neighborCapabilities",
8774 vty_out(vty
, " Neighbor capabilities:\n");
8777 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
8778 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
8779 vty_out(vty
, " 4 Byte AS:");
8780 if (CHECK_FLAG(p
->cap
,
8782 vty_out(vty
, " advertised");
8783 if (CHECK_FLAG(p
->cap
,
8785 vty_out(vty
, " %sreceived",
8795 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
8796 || CHECK_FLAG(p
->cap
,
8797 PEER_CAP_ADDPATH_ADV
)) {
8798 vty_out(vty
, " AddPath:\n");
8800 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
8801 for (safi
= SAFI_UNICAST
;
8802 safi
< SAFI_MAX
; safi
++) {
8807 PEER_CAP_ADDPATH_AF_TX_ADV
)
8812 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
8823 PEER_CAP_ADDPATH_AF_TX_ADV
))
8834 PEER_CAP_ADDPATH_AF_TX_RCV
))
8841 PEER_CAP_ADDPATH_AF_TX_ADV
)
8853 PEER_CAP_ADDPATH_AF_RX_ADV
)
8858 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
8869 PEER_CAP_ADDPATH_AF_RX_ADV
))
8880 PEER_CAP_ADDPATH_AF_RX_RCV
))
8887 PEER_CAP_ADDPATH_AF_RX_ADV
)
8898 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
8899 || CHECK_FLAG(p
->cap
,
8900 PEER_CAP_DYNAMIC_ADV
)) {
8901 vty_out(vty
, " Dynamic:");
8902 if (CHECK_FLAG(p
->cap
,
8903 PEER_CAP_DYNAMIC_ADV
))
8904 vty_out(vty
, " advertised");
8905 if (CHECK_FLAG(p
->cap
,
8906 PEER_CAP_DYNAMIC_RCV
))
8907 vty_out(vty
, " %sreceived",
8910 PEER_CAP_DYNAMIC_ADV
)
8916 /* Extended nexthop */
8917 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
8918 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
8919 vty_out(vty
, " Extended nexthop:");
8920 if (CHECK_FLAG(p
->cap
,
8922 vty_out(vty
, " advertised");
8923 if (CHECK_FLAG(p
->cap
,
8925 vty_out(vty
, " %sreceived",
8933 if (CHECK_FLAG(p
->cap
,
8934 PEER_CAP_ENHE_RCV
)) {
8936 " Address families by peer:\n ");
8937 for (safi
= SAFI_UNICAST
;
8938 safi
< SAFI_MAX
; safi
++)
8943 PEER_CAP_ENHE_AF_RCV
))
8953 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
8954 || CHECK_FLAG(p
->cap
,
8955 PEER_CAP_REFRESH_NEW_RCV
)
8956 || CHECK_FLAG(p
->cap
,
8957 PEER_CAP_REFRESH_OLD_RCV
)) {
8958 vty_out(vty
, " Route refresh:");
8959 if (CHECK_FLAG(p
->cap
,
8960 PEER_CAP_REFRESH_ADV
))
8961 vty_out(vty
, " advertised");
8962 if (CHECK_FLAG(p
->cap
,
8963 PEER_CAP_REFRESH_NEW_RCV
)
8966 PEER_CAP_REFRESH_OLD_RCV
))
8967 vty_out(vty
, " %sreceived(%s)",
8970 PEER_CAP_REFRESH_ADV
)
8975 PEER_CAP_REFRESH_OLD_RCV
)
8978 PEER_CAP_REFRESH_NEW_RCV
))
8982 PEER_CAP_REFRESH_OLD_RCV
)
8989 /* Multiprotocol Extensions */
8990 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
8991 for (safi
= SAFI_UNICAST
;
8992 safi
< SAFI_MAX
; safi
++)
8993 if (p
->afc_adv
[afi
][safi
]
8994 || p
->afc_recv
[afi
][safi
]) {
8996 " Address Family %s:",
9004 if (p
->afc_recv
[afi
]
9015 /* Hostname capability */
9016 vty_out(vty
, " Hostname Capability:");
9018 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9020 " advertised (name: %s,domain name: %s)",
9021 bgp
->peer_self
->hostname
9025 bgp
->peer_self
->domainname
9030 vty_out(vty
, " not advertised");
9033 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9035 " received (name: %s,domain name: %s)",
9036 p
->hostname
? p
->hostname
9038 p
->domainname
? p
->domainname
9041 vty_out(vty
, " not received");
9046 /* Gracefull Restart */
9047 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9048 || CHECK_FLAG(p
->cap
,
9049 PEER_CAP_RESTART_ADV
)) {
9051 " Graceful Restart Capabilty:");
9052 if (CHECK_FLAG(p
->cap
,
9053 PEER_CAP_RESTART_ADV
))
9054 vty_out(vty
, " advertised");
9055 if (CHECK_FLAG(p
->cap
,
9056 PEER_CAP_RESTART_RCV
))
9057 vty_out(vty
, " %sreceived",
9060 PEER_CAP_RESTART_ADV
)
9065 if (CHECK_FLAG(p
->cap
,
9066 PEER_CAP_RESTART_RCV
)) {
9067 int restart_af_count
= 0;
9070 " Remote Restart timer is %d seconds\n",
9073 " Address families by peer:\n ");
9076 afi
< AFI_MAX
; afi
++)
9077 for (safi
= SAFI_UNICAST
;
9084 PEER_CAP_RESTART_AF_RCV
)) {
9097 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
9102 if (!restart_af_count
)
9103 vty_out(vty
, "none");
9111 /* graceful restart information */
9112 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
9114 json_object
*json_grace
= NULL
;
9115 json_object
*json_grace_send
= NULL
;
9116 json_object
*json_grace_recv
= NULL
;
9117 int eor_send_af_count
= 0;
9118 int eor_receive_af_count
= 0;
9121 json_grace
= json_object_new_object();
9122 json_grace_send
= json_object_new_object();
9123 json_grace_recv
= json_object_new_object();
9125 if (p
->status
== Established
) {
9126 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9127 for (safi
= SAFI_UNICAST
;
9128 safi
< SAFI_MAX
; safi
++) {
9132 PEER_STATUS_EOR_SEND
)) {
9133 json_object_boolean_true_add(
9138 eor_send_af_count
++;
9142 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9143 for (safi
= SAFI_UNICAST
;
9144 safi
< SAFI_MAX
; safi
++) {
9148 PEER_STATUS_EOR_RECEIVED
)) {
9149 json_object_boolean_true_add(
9154 eor_receive_af_count
++;
9160 json_object_object_add(json_grace
, "endOfRibSend",
9162 json_object_object_add(json_grace
, "endOfRibRecv",
9165 if (p
->t_gr_restart
)
9166 json_object_int_add(json_grace
,
9167 "gracefulRestartTimerMsecs",
9168 thread_timer_remain_second(
9173 json_object_int_add(
9175 "gracefulStalepathTimerMsecs",
9176 thread_timer_remain_second(
9180 json_object_object_add(
9181 json_neigh
, "gracefulRestartInfo", json_grace
);
9183 vty_out(vty
, " Graceful restart informations:\n");
9184 if (p
->status
== Established
) {
9185 vty_out(vty
, " End-of-RIB send: ");
9186 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9187 for (safi
= SAFI_UNICAST
;
9188 safi
< SAFI_MAX
; safi
++) {
9192 PEER_STATUS_EOR_SEND
)) {
9193 vty_out(vty
, "%s%s",
9200 eor_send_af_count
++;
9205 vty_out(vty
, " End-of-RIB received: ");
9206 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9207 for (safi
= SAFI_UNICAST
;
9208 safi
< SAFI_MAX
; safi
++) {
9212 PEER_STATUS_EOR_RECEIVED
)) {
9213 vty_out(vty
, "%s%s",
9214 eor_receive_af_count
9220 eor_receive_af_count
++;
9227 if (p
->t_gr_restart
)
9229 " The remaining time of restart timer is %ld\n",
9230 thread_timer_remain_second(
9235 " The remaining time of stalepath timer is %ld\n",
9236 thread_timer_remain_second(
9241 json_object
*json_stat
= NULL
;
9242 json_stat
= json_object_new_object();
9243 /* Packet counts. */
9244 json_object_int_add(json_stat
, "depthInq", 0);
9245 json_object_int_add(json_stat
, "depthOutq",
9246 (unsigned long)p
->obuf
->count
);
9247 json_object_int_add(json_stat
, "opensSent", p
->open_out
);
9248 json_object_int_add(json_stat
, "opensRecv", p
->open_in
);
9249 json_object_int_add(json_stat
, "notificationsSent",
9251 json_object_int_add(json_stat
, "notificationsRecv",
9253 json_object_int_add(json_stat
, "updatesSent", p
->update_out
);
9254 json_object_int_add(json_stat
, "updatesRecv", p
->update_in
);
9255 json_object_int_add(json_stat
, "keepalivesSent",
9257 json_object_int_add(json_stat
, "keepalivesRecv",
9259 json_object_int_add(json_stat
, "routeRefreshSent",
9261 json_object_int_add(json_stat
, "routeRefreshRecv",
9263 json_object_int_add(json_stat
, "capabilitySent",
9264 p
->dynamic_cap_out
);
9265 json_object_int_add(json_stat
, "capabilityRecv",
9267 json_object_int_add(json_stat
, "totalSent",
9268 p
->open_out
+ p
->notify_out
+ p
->update_out
9269 + p
->keepalive_out
+ p
->refresh_out
9270 + p
->dynamic_cap_out
);
9271 json_object_int_add(json_stat
, "totalRecv",
9272 p
->open_in
+ p
->notify_in
+ p
->update_in
9273 + p
->keepalive_in
+ p
->refresh_in
9274 + p
->dynamic_cap_in
);
9275 json_object_object_add(json_neigh
, "messageStats", json_stat
);
9277 /* Packet counts. */
9278 vty_out(vty
, " Message statistics:\n");
9279 vty_out(vty
, " Inq depth is 0\n");
9280 vty_out(vty
, " Outq depth is %lu\n",
9281 (unsigned long)p
->obuf
->count
);
9282 vty_out(vty
, " Sent Rcvd\n");
9283 vty_out(vty
, " Opens: %10d %10d\n", p
->open_out
,
9285 vty_out(vty
, " Notifications: %10d %10d\n", p
->notify_out
,
9287 vty_out(vty
, " Updates: %10d %10d\n", p
->update_out
,
9289 vty_out(vty
, " Keepalives: %10d %10d\n", p
->keepalive_out
,
9291 vty_out(vty
, " Route Refresh: %10d %10d\n", p
->refresh_out
,
9293 vty_out(vty
, " Capability: %10d %10d\n",
9294 p
->dynamic_cap_out
, p
->dynamic_cap_in
);
9295 vty_out(vty
, " Total: %10d %10d\n",
9296 p
->open_out
+ p
->notify_out
+ p
->update_out
9297 + p
->keepalive_out
+ p
->refresh_out
9298 + p
->dynamic_cap_out
,
9299 p
->open_in
+ p
->notify_in
+ p
->update_in
9300 + p
->keepalive_in
+ p
->refresh_in
9301 + p
->dynamic_cap_in
);
9305 /* advertisement-interval */
9306 json_object_int_add(json_neigh
,
9307 "minBtwnAdvertisementRunsTimerMsecs",
9308 p
->v_routeadv
* 1000);
9310 /* Update-source. */
9311 if (p
->update_if
|| p
->update_source
) {
9313 json_object_string_add(json_neigh
,
9316 else if (p
->update_source
)
9317 json_object_string_add(
9318 json_neigh
, "updateSource",
9319 sockunion2str(p
->update_source
, buf1
,
9323 /* advertisement-interval */
9325 " Minimum time between advertisement runs is %d seconds\n",
9328 /* Update-source. */
9329 if (p
->update_if
|| p
->update_source
) {
9330 vty_out(vty
, " Update source is ");
9332 vty_out(vty
, "%s", p
->update_if
);
9333 else if (p
->update_source
)
9335 sockunion2str(p
->update_source
, buf1
,
9343 /* Address Family Information */
9344 json_object
*json_hold
= NULL
;
9347 json_hold
= json_object_new_object();
9349 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
9350 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
9351 if (p
->afc
[afi
][safi
])
9352 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
9356 json_object_object_add(json_neigh
, "addressFamilyInfo",
9358 json_object_int_add(json_neigh
, "connectionsEstablished",
9360 json_object_int_add(json_neigh
, "connectionsDropped",
9363 vty_out(vty
, " Connections established %d; dropped %d\n",
9364 p
->established
, p
->dropped
);
9366 if (!p
->last_reset
) {
9368 json_object_string_add(json_neigh
, "lastReset",
9371 vty_out(vty
, " Last reset never\n");
9377 uptime
= bgp_clock();
9378 uptime
-= p
->resettime
;
9379 tm
= gmtime(&uptime
);
9380 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
9382 + (tm
->tm_min
* 60000)
9383 + (tm
->tm_hour
* 3600000));
9384 json_object_string_add(
9385 json_neigh
, "lastResetDueTo",
9386 peer_down_str
[(int)p
->last_reset
]);
9387 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9388 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9389 char errorcodesubcode_hexstr
[5];
9390 char errorcodesubcode_str
[256];
9392 code_str
= bgp_notify_code_str(p
->notify
.code
);
9393 subcode_str
= bgp_notify_subcode_str(
9394 p
->notify
.code
, p
->notify
.subcode
);
9396 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
9397 p
->notify
.code
, p
->notify
.subcode
);
9398 json_object_string_add(json_neigh
,
9399 "lastErrorCodeSubcode",
9400 errorcodesubcode_hexstr
);
9401 snprintf(errorcodesubcode_str
, 255, "%s%s",
9402 code_str
, subcode_str
);
9403 json_object_string_add(json_neigh
,
9404 "lastNotificationReason",
9405 errorcodesubcode_str
);
9406 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
9407 && p
->notify
.code
== BGP_NOTIFY_CEASE
9408 && (p
->notify
.subcode
9409 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9410 || p
->notify
.subcode
9411 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
9412 && p
->notify
.length
) {
9414 const char *msg_str
;
9416 msg_str
= bgp_notify_admin_message(
9417 msgbuf
, sizeof(msgbuf
),
9418 (u_char
*)p
->notify
.data
,
9421 json_object_string_add(
9423 "lastShutdownDescription",
9428 vty_out(vty
, " Last reset %s, ",
9429 peer_uptime(p
->resettime
, timebuf
,
9430 BGP_UPTIME_LEN
, 0, NULL
));
9432 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9433 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9434 code_str
= bgp_notify_code_str(p
->notify
.code
);
9435 subcode_str
= bgp_notify_subcode_str(
9436 p
->notify
.code
, p
->notify
.subcode
);
9437 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
9438 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
9441 code_str
, subcode_str
);
9442 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
9443 && p
->notify
.code
== BGP_NOTIFY_CEASE
9444 && (p
->notify
.subcode
9445 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9446 || p
->notify
.subcode
9447 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
9448 && p
->notify
.length
) {
9450 const char *msg_str
;
9452 msg_str
= bgp_notify_admin_message(
9453 msgbuf
, sizeof(msgbuf
),
9454 (u_char
*)p
->notify
.data
,
9458 " Message: \"%s\"\n",
9462 vty_out(vty
, "due to %s\n",
9463 peer_down_str
[(int)p
->last_reset
]);
9466 if (p
->last_reset_cause_size
) {
9467 msg
= p
->last_reset_cause
;
9469 " Message received that caused BGP to send a NOTIFICATION:\n ");
9470 for (i
= 1; i
<= p
->last_reset_cause_size
;
9472 vty_out(vty
, "%02X", *msg
++);
9474 if (i
!= p
->last_reset_cause_size
) {
9476 vty_out(vty
, "\n ");
9477 } else if (i
% 4 == 0) {
9487 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
9489 json_object_boolean_true_add(json_neigh
,
9490 "prefixesConfigExceedMax");
9493 " Peer had exceeded the max. no. of prefixes configured.\n");
9495 if (p
->t_pmax_restart
) {
9497 json_object_boolean_true_add(
9498 json_neigh
, "reducePrefixNumFrom");
9499 json_object_int_add(json_neigh
,
9500 "restartInTimerMsec",
9501 thread_timer_remain_second(
9506 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
9507 p
->host
, thread_timer_remain_second(
9508 p
->t_pmax_restart
));
9511 json_object_boolean_true_add(
9513 "reducePrefixNumAndClearIpBgp");
9516 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
9521 /* EBGP Multihop and GTSM */
9522 if (p
->sort
!= BGP_PEER_IBGP
) {
9524 if (p
->gtsm_hops
> 0)
9525 json_object_int_add(json_neigh
,
9526 "externalBgpNbrMaxHopsAway",
9528 else if (p
->ttl
> 1)
9529 json_object_int_add(json_neigh
,
9530 "externalBgpNbrMaxHopsAway",
9533 if (p
->gtsm_hops
> 0)
9535 " External BGP neighbor may be up to %d hops away.\n",
9537 else if (p
->ttl
> 1)
9539 " External BGP neighbor may be up to %d hops away.\n",
9543 if (p
->gtsm_hops
> 0) {
9545 json_object_int_add(json_neigh
,
9546 "internalBgpNbrMaxHopsAway",
9550 " Internal BGP neighbor may be up to %d hops away.\n",
9555 /* Local address. */
9558 json_object_string_add(json_neigh
, "hostLocal",
9559 sockunion2str(p
->su_local
, buf1
,
9561 json_object_int_add(json_neigh
, "portLocal",
9562 ntohs(p
->su_local
->sin
.sin_port
));
9564 vty_out(vty
, "Local host: %s, Local port: %d\n",
9565 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
9566 ntohs(p
->su_local
->sin
.sin_port
));
9569 /* Remote address. */
9572 json_object_string_add(json_neigh
, "hostForeign",
9573 sockunion2str(p
->su_remote
, buf1
,
9575 json_object_int_add(json_neigh
, "portForeign",
9576 ntohs(p
->su_remote
->sin
.sin_port
));
9578 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
9579 sockunion2str(p
->su_remote
, buf1
,
9581 ntohs(p
->su_remote
->sin
.sin_port
));
9584 /* Nexthop display. */
9587 json_object_string_add(json_neigh
, "nexthop",
9589 &p
->nexthop
.v4
, buf1
,
9591 json_object_string_add(json_neigh
, "nexthopGlobal",
9593 &p
->nexthop
.v6_global
,
9594 buf1
, sizeof(buf1
)));
9595 json_object_string_add(json_neigh
, "nexthopLocal",
9597 &p
->nexthop
.v6_local
,
9598 buf1
, sizeof(buf1
)));
9599 if (p
->shared_network
)
9600 json_object_string_add(json_neigh
,
9604 json_object_string_add(json_neigh
,
9606 "nonSharedNetwork");
9608 vty_out(vty
, "Nexthop: %s\n",
9609 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
9611 vty_out(vty
, "Nexthop global: %s\n",
9612 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
9614 vty_out(vty
, "Nexthop local: %s\n",
9615 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
9617 vty_out(vty
, "BGP connection: %s\n",
9618 p
->shared_network
? "shared network"
9619 : "non shared network");
9623 /* Timer information. */
9625 json_object_int_add(json_neigh
, "connectRetryTimer",
9627 if (p
->status
== Established
&& p
->rtt
)
9628 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
9631 json_object_int_add(
9632 json_neigh
, "nextStartTimerDueInMsecs",
9633 thread_timer_remain_second(p
->t_start
) * 1000);
9635 json_object_int_add(
9636 json_neigh
, "nextConnectTimerDueInMsecs",
9637 thread_timer_remain_second(p
->t_connect
)
9639 if (p
->t_routeadv
) {
9640 json_object_int_add(json_neigh
, "mraiInterval",
9642 json_object_int_add(
9643 json_neigh
, "mraiTimerExpireInMsecs",
9644 thread_timer_remain_second(p
->t_routeadv
)
9648 json_object_int_add(json_neigh
, "authenticationEnabled",
9652 json_object_string_add(json_neigh
, "readThread", "on");
9654 json_object_string_add(json_neigh
, "readThread", "off");
9656 json_object_string_add(json_neigh
, "writeThread", "on");
9658 json_object_string_add(json_neigh
, "writeThread",
9661 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
9663 if (p
->status
== Established
&& p
->rtt
)
9664 vty_out(vty
, "Estimated round trip time: %d ms\n",
9667 vty_out(vty
, "Next start timer due in %ld seconds\n",
9668 thread_timer_remain_second(p
->t_start
));
9670 vty_out(vty
, "Next connect timer due in %ld seconds\n",
9671 thread_timer_remain_second(p
->t_connect
));
9674 "MRAI (interval %u) timer expires in %ld seconds\n",
9676 thread_timer_remain_second(p
->t_routeadv
));
9678 vty_out(vty
, "Peer Authentication Enabled\n");
9680 vty_out(vty
, "Read thread: %s Write thread: %s\n",
9681 p
->t_read
? "on" : "off", p
->t_write
? "on" : "off");
9684 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
9685 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
9686 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
9691 /* BFD information. */
9692 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
9695 if (p
->conf_if
) /* Configured interface name. */
9696 json_object_object_add(json
, p
->conf_if
, json_neigh
);
9697 else /* Configured IP address. */
9698 json_object_object_add(json
, p
->host
, json_neigh
);
9702 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
9703 enum show_type type
, union sockunion
*su
,
9704 const char *conf_if
, u_char use_json
,
9707 struct listnode
*node
, *nnode
;
9711 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9712 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9717 bgp_show_peer(vty
, peer
, use_json
, json
);
9722 && !strcmp(peer
->conf_if
, conf_if
))
9724 && !strcmp(peer
->hostname
, conf_if
))) {
9726 bgp_show_peer(vty
, peer
, use_json
,
9730 if (sockunion_same(&peer
->su
, su
)) {
9732 bgp_show_peer(vty
, peer
, use_json
,
9740 if (type
== show_peer
&& !find
) {
9742 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
9744 vty_out(vty
, "%% No such neighbor\n");
9748 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9749 json
, JSON_C_TO_STRING_PRETTY
));
9750 json_object_free(json
);
9758 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
9761 struct listnode
*node
, *nnode
;
9763 json_object
*json
= NULL
;
9767 vty_out(vty
, "{\n");
9769 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
9771 if (!(json
= json_object_new_object())) {
9773 "Unable to allocate memory for JSON object");
9775 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
9779 json_object_int_add(json
, "vrfId",
9780 (bgp
->vrf_id
== VRF_UNKNOWN
)
9783 json_object_string_add(
9785 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9790 vty_out(vty
, ",\n");
9794 vty_out(vty
, "\"%s\":",
9795 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9799 vty_out(vty
, "\nInstance %s:\n",
9800 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9804 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
, use_json
,
9809 vty_out(vty
, "}\n");
9812 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
9813 enum show_type type
, const char *ip_str
,
9819 json_object
*json
= NULL
;
9822 if (strmatch(name
, "all")) {
9823 bgp_show_all_instances_neighbors_vty(vty
, use_json
);
9826 bgp
= bgp_lookup_by_name(name
);
9829 json
= json_object_new_object();
9830 json_object_boolean_true_add(
9831 json
, "bgpNoSuchInstance");
9832 vty_out(vty
, "%s\n",
9833 json_object_to_json_string_ext(
9835 JSON_C_TO_STRING_PRETTY
));
9836 json_object_free(json
);
9839 "%% No such BGP instance exist\n");
9845 bgp
= bgp_get_default();
9849 json
= json_object_new_object();
9851 ret
= str2sockunion(ip_str
, &su
);
9853 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
9856 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
9859 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
9862 json_object_free(json
);
9868 /* "show [ip] bgp neighbors" commands. */
9869 DEFUN (show_ip_bgp_neighbors
,
9870 show_ip_bgp_neighbors_cmd
,
9871 "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]",
9875 BGP_INSTANCE_HELP_STR
9879 "Display information about all VPNv4 NLRIs\n"
9880 "Display information for a route distinguisher\n"
9881 "VPN Route Distinguisher\n"
9882 "Detailed information on TCP and BGP neighbor connections\n"
9883 "Neighbor to display information about\n"
9884 "Neighbor to display information about\n"
9885 "Neighbor on BGP configured interface\n"
9889 char *sh_arg
= NULL
;
9890 enum show_type sh_type
;
9892 u_char uj
= use_json(argc
, argv
);
9896 if (argv_find(argv
, argc
, "view", &idx
)
9897 || argv_find(argv
, argc
, "vrf", &idx
))
9898 vrf
= argv
[idx
+ 1]->arg
;
9901 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
9902 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
9903 || argv_find(argv
, argc
, "WORD", &idx
)) {
9904 sh_type
= show_peer
;
9905 sh_arg
= argv
[idx
]->arg
;
9909 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
9912 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
9913 paths' and `show ip mbgp paths'. Those functions results are the
9915 DEFUN (show_ip_bgp_paths
,
9916 show_ip_bgp_paths_cmd
,
9917 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
9922 "Path information\n")
9924 vty_out(vty
, "Address Refcnt Path\n");
9925 aspath_print_all_vty(vty
);
9931 static void community_show_all_iterator(struct hash_backet
*backet
,
9934 struct community
*com
;
9936 com
= (struct community
*)backet
->data
;
9937 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
9938 community_str(com
));
9941 /* Show BGP's community internal data. */
9942 DEFUN (show_ip_bgp_community_info
,
9943 show_ip_bgp_community_info_cmd
,
9944 "show [ip] bgp community-info",
9948 "List all bgp community information\n")
9950 vty_out(vty
, "Address Refcnt Community\n");
9952 hash_iterate(community_hash(),
9953 (void (*)(struct hash_backet
*,
9954 void *))community_show_all_iterator
,
9960 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
9963 struct lcommunity
*lcom
;
9965 lcom
= (struct lcommunity
*)backet
->data
;
9966 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
9967 lcommunity_str(lcom
));
9970 /* Show BGP's community internal data. */
9971 DEFUN (show_ip_bgp_lcommunity_info
,
9972 show_ip_bgp_lcommunity_info_cmd
,
9973 "show ip bgp large-community-info",
9977 "List all bgp large-community information\n")
9979 vty_out(vty
, "Address Refcnt Large-community\n");
9981 hash_iterate(lcommunity_hash(),
9982 (void (*)(struct hash_backet
*,
9983 void *))lcommunity_show_all_iterator
,
9990 DEFUN (show_ip_bgp_attr_info
,
9991 show_ip_bgp_attr_info_cmd
,
9992 "show [ip] bgp attribute-info",
9996 "List all bgp attribute information\n")
10002 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
10005 struct listnode
*node
, *nnode
;
10008 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10009 vty_out(vty
, "\nInstance %s:\n",
10010 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10013 update_group_show(bgp
, afi
, safi
, vty
, 0);
10017 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
10018 int safi
, uint64_t subgrp_id
)
10023 if (strmatch(name
, "all")) {
10024 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
10025 return CMD_SUCCESS
;
10027 bgp
= bgp_lookup_by_name(name
);
10030 bgp
= bgp_get_default();
10034 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
10035 return CMD_SUCCESS
;
10038 DEFUN (show_ip_bgp_updgrps
,
10039 show_ip_bgp_updgrps_cmd
,
10040 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
10044 BGP_INSTANCE_HELP_STR
10046 BGP_SAFI_WITH_LABEL_HELP_STR
10047 "Detailed info about dynamic update groups\n"
10048 "Specific subgroup to display detailed info for\n")
10051 afi_t afi
= AFI_IP6
;
10052 safi_t safi
= SAFI_UNICAST
;
10053 uint64_t subgrp_id
= 0;
10057 /* show [ip] bgp */
10058 if (argv_find(argv
, argc
, "ip", &idx
))
10060 /* [<view|vrf> VIEWVRFNAME] */
10061 if (argv_find(argv
, argc
, "view", &idx
)
10062 || argv_find(argv
, argc
, "vrf", &idx
))
10063 vrf
= argv
[++idx
]->arg
;
10064 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10065 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
10066 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10069 /* get subgroup id, if provided */
10071 if (argv
[idx
]->type
== VARIABLE_TKN
)
10072 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
10074 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
10077 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
10078 show_bgp_instance_all_ipv6_updgrps_cmd
,
10079 "show [ip] bgp <view|vrf> all update-groups",
10083 BGP_INSTANCE_ALL_HELP_STR
10084 "Detailed info about dynamic update groups\n")
10086 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
10087 return CMD_SUCCESS
;
10090 DEFUN (show_bgp_updgrps_stats
,
10091 show_bgp_updgrps_stats_cmd
,
10092 "show [ip] bgp update-groups statistics",
10096 "Detailed info about dynamic update groups\n"
10101 bgp
= bgp_get_default();
10103 update_group_show_stats(bgp
, vty
);
10105 return CMD_SUCCESS
;
10108 DEFUN (show_bgp_instance_updgrps_stats
,
10109 show_bgp_instance_updgrps_stats_cmd
,
10110 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
10114 BGP_INSTANCE_HELP_STR
10115 "Detailed info about dynamic update groups\n"
10121 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
10123 update_group_show_stats(bgp
, vty
);
10125 return CMD_SUCCESS
;
10128 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
10129 afi_t afi
, safi_t safi
,
10130 const char *what
, uint64_t subgrp_id
)
10135 bgp
= bgp_lookup_by_name(name
);
10137 bgp
= bgp_get_default();
10140 if (!strcmp(what
, "advertise-queue"))
10141 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
10143 else if (!strcmp(what
, "advertised-routes"))
10144 update_group_show_advertised(bgp
, afi
, safi
, vty
,
10146 else if (!strcmp(what
, "packet-queue"))
10147 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
10152 DEFUN (show_ip_bgp_updgrps_adj
,
10153 show_ip_bgp_updgrps_adj_cmd
,
10154 "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
10158 "Detailed info about dynamic update groups\n"
10159 "Advertisement queue\n"
10160 "Announced routes\n"
10164 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10165 argv
[idx_type
]->arg
, 0);
10166 return CMD_SUCCESS
;
10169 DEFUN (show_ip_bgp_instance_updgrps_adj
,
10170 show_ip_bgp_instance_updgrps_adj_cmd
,
10171 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>",
10175 BGP_INSTANCE_HELP_STR
10176 "Detailed info about dynamic update groups\n"
10177 "Advertisement queue\n"
10178 "Announced routes\n"
10183 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_word
]->arg
, AFI_IP
,
10184 SAFI_UNICAST
, argv
[idx_type
]->arg
, 0);
10185 return CMD_SUCCESS
;
10188 DEFUN (show_bgp_updgrps_afi_adj
,
10189 show_bgp_updgrps_afi_adj_cmd
,
10190 "show [ip] bgp "BGP_AFI_SAFI_CMD_STR
" update-groups <advertise-queue|advertised-routes|packet-queue>",
10194 BGP_AFI_SAFI_HELP_STR
10195 "Detailed info about dynamic update groups\n"
10196 "Advertisement queue\n"
10197 "Announced routes\n"
10203 show_bgp_updgrps_adj_info_aux(
10204 vty
, NULL
, bgp_vty_afi_from_str(argv
[idx_afi
]->text
),
10205 bgp_vty_safi_from_str(argv
[idx_safi
]->text
),
10206 argv
[idx_type
]->arg
, 0);
10207 return CMD_SUCCESS
;
10210 DEFUN (show_bgp_updgrps_adj
,
10211 show_bgp_updgrps_adj_cmd
,
10212 "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
10216 "Detailed info about dynamic update groups\n"
10217 "Advertisement queue\n"
10218 "Announced routes\n"
10222 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10223 argv
[idx_type
]->arg
, 0);
10224 return CMD_SUCCESS
;
10227 DEFUN (show_bgp_instance_updgrps_adj
,
10228 show_bgp_instance_updgrps_adj_cmd
,
10229 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>",
10233 BGP_INSTANCE_HELP_STR
10234 "Detailed info about dynamic update groups\n"
10235 "Advertisement queue\n"
10236 "Announced routes\n"
10241 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_word
]->arg
, AFI_IP6
,
10242 SAFI_UNICAST
, argv
[idx_type
]->arg
, 0);
10243 return CMD_SUCCESS
;
10246 DEFUN (show_ip_bgp_updgrps_adj_s
,
10247 show_ip_bgp_updgrps_adj_s_cmd
,
10248 "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10252 "Detailed info about dynamic update groups\n"
10253 "Specific subgroup to display info for\n"
10254 "Advertisement queue\n"
10255 "Announced routes\n"
10258 int idx_subgroup_id
= 4;
10260 uint64_t subgrp_id
;
10262 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10264 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10265 argv
[idx_type
]->arg
, subgrp_id
);
10266 return CMD_SUCCESS
;
10269 DEFUN (show_ip_bgp_instance_updgrps_adj_s
,
10270 show_ip_bgp_instance_updgrps_adj_s_cmd
,
10271 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10275 BGP_INSTANCE_HELP_STR
10276 "Detailed info about dynamic update groups\n"
10277 "Specific subgroup to display info for\n"
10278 "Advertisement queue\n"
10279 "Announced routes\n"
10283 int idx_subgroup_id
= 6;
10285 uint64_t subgrp_id
;
10287 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10289 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_vrf
]->arg
, AFI_IP
,
10290 SAFI_UNICAST
, argv
[idx_type
]->arg
,
10292 return CMD_SUCCESS
;
10295 DEFUN (show_bgp_updgrps_afi_adj_s
,
10296 show_bgp_updgrps_afi_adj_s_cmd
,
10297 "show [ip] bgp "BGP_AFI_SAFI_CMD_STR
" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10301 BGP_AFI_SAFI_HELP_STR
10302 "Detailed info about dynamic update groups\n"
10303 "Specific subgroup to display info for\n"
10304 "Advertisement queue\n"
10305 "Announced routes\n"
10310 int idx_subgroup_id
= 5;
10312 uint64_t subgrp_id
;
10314 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10316 show_bgp_updgrps_adj_info_aux(
10317 vty
, NULL
, bgp_vty_afi_from_str(argv
[idx_afi
]->text
),
10318 bgp_vty_safi_from_str(argv
[idx_safi
]->text
),
10319 argv
[idx_type
]->arg
, subgrp_id
);
10320 return CMD_SUCCESS
;
10323 DEFUN (show_bgp_updgrps_adj_s
,
10324 show_bgp_updgrps_adj_s_cmd
,
10325 "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10329 "Detailed info about dynamic update groups\n"
10330 "Specific subgroup to display info for\n"
10331 "Advertisement queue\n"
10332 "Announced routes\n"
10335 int idx_subgroup_id
= 3;
10337 uint64_t subgrp_id
;
10339 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10341 show_bgp_updgrps_adj_info_aux(vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10342 argv
[idx_type
]->arg
, subgrp_id
);
10343 return CMD_SUCCESS
;
10346 DEFUN (show_bgp_instance_updgrps_adj_s
,
10347 show_bgp_instance_updgrps_adj_s_cmd
,
10348 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
10352 BGP_INSTANCE_HELP_STR
10353 "Detailed info about dynamic update groups\n"
10354 "Specific subgroup to display info for\n"
10355 "Advertisement queue\n"
10356 "Announced routes\n"
10360 int idx_subgroup_id
= 5;
10362 uint64_t subgrp_id
;
10364 subgrp_id
= strtoull(argv
[idx_subgroup_id
]->arg
, NULL
, 10);
10366 show_bgp_updgrps_adj_info_aux(vty
, argv
[idx_vrf
]->arg
, AFI_IP6
,
10367 SAFI_UNICAST
, argv
[idx_type
]->arg
,
10369 return CMD_SUCCESS
;
10373 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
10375 struct listnode
*node
, *nnode
;
10376 struct prefix
*range
;
10379 char buf
[PREFIX2STR_BUFFER
];
10382 const char *peer_status
;
10383 const char *af_str
;
10388 conf
= group
->conf
;
10390 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
10391 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10393 } else if (conf
->as_type
== AS_INTERNAL
) {
10394 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
10397 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
10400 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
10401 vty_out(vty
, " Peer-group type is internal\n");
10403 vty_out(vty
, " Peer-group type is external\n");
10405 /* Display AFs configured. */
10406 vty_out(vty
, " Configured address-families:");
10407 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
10408 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++) {
10409 if (conf
->afc
[afi
][safi
]) {
10411 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
10415 vty_out(vty
, " none\n");
10417 vty_out(vty
, "\n");
10419 /* Display listen ranges (for dynamic neighbors), if any */
10420 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
10423 else if (afi
== AFI_IP6
)
10427 lr_count
= listcount(group
->listen_range
[afi
]);
10429 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
10433 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
10435 prefix2str(range
, buf
, sizeof(buf
));
10436 vty_out(vty
, " %s\n", buf
);
10441 /* Display group members and their status */
10442 if (listcount(group
->peer
)) {
10443 vty_out(vty
, " Peer-group members:\n");
10444 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
10445 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
10446 peer_status
= "Idle (Admin)";
10447 else if (CHECK_FLAG(peer
->sflags
,
10448 PEER_STATUS_PREFIX_OVERFLOW
))
10449 peer_status
= "Idle (PfxCt)";
10451 peer_status
= lookup_msg(bgp_status_msg
,
10452 peer
->status
, NULL
);
10454 dynamic
= peer_dynamic_neighbor(peer
);
10455 vty_out(vty
, " %s %s %s \n", peer
->host
,
10456 dynamic
? "(dynamic)" : "", peer_status
);
10460 return CMD_SUCCESS
;
10463 /* Show BGP peer group's information. */
10464 enum show_group_type
{ show_all_groups
, show_peer_group
};
10466 static int bgp_show_peer_group(struct vty
*vty
, struct bgp
*bgp
,
10467 enum show_group_type type
,
10468 const char *group_name
)
10470 struct listnode
*node
, *nnode
;
10471 struct peer_group
*group
;
10474 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
10476 case show_all_groups
:
10477 bgp_show_one_peer_group(vty
, group
);
10479 case show_peer_group
:
10481 && (strcmp(group
->name
, group_name
) == 0)) {
10483 bgp_show_one_peer_group(vty
, group
);
10489 if (type
== show_peer_group
&& !find
)
10490 vty_out(vty
, "%% No such peer-group\n");
10492 return CMD_SUCCESS
;
10495 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
10496 enum show_group_type type
,
10497 const char *group_name
)
10500 int ret
= CMD_SUCCESS
;
10503 bgp
= bgp_lookup_by_name(name
);
10505 bgp
= bgp_get_default();
10508 vty_out(vty
, "%% No such BGP instance exist\n");
10509 return CMD_WARNING
;
10512 ret
= bgp_show_peer_group(vty
, bgp
, type
, group_name
);
10517 DEFUN (show_ip_bgp_peer_groups
,
10518 show_ip_bgp_peer_groups_cmd
,
10519 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
10523 BGP_INSTANCE_HELP_STR
10524 "Detailed information on BGP peer groups\n"
10525 "Peer group name\n")
10531 vrf
= argv_find(argv
, argc
, "WORD", &idx
) ? argv
[idx
]->arg
: NULL
;
10532 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
10534 return bgp_show_peer_group_vty(vty
, vrf
, show_all_groups
, pg
);
10538 /* Redistribute VTY commands. */
10540 DEFUN (bgp_redistribute_ipv4
,
10541 bgp_redistribute_ipv4_cmd
,
10542 "redistribute " FRR_IP_REDIST_STR_BGPD
,
10543 "Redistribute information from another routing protocol\n"
10544 FRR_IP_REDIST_HELP_STR_BGPD
)
10546 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10547 int idx_protocol
= 1;
10550 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10552 vty_out(vty
, "%% Invalid route type\n");
10553 return CMD_WARNING_CONFIG_FAILED
;
10556 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10557 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10561 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
10562 "redistribute " FRR_IP_REDIST_STR_BGPD
,
10563 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
10565 DEFUN (bgp_redistribute_ipv4_rmap
,
10566 bgp_redistribute_ipv4_rmap_cmd
,
10567 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
10568 "Redistribute information from another routing protocol\n"
10569 FRR_IP_REDIST_HELP_STR_BGPD
10570 "Route map reference\n"
10571 "Pointer to route-map entries\n")
10573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10574 int idx_protocol
= 1;
10577 struct bgp_redist
*red
;
10579 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10581 vty_out(vty
, "%% Invalid route type\n");
10582 return CMD_WARNING_CONFIG_FAILED
;
10585 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10586 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10587 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10591 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
10592 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
10593 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10594 "Route map reference\n"
10595 "Pointer to route-map entries\n")
10597 DEFUN (bgp_redistribute_ipv4_metric
,
10598 bgp_redistribute_ipv4_metric_cmd
,
10599 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
10600 "Redistribute information from another routing protocol\n"
10601 FRR_IP_REDIST_HELP_STR_BGPD
10602 "Metric for redistributed routes\n"
10603 "Default metric\n")
10605 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10606 int idx_protocol
= 1;
10607 int idx_number
= 3;
10610 struct bgp_redist
*red
;
10612 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10614 vty_out(vty
, "%% Invalid route type\n");
10615 return CMD_WARNING_CONFIG_FAILED
;
10617 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10619 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10620 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
10621 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10625 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
10626 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
10627 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10628 "Metric for redistributed routes\n"
10629 "Default metric\n")
10631 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
10632 bgp_redistribute_ipv4_rmap_metric_cmd
,
10633 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
10634 "Redistribute information from another routing protocol\n"
10635 FRR_IP_REDIST_HELP_STR_BGPD
10636 "Route map reference\n"
10637 "Pointer to route-map entries\n"
10638 "Metric for redistributed routes\n"
10639 "Default metric\n")
10641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10642 int idx_protocol
= 1;
10644 int idx_number
= 5;
10647 struct bgp_redist
*red
;
10649 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10651 vty_out(vty
, "%% Invalid route type\n");
10652 return CMD_WARNING_CONFIG_FAILED
;
10654 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10656 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10657 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10658 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
10659 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10663 bgp_redistribute_ipv4_rmap_metric
,
10664 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
10665 "redistribute " FRR_IP_REDIST_STR_BGPD
10666 " route-map WORD metric (0-4294967295)",
10667 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10668 "Route map reference\n"
10669 "Pointer to route-map entries\n"
10670 "Metric for redistributed routes\n"
10671 "Default metric\n")
10673 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
10674 bgp_redistribute_ipv4_metric_rmap_cmd
,
10675 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
10676 "Redistribute information from another routing protocol\n"
10677 FRR_IP_REDIST_HELP_STR_BGPD
10678 "Metric for redistributed routes\n"
10680 "Route map reference\n"
10681 "Pointer to route-map entries\n")
10683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10684 int idx_protocol
= 1;
10685 int idx_number
= 3;
10689 struct bgp_redist
*red
;
10691 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10693 vty_out(vty
, "%% Invalid route type\n");
10694 return CMD_WARNING_CONFIG_FAILED
;
10696 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10698 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
10699 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
10700 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10701 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
10705 bgp_redistribute_ipv4_metric_rmap
,
10706 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
10707 "redistribute " FRR_IP_REDIST_STR_BGPD
10708 " metric (0-4294967295) route-map WORD",
10709 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10710 "Metric for redistributed routes\n"
10712 "Route map reference\n"
10713 "Pointer to route-map entries\n")
10715 DEFUN (bgp_redistribute_ipv4_ospf
,
10716 bgp_redistribute_ipv4_ospf_cmd
,
10717 "redistribute <ospf|table> (1-65535)",
10718 "Redistribute information from another routing protocol\n"
10719 "Open Shortest Path First (OSPFv2)\n"
10720 "Non-main Kernel Routing Table\n"
10721 "Instance ID/Table ID\n")
10723 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10724 int idx_ospf_table
= 1;
10725 int idx_number
= 2;
10729 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10731 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10732 protocol
= ZEBRA_ROUTE_OSPF
;
10734 protocol
= ZEBRA_ROUTE_TABLE
;
10736 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10737 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10740 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
10741 "redistribute <ospf|table> (1-65535)",
10742 "Redistribute information from another routing protocol\n"
10743 "Open Shortest Path First (OSPFv2)\n"
10744 "Non-main Kernel Routing Table\n"
10745 "Instance ID/Table ID\n")
10747 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
10748 bgp_redistribute_ipv4_ospf_rmap_cmd
,
10749 "redistribute <ospf|table> (1-65535) route-map WORD",
10750 "Redistribute information from another routing protocol\n"
10751 "Open Shortest Path First (OSPFv2)\n"
10752 "Non-main Kernel Routing Table\n"
10753 "Instance ID/Table ID\n"
10754 "Route map reference\n"
10755 "Pointer to route-map entries\n")
10757 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10758 int idx_ospf_table
= 1;
10759 int idx_number
= 2;
10761 struct bgp_redist
*red
;
10765 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10766 protocol
= ZEBRA_ROUTE_OSPF
;
10768 protocol
= ZEBRA_ROUTE_TABLE
;
10770 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10771 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10772 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10773 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10776 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
10777 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
10778 "redistribute <ospf|table> (1-65535) route-map WORD",
10779 "Redistribute information from another routing protocol\n"
10780 "Open Shortest Path First (OSPFv2)\n"
10781 "Non-main Kernel Routing Table\n"
10782 "Instance ID/Table ID\n"
10783 "Route map reference\n"
10784 "Pointer to route-map entries\n")
10786 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
10787 bgp_redistribute_ipv4_ospf_metric_cmd
,
10788 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
10789 "Redistribute information from another routing protocol\n"
10790 "Open Shortest Path First (OSPFv2)\n"
10791 "Non-main Kernel Routing Table\n"
10792 "Instance ID/Table ID\n"
10793 "Metric for redistributed routes\n"
10794 "Default metric\n")
10796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10797 int idx_ospf_table
= 1;
10798 int idx_number
= 2;
10799 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 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10818 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
10819 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
10820 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
10821 "Redistribute information from another routing protocol\n"
10822 "Open Shortest Path First (OSPFv2)\n"
10823 "Non-main Kernel Routing Table\n"
10824 "Instance ID/Table ID\n"
10825 "Metric for redistributed routes\n"
10826 "Default metric\n")
10828 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
10829 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
10830 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
10831 "Redistribute information from another routing protocol\n"
10832 "Open Shortest Path First (OSPFv2)\n"
10833 "Non-main Kernel Routing Table\n"
10834 "Instance ID/Table ID\n"
10835 "Route map reference\n"
10836 "Pointer to route-map entries\n"
10837 "Metric for redistributed routes\n"
10838 "Default metric\n")
10840 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10841 int idx_ospf_table
= 1;
10842 int idx_number
= 2;
10844 int idx_number_2
= 6;
10846 struct bgp_redist
*red
;
10850 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10851 protocol
= ZEBRA_ROUTE_OSPF
;
10853 protocol
= ZEBRA_ROUTE_TABLE
;
10855 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10856 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
10858 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10859 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10860 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
10861 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10865 bgp_redistribute_ipv4_ospf_rmap_metric
,
10866 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
10867 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
10868 "Redistribute information from another routing protocol\n"
10869 "Open Shortest Path First (OSPFv2)\n"
10870 "Non-main Kernel Routing Table\n"
10871 "Instance ID/Table ID\n"
10872 "Route map reference\n"
10873 "Pointer to route-map entries\n"
10874 "Metric for redistributed routes\n"
10875 "Default metric\n")
10877 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
10878 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
10879 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
10880 "Redistribute information from another routing protocol\n"
10881 "Open Shortest Path First (OSPFv2)\n"
10882 "Non-main Kernel Routing Table\n"
10883 "Instance ID/Table ID\n"
10884 "Metric for redistributed routes\n"
10886 "Route map reference\n"
10887 "Pointer to route-map entries\n")
10889 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10890 int idx_ospf_table
= 1;
10891 int idx_number
= 2;
10892 int idx_number_2
= 4;
10895 struct bgp_redist
*red
;
10899 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10900 protocol
= ZEBRA_ROUTE_OSPF
;
10902 protocol
= ZEBRA_ROUTE_TABLE
;
10904 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10905 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
10907 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
10908 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
10909 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
10910 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
10914 bgp_redistribute_ipv4_ospf_metric_rmap
,
10915 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
10916 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
10917 "Redistribute information from another routing protocol\n"
10918 "Open Shortest Path First (OSPFv2)\n"
10919 "Non-main Kernel Routing Table\n"
10920 "Instance ID/Table ID\n"
10921 "Metric for redistributed routes\n"
10923 "Route map reference\n"
10924 "Pointer to route-map entries\n")
10926 DEFUN (no_bgp_redistribute_ipv4_ospf
,
10927 no_bgp_redistribute_ipv4_ospf_cmd
,
10928 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
10930 "Redistribute information from another routing protocol\n"
10931 "Open Shortest Path First (OSPFv2)\n"
10932 "Non-main Kernel Routing Table\n"
10933 "Instance ID/Table ID\n"
10934 "Metric for redistributed routes\n"
10936 "Route map reference\n"
10937 "Pointer to route-map entries\n")
10939 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10940 int idx_ospf_table
= 2;
10941 int idx_number
= 3;
10945 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
10946 protocol
= ZEBRA_ROUTE_OSPF
;
10948 protocol
= ZEBRA_ROUTE_TABLE
;
10950 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
10951 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
10955 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
10956 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
10958 "Redistribute information from another routing protocol\n"
10959 "Open Shortest Path First (OSPFv2)\n"
10960 "Non-main Kernel Routing Table\n"
10961 "Instance ID/Table ID\n"
10962 "Metric for redistributed routes\n"
10964 "Route map reference\n"
10965 "Pointer to route-map entries\n")
10967 DEFUN (no_bgp_redistribute_ipv4
,
10968 no_bgp_redistribute_ipv4_cmd
,
10969 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
10971 "Redistribute information from another routing protocol\n"
10972 FRR_IP_REDIST_HELP_STR_BGPD
10973 "Metric for redistributed routes\n"
10975 "Route map reference\n"
10976 "Pointer to route-map entries\n")
10978 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
10979 int idx_protocol
= 2;
10982 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
10984 vty_out(vty
, "%% Invalid route type\n");
10985 return CMD_WARNING_CONFIG_FAILED
;
10987 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
10991 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
10992 "no redistribute " FRR_IP_REDIST_STR_BGPD
10993 " [metric (0-4294967295)] [route-map WORD]",
10995 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
10996 "Metric for redistributed routes\n"
10998 "Route map reference\n"
10999 "Pointer to route-map entries\n")
11001 DEFUN (bgp_redistribute_ipv6
,
11002 bgp_redistribute_ipv6_cmd
,
11003 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11004 "Redistribute information from another routing protocol\n"
11005 FRR_IP6_REDIST_HELP_STR_BGPD
)
11007 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11008 int idx_protocol
= 1;
11011 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11013 vty_out(vty
, "%% Invalid route type\n");
11014 return CMD_WARNING_CONFIG_FAILED
;
11017 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11018 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11021 DEFUN (bgp_redistribute_ipv6_rmap
,
11022 bgp_redistribute_ipv6_rmap_cmd
,
11023 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
11024 "Redistribute information from another routing protocol\n"
11025 FRR_IP6_REDIST_HELP_STR_BGPD
11026 "Route map reference\n"
11027 "Pointer to route-map entries\n")
11029 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11030 int idx_protocol
= 1;
11033 struct bgp_redist
*red
;
11035 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11037 vty_out(vty
, "%% Invalid route type\n");
11038 return CMD_WARNING_CONFIG_FAILED
;
11041 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11042 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11043 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11046 DEFUN (bgp_redistribute_ipv6_metric
,
11047 bgp_redistribute_ipv6_metric_cmd
,
11048 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
11049 "Redistribute information from another routing protocol\n"
11050 FRR_IP6_REDIST_HELP_STR_BGPD
11051 "Metric for redistributed routes\n"
11052 "Default metric\n")
11054 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11055 int idx_protocol
= 1;
11056 int idx_number
= 3;
11059 struct bgp_redist
*red
;
11061 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11063 vty_out(vty
, "%% Invalid route type\n");
11064 return CMD_WARNING_CONFIG_FAILED
;
11066 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11068 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11069 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11070 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11073 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
11074 bgp_redistribute_ipv6_rmap_metric_cmd
,
11075 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11076 "Redistribute information from another routing protocol\n"
11077 FRR_IP6_REDIST_HELP_STR_BGPD
11078 "Route map reference\n"
11079 "Pointer to route-map entries\n"
11080 "Metric for redistributed routes\n"
11081 "Default metric\n")
11083 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11084 int idx_protocol
= 1;
11086 int idx_number
= 5;
11089 struct bgp_redist
*red
;
11091 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11093 vty_out(vty
, "%% Invalid route type\n");
11094 return CMD_WARNING_CONFIG_FAILED
;
11096 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11098 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11099 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11100 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11101 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11104 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
11105 bgp_redistribute_ipv6_metric_rmap_cmd
,
11106 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11107 "Redistribute information from another routing protocol\n"
11108 FRR_IP6_REDIST_HELP_STR_BGPD
11109 "Metric for redistributed routes\n"
11111 "Route map reference\n"
11112 "Pointer to route-map entries\n")
11114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11115 int idx_protocol
= 1;
11116 int idx_number
= 3;
11120 struct bgp_redist
*red
;
11122 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11124 vty_out(vty
, "%% Invalid route type\n");
11125 return CMD_WARNING_CONFIG_FAILED
;
11127 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11129 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11130 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
11131 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11132 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11135 DEFUN (no_bgp_redistribute_ipv6
,
11136 no_bgp_redistribute_ipv6_cmd
,
11137 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11139 "Redistribute information from another routing protocol\n"
11140 FRR_IP6_REDIST_HELP_STR_BGPD
11141 "Metric for redistributed routes\n"
11143 "Route map reference\n"
11144 "Pointer to route-map entries\n")
11146 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11147 int idx_protocol
= 2;
11150 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11152 vty_out(vty
, "%% Invalid route type\n");
11153 return CMD_WARNING_CONFIG_FAILED
;
11156 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
11159 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
11164 /* Unicast redistribution only. */
11165 if (safi
!= SAFI_UNICAST
)
11168 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
11169 /* Redistribute BGP does not make sense. */
11170 if (i
!= ZEBRA_ROUTE_BGP
) {
11171 struct list
*red_list
;
11172 struct listnode
*node
;
11173 struct bgp_redist
*red
;
11175 red_list
= bgp
->redist
[afi
][i
];
11179 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
11180 /* "redistribute" configuration. */
11181 vty_out(vty
, " redistribute %s",
11182 zebra_route_string(i
));
11184 vty_out(vty
, " %d", red
->instance
);
11185 if (red
->redist_metric_flag
)
11186 vty_out(vty
, " metric %u",
11187 red
->redist_metric
);
11188 if (red
->rmap
.name
)
11189 vty_out(vty
, " route-map %s",
11191 vty_out(vty
, "\n");
11197 /* BGP node structure. */
11198 static struct cmd_node bgp_node
= {
11199 BGP_NODE
, "%s(config-router)# ", 1,
11202 static struct cmd_node bgp_ipv4_unicast_node
= {
11203 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
11206 static struct cmd_node bgp_ipv4_multicast_node
= {
11207 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
11210 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
11211 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
11214 static struct cmd_node bgp_ipv6_unicast_node
= {
11215 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
11218 static struct cmd_node bgp_ipv6_multicast_node
= {
11219 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
11222 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
11223 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
11226 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
11227 "%s(config-router-af)# ", 1};
11229 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
11230 "%s(config-router-af-vpnv6)# ", 1};
11232 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
11233 "%s(config-router-evpn)# ", 1};
11235 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
11236 "%s(config-router-af-vni)# ", 1};
11238 static void community_list_vty(void);
11240 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
11244 struct peer_group
*group
;
11245 struct listnode
*lnbgp
, *lnpeer
;
11247 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
11248 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
11249 /* only provide suggestions on the appropriate input
11251 * they'll otherwise show up multiple times */
11252 enum cmd_token_type match_type
;
11253 char *name
= peer
->host
;
11255 if (peer
->conf_if
) {
11256 match_type
= VARIABLE_TKN
;
11257 name
= peer
->conf_if
;
11258 } else if (strchr(peer
->host
, ':'))
11259 match_type
= IPV6_TKN
;
11261 match_type
= IPV4_TKN
;
11263 if (token
->type
!= match_type
)
11266 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
11269 if (token
->type
== VARIABLE_TKN
)
11270 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
11271 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
11276 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
11277 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
11278 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
11279 {.completions
= NULL
}};
11281 void bgp_vty_init(void)
11283 cmd_variable_handler_register(bgp_var_neighbor
);
11285 /* Install bgp top node. */
11286 install_node(&bgp_node
, bgp_config_write
);
11287 install_node(&bgp_ipv4_unicast_node
, NULL
);
11288 install_node(&bgp_ipv4_multicast_node
, NULL
);
11289 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
11290 install_node(&bgp_ipv6_unicast_node
, NULL
);
11291 install_node(&bgp_ipv6_multicast_node
, NULL
);
11292 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
11293 install_node(&bgp_vpnv4_node
, NULL
);
11294 install_node(&bgp_vpnv6_node
, NULL
);
11295 install_node(&bgp_evpn_node
, NULL
);
11296 install_node(&bgp_evpn_vni_node
, NULL
);
11298 /* Install default VTY commands to new nodes. */
11299 install_default(BGP_NODE
);
11300 install_default(BGP_IPV4_NODE
);
11301 install_default(BGP_IPV4M_NODE
);
11302 install_default(BGP_IPV4L_NODE
);
11303 install_default(BGP_IPV6_NODE
);
11304 install_default(BGP_IPV6M_NODE
);
11305 install_default(BGP_IPV6L_NODE
);
11306 install_default(BGP_VPNV4_NODE
);
11307 install_default(BGP_VPNV6_NODE
);
11308 install_default(BGP_EVPN_NODE
);
11309 install_default(BGP_EVPN_VNI_NODE
);
11311 /* "bgp multiple-instance" commands. */
11312 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
11313 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
11315 /* "bgp config-type" commands. */
11316 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
11317 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
11319 /* bgp route-map delay-timer commands. */
11320 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
11321 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
11323 /* Dummy commands (Currently not supported) */
11324 install_element(BGP_NODE
, &no_synchronization_cmd
);
11325 install_element(BGP_NODE
, &no_auto_summary_cmd
);
11327 /* "router bgp" commands. */
11328 install_element(CONFIG_NODE
, &router_bgp_cmd
);
11330 /* "no router bgp" commands. */
11331 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
11333 /* "bgp router-id" commands. */
11334 install_element(BGP_NODE
, &bgp_router_id_cmd
);
11335 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
11337 /* "bgp cluster-id" commands. */
11338 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
11339 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
11341 /* "bgp confederation" commands. */
11342 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
11343 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
11345 /* "bgp confederation peers" commands. */
11346 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
11347 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
11349 /* bgp max-med command */
11350 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
11351 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
11352 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
11353 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
11354 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
11356 /* bgp disable-ebgp-connected-nh-check */
11357 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
11358 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
11360 /* bgp update-delay command */
11361 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
11362 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
11363 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
11365 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
11366 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
11368 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
11369 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
11371 /* "maximum-paths" commands. */
11372 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
11373 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
11374 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
11375 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
11376 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
11377 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
11378 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
11379 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
11380 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
11381 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
11382 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11383 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11384 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
11385 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11386 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11388 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
11389 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
11390 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
11391 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
11392 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
11394 /* "timers bgp" commands. */
11395 install_element(BGP_NODE
, &bgp_timers_cmd
);
11396 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
11398 /* route-map delay-timer commands - per instance for backwards compat.
11400 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
11401 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
11403 /* "bgp client-to-client reflection" commands */
11404 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
11405 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
11407 /* "bgp always-compare-med" commands */
11408 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
11409 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
11411 /* "bgp deterministic-med" commands */
11412 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
11413 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
11415 /* "bgp graceful-restart" commands */
11416 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
11417 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
11418 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
11419 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
11420 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
11421 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
11423 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
11424 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
11426 /* "bgp graceful-shutdown" commands */
11427 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
11428 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
11430 /* "bgp fast-external-failover" commands */
11431 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
11432 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
11434 /* "bgp enforce-first-as" commands */
11435 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
11436 install_element(BGP_NODE
, &no_bgp_enforce_first_as_cmd
);
11438 /* "bgp bestpath compare-routerid" commands */
11439 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
11440 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
11442 /* "bgp bestpath as-path ignore" commands */
11443 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
11444 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
11446 /* "bgp bestpath as-path confed" commands */
11447 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
11448 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
11450 /* "bgp bestpath as-path multipath-relax" commands */
11451 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
11452 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
11454 /* "bgp log-neighbor-changes" commands */
11455 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
11456 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
11458 /* "bgp bestpath med" commands */
11459 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
11460 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
11462 /* "no bgp default ipv4-unicast" commands. */
11463 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
11464 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
11466 /* "bgp network import-check" commands. */
11467 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
11468 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
11469 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
11471 /* "bgp default local-preference" commands. */
11472 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
11473 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
11475 /* bgp default show-hostname */
11476 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
11477 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
11479 /* "bgp default subgroup-pkt-queue-max" commands. */
11480 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
11481 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
11483 /* bgp ibgp-allow-policy-mods command */
11484 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
11485 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
11487 /* "bgp listen limit" commands. */
11488 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
11489 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
11491 /* "bgp listen range" commands. */
11492 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
11493 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
11495 /* "neighbor remote-as" commands. */
11496 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
11497 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
11498 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
11499 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
11500 install_element(BGP_NODE
,
11501 &neighbor_interface_v6only_config_remote_as_cmd
);
11502 install_element(BGP_NODE
, &no_neighbor_cmd
);
11503 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
11505 /* "neighbor peer-group" commands. */
11506 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
11507 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
11508 install_element(BGP_NODE
,
11509 &no_neighbor_interface_peer_group_remote_as_cmd
);
11511 /* "neighbor local-as" commands. */
11512 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
11513 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
11514 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
11515 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
11517 /* "neighbor solo" commands. */
11518 install_element(BGP_NODE
, &neighbor_solo_cmd
);
11519 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
11521 /* "neighbor password" commands. */
11522 install_element(BGP_NODE
, &neighbor_password_cmd
);
11523 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
11525 /* "neighbor activate" commands. */
11526 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
11527 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
11528 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
11529 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
11530 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
11531 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
11532 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
11533 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
11534 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
11535 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
11537 /* "no neighbor activate" commands. */
11538 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
11539 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
11540 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
11541 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
11542 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
11543 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
11544 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
11545 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
11546 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
11547 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
11549 /* "neighbor peer-group" set commands. */
11550 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
11551 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11552 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11553 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11554 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11555 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11556 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11557 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
11559 /* "no neighbor peer-group unset" commands. */
11560 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
11561 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11562 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11563 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11564 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11565 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11566 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11567 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
11569 /* "neighbor softreconfiguration inbound" commands.*/
11570 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
11571 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
11572 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
11573 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11574 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
11575 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11576 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
11577 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11578 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
11579 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11580 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
11581 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11582 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
11583 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11584 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
11585 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11586 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
11587 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
11589 /* "neighbor attribute-unchanged" commands. */
11590 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
11591 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
11592 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
11593 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
11594 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
11595 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
11596 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
11597 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
11598 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
11599 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
11600 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
11601 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
11602 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
11603 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
11604 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
11605 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
11606 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
11607 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
11609 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
11610 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
11612 /* "nexthop-local unchanged" commands */
11613 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
11614 install_element(BGP_IPV6_NODE
,
11615 &no_neighbor_nexthop_local_unchanged_cmd
);
11617 /* "neighbor next-hop-self" commands. */
11618 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
11619 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
11620 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
11621 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
11622 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
11623 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
11624 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
11625 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
11626 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
11627 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
11628 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
11629 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
11630 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
11631 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
11632 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
11633 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
11634 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
11635 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
11637 /* "neighbor next-hop-self force" commands. */
11638 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
11639 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
11640 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
11641 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11642 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
11643 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11644 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
11645 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11646 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
11647 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11648 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
11649 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11650 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
11651 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11652 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
11653 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11654 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
11655 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
11657 /* "neighbor as-override" commands. */
11658 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
11659 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
11660 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
11661 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
11662 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
11663 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
11664 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
11665 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
11666 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
11667 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
11668 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
11669 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
11670 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
11671 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
11672 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
11673 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
11674 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
11675 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
11677 /* "neighbor remove-private-AS" commands. */
11678 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
11679 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
11680 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
11681 install_element(BGP_NODE
,
11682 &no_neighbor_remove_private_as_all_hidden_cmd
);
11683 install_element(BGP_NODE
,
11684 &neighbor_remove_private_as_replace_as_hidden_cmd
);
11685 install_element(BGP_NODE
,
11686 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
11687 install_element(BGP_NODE
,
11688 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
11691 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
11692 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
11693 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
11694 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
11695 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11696 install_element(BGP_IPV4_NODE
,
11697 &neighbor_remove_private_as_replace_as_cmd
);
11698 install_element(BGP_IPV4_NODE
,
11699 &no_neighbor_remove_private_as_replace_as_cmd
);
11700 install_element(BGP_IPV4_NODE
,
11701 &neighbor_remove_private_as_all_replace_as_cmd
);
11702 install_element(BGP_IPV4_NODE
,
11703 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11704 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
11705 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
11706 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
11707 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11708 install_element(BGP_IPV4M_NODE
,
11709 &neighbor_remove_private_as_replace_as_cmd
);
11710 install_element(BGP_IPV4M_NODE
,
11711 &no_neighbor_remove_private_as_replace_as_cmd
);
11712 install_element(BGP_IPV4M_NODE
,
11713 &neighbor_remove_private_as_all_replace_as_cmd
);
11714 install_element(BGP_IPV4M_NODE
,
11715 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11716 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
11717 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
11718 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
11719 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11720 install_element(BGP_IPV4L_NODE
,
11721 &neighbor_remove_private_as_replace_as_cmd
);
11722 install_element(BGP_IPV4L_NODE
,
11723 &no_neighbor_remove_private_as_replace_as_cmd
);
11724 install_element(BGP_IPV4L_NODE
,
11725 &neighbor_remove_private_as_all_replace_as_cmd
);
11726 install_element(BGP_IPV4L_NODE
,
11727 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11728 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
11729 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
11730 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
11731 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11732 install_element(BGP_IPV6_NODE
,
11733 &neighbor_remove_private_as_replace_as_cmd
);
11734 install_element(BGP_IPV6_NODE
,
11735 &no_neighbor_remove_private_as_replace_as_cmd
);
11736 install_element(BGP_IPV6_NODE
,
11737 &neighbor_remove_private_as_all_replace_as_cmd
);
11738 install_element(BGP_IPV6_NODE
,
11739 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11740 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
11741 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
11742 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
11743 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11744 install_element(BGP_IPV6M_NODE
,
11745 &neighbor_remove_private_as_replace_as_cmd
);
11746 install_element(BGP_IPV6M_NODE
,
11747 &no_neighbor_remove_private_as_replace_as_cmd
);
11748 install_element(BGP_IPV6M_NODE
,
11749 &neighbor_remove_private_as_all_replace_as_cmd
);
11750 install_element(BGP_IPV6M_NODE
,
11751 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11752 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
11753 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
11754 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
11755 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11756 install_element(BGP_IPV6L_NODE
,
11757 &neighbor_remove_private_as_replace_as_cmd
);
11758 install_element(BGP_IPV6L_NODE
,
11759 &no_neighbor_remove_private_as_replace_as_cmd
);
11760 install_element(BGP_IPV6L_NODE
,
11761 &neighbor_remove_private_as_all_replace_as_cmd
);
11762 install_element(BGP_IPV6L_NODE
,
11763 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11764 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
11765 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
11766 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
11767 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11768 install_element(BGP_VPNV4_NODE
,
11769 &neighbor_remove_private_as_replace_as_cmd
);
11770 install_element(BGP_VPNV4_NODE
,
11771 &no_neighbor_remove_private_as_replace_as_cmd
);
11772 install_element(BGP_VPNV4_NODE
,
11773 &neighbor_remove_private_as_all_replace_as_cmd
);
11774 install_element(BGP_VPNV4_NODE
,
11775 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11776 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
11777 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
11778 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
11779 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
11780 install_element(BGP_VPNV6_NODE
,
11781 &neighbor_remove_private_as_replace_as_cmd
);
11782 install_element(BGP_VPNV6_NODE
,
11783 &no_neighbor_remove_private_as_replace_as_cmd
);
11784 install_element(BGP_VPNV6_NODE
,
11785 &neighbor_remove_private_as_all_replace_as_cmd
);
11786 install_element(BGP_VPNV6_NODE
,
11787 &no_neighbor_remove_private_as_all_replace_as_cmd
);
11789 /* "neighbor send-community" commands.*/
11790 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
11791 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
11792 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
11793 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
11794 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
11795 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
11796 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
11797 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
11798 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
11799 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
11800 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
11801 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
11802 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
11803 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
11804 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
11805 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
11806 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
11807 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
11808 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
11809 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
11810 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
11811 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
11812 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
11813 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
11814 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
11815 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
11816 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
11817 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
11818 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
11819 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
11820 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
11821 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
11822 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
11823 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
11824 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
11825 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
11827 /* "neighbor route-reflector" commands.*/
11828 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
11829 install_element(BGP_NODE
,
11830 &no_neighbor_route_reflector_client_hidden_cmd
);
11831 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
11832 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
11833 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
11834 install_element(BGP_IPV4M_NODE
,
11835 &no_neighbor_route_reflector_client_cmd
);
11836 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
11837 install_element(BGP_IPV4L_NODE
,
11838 &no_neighbor_route_reflector_client_cmd
);
11839 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
11840 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
11841 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
11842 install_element(BGP_IPV6M_NODE
,
11843 &no_neighbor_route_reflector_client_cmd
);
11844 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
11845 install_element(BGP_IPV6L_NODE
,
11846 &no_neighbor_route_reflector_client_cmd
);
11847 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
11848 install_element(BGP_VPNV4_NODE
,
11849 &no_neighbor_route_reflector_client_cmd
);
11850 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
11851 install_element(BGP_VPNV6_NODE
,
11852 &no_neighbor_route_reflector_client_cmd
);
11853 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
11854 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
11856 /* "neighbor route-server" commands.*/
11857 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
11858 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
11859 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
11860 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
11861 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
11862 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
11863 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
11864 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
11865 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
11866 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
11867 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
11868 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
11869 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
11870 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
11871 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
11872 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
11873 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
11874 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
11876 /* "neighbor addpath-tx-all-paths" commands.*/
11877 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
11878 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
11879 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11880 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11881 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11882 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11883 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11884 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11885 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11886 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11887 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11888 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11889 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11890 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11891 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11892 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11893 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
11894 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
11896 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
11897 install_element(BGP_NODE
,
11898 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
11899 install_element(BGP_NODE
,
11900 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
11901 install_element(BGP_IPV4_NODE
,
11902 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11903 install_element(BGP_IPV4_NODE
,
11904 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11905 install_element(BGP_IPV4M_NODE
,
11906 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11907 install_element(BGP_IPV4M_NODE
,
11908 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11909 install_element(BGP_IPV4L_NODE
,
11910 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11911 install_element(BGP_IPV4L_NODE
,
11912 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11913 install_element(BGP_IPV6_NODE
,
11914 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11915 install_element(BGP_IPV6_NODE
,
11916 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11917 install_element(BGP_IPV6M_NODE
,
11918 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11919 install_element(BGP_IPV6M_NODE
,
11920 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11921 install_element(BGP_IPV6L_NODE
,
11922 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11923 install_element(BGP_IPV6L_NODE
,
11924 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11925 install_element(BGP_VPNV4_NODE
,
11926 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11927 install_element(BGP_VPNV4_NODE
,
11928 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11929 install_element(BGP_VPNV6_NODE
,
11930 &neighbor_addpath_tx_bestpath_per_as_cmd
);
11931 install_element(BGP_VPNV6_NODE
,
11932 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
11934 /* "neighbor passive" commands. */
11935 install_element(BGP_NODE
, &neighbor_passive_cmd
);
11936 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
11939 /* "neighbor shutdown" commands. */
11940 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
11941 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
11942 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
11943 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
11945 /* "neighbor capability extended-nexthop" commands.*/
11946 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
11947 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
11949 /* "neighbor capability orf prefix-list" commands.*/
11950 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
11951 install_element(BGP_NODE
,
11952 &no_neighbor_capability_orf_prefix_hidden_cmd
);
11953 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
11954 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11955 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
11956 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11957 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
11958 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11959 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
11960 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11961 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
11962 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11963 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
11964 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
11966 /* "neighbor capability dynamic" commands.*/
11967 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
11968 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
11970 /* "neighbor dont-capability-negotiate" commands. */
11971 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
11972 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
11974 /* "neighbor ebgp-multihop" commands. */
11975 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
11976 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
11977 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
11979 /* "neighbor disable-connected-check" commands. */
11980 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
11981 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
11983 /* "neighbor description" commands. */
11984 install_element(BGP_NODE
, &neighbor_description_cmd
);
11985 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
11987 /* "neighbor update-source" commands. "*/
11988 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
11989 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
11991 /* "neighbor default-originate" commands. */
11992 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
11993 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
11994 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
11995 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
11996 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
11997 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
11998 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
11999 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
12000 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
12001 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
12002 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
12003 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
12004 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
12005 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
12006 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
12007 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
12008 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
12009 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
12010 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
12011 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
12012 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
12014 /* "neighbor port" commands. */
12015 install_element(BGP_NODE
, &neighbor_port_cmd
);
12016 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
12018 /* "neighbor weight" commands. */
12019 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
12020 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
12022 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
12023 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
12024 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
12025 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
12026 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
12027 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
12028 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
12029 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
12030 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
12031 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
12032 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
12033 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
12034 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
12035 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
12036 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
12037 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
12039 /* "neighbor override-capability" commands. */
12040 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
12041 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
12043 /* "neighbor strict-capability-match" commands. */
12044 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
12045 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
12047 /* "neighbor timers" commands. */
12048 install_element(BGP_NODE
, &neighbor_timers_cmd
);
12049 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
12051 /* "neighbor timers connect" commands. */
12052 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
12053 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
12055 /* "neighbor advertisement-interval" commands. */
12056 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
12057 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
12059 /* "neighbor interface" commands. */
12060 install_element(BGP_NODE
, &neighbor_interface_cmd
);
12061 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
12063 /* "neighbor distribute" commands. */
12064 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
12065 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
12066 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
12067 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
12068 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
12069 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
12070 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
12071 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
12072 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
12073 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
12074 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
12075 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
12076 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
12077 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
12078 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
12079 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
12080 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
12081 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
12083 /* "neighbor prefix-list" commands. */
12084 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
12085 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
12086 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
12087 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
12088 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
12089 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
12090 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
12091 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
12092 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
12093 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
12094 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
12095 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
12096 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
12097 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
12098 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
12099 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
12100 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
12101 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
12103 /* "neighbor filter-list" commands. */
12104 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
12105 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
12106 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
12107 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
12108 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
12109 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
12110 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
12111 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
12112 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
12113 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
12114 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
12115 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
12116 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
12117 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
12118 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
12119 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
12120 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
12121 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
12123 /* "neighbor route-map" commands. */
12124 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
12125 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
12126 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
12127 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
12128 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
12129 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
12130 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
12131 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
12132 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
12133 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
12134 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
12135 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
12136 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
12137 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
12138 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
12139 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
12140 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
12141 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
12142 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
12143 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
12145 /* "neighbor unsuppress-map" commands. */
12146 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
12147 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
12148 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
12149 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12150 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
12151 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12152 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
12153 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12154 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
12155 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12156 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
12157 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
12158 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
12159 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
12160 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
12161 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
12162 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
12163 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
12165 /* "neighbor maximum-prefix" commands. */
12166 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
12167 install_element(BGP_NODE
,
12168 &neighbor_maximum_prefix_threshold_hidden_cmd
);
12169 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
12170 install_element(BGP_NODE
,
12171 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
12172 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
12173 install_element(BGP_NODE
,
12174 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
12175 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
12176 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
12177 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12178 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12179 install_element(BGP_IPV4_NODE
,
12180 &neighbor_maximum_prefix_threshold_warning_cmd
);
12181 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12182 install_element(BGP_IPV4_NODE
,
12183 &neighbor_maximum_prefix_threshold_restart_cmd
);
12184 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12185 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
12186 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12187 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12188 install_element(BGP_IPV4M_NODE
,
12189 &neighbor_maximum_prefix_threshold_warning_cmd
);
12190 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12191 install_element(BGP_IPV4M_NODE
,
12192 &neighbor_maximum_prefix_threshold_restart_cmd
);
12193 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12194 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
12195 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12196 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12197 install_element(BGP_IPV4L_NODE
,
12198 &neighbor_maximum_prefix_threshold_warning_cmd
);
12199 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12200 install_element(BGP_IPV4L_NODE
,
12201 &neighbor_maximum_prefix_threshold_restart_cmd
);
12202 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12203 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
12204 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12205 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12206 install_element(BGP_IPV6_NODE
,
12207 &neighbor_maximum_prefix_threshold_warning_cmd
);
12208 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12209 install_element(BGP_IPV6_NODE
,
12210 &neighbor_maximum_prefix_threshold_restart_cmd
);
12211 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12212 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
12213 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12214 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12215 install_element(BGP_IPV6M_NODE
,
12216 &neighbor_maximum_prefix_threshold_warning_cmd
);
12217 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12218 install_element(BGP_IPV6M_NODE
,
12219 &neighbor_maximum_prefix_threshold_restart_cmd
);
12220 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
12221 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
12222 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12223 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12224 install_element(BGP_IPV6L_NODE
,
12225 &neighbor_maximum_prefix_threshold_warning_cmd
);
12226 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12227 install_element(BGP_IPV6L_NODE
,
12228 &neighbor_maximum_prefix_threshold_restart_cmd
);
12229 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
12230 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
12231 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12232 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12233 install_element(BGP_VPNV4_NODE
,
12234 &neighbor_maximum_prefix_threshold_warning_cmd
);
12235 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12236 install_element(BGP_VPNV4_NODE
,
12237 &neighbor_maximum_prefix_threshold_restart_cmd
);
12238 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
12239 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
12240 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
12241 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
12242 install_element(BGP_VPNV6_NODE
,
12243 &neighbor_maximum_prefix_threshold_warning_cmd
);
12244 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
12245 install_element(BGP_VPNV6_NODE
,
12246 &neighbor_maximum_prefix_threshold_restart_cmd
);
12247 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
12249 /* "neighbor allowas-in" */
12250 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
12251 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
12252 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
12253 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
12254 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
12255 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
12256 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
12257 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
12258 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
12259 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
12260 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
12261 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
12262 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
12263 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
12264 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
12265 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
12266 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
12267 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
12268 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
12269 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
12271 /* address-family commands. */
12272 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
12273 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
12274 #ifdef KEEP_OLD_VPN_COMMANDS
12275 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
12276 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
12277 #endif /* KEEP_OLD_VPN_COMMANDS */
12279 install_element(BGP_NODE
, &address_family_evpn_cmd
);
12281 /* "exit-address-family" command. */
12282 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
12283 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
12284 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
12285 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
12286 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
12287 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
12288 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
12289 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
12290 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
12292 /* "clear ip bgp commands" */
12293 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
12295 /* clear ip bgp prefix */
12296 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
12297 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
12298 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
12300 /* "show [ip] bgp summary" commands. */
12301 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
12302 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_adj_cmd
);
12303 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_adj_s_cmd
);
12304 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
12305 install_element(VIEW_NODE
, &show_bgp_updgrps_adj_cmd
);
12306 install_element(VIEW_NODE
, &show_bgp_updgrps_adj_s_cmd
);
12307 install_element(VIEW_NODE
, &show_bgp_updgrps_afi_adj_cmd
);
12308 install_element(VIEW_NODE
, &show_bgp_updgrps_afi_adj_s_cmd
);
12309 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
12310 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_cmd
);
12311 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
12312 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
12313 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_adj_cmd
);
12314 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_adj_s_cmd
);
12315 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
12317 /* "show [ip] bgp neighbors" commands. */
12318 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
12320 /* "show [ip] bgp peer-group" commands. */
12321 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
12323 /* "show [ip] bgp paths" commands. */
12324 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
12326 /* "show [ip] bgp community" commands. */
12327 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
12329 /* "show ip bgp large-community" commands. */
12330 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
12331 /* "show [ip] bgp attribute-info" commands. */
12332 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
12334 /* "redistribute" commands. */
12335 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
12336 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
12337 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
12338 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
12339 install_element(BGP_NODE
,
12340 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
12341 install_element(BGP_NODE
,
12342 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
12343 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
12344 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
12345 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
12346 install_element(BGP_NODE
,
12347 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
12348 install_element(BGP_NODE
,
12349 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
12350 install_element(BGP_NODE
,
12351 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
12352 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
12353 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
12354 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
12355 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
12356 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
12357 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
12358 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
12359 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
12360 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
12361 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
12362 install_element(BGP_IPV4_NODE
,
12363 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
12364 install_element(BGP_IPV4_NODE
,
12365 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
12366 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
12367 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
12368 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
12369 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
12370 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
12371 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
12373 /* ttl_security commands */
12374 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
12375 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
12377 /* "show [ip] bgp memory" commands. */
12378 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
12380 /* "show bgp martian next-hop" */
12381 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
12383 /* "show [ip] bgp views" commands. */
12384 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
12386 /* "show [ip] bgp vrfs" commands. */
12387 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
12389 /* Community-list. */
12390 community_list_vty();
12393 #include "memory.h"
12394 #include "bgp_regex.h"
12395 #include "bgp_clist.h"
12396 #include "bgp_ecommunity.h"
12398 /* VTY functions. */
12400 /* Direction value to string conversion. */
12401 static const char *community_direct_str(int direct
)
12404 case COMMUNITY_DENY
:
12406 case COMMUNITY_PERMIT
:
12413 /* Display error string. */
12414 static void community_list_perror(struct vty
*vty
, int ret
)
12417 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
12418 vty_out(vty
, "%% Can't find community-list\n");
12420 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
12421 vty_out(vty
, "%% Malformed community-list value\n");
12423 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
12425 "%% Community name conflict, previously defined as standard community\n");
12427 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
12429 "%% Community name conflict, previously defined as expanded community\n");
12434 /* "community-list" keyword help string. */
12435 #define COMMUNITY_LIST_STR "Add a community list entry\n"
12437 /* ip community-list standard */
12438 DEFUN (ip_community_list_standard
,
12439 ip_community_list_standard_cmd
,
12440 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
12443 "Community list number (standard)\n"
12444 "Add an standard community-list entry\n"
12445 "Community list name\n"
12446 "Specify community to reject\n"
12447 "Specify community to accept\n"
12450 char *cl_name_or_number
= NULL
;
12452 int style
= COMMUNITY_LIST_STANDARD
;
12455 argv_find(argv
, argc
, "(1-99)", &idx
);
12456 argv_find(argv
, argc
, "WORD", &idx
);
12457 cl_name_or_number
= argv
[idx
]->arg
;
12458 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12460 argv_find(argv
, argc
, "AA:NN", &idx
);
12461 char *str
= argv_concat(argv
, argc
, idx
);
12463 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
12466 XFREE(MTYPE_TMP
, str
);
12469 /* Display error string. */
12470 community_list_perror(vty
, ret
);
12471 return CMD_WARNING_CONFIG_FAILED
;
12474 return CMD_SUCCESS
;
12477 DEFUN (no_ip_community_list_standard_all
,
12478 no_ip_community_list_standard_all_cmd
,
12479 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
12483 "Community list number (standard)\n"
12484 "Add an standard community-list entry\n"
12485 "Community list name\n"
12486 "Specify community to reject\n"
12487 "Specify community to accept\n"
12490 int delete_all
= 0;
12492 char *cl_name_or_number
= NULL
;
12494 int style
= COMMUNITY_LIST_STANDARD
;
12497 argv_find(argv
, argc
, "(1-99)", &idx
);
12498 argv_find(argv
, argc
, "WORD", &idx
);
12499 cl_name_or_number
= argv
[idx
]->arg
;
12500 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12502 argv_find(argv
, argc
, "AA:NN", &idx
);
12503 char *str
= argv_concat(argv
, argc
, idx
);
12505 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
12506 direct
, style
, delete_all
);
12508 XFREE(MTYPE_TMP
, str
);
12511 community_list_perror(vty
, ret
);
12512 return CMD_WARNING_CONFIG_FAILED
;
12515 return CMD_SUCCESS
;
12518 /* ip community-list expanded */
12519 DEFUN (ip_community_list_expanded_all
,
12520 ip_community_list_expanded_all_cmd
,
12521 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
12524 "Community list number (expanded)\n"
12525 "Add an expanded community-list entry\n"
12526 "Community list name\n"
12527 "Specify community to reject\n"
12528 "Specify community to accept\n"
12531 char *cl_name_or_number
= NULL
;
12533 int style
= COMMUNITY_LIST_EXPANDED
;
12536 argv_find(argv
, argc
, "(100-500)", &idx
);
12537 argv_find(argv
, argc
, "WORD", &idx
);
12538 cl_name_or_number
= argv
[idx
]->arg
;
12539 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12541 argv_find(argv
, argc
, "AA:NN", &idx
);
12542 char *str
= argv_concat(argv
, argc
, idx
);
12544 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
12547 XFREE(MTYPE_TMP
, str
);
12550 /* Display error string. */
12551 community_list_perror(vty
, ret
);
12552 return CMD_WARNING_CONFIG_FAILED
;
12555 return CMD_SUCCESS
;
12558 DEFUN (no_ip_community_list_expanded_all
,
12559 no_ip_community_list_expanded_all_cmd
,
12560 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
12564 "Community list number (expanded)\n"
12565 "Add an expanded community-list entry\n"
12566 "Community list name\n"
12567 "Specify community to reject\n"
12568 "Specify community to accept\n"
12571 int delete_all
= 0;
12573 char *cl_name_or_number
= NULL
;
12575 int style
= COMMUNITY_LIST_EXPANDED
;
12578 argv_find(argv
, argc
, "(100-500)", &idx
);
12579 argv_find(argv
, argc
, "WORD", &idx
);
12580 cl_name_or_number
= argv
[idx
]->arg
;
12581 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12583 argv_find(argv
, argc
, "AA:NN", &idx
);
12584 char *str
= argv_concat(argv
, argc
, idx
);
12586 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
12587 direct
, style
, delete_all
);
12589 XFREE(MTYPE_TMP
, str
);
12592 community_list_perror(vty
, ret
);
12593 return CMD_WARNING_CONFIG_FAILED
;
12596 return CMD_SUCCESS
;
12599 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
12601 struct community_entry
*entry
;
12603 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
12604 if (entry
== list
->head
) {
12605 if (all_digit(list
->name
))
12606 vty_out(vty
, "Community %s list %s\n",
12607 entry
->style
== COMMUNITY_LIST_STANDARD
12609 : "(expanded) access",
12612 vty_out(vty
, "Named Community %s list %s\n",
12613 entry
->style
== COMMUNITY_LIST_STANDARD
12619 vty_out(vty
, " %s\n",
12620 community_direct_str(entry
->direct
));
12622 vty_out(vty
, " %s %s\n",
12623 community_direct_str(entry
->direct
),
12624 entry
->style
== COMMUNITY_LIST_STANDARD
12625 ? community_str(entry
->u
.com
)
12630 DEFUN (show_ip_community_list
,
12631 show_ip_community_list_cmd
,
12632 "show ip community-list",
12635 "List community-list\n")
12637 struct community_list
*list
;
12638 struct community_list_master
*cm
;
12640 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
12642 return CMD_SUCCESS
;
12644 for (list
= cm
->num
.head
; list
; list
= list
->next
)
12645 community_list_show(vty
, list
);
12647 for (list
= cm
->str
.head
; list
; list
= list
->next
)
12648 community_list_show(vty
, list
);
12650 return CMD_SUCCESS
;
12653 DEFUN (show_ip_community_list_arg
,
12654 show_ip_community_list_arg_cmd
,
12655 "show ip community-list <(1-500)|WORD>",
12658 "List community-list\n"
12659 "Community-list number\n"
12660 "Community-list name\n")
12662 int idx_comm_list
= 3;
12663 struct community_list
*list
;
12665 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
12666 COMMUNITY_LIST_MASTER
);
12668 vty_out(vty
, "%% Can't find community-list\n");
12669 return CMD_WARNING
;
12672 community_list_show(vty
, list
);
12674 return CMD_SUCCESS
;
12678 * Large Community code.
12680 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
12681 struct cmd_token
**argv
, int style
,
12682 int reject_all_digit_name
)
12690 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
12693 /* All digit name check. */
12695 argv_find(argv
, argc
, "WORD", &idx
);
12696 argv_find(argv
, argc
, "(1-99)", &idx
);
12697 argv_find(argv
, argc
, "(100-500)", &idx
);
12698 cl_name
= argv
[idx
]->arg
;
12699 if (reject_all_digit_name
&& all_digit(cl_name
)) {
12700 vty_out(vty
, "%% Community name cannot have all digits\n");
12701 return CMD_WARNING_CONFIG_FAILED
;
12705 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
12706 argv_find(argv
, argc
, "LINE", &idx
);
12707 /* Concat community string argument. */
12709 str
= argv_concat(argv
, argc
, idx
);
12713 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
12715 /* Free temporary community list string allocated by
12718 XFREE(MTYPE_TMP
, str
);
12721 community_list_perror(vty
, ret
);
12722 return CMD_WARNING_CONFIG_FAILED
;
12724 return CMD_SUCCESS
;
12727 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
12728 struct cmd_token
**argv
, int style
)
12735 argv_find(argv
, argc
, "permit", &idx
);
12736 argv_find(argv
, argc
, "deny", &idx
);
12739 /* Check the list direct. */
12740 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
12741 direct
= COMMUNITY_PERMIT
;
12743 direct
= COMMUNITY_DENY
;
12746 argv_find(argv
, argc
, "LINE", &idx
);
12747 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
12748 /* Concat community string argument. */
12749 str
= argv_concat(argv
, argc
, idx
);
12753 argv_find(argv
, argc
, "(1-99)", &idx
);
12754 argv_find(argv
, argc
, "(100-500)", &idx
);
12755 argv_find(argv
, argc
, "WORD", &idx
);
12757 /* Unset community list. */
12758 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
12761 /* Free temporary community list string allocated by
12764 XFREE(MTYPE_TMP
, str
);
12767 community_list_perror(vty
, ret
);
12768 return CMD_WARNING_CONFIG_FAILED
;
12771 return CMD_SUCCESS
;
12774 /* "large-community-list" keyword help string. */
12775 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
12776 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
12778 DEFUN (ip_lcommunity_list_standard
,
12779 ip_lcommunity_list_standard_cmd
,
12780 "ip large-community-list (1-99) <deny|permit>",
12782 LCOMMUNITY_LIST_STR
12783 "Large Community list number (standard)\n"
12784 "Specify large community to reject\n"
12785 "Specify large community to accept\n")
12787 return lcommunity_list_set_vty(vty
, argc
, argv
,
12788 LARGE_COMMUNITY_LIST_STANDARD
, 0);
12791 DEFUN (ip_lcommunity_list_standard1
,
12792 ip_lcommunity_list_standard1_cmd
,
12793 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
12795 LCOMMUNITY_LIST_STR
12796 "Large Community list number (standard)\n"
12797 "Specify large community to reject\n"
12798 "Specify large community to accept\n"
12799 LCOMMUNITY_VAL_STR
)
12801 return lcommunity_list_set_vty(vty
, argc
, argv
,
12802 LARGE_COMMUNITY_LIST_STANDARD
, 0);
12805 DEFUN (ip_lcommunity_list_expanded
,
12806 ip_lcommunity_list_expanded_cmd
,
12807 "ip large-community-list (100-500) <deny|permit> LINE...",
12809 LCOMMUNITY_LIST_STR
12810 "Large Community list number (expanded)\n"
12811 "Specify large community to reject\n"
12812 "Specify large community to accept\n"
12813 "An ordered list as a regular-expression\n")
12815 return lcommunity_list_set_vty(vty
, argc
, argv
,
12816 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
12819 DEFUN (ip_lcommunity_list_name_standard
,
12820 ip_lcommunity_list_name_standard_cmd
,
12821 "ip large-community-list standard WORD <deny|permit>",
12823 LCOMMUNITY_LIST_STR
12824 "Specify standard large-community-list\n"
12825 "Large Community list name\n"
12826 "Specify large community to reject\n"
12827 "Specify large community to accept\n")
12829 return lcommunity_list_set_vty(vty
, argc
, argv
,
12830 LARGE_COMMUNITY_LIST_STANDARD
, 1);
12833 DEFUN (ip_lcommunity_list_name_standard1
,
12834 ip_lcommunity_list_name_standard1_cmd
,
12835 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
12837 LCOMMUNITY_LIST_STR
12838 "Specify standard large-community-list\n"
12839 "Large Community list name\n"
12840 "Specify large community to reject\n"
12841 "Specify large community to accept\n"
12842 LCOMMUNITY_VAL_STR
)
12844 return lcommunity_list_set_vty(vty
, argc
, argv
,
12845 LARGE_COMMUNITY_LIST_STANDARD
, 1);
12848 DEFUN (ip_lcommunity_list_name_expanded
,
12849 ip_lcommunity_list_name_expanded_cmd
,
12850 "ip large-community-list expanded WORD <deny|permit> LINE...",
12852 LCOMMUNITY_LIST_STR
12853 "Specify expanded large-community-list\n"
12854 "Large Community list name\n"
12855 "Specify large community to reject\n"
12856 "Specify large community to accept\n"
12857 "An ordered list as a regular-expression\n")
12859 return lcommunity_list_set_vty(vty
, argc
, argv
,
12860 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
12863 DEFUN (no_ip_lcommunity_list_standard_all
,
12864 no_ip_lcommunity_list_standard_all_cmd
,
12865 "no ip large-community-list <(1-99)|(100-500)|WORD>",
12868 LCOMMUNITY_LIST_STR
12869 "Large Community list number (standard)\n"
12870 "Large Community list number (expanded)\n"
12871 "Large Community list name\n")
12873 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12874 LARGE_COMMUNITY_LIST_STANDARD
);
12877 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
12878 no_ip_lcommunity_list_name_expanded_all_cmd
,
12879 "no ip large-community-list expanded WORD",
12882 LCOMMUNITY_LIST_STR
12883 "Specify expanded large-community-list\n"
12884 "Large Community list name\n")
12886 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12887 LARGE_COMMUNITY_LIST_EXPANDED
);
12890 DEFUN (no_ip_lcommunity_list_standard
,
12891 no_ip_lcommunity_list_standard_cmd
,
12892 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
12895 LCOMMUNITY_LIST_STR
12896 "Large Community list number (standard)\n"
12897 "Specify large community to reject\n"
12898 "Specify large community to accept\n"
12899 LCOMMUNITY_VAL_STR
)
12901 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12902 LARGE_COMMUNITY_LIST_STANDARD
);
12905 DEFUN (no_ip_lcommunity_list_expanded
,
12906 no_ip_lcommunity_list_expanded_cmd
,
12907 "no ip large-community-list (100-500) <deny|permit> LINE...",
12910 LCOMMUNITY_LIST_STR
12911 "Large Community list number (expanded)\n"
12912 "Specify large community to reject\n"
12913 "Specify large community to accept\n"
12914 "An ordered list as a regular-expression\n")
12916 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12917 LARGE_COMMUNITY_LIST_EXPANDED
);
12920 DEFUN (no_ip_lcommunity_list_name_standard
,
12921 no_ip_lcommunity_list_name_standard_cmd
,
12922 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
12925 LCOMMUNITY_LIST_STR
12926 "Specify standard large-community-list\n"
12927 "Large Community list name\n"
12928 "Specify large community to reject\n"
12929 "Specify large community to accept\n"
12930 LCOMMUNITY_VAL_STR
)
12932 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12933 LARGE_COMMUNITY_LIST_STANDARD
);
12936 DEFUN (no_ip_lcommunity_list_name_expanded
,
12937 no_ip_lcommunity_list_name_expanded_cmd
,
12938 "no ip large-community-list expanded WORD <deny|permit> LINE...",
12941 LCOMMUNITY_LIST_STR
12942 "Specify expanded large-community-list\n"
12943 "Large community list name\n"
12944 "Specify large community to reject\n"
12945 "Specify large community to accept\n"
12946 "An ordered list as a regular-expression\n")
12948 return lcommunity_list_unset_vty(vty
, argc
, argv
,
12949 LARGE_COMMUNITY_LIST_EXPANDED
);
12952 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
12954 struct community_entry
*entry
;
12956 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
12957 if (entry
== list
->head
) {
12958 if (all_digit(list
->name
))
12959 vty_out(vty
, "Large community %s list %s\n",
12960 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
12962 : "(expanded) access",
12966 "Named large community %s list %s\n",
12967 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
12973 vty_out(vty
, " %s\n",
12974 community_direct_str(entry
->direct
));
12976 vty_out(vty
, " %s %s\n",
12977 community_direct_str(entry
->direct
),
12978 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
12979 ? entry
->u
.ecom
->str
12984 DEFUN (show_ip_lcommunity_list
,
12985 show_ip_lcommunity_list_cmd
,
12986 "show ip large-community-list",
12989 "List large-community list\n")
12991 struct community_list
*list
;
12992 struct community_list_master
*cm
;
12994 cm
= community_list_master_lookup(bgp_clist
,
12995 LARGE_COMMUNITY_LIST_MASTER
);
12997 return CMD_SUCCESS
;
12999 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13000 lcommunity_list_show(vty
, list
);
13002 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13003 lcommunity_list_show(vty
, list
);
13005 return CMD_SUCCESS
;
13008 DEFUN (show_ip_lcommunity_list_arg
,
13009 show_ip_lcommunity_list_arg_cmd
,
13010 "show ip large-community-list <(1-500)|WORD>",
13013 "List large-community list\n"
13014 "large-community-list number\n"
13015 "large-community-list name\n")
13017 struct community_list
*list
;
13019 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
13020 LARGE_COMMUNITY_LIST_MASTER
);
13022 vty_out(vty
, "%% Can't find extcommunity-list\n");
13023 return CMD_WARNING
;
13026 lcommunity_list_show(vty
, list
);
13028 return CMD_SUCCESS
;
13031 /* "extcommunity-list" keyword help string. */
13032 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
13033 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
13035 DEFUN (ip_extcommunity_list_standard
,
13036 ip_extcommunity_list_standard_cmd
,
13037 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13039 EXTCOMMUNITY_LIST_STR
13040 "Extended Community list number (standard)\n"
13041 "Specify standard extcommunity-list\n"
13042 "Community list name\n"
13043 "Specify community to reject\n"
13044 "Specify community to accept\n"
13045 EXTCOMMUNITY_VAL_STR
)
13047 int style
= EXTCOMMUNITY_LIST_STANDARD
;
13049 char *cl_number_or_name
= NULL
;
13052 argv_find(argv
, argc
, "(1-99)", &idx
);
13053 argv_find(argv
, argc
, "WORD", &idx
);
13054 cl_number_or_name
= argv
[idx
]->arg
;
13055 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13057 argv_find(argv
, argc
, "AA:NN", &idx
);
13058 char *str
= argv_concat(argv
, argc
, idx
);
13060 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
13063 XFREE(MTYPE_TMP
, str
);
13066 community_list_perror(vty
, ret
);
13067 return CMD_WARNING_CONFIG_FAILED
;
13070 return CMD_SUCCESS
;
13073 DEFUN (ip_extcommunity_list_name_expanded
,
13074 ip_extcommunity_list_name_expanded_cmd
,
13075 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
13077 EXTCOMMUNITY_LIST_STR
13078 "Extended Community list number (expanded)\n"
13079 "Specify expanded extcommunity-list\n"
13080 "Extended Community list name\n"
13081 "Specify community to reject\n"
13082 "Specify community to accept\n"
13083 "An ordered list as a regular-expression\n")
13085 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
13087 char *cl_number_or_name
= NULL
;
13090 argv_find(argv
, argc
, "(100-500)", &idx
);
13091 argv_find(argv
, argc
, "WORD", &idx
);
13092 cl_number_or_name
= argv
[idx
]->arg
;
13093 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13095 argv_find(argv
, argc
, "LINE", &idx
);
13096 char *str
= argv_concat(argv
, argc
, idx
);
13098 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
13101 XFREE(MTYPE_TMP
, str
);
13104 community_list_perror(vty
, ret
);
13105 return CMD_WARNING_CONFIG_FAILED
;
13108 return CMD_SUCCESS
;
13111 DEFUN (no_ip_extcommunity_list_standard_all
,
13112 no_ip_extcommunity_list_standard_all_cmd
,
13113 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13116 EXTCOMMUNITY_LIST_STR
13117 "Extended Community list number (standard)\n"
13118 "Specify standard extcommunity-list\n"
13119 "Community list name\n"
13120 "Specify community to reject\n"
13121 "Specify community to accept\n"
13122 EXTCOMMUNITY_VAL_STR
)
13126 int style
= EXTCOMMUNITY_LIST_STANDARD
;
13128 char *cl_number_or_name
= NULL
;
13131 argv_find(argv
, argc
, "(1-99)", &idx
);
13132 argv_find(argv
, argc
, "WORD", &idx
);
13133 cl_number_or_name
= argv
[idx
]->arg
;
13134 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13136 argv_find(argv
, argc
, "AA:NN", &idx
);
13137 char *str
= argv_concat(argv
, argc
, idx
);
13139 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13140 direct
, style
, deleteall
);
13142 XFREE(MTYPE_TMP
, str
);
13145 community_list_perror(vty
, ret
);
13146 return CMD_WARNING_CONFIG_FAILED
;
13149 return CMD_SUCCESS
;
13152 DEFUN (no_ip_extcommunity_list_expanded_all
,
13153 no_ip_extcommunity_list_expanded_all_cmd
,
13154 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
13157 EXTCOMMUNITY_LIST_STR
13158 "Extended Community list number (expanded)\n"
13159 "Specify expanded extcommunity-list\n"
13160 "Extended Community list name\n"
13161 "Specify community to reject\n"
13162 "Specify community to accept\n"
13163 "An ordered list as a regular-expression\n")
13167 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
13169 char *cl_number_or_name
= NULL
;
13172 argv_find(argv
, argc
, "(100-500)", &idx
);
13173 argv_find(argv
, argc
, "WORD", &idx
);
13174 cl_number_or_name
= argv
[idx
]->arg
;
13175 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13177 argv_find(argv
, argc
, "LINE", &idx
);
13178 char *str
= argv_concat(argv
, argc
, idx
);
13180 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
13181 direct
, style
, deleteall
);
13183 XFREE(MTYPE_TMP
, str
);
13186 community_list_perror(vty
, ret
);
13187 return CMD_WARNING_CONFIG_FAILED
;
13190 return CMD_SUCCESS
;
13193 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
13195 struct community_entry
*entry
;
13197 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13198 if (entry
== list
->head
) {
13199 if (all_digit(list
->name
))
13200 vty_out(vty
, "Extended community %s list %s\n",
13201 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13203 : "(expanded) access",
13207 "Named extended community %s list %s\n",
13208 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13214 vty_out(vty
, " %s\n",
13215 community_direct_str(entry
->direct
));
13217 vty_out(vty
, " %s %s\n",
13218 community_direct_str(entry
->direct
),
13219 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13220 ? entry
->u
.ecom
->str
13225 DEFUN (show_ip_extcommunity_list
,
13226 show_ip_extcommunity_list_cmd
,
13227 "show ip extcommunity-list",
13230 "List extended-community list\n")
13232 struct community_list
*list
;
13233 struct community_list_master
*cm
;
13235 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
13237 return CMD_SUCCESS
;
13239 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13240 extcommunity_list_show(vty
, list
);
13242 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13243 extcommunity_list_show(vty
, list
);
13245 return CMD_SUCCESS
;
13248 DEFUN (show_ip_extcommunity_list_arg
,
13249 show_ip_extcommunity_list_arg_cmd
,
13250 "show ip extcommunity-list <(1-500)|WORD>",
13253 "List extended-community list\n"
13254 "Extcommunity-list number\n"
13255 "Extcommunity-list name\n")
13257 int idx_comm_list
= 3;
13258 struct community_list
*list
;
13260 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13261 EXTCOMMUNITY_LIST_MASTER
);
13263 vty_out(vty
, "%% Can't find extcommunity-list\n");
13264 return CMD_WARNING
;
13267 extcommunity_list_show(vty
, list
);
13269 return CMD_SUCCESS
;
13272 /* Return configuration string of community-list entry. */
13273 static const char *community_list_config_str(struct community_entry
*entry
)
13280 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13281 str
= community_str(entry
->u
.com
);
13283 str
= entry
->config
;
13288 /* Display community-list and extcommunity-list configuration. */
13289 static int community_list_config_write(struct vty
*vty
)
13291 struct community_list
*list
;
13292 struct community_entry
*entry
;
13293 struct community_list_master
*cm
;
13296 /* Community-list. */
13297 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13299 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13300 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13301 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
13302 community_direct_str(entry
->direct
),
13303 community_list_config_str(entry
));
13306 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13307 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13308 vty_out(vty
, "ip community-list %s %s %s %s\n",
13309 entry
->style
== COMMUNITY_LIST_STANDARD
13312 list
->name
, community_direct_str(entry
->direct
),
13313 community_list_config_str(entry
));
13317 /* Extcommunity-list. */
13318 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
13320 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13321 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13322 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
13323 list
->name
, community_direct_str(entry
->direct
),
13324 community_list_config_str(entry
));
13327 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13328 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13329 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
13330 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
13333 list
->name
, community_direct_str(entry
->direct
),
13334 community_list_config_str(entry
));
13339 /* lcommunity-list. */
13340 cm
= community_list_master_lookup(bgp_clist
,
13341 LARGE_COMMUNITY_LIST_MASTER
);
13343 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13344 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13345 vty_out(vty
, "ip large-community-list %s %s %s\n",
13346 list
->name
, community_direct_str(entry
->direct
),
13347 community_list_config_str(entry
));
13350 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13351 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13352 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
13353 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
13356 list
->name
, community_direct_str(entry
->direct
),
13357 community_list_config_str(entry
));
13364 static struct cmd_node community_list_node
= {
13365 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
13368 static void community_list_vty(void)
13370 install_node(&community_list_node
, community_list_config_write
);
13372 /* Community-list. */
13373 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
13374 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
13375 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
13376 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
13377 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
13378 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
13380 /* Extcommunity-list. */
13381 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
13382 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
13383 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
13384 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
13385 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
13386 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
13388 /* Large Community List */
13389 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
13390 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
13391 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
13392 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
13393 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
13394 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
13395 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
13396 install_element(CONFIG_NODE
,
13397 &no_ip_lcommunity_list_name_expanded_all_cmd
);
13398 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
13399 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
13400 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
13401 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
13402 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
13403 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);