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"
39 #include "bgpd/bgpd.h"
40 #include "bgpd/bgp_advertise.h"
41 #include "bgpd/bgp_attr.h"
42 #include "bgpd/bgp_aspath.h"
43 #include "bgpd/bgp_community.h"
44 #include "bgpd/bgp_ecommunity.h"
45 #include "bgpd/bgp_lcommunity.h"
46 #include "bgpd/bgp_damp.h"
47 #include "bgpd/bgp_debug.h"
48 #include "bgpd/bgp_fsm.h"
49 #include "bgpd/bgp_nexthop.h"
50 #include "bgpd/bgp_open.h"
51 #include "bgpd/bgp_regex.h"
52 #include "bgpd/bgp_route.h"
53 #include "bgpd/bgp_mplsvpn.h"
54 #include "bgpd/bgp_zebra.h"
55 #include "bgpd/bgp_table.h"
56 #include "bgpd/bgp_vty.h"
57 #include "bgpd/bgp_mpath.h"
58 #include "bgpd/bgp_packet.h"
59 #include "bgpd/bgp_updgrp.h"
60 #include "bgpd/bgp_bfd.h"
61 #include "bgpd/bgp_io.h"
62 #include "bgpd/bgp_evpn.h"
64 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
65 struct prefix
*range
, int exact
);
67 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
76 return BGP_IPV4M_NODE
;
78 case SAFI_LABELED_UNICAST
:
79 return BGP_IPV4L_NODE
;
82 return BGP_VPNV4_NODE
;
85 return BGP_FLOWSPECV4_NODE
;
98 return BGP_IPV6M_NODE
;
100 case SAFI_LABELED_UNICAST
:
101 return BGP_IPV6L_NODE
;
104 return BGP_VPNV6_NODE
;
107 return BGP_FLOWSPECV6_NODE
;
110 return BGP_IPV4_NODE
;
115 return BGP_EVPN_NODE
;
118 // We should never be here but to clarify the switch statement..
119 return BGP_IPV4_NODE
;
123 // Impossible to happen
124 return BGP_IPV4_NODE
;
127 /* Utility function to get address family from current node. */
128 afi_t
bgp_node_afi(struct vty
*vty
)
136 case BGP_FLOWSPECV6_NODE
:
149 /* Utility function to get subsequent address family from current
151 safi_t
bgp_node_safi(struct vty
*vty
)
157 safi
= SAFI_MPLS_VPN
;
161 safi
= SAFI_MULTICAST
;
168 safi
= SAFI_LABELED_UNICAST
;
170 case BGP_FLOWSPECV4_NODE
:
171 case BGP_FLOWSPECV6_NODE
:
172 safi
= SAFI_FLOWSPEC
;
182 * Converts an AFI in string form to afi_t
184 * @param afi string, one of
187 * @return the corresponding afi_t
189 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
191 afi_t afi
= AFI_MAX
; /* unknown */
192 if (strmatch(afi_str
, "ipv4"))
194 else if (strmatch(afi_str
, "ipv6"))
199 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
203 if (argv_find(argv
, argc
, "ipv4", index
)) {
207 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
215 /* supports <unicast|multicast|vpn|labeled-unicast> */
216 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
218 safi_t safi
= SAFI_MAX
; /* unknown */
219 if (strmatch(safi_str
, "multicast"))
220 safi
= SAFI_MULTICAST
;
221 else if (strmatch(safi_str
, "unicast"))
223 else if (strmatch(safi_str
, "vpn"))
224 safi
= SAFI_MPLS_VPN
;
225 else if (strmatch(safi_str
, "labeled-unicast"))
226 safi
= SAFI_LABELED_UNICAST
;
227 else if (strmatch(safi_str
, "flowspec"))
228 safi
= SAFI_FLOWSPEC
;
232 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
236 if (argv_find(argv
, argc
, "unicast", index
)) {
239 *safi
= SAFI_UNICAST
;
240 } else if (argv_find(argv
, argc
, "multicast", index
)) {
243 *safi
= SAFI_MULTICAST
;
244 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
247 *safi
= SAFI_LABELED_UNICAST
;
248 } else if (argv_find(argv
, argc
, "vpn", index
)) {
251 *safi
= SAFI_MPLS_VPN
;
252 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
255 *safi
= SAFI_FLOWSPEC
;
261 * bgp_vty_find_and_parse_afi_safi_bgp
263 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
264 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
265 * to appropriate values for the calling function. This is to allow the
266 * calling function to make decisions appropriate for the show command
267 * that is being parsed.
269 * The show commands are generally of the form:
270 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
271 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
273 * Since we use argv_find if the show command in particular doesn't have:
275 * [<view|vrf> VIEWVRFNAME]
276 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
277 * The command parsing should still be ok.
279 * vty -> The vty for the command so we can output some useful data in
280 * the event of a parse error in the vrf.
281 * argv -> The command tokens
282 * argc -> How many command tokens we have
283 * idx -> The current place in the command, generally should be 0 for this
285 * afi -> The parsed afi if it was included in the show command, returned here
286 * safi -> The parsed safi if it was included in the show command, returned here
287 * bgp -> Pointer to the bgp data structure we need to fill in.
289 * The function returns the correct location in the parse tree for the
292 * Returns 0 for failure to parse correctly, else the idx position of where
293 * it found the last token.
295 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
296 struct cmd_token
**argv
, int argc
,
297 int *idx
, afi_t
*afi
, safi_t
*safi
,
300 char *vrf_name
= NULL
;
306 if (argv_find(argv
, argc
, "ip", idx
))
309 if (argv_find(argv
, argc
, "view", idx
)
310 || argv_find(argv
, argc
, "vrf", idx
)) {
311 vrf_name
= argv
[*idx
+ 1]->arg
;
313 if (strmatch(vrf_name
, "all"))
316 *bgp
= bgp_lookup_by_name(vrf_name
);
319 "View/Vrf specified is unknown: %s\n",
326 *bgp
= bgp_get_default();
328 vty_out(vty
, "Unable to find default BGP instance\n");
334 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
335 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
341 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
343 struct interface
*ifp
= NULL
;
345 if (su
->sa
.sa_family
== AF_INET
)
346 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
347 else if (su
->sa
.sa_family
== AF_INET6
)
348 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
349 su
->sin6
.sin6_scope_id
,
358 /* Utility function for looking up peer from VTY. */
359 /* This is used only for configuration, so disallow if attempted on
360 * a dynamic neighbor.
362 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
364 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
373 ret
= str2sockunion(ip_str
, &su
);
375 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
377 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
380 "%% Malformed address or name: %s\n",
386 peer
= peer_lookup(bgp
, &su
);
389 "%% Specify remote-as or peer-group commands first\n");
392 if (peer_dynamic_neighbor(peer
)) {
394 "%% Operation not allowed on a dynamic neighbor\n");
401 /* Utility function for looking up peer or peer group. */
402 /* This is used only for configuration, so disallow if attempted on
403 * a dynamic neighbor.
405 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
407 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
410 struct peer
*peer
= NULL
;
411 struct peer_group
*group
= NULL
;
417 ret
= str2sockunion(peer_str
, &su
);
419 /* IP address, locate peer. */
420 peer
= peer_lookup(bgp
, &su
);
422 /* Not IP, could match either peer configured on interface or a
424 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
426 group
= peer_group_lookup(bgp
, peer_str
);
430 if (peer_dynamic_neighbor(peer
)) {
432 "%% Operation not allowed on a dynamic neighbor\n");
442 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
447 int bgp_vty_return(struct vty
*vty
, int ret
)
449 const char *str
= NULL
;
452 case BGP_ERR_INVALID_VALUE
:
453 str
= "Invalid value";
455 case BGP_ERR_INVALID_FLAG
:
456 str
= "Invalid flag";
458 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
459 str
= "Peer-group has been shutdown. Activate the peer-group first";
461 case BGP_ERR_PEER_FLAG_CONFLICT
:
462 str
= "Can't set override-capability and strict-capability-match at the same time";
464 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
465 str
= "Specify remote-as or peer-group remote AS first";
467 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
468 str
= "Cannot change the peer-group. Deconfigure first";
470 case BGP_ERR_PEER_GROUP_MISMATCH
:
471 str
= "Peer is not a member of this peer-group";
473 case BGP_ERR_PEER_FILTER_CONFLICT
:
474 str
= "Prefix/distribute list can not co-exist";
476 case BGP_ERR_NOT_INTERNAL_PEER
:
477 str
= "Invalid command. Not an internal neighbor";
479 case BGP_ERR_REMOVE_PRIVATE_AS
:
480 str
= "remove-private-AS cannot be configured for IBGP peers";
482 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
483 str
= "Local-AS allowed only for EBGP peers";
485 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
486 str
= "Cannot have local-as same as BGP AS number";
488 case BGP_ERR_TCPSIG_FAILED
:
489 str
= "Error while applying TCP-Sig to session(s)";
491 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
492 str
= "ebgp-multihop and ttl-security cannot be configured together";
494 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
495 str
= "ttl-security only allowed for EBGP peers";
497 case BGP_ERR_AS_OVERRIDE
:
498 str
= "as-override cannot be configured for IBGP peers";
500 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
501 str
= "Invalid limit for number of dynamic neighbors";
503 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
504 str
= "Dynamic neighbor listen range already exists";
506 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
507 str
= "Operation not allowed on a dynamic neighbor";
509 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
510 str
= "Operation not allowed on a directly connected neighbor";
512 case BGP_ERR_PEER_SAFI_CONFLICT
:
513 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
517 vty_out(vty
, "%% %s\n", str
);
518 return CMD_WARNING_CONFIG_FAILED
;
523 /* BGP clear sort. */
532 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
533 safi_t safi
, int error
)
536 case BGP_ERR_AF_UNCONFIGURED
:
538 "%%BGP: Enable %s address family for the neighbor %s\n",
539 afi_safi_print(afi
, safi
), peer
->host
);
541 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
543 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
551 /* `clear ip bgp' functions. */
552 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
553 enum clear_sort sort
, enum bgp_clear_type stype
,
559 struct listnode
*node
, *nnode
;
561 /* Clear all neighbors. */
563 * Pass along pointer to next node to peer_clear() when walking all
564 * nodes on the BGP instance as that may get freed if it is a
567 if (sort
== clear_all
) {
568 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
569 if (!peer
->afc
[afi
][safi
])
572 if (stype
== BGP_CLEAR_SOFT_NONE
)
573 ret
= peer_clear(peer
, &nnode
);
575 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
578 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
583 /* This is to apply read-only mode on this clear. */
584 if (stype
== BGP_CLEAR_SOFT_NONE
)
585 bgp
->update_delay_over
= 0;
588 vty_out(vty
, "%%BGP: No %s peer configured",
589 afi_safi_print(afi
, safi
));
594 /* Clear specified neighbor. */
595 if (sort
== clear_peer
) {
598 /* Make sockunion for lookup. */
599 ret
= str2sockunion(arg
, &su
);
601 peer
= peer_lookup_by_conf_if(bgp
, arg
);
603 peer
= peer_lookup_by_hostname(bgp
, arg
);
606 "Malformed address or name: %s\n",
612 peer
= peer_lookup(bgp
, &su
);
615 "%%BGP: Unknown neighbor - \"%s\"\n",
621 if (!peer
->afc
[afi
][safi
])
622 ret
= BGP_ERR_AF_UNCONFIGURED
;
623 else if (stype
== BGP_CLEAR_SOFT_NONE
)
624 ret
= peer_clear(peer
, NULL
);
626 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
629 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
634 /* Clear all neighbors belonging to a specific peer-group. */
635 if (sort
== clear_group
) {
636 struct peer_group
*group
;
638 group
= peer_group_lookup(bgp
, arg
);
640 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
644 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
645 if (!peer
->afc
[afi
][safi
])
648 if (stype
== BGP_CLEAR_SOFT_NONE
)
649 ret
= peer_clear(peer
, NULL
);
651 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
654 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
661 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
662 afi_safi_print(afi
, safi
), arg
);
667 /* Clear all external (eBGP) neighbors. */
668 if (sort
== clear_external
) {
669 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
670 if (peer
->sort
== BGP_PEER_IBGP
)
673 if (!peer
->afc
[afi
][safi
])
676 if (stype
== BGP_CLEAR_SOFT_NONE
)
677 ret
= peer_clear(peer
, &nnode
);
679 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
682 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
689 "%%BGP: No external %s peer is configured\n",
690 afi_safi_print(afi
, safi
));
695 /* Clear all neighbors belonging to a specific AS. */
696 if (sort
== clear_as
) {
697 as_t as
= strtoul(arg
, NULL
, 10);
699 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
703 if (!peer
->afc
[afi
][safi
])
704 ret
= BGP_ERR_AF_UNCONFIGURED
;
705 else if (stype
== BGP_CLEAR_SOFT_NONE
)
706 ret
= peer_clear(peer
, &nnode
);
708 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
711 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
718 "%%BGP: No %s peer is configured with AS %s\n",
719 afi_safi_print(afi
, safi
), arg
);
727 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
728 safi_t safi
, enum clear_sort sort
,
729 enum bgp_clear_type stype
, const char *arg
)
733 /* BGP structure lookup. */
735 bgp
= bgp_lookup_by_name(name
);
737 vty_out(vty
, "Can't find BGP instance %s\n", name
);
741 bgp
= bgp_get_default();
743 vty_out(vty
, "No BGP process is configured\n");
748 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
751 /* clear soft inbound */
752 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
754 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
755 BGP_CLEAR_SOFT_IN
, NULL
);
756 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
757 BGP_CLEAR_SOFT_IN
, NULL
);
760 /* clear soft outbound */
761 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
763 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
764 BGP_CLEAR_SOFT_OUT
, NULL
);
765 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
766 BGP_CLEAR_SOFT_OUT
, NULL
);
770 #ifndef VTYSH_EXTRACT_PL
771 #include "bgpd/bgp_vty_clippy.c"
774 /* BGP global configuration. */
775 #if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601)
776 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
777 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
779 DEFUN_HIDDEN (bgp_multiple_instance_func
,
780 bgp_multiple_instance_cmd
,
781 "bgp multiple-instance",
783 "Enable bgp multiple instance\n")
785 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
789 DEFUN_HIDDEN (no_bgp_multiple_instance
,
790 no_bgp_multiple_instance_cmd
,
791 "no bgp multiple-instance",
794 "BGP multiple instance\n")
798 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
799 vty_out(vty
, "if you are using this please let the developers know\n");
800 zlog_warn("Deprecated option: `bgp multiple-instance` being used");
801 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
803 vty_out(vty
, "%% There are more than two BGP instances\n");
804 return CMD_WARNING_CONFIG_FAILED
;
809 #if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601)
810 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
811 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
813 DEFUN_HIDDEN (bgp_config_type
,
815 "bgp config-type <cisco|zebra>",
817 "Configuration type\n"
822 if (argv_find(argv
, argc
, "cisco", &idx
)) {
823 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
824 vty_out(vty
, "if you are using this please let the developers know!\n");
825 zlog_warn("Deprecated option: `bgp config-type cisco` being used");
826 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
828 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
833 DEFUN_HIDDEN (no_bgp_config_type
,
834 no_bgp_config_type_cmd
,
835 "no bgp config-type [<cisco|zebra>]",
838 "Display configuration type\n"
842 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
847 DEFUN (no_synchronization
,
848 no_synchronization_cmd
,
849 "no synchronization",
851 "Perform IGP synchronization\n")
856 DEFUN (no_auto_summary
,
860 "Enable automatic network number summarization\n")
865 /* "router bgp" commands. */
866 DEFUN_NOSH (router_bgp
,
868 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
872 BGP_INSTANCE_HELP_STR
)
875 int idx_view_vrf
= 3;
880 const char *name
= NULL
;
881 enum bgp_instance_type inst_type
;
883 // "router bgp" without an ASN
885 // Pending: Make VRF option available for ASN less config
886 bgp
= bgp_get_default();
889 vty_out(vty
, "%% No BGP process is configured\n");
890 return CMD_WARNING_CONFIG_FAILED
;
893 if (listcount(bm
->bgp
) > 1) {
894 vty_out(vty
, "%% Please specify ASN and VRF\n");
895 return CMD_WARNING_CONFIG_FAILED
;
901 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
903 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
905 name
= argv
[idx_vrf
]->arg
;
907 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf"))
908 inst_type
= BGP_INSTANCE_TYPE_VRF
;
909 else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
910 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
913 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
915 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
917 "Please specify 'bgp multiple-instance' first\n");
918 return CMD_WARNING_CONFIG_FAILED
;
919 case BGP_ERR_AS_MISMATCH
:
920 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
921 return CMD_WARNING_CONFIG_FAILED
;
922 case BGP_ERR_INSTANCE_MISMATCH
:
924 "BGP instance name and AS number mismatch\n");
926 "BGP instance is already running; AS is %u\n",
928 return CMD_WARNING_CONFIG_FAILED
;
932 * If we just instantiated the default instance, complete
933 * any pending VRF-VPN leaking that was configured via
934 * earlier "router bgp X vrf FOO" blocks.
936 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
937 vpn_leak_postchange_all();
939 /* Pending: handle when user tries to change a view to vrf n vv.
943 /* unset the auto created flag as the user config is now present */
944 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
945 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
950 /* "no router bgp" commands. */
951 DEFUN (no_router_bgp
,
953 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
958 BGP_INSTANCE_HELP_STR
)
964 const char *name
= NULL
;
966 // "no router bgp" without an ASN
968 // Pending: Make VRF option available for ASN less config
969 bgp
= bgp_get_default();
972 vty_out(vty
, "%% No BGP process is configured\n");
973 return CMD_WARNING_CONFIG_FAILED
;
976 if (listcount(bm
->bgp
) > 1) {
977 vty_out(vty
, "%% Please specify ASN and VRF\n");
978 return CMD_WARNING_CONFIG_FAILED
;
982 vty_out(vty
, "%% Please unconfigure l3vni %u",
984 return CMD_WARNING_CONFIG_FAILED
;
987 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
990 name
= argv
[idx_vrf
]->arg
;
992 /* Lookup bgp structure. */
993 bgp
= bgp_lookup(as
, name
);
995 vty_out(vty
, "%% Can't find BGP instance\n");
996 return CMD_WARNING_CONFIG_FAILED
;
1000 vty_out(vty
, "%% Please unconfigure l3vni %u",
1002 return CMD_WARNING_CONFIG_FAILED
;
1012 /* BGP router-id. */
1014 DEFPY (bgp_router_id
,
1016 "bgp router-id A.B.C.D",
1018 "Override configured router identifier\n"
1019 "Manually configured router identifier\n")
1021 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1022 bgp_router_id_static_set(bgp
, router_id
);
1026 DEFPY (no_bgp_router_id
,
1027 no_bgp_router_id_cmd
,
1028 "no bgp router-id [A.B.C.D]",
1031 "Override configured router identifier\n"
1032 "Manually configured router identifier\n")
1034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1036 if (router_id_str
) {
1037 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1038 vty_out(vty
, "%% BGP router-id doesn't match\n");
1039 return CMD_WARNING_CONFIG_FAILED
;
1043 router_id
.s_addr
= 0;
1044 bgp_router_id_static_set(bgp
, router_id
);
1050 /* BGP Cluster ID. */
1051 DEFUN (bgp_cluster_id
,
1053 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1055 "Configure Route-Reflector Cluster-id\n"
1056 "Route-Reflector Cluster-id in IP address format\n"
1057 "Route-Reflector Cluster-id as 32 bit quantity\n")
1059 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1062 struct in_addr cluster
;
1064 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1066 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1067 return CMD_WARNING_CONFIG_FAILED
;
1070 bgp_cluster_id_set(bgp
, &cluster
);
1071 bgp_clear_star_soft_out(vty
, bgp
->name
);
1076 DEFUN (no_bgp_cluster_id
,
1077 no_bgp_cluster_id_cmd
,
1078 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1081 "Configure Route-Reflector Cluster-id\n"
1082 "Route-Reflector Cluster-id in IP address format\n"
1083 "Route-Reflector Cluster-id as 32 bit quantity\n")
1085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1086 bgp_cluster_id_unset(bgp
);
1087 bgp_clear_star_soft_out(vty
, bgp
->name
);
1092 DEFUN (bgp_confederation_identifier
,
1093 bgp_confederation_identifier_cmd
,
1094 "bgp confederation identifier (1-4294967295)",
1095 "BGP specific commands\n"
1096 "AS confederation parameters\n"
1098 "Set routing domain confederation AS\n")
1100 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1104 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1106 bgp_confederation_id_set(bgp
, as
);
1111 DEFUN (no_bgp_confederation_identifier
,
1112 no_bgp_confederation_identifier_cmd
,
1113 "no bgp confederation identifier [(1-4294967295)]",
1115 "BGP specific commands\n"
1116 "AS confederation parameters\n"
1118 "Set routing domain confederation AS\n")
1120 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1121 bgp_confederation_id_unset(bgp
);
1126 DEFUN (bgp_confederation_peers
,
1127 bgp_confederation_peers_cmd
,
1128 "bgp confederation peers (1-4294967295)...",
1129 "BGP specific commands\n"
1130 "AS confederation parameters\n"
1131 "Peer ASs in BGP confederation\n"
1134 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1139 for (i
= idx_asn
; i
< argc
; i
++) {
1140 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1142 if (bgp
->as
== as
) {
1144 "%% Local member-AS not allowed in confed peer list\n");
1148 bgp_confederation_peers_add(bgp
, as
);
1153 DEFUN (no_bgp_confederation_peers
,
1154 no_bgp_confederation_peers_cmd
,
1155 "no bgp confederation peers (1-4294967295)...",
1157 "BGP specific commands\n"
1158 "AS confederation parameters\n"
1159 "Peer ASs in BGP confederation\n"
1162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1167 for (i
= idx_asn
; i
< argc
; i
++) {
1168 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1170 bgp_confederation_peers_remove(bgp
, as
);
1176 * Central routine for maximum-paths configuration.
1177 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1178 * @set: 1 for setting values, 0 for removing the max-paths config.
1180 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1181 const char *mpaths
, uint16_t options
,
1184 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1185 uint16_t maxpaths
= 0;
1190 afi
= bgp_node_afi(vty
);
1191 safi
= bgp_node_safi(vty
);
1194 maxpaths
= strtol(mpaths
, NULL
, 10);
1195 if (maxpaths
> multipath_num
) {
1197 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1198 maxpaths
, multipath_num
);
1199 return CMD_WARNING_CONFIG_FAILED
;
1201 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1204 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1208 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1209 (set
== 1) ? "" : "un",
1210 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1211 maxpaths
, afi
, safi
);
1212 return CMD_WARNING_CONFIG_FAILED
;
1215 bgp_recalculate_all_bestpaths(bgp
);
1220 DEFUN (bgp_maxmed_admin
,
1221 bgp_maxmed_admin_cmd
,
1222 "bgp max-med administrative ",
1224 "Advertise routes with max-med\n"
1225 "Administratively applied, for an indefinite period\n")
1227 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1229 bgp
->v_maxmed_admin
= 1;
1230 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1232 bgp_maxmed_update(bgp
);
1237 DEFUN (bgp_maxmed_admin_medv
,
1238 bgp_maxmed_admin_medv_cmd
,
1239 "bgp max-med administrative (0-4294967295)",
1241 "Advertise routes with max-med\n"
1242 "Administratively applied, for an indefinite period\n"
1243 "Max MED value to be used\n")
1245 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1248 bgp
->v_maxmed_admin
= 1;
1249 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1251 bgp_maxmed_update(bgp
);
1256 DEFUN (no_bgp_maxmed_admin
,
1257 no_bgp_maxmed_admin_cmd
,
1258 "no bgp max-med administrative [(0-4294967295)]",
1261 "Advertise routes with max-med\n"
1262 "Administratively applied, for an indefinite period\n"
1263 "Max MED value to be used\n")
1265 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1266 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1267 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1268 bgp_maxmed_update(bgp
);
1273 DEFUN (bgp_maxmed_onstartup
,
1274 bgp_maxmed_onstartup_cmd
,
1275 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1277 "Advertise routes with max-med\n"
1278 "Effective on a startup\n"
1279 "Time (seconds) period for max-med\n"
1280 "Max MED value to be used\n")
1282 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1285 argv_find(argv
, argc
, "(5-86400)", &idx
);
1286 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1287 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1288 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1290 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1292 bgp_maxmed_update(bgp
);
1297 DEFUN (no_bgp_maxmed_onstartup
,
1298 no_bgp_maxmed_onstartup_cmd
,
1299 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1302 "Advertise routes with max-med\n"
1303 "Effective on a startup\n"
1304 "Time (seconds) period for max-med\n"
1305 "Max MED value to be used\n")
1307 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1309 /* Cancel max-med onstartup if its on */
1310 if (bgp
->t_maxmed_onstartup
) {
1311 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1312 bgp
->maxmed_onstartup_over
= 1;
1315 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1316 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1318 bgp_maxmed_update(bgp
);
1323 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1327 uint16_t update_delay
;
1328 uint16_t establish_wait
;
1330 update_delay
= strtoul(delay
, NULL
, 10);
1332 if (!wait
) /* update-delay <delay> */
1334 bgp
->v_update_delay
= update_delay
;
1335 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1339 /* update-delay <delay> <establish-wait> */
1340 establish_wait
= atoi(wait
);
1341 if (update_delay
< establish_wait
) {
1343 "%%Failed: update-delay less than the establish-wait!\n");
1344 return CMD_WARNING_CONFIG_FAILED
;
1347 bgp
->v_update_delay
= update_delay
;
1348 bgp
->v_establish_wait
= establish_wait
;
1353 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1357 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1358 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1363 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1365 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1366 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1367 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1368 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1374 /* Update-delay configuration */
1375 DEFUN (bgp_update_delay
,
1376 bgp_update_delay_cmd
,
1377 "update-delay (0-3600)",
1378 "Force initial delay for best-path and updates\n"
1382 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1385 DEFUN (bgp_update_delay_establish_wait
,
1386 bgp_update_delay_establish_wait_cmd
,
1387 "update-delay (0-3600) (1-3600)",
1388 "Force initial delay for best-path and updates\n"
1393 int idx_number_2
= 2;
1394 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1395 argv
[idx_number_2
]->arg
);
1398 /* Update-delay deconfiguration */
1399 DEFUN (no_bgp_update_delay
,
1400 no_bgp_update_delay_cmd
,
1401 "no update-delay [(0-3600) [(1-3600)]]",
1403 "Force initial delay for best-path and updates\n"
1407 return bgp_update_delay_deconfig_vty(vty
);
1411 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1414 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1417 uint32_t quanta
= strtoul(num
, NULL
, 10);
1418 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1419 memory_order_relaxed
);
1421 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1422 memory_order_relaxed
);
1428 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1431 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1434 uint32_t quanta
= strtoul(num
, NULL
, 10);
1435 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1436 memory_order_relaxed
);
1438 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1439 memory_order_relaxed
);
1445 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1448 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1449 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1450 vty_out(vty
, " write-quanta %d\n", quanta
);
1453 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1456 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1457 if (quanta
!= BGP_READ_PACKET_MAX
)
1458 vty_out(vty
, " read-quanta %d\n", quanta
);
1461 /* Packet quanta configuration */
1462 DEFUN (bgp_wpkt_quanta
,
1463 bgp_wpkt_quanta_cmd
,
1464 "write-quanta (1-10)",
1465 "How many packets to write to peer socket per run\n"
1466 "Number of packets\n")
1469 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1472 DEFUN (no_bgp_wpkt_quanta
,
1473 no_bgp_wpkt_quanta_cmd
,
1474 "no write-quanta (1-10)",
1476 "How many packets to write to peer socket per I/O cycle\n"
1477 "Number of packets\n")
1480 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1483 DEFUN (bgp_rpkt_quanta
,
1484 bgp_rpkt_quanta_cmd
,
1485 "read-quanta (1-10)",
1486 "How many packets to read from peer socket per I/O cycle\n"
1487 "Number of packets\n")
1490 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1493 DEFUN (no_bgp_rpkt_quanta
,
1494 no_bgp_rpkt_quanta_cmd
,
1495 "no read-quanta (1-10)",
1497 "How many packets to read from peer socket per I/O cycle\n"
1498 "Number of packets\n")
1501 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1504 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1506 if (!bgp
->heuristic_coalesce
)
1507 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1511 DEFUN (bgp_coalesce_time
,
1512 bgp_coalesce_time_cmd
,
1513 "coalesce-time (0-4294967295)",
1514 "Subgroup coalesce timer\n"
1515 "Subgroup coalesce timer value (in ms)\n")
1517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1520 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1521 bgp
->heuristic_coalesce
= false;
1522 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1526 DEFUN (no_bgp_coalesce_time
,
1527 no_bgp_coalesce_time_cmd
,
1528 "no coalesce-time (0-4294967295)",
1530 "Subgroup coalesce timer\n"
1531 "Subgroup coalesce timer value (in ms)\n")
1533 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1535 bgp
->heuristic_coalesce
= true;
1536 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1540 /* Maximum-paths configuration */
1541 DEFUN (bgp_maxpaths
,
1543 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1544 "Forward packets over multiple paths\n"
1545 "Number of paths\n")
1548 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1549 argv
[idx_number
]->arg
, 0, 1);
1552 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1553 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1554 "Forward packets over multiple paths\n"
1555 "Number of paths\n")
1557 DEFUN (bgp_maxpaths_ibgp
,
1558 bgp_maxpaths_ibgp_cmd
,
1559 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1560 "Forward packets over multiple paths\n"
1562 "Number of paths\n")
1565 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1566 argv
[idx_number
]->arg
, 0, 1);
1569 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1570 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1571 "Forward packets over multiple paths\n"
1573 "Number of paths\n")
1575 DEFUN (bgp_maxpaths_ibgp_cluster
,
1576 bgp_maxpaths_ibgp_cluster_cmd
,
1577 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1578 "Forward packets over multiple paths\n"
1581 "Match the cluster length\n")
1584 return bgp_maxpaths_config_vty(
1585 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1586 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1589 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1590 "maximum-paths ibgp " CMD_RANGE_STR(
1591 1, MULTIPATH_NUM
) " equal-cluster-length",
1592 "Forward packets over multiple paths\n"
1595 "Match the cluster length\n")
1597 DEFUN (no_bgp_maxpaths
,
1598 no_bgp_maxpaths_cmd
,
1599 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1601 "Forward packets over multiple paths\n"
1602 "Number of paths\n")
1604 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1607 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1608 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1609 "Forward packets over multiple paths\n"
1610 "Number of paths\n")
1612 DEFUN (no_bgp_maxpaths_ibgp
,
1613 no_bgp_maxpaths_ibgp_cmd
,
1614 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1616 "Forward packets over multiple paths\n"
1619 "Match the cluster length\n")
1621 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1624 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1625 "no maximum-paths ibgp [" CMD_RANGE_STR(
1626 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1628 "Forward packets over multiple paths\n"
1631 "Match the cluster length\n")
1633 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1636 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1637 vty_out(vty
, " maximum-paths %d\n",
1638 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1641 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1642 vty_out(vty
, " maximum-paths ibgp %d",
1643 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1644 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1645 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1646 vty_out(vty
, " equal-cluster-length");
1655 "timers bgp (0-65535) (0-65535)",
1656 "Adjust routing timers\n"
1658 "Keepalive interval\n"
1661 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1663 int idx_number_2
= 3;
1664 unsigned long keepalive
= 0;
1665 unsigned long holdtime
= 0;
1667 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1668 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1670 /* Holdtime value check. */
1671 if (holdtime
< 3 && holdtime
!= 0) {
1673 "%% hold time value must be either 0 or greater than 3\n");
1674 return CMD_WARNING_CONFIG_FAILED
;
1677 bgp_timers_set(bgp
, keepalive
, holdtime
);
1682 DEFUN (no_bgp_timers
,
1684 "no timers bgp [(0-65535) (0-65535)]",
1686 "Adjust routing timers\n"
1688 "Keepalive interval\n"
1691 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1692 bgp_timers_unset(bgp
);
1698 DEFUN (bgp_client_to_client_reflection
,
1699 bgp_client_to_client_reflection_cmd
,
1700 "bgp client-to-client reflection",
1701 "BGP specific commands\n"
1702 "Configure client to client route reflection\n"
1703 "reflection of routes allowed\n")
1705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1706 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1707 bgp_clear_star_soft_out(vty
, bgp
->name
);
1712 DEFUN (no_bgp_client_to_client_reflection
,
1713 no_bgp_client_to_client_reflection_cmd
,
1714 "no bgp client-to-client reflection",
1716 "BGP specific commands\n"
1717 "Configure client to client route reflection\n"
1718 "reflection of routes allowed\n")
1720 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1721 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1722 bgp_clear_star_soft_out(vty
, bgp
->name
);
1727 /* "bgp always-compare-med" configuration. */
1728 DEFUN (bgp_always_compare_med
,
1729 bgp_always_compare_med_cmd
,
1730 "bgp always-compare-med",
1731 "BGP specific commands\n"
1732 "Allow comparing MED from different neighbors\n")
1734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1735 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1736 bgp_recalculate_all_bestpaths(bgp
);
1741 DEFUN (no_bgp_always_compare_med
,
1742 no_bgp_always_compare_med_cmd
,
1743 "no bgp always-compare-med",
1745 "BGP specific commands\n"
1746 "Allow comparing MED from different neighbors\n")
1748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1749 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1750 bgp_recalculate_all_bestpaths(bgp
);
1755 /* "bgp deterministic-med" configuration. */
1756 DEFUN (bgp_deterministic_med
,
1757 bgp_deterministic_med_cmd
,
1758 "bgp deterministic-med",
1759 "BGP specific commands\n"
1760 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1764 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1765 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1766 bgp_recalculate_all_bestpaths(bgp
);
1772 DEFUN (no_bgp_deterministic_med
,
1773 no_bgp_deterministic_med_cmd
,
1774 "no bgp deterministic-med",
1776 "BGP specific commands\n"
1777 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1779 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1780 int bestpath_per_as_used
;
1784 struct listnode
*node
, *nnode
;
1786 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1787 bestpath_per_as_used
= 0;
1789 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1790 FOREACH_AFI_SAFI (afi
, safi
)
1792 peer
->af_flags
[afi
][safi
],
1793 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1794 bestpath_per_as_used
= 1;
1798 if (bestpath_per_as_used
)
1802 if (bestpath_per_as_used
) {
1804 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1805 return CMD_WARNING_CONFIG_FAILED
;
1807 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1808 bgp_recalculate_all_bestpaths(bgp
);
1815 /* "bgp graceful-restart" configuration. */
1816 DEFUN (bgp_graceful_restart
,
1817 bgp_graceful_restart_cmd
,
1818 "bgp graceful-restart",
1819 "BGP specific commands\n"
1820 "Graceful restart capability parameters\n")
1822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1823 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1827 DEFUN (no_bgp_graceful_restart
,
1828 no_bgp_graceful_restart_cmd
,
1829 "no bgp graceful-restart",
1831 "BGP specific commands\n"
1832 "Graceful restart capability parameters\n")
1834 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1835 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1839 DEFUN (bgp_graceful_restart_stalepath_time
,
1840 bgp_graceful_restart_stalepath_time_cmd
,
1841 "bgp graceful-restart stalepath-time (1-3600)",
1842 "BGP specific commands\n"
1843 "Graceful restart capability parameters\n"
1844 "Set the max time to hold onto restarting peer's stale paths\n"
1845 "Delay value (seconds)\n")
1847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1851 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1852 bgp
->stalepath_time
= stalepath
;
1856 DEFUN (bgp_graceful_restart_restart_time
,
1857 bgp_graceful_restart_restart_time_cmd
,
1858 "bgp graceful-restart restart-time (1-3600)",
1859 "BGP specific commands\n"
1860 "Graceful restart capability parameters\n"
1861 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1862 "Delay value (seconds)\n")
1864 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1868 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1869 bgp
->restart_time
= restart
;
1873 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1874 no_bgp_graceful_restart_stalepath_time_cmd
,
1875 "no bgp graceful-restart stalepath-time [(1-3600)]",
1877 "BGP specific commands\n"
1878 "Graceful restart capability parameters\n"
1879 "Set the max time to hold onto restarting peer's stale paths\n"
1880 "Delay value (seconds)\n")
1882 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1884 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1888 DEFUN (no_bgp_graceful_restart_restart_time
,
1889 no_bgp_graceful_restart_restart_time_cmd
,
1890 "no bgp graceful-restart restart-time [(1-3600)]",
1892 "BGP specific commands\n"
1893 "Graceful restart capability parameters\n"
1894 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1895 "Delay value (seconds)\n")
1897 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1899 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1903 DEFUN (bgp_graceful_restart_preserve_fw
,
1904 bgp_graceful_restart_preserve_fw_cmd
,
1905 "bgp graceful-restart preserve-fw-state",
1906 "BGP specific commands\n"
1907 "Graceful restart capability parameters\n"
1908 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1910 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1911 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1915 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1916 no_bgp_graceful_restart_preserve_fw_cmd
,
1917 "no bgp graceful-restart preserve-fw-state",
1919 "BGP specific commands\n"
1920 "Graceful restart capability parameters\n"
1921 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1924 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1928 static void bgp_redistribute_redo(struct bgp
*bgp
)
1932 struct list
*red_list
;
1933 struct listnode
*node
;
1934 struct bgp_redist
*red
;
1936 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1937 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1939 red_list
= bgp
->redist
[afi
][i
];
1943 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1944 bgp_redistribute_resend(bgp
, afi
, i
,
1951 /* "bgp graceful-shutdown" configuration */
1952 DEFUN (bgp_graceful_shutdown
,
1953 bgp_graceful_shutdown_cmd
,
1954 "bgp graceful-shutdown",
1956 "Graceful shutdown parameters\n")
1958 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1960 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1961 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1962 bgp_static_redo_import_check(bgp
);
1963 bgp_redistribute_redo(bgp
);
1964 bgp_clear_star_soft_out(vty
, bgp
->name
);
1965 bgp_clear_star_soft_in(vty
, bgp
->name
);
1971 DEFUN (no_bgp_graceful_shutdown
,
1972 no_bgp_graceful_shutdown_cmd
,
1973 "no bgp graceful-shutdown",
1976 "Graceful shutdown parameters\n")
1978 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1980 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1981 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1982 bgp_static_redo_import_check(bgp
);
1983 bgp_redistribute_redo(bgp
);
1984 bgp_clear_star_soft_out(vty
, bgp
->name
);
1985 bgp_clear_star_soft_in(vty
, bgp
->name
);
1991 /* "bgp fast-external-failover" configuration. */
1992 DEFUN (bgp_fast_external_failover
,
1993 bgp_fast_external_failover_cmd
,
1994 "bgp fast-external-failover",
1996 "Immediately reset session if a link to a directly connected external peer goes down\n")
1998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1999 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2003 DEFUN (no_bgp_fast_external_failover
,
2004 no_bgp_fast_external_failover_cmd
,
2005 "no bgp fast-external-failover",
2008 "Immediately reset session if a link to a directly connected external peer goes down\n")
2010 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2011 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2015 /* "bgp enforce-first-as" configuration. */
2016 #if defined(VERSION_TYPE_DEV) && CONFDATE > 20180517
2017 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2020 DEFUN_HIDDEN (bgp_enforce_first_as
,
2021 bgp_enforce_first_as_cmd
,
2022 "[no] bgp enforce-first-as",
2025 "Enforce the first AS for EBGP routes\n")
2027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2029 if (strmatch(argv
[0]->text
, "no"))
2030 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2032 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2037 /* "bgp bestpath compare-routerid" configuration. */
2038 DEFUN (bgp_bestpath_compare_router_id
,
2039 bgp_bestpath_compare_router_id_cmd
,
2040 "bgp bestpath compare-routerid",
2041 "BGP specific commands\n"
2042 "Change the default bestpath selection\n"
2043 "Compare router-id for identical EBGP paths\n")
2045 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2046 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2047 bgp_recalculate_all_bestpaths(bgp
);
2052 DEFUN (no_bgp_bestpath_compare_router_id
,
2053 no_bgp_bestpath_compare_router_id_cmd
,
2054 "no bgp bestpath compare-routerid",
2056 "BGP specific commands\n"
2057 "Change the default bestpath selection\n"
2058 "Compare router-id for identical EBGP paths\n")
2060 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2061 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2062 bgp_recalculate_all_bestpaths(bgp
);
2067 /* "bgp bestpath as-path ignore" configuration. */
2068 DEFUN (bgp_bestpath_aspath_ignore
,
2069 bgp_bestpath_aspath_ignore_cmd
,
2070 "bgp bestpath as-path ignore",
2071 "BGP specific commands\n"
2072 "Change the default bestpath selection\n"
2073 "AS-path attribute\n"
2074 "Ignore as-path length in selecting a route\n")
2076 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2077 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2078 bgp_recalculate_all_bestpaths(bgp
);
2083 DEFUN (no_bgp_bestpath_aspath_ignore
,
2084 no_bgp_bestpath_aspath_ignore_cmd
,
2085 "no bgp bestpath as-path ignore",
2087 "BGP specific commands\n"
2088 "Change the default bestpath selection\n"
2089 "AS-path attribute\n"
2090 "Ignore as-path length in selecting a route\n")
2092 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2093 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2094 bgp_recalculate_all_bestpaths(bgp
);
2099 /* "bgp bestpath as-path confed" configuration. */
2100 DEFUN (bgp_bestpath_aspath_confed
,
2101 bgp_bestpath_aspath_confed_cmd
,
2102 "bgp bestpath as-path confed",
2103 "BGP specific commands\n"
2104 "Change the default bestpath selection\n"
2105 "AS-path attribute\n"
2106 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2108 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2109 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2110 bgp_recalculate_all_bestpaths(bgp
);
2115 DEFUN (no_bgp_bestpath_aspath_confed
,
2116 no_bgp_bestpath_aspath_confed_cmd
,
2117 "no bgp bestpath as-path confed",
2119 "BGP specific commands\n"
2120 "Change the default bestpath selection\n"
2121 "AS-path attribute\n"
2122 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2125 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2126 bgp_recalculate_all_bestpaths(bgp
);
2131 /* "bgp bestpath as-path multipath-relax" configuration. */
2132 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2133 bgp_bestpath_aspath_multipath_relax_cmd
,
2134 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2135 "BGP specific commands\n"
2136 "Change the default bestpath selection\n"
2137 "AS-path attribute\n"
2138 "Allow load sharing across routes that have different AS paths (but same length)\n"
2139 "Generate an AS_SET\n"
2140 "Do not generate an AS_SET\n")
2142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2144 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2146 /* no-as-set is now the default behavior so we can silently
2148 if (argv_find(argv
, argc
, "as-set", &idx
))
2149 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2151 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2153 bgp_recalculate_all_bestpaths(bgp
);
2158 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2159 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2160 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2162 "BGP specific commands\n"
2163 "Change the default bestpath selection\n"
2164 "AS-path attribute\n"
2165 "Allow load sharing across routes that have different AS paths (but same length)\n"
2166 "Generate an AS_SET\n"
2167 "Do not generate an AS_SET\n")
2169 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2170 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2171 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2172 bgp_recalculate_all_bestpaths(bgp
);
2177 /* "bgp log-neighbor-changes" configuration. */
2178 DEFUN (bgp_log_neighbor_changes
,
2179 bgp_log_neighbor_changes_cmd
,
2180 "bgp log-neighbor-changes",
2181 "BGP specific commands\n"
2182 "Log neighbor up/down and reset reason\n")
2184 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2185 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2189 DEFUN (no_bgp_log_neighbor_changes
,
2190 no_bgp_log_neighbor_changes_cmd
,
2191 "no bgp log-neighbor-changes",
2193 "BGP specific commands\n"
2194 "Log neighbor up/down and reset reason\n")
2196 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2197 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2201 /* "bgp bestpath med" configuration. */
2202 DEFUN (bgp_bestpath_med
,
2203 bgp_bestpath_med_cmd
,
2204 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2205 "BGP specific commands\n"
2206 "Change the default bestpath selection\n"
2208 "Compare MED among confederation paths\n"
2209 "Treat missing MED as the least preferred one\n"
2210 "Treat missing MED as the least preferred one\n"
2211 "Compare MED among confederation paths\n")
2213 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2216 if (argv_find(argv
, argc
, "confed", &idx
))
2217 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2219 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2220 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2222 bgp_recalculate_all_bestpaths(bgp
);
2227 DEFUN (no_bgp_bestpath_med
,
2228 no_bgp_bestpath_med_cmd
,
2229 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2231 "BGP specific commands\n"
2232 "Change the default bestpath selection\n"
2234 "Compare MED among confederation paths\n"
2235 "Treat missing MED as the least preferred one\n"
2236 "Treat missing MED as the least preferred one\n"
2237 "Compare MED among confederation paths\n")
2239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2242 if (argv_find(argv
, argc
, "confed", &idx
))
2243 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2245 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2246 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2248 bgp_recalculate_all_bestpaths(bgp
);
2253 /* "no bgp default ipv4-unicast". */
2254 DEFUN (no_bgp_default_ipv4_unicast
,
2255 no_bgp_default_ipv4_unicast_cmd
,
2256 "no bgp default ipv4-unicast",
2258 "BGP specific commands\n"
2259 "Configure BGP defaults\n"
2260 "Activate ipv4-unicast for a peer by default\n")
2262 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2263 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2267 DEFUN (bgp_default_ipv4_unicast
,
2268 bgp_default_ipv4_unicast_cmd
,
2269 "bgp default ipv4-unicast",
2270 "BGP specific commands\n"
2271 "Configure BGP defaults\n"
2272 "Activate ipv4-unicast for a peer by default\n")
2274 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2275 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2279 /* Display hostname in certain command outputs */
2280 DEFUN (bgp_default_show_hostname
,
2281 bgp_default_show_hostname_cmd
,
2282 "bgp default show-hostname",
2283 "BGP specific commands\n"
2284 "Configure BGP defaults\n"
2285 "Show hostname in certain command ouputs\n")
2287 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2288 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2292 DEFUN (no_bgp_default_show_hostname
,
2293 no_bgp_default_show_hostname_cmd
,
2294 "no bgp default show-hostname",
2296 "BGP specific commands\n"
2297 "Configure BGP defaults\n"
2298 "Show hostname in certain command ouputs\n")
2300 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2301 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2305 /* "bgp network import-check" configuration. */
2306 DEFUN (bgp_network_import_check
,
2307 bgp_network_import_check_cmd
,
2308 "bgp network import-check",
2309 "BGP specific commands\n"
2310 "BGP network command\n"
2311 "Check BGP network route exists in IGP\n")
2313 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2314 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2315 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2316 bgp_static_redo_import_check(bgp
);
2322 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2323 "bgp network import-check exact",
2324 "BGP specific commands\n"
2325 "BGP network command\n"
2326 "Check BGP network route exists in IGP\n"
2327 "Match route precisely\n")
2329 DEFUN (no_bgp_network_import_check
,
2330 no_bgp_network_import_check_cmd
,
2331 "no bgp network import-check",
2333 "BGP specific commands\n"
2334 "BGP network command\n"
2335 "Check BGP network route exists in IGP\n")
2337 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2338 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2339 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2340 bgp_static_redo_import_check(bgp
);
2346 DEFUN (bgp_default_local_preference
,
2347 bgp_default_local_preference_cmd
,
2348 "bgp default local-preference (0-4294967295)",
2349 "BGP specific commands\n"
2350 "Configure BGP defaults\n"
2351 "local preference (higher=more preferred)\n"
2352 "Configure default local preference value\n")
2354 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2356 uint32_t local_pref
;
2358 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2360 bgp_default_local_preference_set(bgp
, local_pref
);
2361 bgp_clear_star_soft_in(vty
, bgp
->name
);
2366 DEFUN (no_bgp_default_local_preference
,
2367 no_bgp_default_local_preference_cmd
,
2368 "no bgp default local-preference [(0-4294967295)]",
2370 "BGP specific commands\n"
2371 "Configure BGP defaults\n"
2372 "local preference (higher=more preferred)\n"
2373 "Configure default local preference value\n")
2375 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2376 bgp_default_local_preference_unset(bgp
);
2377 bgp_clear_star_soft_in(vty
, bgp
->name
);
2383 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2384 bgp_default_subgroup_pkt_queue_max_cmd
,
2385 "bgp default subgroup-pkt-queue-max (20-100)",
2386 "BGP specific commands\n"
2387 "Configure BGP defaults\n"
2388 "subgroup-pkt-queue-max\n"
2389 "Configure subgroup packet queue max\n")
2391 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2395 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2397 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2402 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2403 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2404 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2406 "BGP specific commands\n"
2407 "Configure BGP defaults\n"
2408 "subgroup-pkt-queue-max\n"
2409 "Configure subgroup packet queue max\n")
2411 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2412 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2417 DEFUN (bgp_rr_allow_outbound_policy
,
2418 bgp_rr_allow_outbound_policy_cmd
,
2419 "bgp route-reflector allow-outbound-policy",
2420 "BGP specific commands\n"
2421 "Allow modifications made by out route-map\n"
2422 "on ibgp neighbors\n")
2424 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2426 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2427 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2428 update_group_announce_rrclients(bgp
);
2429 bgp_clear_star_soft_out(vty
, bgp
->name
);
2435 DEFUN (no_bgp_rr_allow_outbound_policy
,
2436 no_bgp_rr_allow_outbound_policy_cmd
,
2437 "no bgp route-reflector allow-outbound-policy",
2439 "BGP specific commands\n"
2440 "Allow modifications made by out route-map\n"
2441 "on ibgp neighbors\n")
2443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2445 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2446 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2447 update_group_announce_rrclients(bgp
);
2448 bgp_clear_star_soft_out(vty
, bgp
->name
);
2454 DEFUN (bgp_listen_limit
,
2455 bgp_listen_limit_cmd
,
2456 "bgp listen limit (1-5000)",
2457 "BGP specific commands\n"
2458 "Configure BGP defaults\n"
2459 "maximum number of BGP Dynamic Neighbors that can be created\n"
2460 "Configure Dynamic Neighbors listen limit value\n")
2462 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2466 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2468 bgp_listen_limit_set(bgp
, listen_limit
);
2473 DEFUN (no_bgp_listen_limit
,
2474 no_bgp_listen_limit_cmd
,
2475 "no bgp listen limit [(1-5000)]",
2476 "BGP specific commands\n"
2477 "Configure BGP defaults\n"
2478 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2479 "Configure Dynamic Neighbors listen limit value to default\n"
2480 "Configure Dynamic Neighbors listen limit value\n")
2482 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2483 bgp_listen_limit_unset(bgp
);
2489 * Check if this listen range is already configured. Check for exact
2490 * match or overlap based on input.
2492 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2493 struct prefix
*range
, int exact
)
2495 struct listnode
*node
, *nnode
;
2496 struct listnode
*node1
, *nnode1
;
2497 struct peer_group
*group
;
2502 afi
= family2afi(range
->family
);
2503 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2504 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2507 match
= prefix_same(range
, lr
);
2509 match
= (prefix_match(range
, lr
)
2510 || prefix_match(lr
, range
));
2519 DEFUN (bgp_listen_range
,
2520 bgp_listen_range_cmd
,
2521 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2522 "BGP specific commands\n"
2523 "Configure BGP dynamic neighbors listen range\n"
2524 "Configure BGP dynamic neighbors listen range\n"
2526 "Member of the peer-group\n"
2527 "Peer-group name\n")
2529 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2530 struct prefix range
;
2531 struct peer_group
*group
, *existing_group
;
2536 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2537 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2538 char *prefix
= argv
[idx
]->arg
;
2539 argv_find(argv
, argc
, "WORD", &idx
);
2540 char *peergroup
= argv
[idx
]->arg
;
2542 /* Convert IP prefix string to struct prefix. */
2543 ret
= str2prefix(prefix
, &range
);
2545 vty_out(vty
, "%% Malformed listen range\n");
2546 return CMD_WARNING_CONFIG_FAILED
;
2549 afi
= family2afi(range
.family
);
2551 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2553 "%% Malformed listen range (link-local address)\n");
2554 return CMD_WARNING_CONFIG_FAILED
;
2559 /* Check if same listen range is already configured. */
2560 existing_group
= listen_range_exists(bgp
, &range
, 1);
2561 if (existing_group
) {
2562 if (strcmp(existing_group
->name
, peergroup
) == 0)
2566 "%% Same listen range is attached to peer-group %s\n",
2567 existing_group
->name
);
2568 return CMD_WARNING_CONFIG_FAILED
;
2572 /* Check if an overlapping listen range exists. */
2573 if (listen_range_exists(bgp
, &range
, 0)) {
2575 "%% Listen range overlaps with existing listen range\n");
2576 return CMD_WARNING_CONFIG_FAILED
;
2579 group
= peer_group_lookup(bgp
, peergroup
);
2581 vty_out(vty
, "%% Configure the peer-group first\n");
2582 return CMD_WARNING_CONFIG_FAILED
;
2585 ret
= peer_group_listen_range_add(group
, &range
);
2586 return bgp_vty_return(vty
, ret
);
2589 DEFUN (no_bgp_listen_range
,
2590 no_bgp_listen_range_cmd
,
2591 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2593 "BGP specific commands\n"
2594 "Unconfigure BGP dynamic neighbors listen range\n"
2595 "Unconfigure BGP dynamic neighbors listen range\n"
2597 "Member of the peer-group\n"
2598 "Peer-group name\n")
2600 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2601 struct prefix range
;
2602 struct peer_group
*group
;
2607 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2608 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2609 char *prefix
= argv
[idx
]->arg
;
2610 argv_find(argv
, argc
, "WORD", &idx
);
2611 char *peergroup
= argv
[idx
]->arg
;
2613 /* Convert IP prefix string to struct prefix. */
2614 ret
= str2prefix(prefix
, &range
);
2616 vty_out(vty
, "%% Malformed listen range\n");
2617 return CMD_WARNING_CONFIG_FAILED
;
2620 afi
= family2afi(range
.family
);
2622 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2624 "%% Malformed listen range (link-local address)\n");
2625 return CMD_WARNING_CONFIG_FAILED
;
2630 group
= peer_group_lookup(bgp
, peergroup
);
2632 vty_out(vty
, "%% Peer-group does not exist\n");
2633 return CMD_WARNING_CONFIG_FAILED
;
2636 ret
= peer_group_listen_range_del(group
, &range
);
2637 return bgp_vty_return(vty
, ret
);
2640 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2642 struct peer_group
*group
;
2643 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2644 struct prefix
*range
;
2646 char buf
[PREFIX2STR_BUFFER
];
2648 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2649 vty_out(vty
, " bgp listen limit %d\n",
2650 bgp
->dynamic_neighbors_limit
);
2652 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2653 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2654 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2656 prefix2str(range
, buf
, sizeof(buf
));
2658 " bgp listen range %s peer-group %s\n",
2666 DEFUN (bgp_disable_connected_route_check
,
2667 bgp_disable_connected_route_check_cmd
,
2668 "bgp disable-ebgp-connected-route-check",
2669 "BGP specific commands\n"
2670 "Disable checking if nexthop is connected on ebgp sessions\n")
2672 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2673 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2674 bgp_clear_star_soft_in(vty
, bgp
->name
);
2679 DEFUN (no_bgp_disable_connected_route_check
,
2680 no_bgp_disable_connected_route_check_cmd
,
2681 "no bgp disable-ebgp-connected-route-check",
2683 "BGP specific commands\n"
2684 "Disable checking if nexthop is connected on ebgp sessions\n")
2686 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2687 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2688 bgp_clear_star_soft_in(vty
, bgp
->name
);
2694 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2695 const char *as_str
, afi_t afi
, safi_t safi
)
2697 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2700 int as_type
= AS_SPECIFIED
;
2703 if (as_str
[0] == 'i') {
2705 as_type
= AS_INTERNAL
;
2706 } else if (as_str
[0] == 'e') {
2708 as_type
= AS_EXTERNAL
;
2710 /* Get AS number. */
2711 as
= strtoul(as_str
, NULL
, 10);
2714 /* If peer is peer group, call proper function. */
2715 ret
= str2sockunion(peer_str
, &su
);
2717 /* Check for peer by interface */
2718 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2721 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2724 "%% Create the peer-group or interface first\n");
2725 return CMD_WARNING_CONFIG_FAILED
;
2730 if (peer_address_self_check(bgp
, &su
)) {
2732 "%% Can not configure the local system as neighbor\n");
2733 return CMD_WARNING_CONFIG_FAILED
;
2735 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2738 /* This peer belongs to peer group. */
2740 case BGP_ERR_PEER_GROUP_MEMBER
:
2742 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2744 return CMD_WARNING_CONFIG_FAILED
;
2745 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2747 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2749 return CMD_WARNING_CONFIG_FAILED
;
2751 return bgp_vty_return(vty
, ret
);
2754 DEFUN (bgp_default_shutdown
,
2755 bgp_default_shutdown_cmd
,
2756 "[no] bgp default shutdown",
2759 "Configure BGP defaults\n"
2760 "Apply administrative shutdown to newly configured peers\n")
2762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2763 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2767 DEFUN (neighbor_remote_as
,
2768 neighbor_remote_as_cmd
,
2769 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2772 "Specify a BGP neighbor\n"
2774 "Internal BGP peer\n"
2775 "External BGP peer\n")
2778 int idx_remote_as
= 3;
2779 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2780 argv
[idx_remote_as
]->arg
, AFI_IP
,
2784 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2785 afi_t afi
, safi_t safi
, int v6only
,
2786 const char *peer_group_name
,
2789 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2791 int as_type
= AS_UNSPECIFIED
;
2793 struct peer_group
*group
;
2797 group
= peer_group_lookup(bgp
, conf_if
);
2800 vty_out(vty
, "%% Name conflict with peer-group \n");
2801 return CMD_WARNING_CONFIG_FAILED
;
2805 if (as_str
[0] == 'i') {
2806 as_type
= AS_INTERNAL
;
2807 } else if (as_str
[0] == 'e') {
2808 as_type
= AS_EXTERNAL
;
2810 /* Get AS number. */
2811 as
= strtoul(as_str
, NULL
, 10);
2812 as_type
= AS_SPECIFIED
;
2816 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2819 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2822 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2823 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2824 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2825 as_type
, 0, 0, NULL
);
2827 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2828 as_type
, afi
, safi
, NULL
);
2831 vty_out(vty
, "%% BGP failed to create peer\n");
2832 return CMD_WARNING_CONFIG_FAILED
;
2836 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2838 /* Request zebra to initiate IPv6 RAs on this interface. We do
2840 * any unnumbered peer in order to not worry about run-time
2842 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2844 * gets deleted later etc.)
2847 bgp_zebra_initiate_radv(bgp
, peer
);
2850 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2851 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2853 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2855 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2857 /* v6only flag changed. Reset bgp seesion */
2858 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2859 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2860 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2861 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2863 bgp_session_reset(peer
);
2866 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2867 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2868 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2869 UNSET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2872 if (peer_group_name
) {
2873 group
= peer_group_lookup(bgp
, peer_group_name
);
2875 vty_out(vty
, "%% Configure the peer-group first\n");
2876 return CMD_WARNING_CONFIG_FAILED
;
2879 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2882 return bgp_vty_return(vty
, ret
);
2885 DEFUN (neighbor_interface_config
,
2886 neighbor_interface_config_cmd
,
2887 "neighbor WORD interface [peer-group WORD]",
2889 "Interface name or neighbor tag\n"
2890 "Enable BGP on interface\n"
2891 "Member of the peer-group\n"
2892 "Peer-group name\n")
2895 int idx_peer_group_word
= 4;
2897 if (argc
> idx_peer_group_word
)
2898 return peer_conf_interface_get(
2899 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2900 argv
[idx_peer_group_word
]->arg
, NULL
);
2902 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2903 SAFI_UNICAST
, 0, NULL
, NULL
);
2906 DEFUN (neighbor_interface_config_v6only
,
2907 neighbor_interface_config_v6only_cmd
,
2908 "neighbor WORD interface v6only [peer-group WORD]",
2910 "Interface name or neighbor tag\n"
2911 "Enable BGP on interface\n"
2912 "Enable BGP with v6 link-local only\n"
2913 "Member of the peer-group\n"
2914 "Peer-group name\n")
2917 int idx_peer_group_word
= 5;
2919 if (argc
> idx_peer_group_word
)
2920 return peer_conf_interface_get(
2921 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2922 argv
[idx_peer_group_word
]->arg
, NULL
);
2924 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2925 SAFI_UNICAST
, 1, NULL
, NULL
);
2929 DEFUN (neighbor_interface_config_remote_as
,
2930 neighbor_interface_config_remote_as_cmd
,
2931 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2933 "Interface name or neighbor tag\n"
2934 "Enable BGP on interface\n"
2935 "Specify a BGP neighbor\n"
2937 "Internal BGP peer\n"
2938 "External BGP peer\n")
2941 int idx_remote_as
= 4;
2942 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2943 SAFI_UNICAST
, 0, NULL
,
2944 argv
[idx_remote_as
]->arg
);
2947 DEFUN (neighbor_interface_v6only_config_remote_as
,
2948 neighbor_interface_v6only_config_remote_as_cmd
,
2949 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2951 "Interface name or neighbor tag\n"
2952 "Enable BGP with v6 link-local only\n"
2953 "Enable BGP on interface\n"
2954 "Specify a BGP neighbor\n"
2956 "Internal BGP peer\n"
2957 "External BGP peer\n")
2960 int idx_remote_as
= 5;
2961 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2962 SAFI_UNICAST
, 1, NULL
,
2963 argv
[idx_remote_as
]->arg
);
2966 DEFUN (neighbor_peer_group
,
2967 neighbor_peer_group_cmd
,
2968 "neighbor WORD peer-group",
2970 "Interface name or neighbor tag\n"
2971 "Configure peer-group\n")
2973 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2976 struct peer_group
*group
;
2978 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2980 vty_out(vty
, "%% Name conflict with interface: \n");
2981 return CMD_WARNING_CONFIG_FAILED
;
2984 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2986 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2987 return CMD_WARNING_CONFIG_FAILED
;
2995 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
2999 "Specify a BGP neighbor\n"
3001 "Internal BGP peer\n"
3002 "External BGP peer\n")
3004 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3008 struct peer_group
*group
;
3012 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3014 /* look up for neighbor by interface name config. */
3015 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3017 /* Request zebra to terminate IPv6 RAs on this
3020 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3025 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3027 peer_group_delete(group
);
3029 vty_out(vty
, "%% Create the peer-group first\n");
3030 return CMD_WARNING_CONFIG_FAILED
;
3033 peer
= peer_lookup(bgp
, &su
);
3035 if (peer_dynamic_neighbor(peer
)) {
3037 "%% Operation not allowed on a dynamic neighbor\n");
3038 return CMD_WARNING_CONFIG_FAILED
;
3041 other
= peer
->doppelganger
;
3043 if (other
&& other
->status
!= Deleted
)
3051 DEFUN (no_neighbor_interface_config
,
3052 no_neighbor_interface_config_cmd
,
3053 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3057 "Configure BGP on interface\n"
3058 "Enable BGP with v6 link-local only\n"
3059 "Member of the peer-group\n"
3061 "Specify a BGP neighbor\n"
3063 "Internal BGP peer\n"
3064 "External BGP peer\n")
3066 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3070 /* look up for neighbor by interface name config. */
3071 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3073 /* Request zebra to terminate IPv6 RAs on this interface. */
3075 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3078 vty_out(vty
, "%% Create the bgp interface first\n");
3079 return CMD_WARNING_CONFIG_FAILED
;
3084 DEFUN (no_neighbor_peer_group
,
3085 no_neighbor_peer_group_cmd
,
3086 "no neighbor WORD peer-group",
3090 "Configure peer-group\n")
3092 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3094 struct peer_group
*group
;
3096 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3098 peer_group_delete(group
);
3100 vty_out(vty
, "%% Create the peer-group first\n");
3101 return CMD_WARNING_CONFIG_FAILED
;
3106 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3107 no_neighbor_interface_peer_group_remote_as_cmd
,
3108 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3111 "Interface name or neighbor tag\n"
3112 "Specify a BGP neighbor\n"
3114 "Internal BGP peer\n"
3115 "External BGP peer\n")
3117 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3119 struct peer_group
*group
;
3122 /* look up for neighbor by interface name config. */
3123 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3125 peer_as_change(peer
, 0, AS_SPECIFIED
);
3129 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3131 peer_group_remote_as_delete(group
);
3133 vty_out(vty
, "%% Create the peer-group or interface first\n");
3134 return CMD_WARNING_CONFIG_FAILED
;
3139 DEFUN (neighbor_local_as
,
3140 neighbor_local_as_cmd
,
3141 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3144 "Specify a local-as number\n"
3145 "AS number used as local AS\n")
3153 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3155 return CMD_WARNING_CONFIG_FAILED
;
3157 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3158 ret
= peer_local_as_set(peer
, as
, 0, 0);
3159 return bgp_vty_return(vty
, ret
);
3162 DEFUN (neighbor_local_as_no_prepend
,
3163 neighbor_local_as_no_prepend_cmd
,
3164 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3167 "Specify a local-as number\n"
3168 "AS number used as local AS\n"
3169 "Do not prepend local-as to updates from ebgp peers\n")
3177 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3179 return CMD_WARNING_CONFIG_FAILED
;
3181 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3182 ret
= peer_local_as_set(peer
, as
, 1, 0);
3183 return bgp_vty_return(vty
, ret
);
3186 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3187 neighbor_local_as_no_prepend_replace_as_cmd
,
3188 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3191 "Specify a local-as number\n"
3192 "AS number used as local AS\n"
3193 "Do not prepend local-as to updates from ebgp peers\n"
3194 "Do not prepend local-as to updates from ibgp peers\n")
3202 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3204 return CMD_WARNING_CONFIG_FAILED
;
3206 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3207 ret
= peer_local_as_set(peer
, as
, 1, 1);
3208 return bgp_vty_return(vty
, ret
);
3211 DEFUN (no_neighbor_local_as
,
3212 no_neighbor_local_as_cmd
,
3213 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3217 "Specify a local-as number\n"
3218 "AS number used as local AS\n"
3219 "Do not prepend local-as to updates from ebgp peers\n"
3220 "Do not prepend local-as to updates from ibgp peers\n")
3226 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3228 return CMD_WARNING_CONFIG_FAILED
;
3230 ret
= peer_local_as_unset(peer
);
3231 return bgp_vty_return(vty
, ret
);
3235 DEFUN (neighbor_solo
,
3237 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3240 "Solo peer - part of its own update group\n")
3246 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3248 return CMD_WARNING_CONFIG_FAILED
;
3250 ret
= update_group_adjust_soloness(peer
, 1);
3251 return bgp_vty_return(vty
, ret
);
3254 DEFUN (no_neighbor_solo
,
3255 no_neighbor_solo_cmd
,
3256 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3260 "Solo peer - part of its own update group\n")
3266 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3268 return CMD_WARNING_CONFIG_FAILED
;
3270 ret
= update_group_adjust_soloness(peer
, 0);
3271 return bgp_vty_return(vty
, ret
);
3274 DEFUN (neighbor_password
,
3275 neighbor_password_cmd
,
3276 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3287 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3289 return CMD_WARNING_CONFIG_FAILED
;
3291 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3292 return bgp_vty_return(vty
, ret
);
3295 DEFUN (no_neighbor_password
,
3296 no_neighbor_password_cmd
,
3297 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3308 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3310 return CMD_WARNING_CONFIG_FAILED
;
3312 ret
= peer_password_unset(peer
);
3313 return bgp_vty_return(vty
, ret
);
3316 DEFUN (neighbor_activate
,
3317 neighbor_activate_cmd
,
3318 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3321 "Enable the Address Family for this Neighbor\n")
3327 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3329 return CMD_WARNING_CONFIG_FAILED
;
3331 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3332 return bgp_vty_return(vty
, ret
);
3335 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3336 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3337 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3338 "Enable the Address Family for this Neighbor\n")
3340 DEFUN (no_neighbor_activate
,
3341 no_neighbor_activate_cmd
,
3342 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3346 "Enable the Address Family for this Neighbor\n")
3353 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3355 return CMD_WARNING_CONFIG_FAILED
;
3357 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3358 return bgp_vty_return(vty
, ret
);
3361 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3362 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3363 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3364 "Enable the Address Family for this Neighbor\n")
3366 DEFUN (neighbor_set_peer_group
,
3367 neighbor_set_peer_group_cmd
,
3368 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3371 "Member of the peer-group\n"
3372 "Peer-group name\n")
3374 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3381 struct peer_group
*group
;
3383 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3385 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3387 vty_out(vty
, "%% Malformed address or name: %s\n",
3388 argv
[idx_peer
]->arg
);
3389 return CMD_WARNING_CONFIG_FAILED
;
3392 if (peer_address_self_check(bgp
, &su
)) {
3394 "%% Can not configure the local system as neighbor\n");
3395 return CMD_WARNING_CONFIG_FAILED
;
3398 /* Disallow for dynamic neighbor. */
3399 peer
= peer_lookup(bgp
, &su
);
3400 if (peer
&& peer_dynamic_neighbor(peer
)) {
3402 "%% Operation not allowed on a dynamic neighbor\n");
3403 return CMD_WARNING_CONFIG_FAILED
;
3407 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3409 vty_out(vty
, "%% Configure the peer-group first\n");
3410 return CMD_WARNING_CONFIG_FAILED
;
3413 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3415 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3417 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3419 return CMD_WARNING_CONFIG_FAILED
;
3422 return bgp_vty_return(vty
, ret
);
3425 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3426 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3427 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3428 "Member of the peer-group\n"
3429 "Peer-group name\n")
3431 DEFUN (no_neighbor_set_peer_group
,
3432 no_neighbor_set_peer_group_cmd
,
3433 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3437 "Member of the peer-group\n"
3438 "Peer-group name\n")
3440 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3445 struct peer_group
*group
;
3447 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3449 return CMD_WARNING_CONFIG_FAILED
;
3451 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3453 vty_out(vty
, "%% Configure the peer-group first\n");
3454 return CMD_WARNING_CONFIG_FAILED
;
3457 ret
= peer_delete(peer
);
3459 return bgp_vty_return(vty
, ret
);
3462 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3463 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3464 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3465 "Member of the peer-group\n"
3466 "Peer-group name\n")
3468 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3469 uint32_t flag
, int set
)
3474 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3476 return CMD_WARNING_CONFIG_FAILED
;
3479 * If 'neighbor <interface>', then this is for directly connected peers,
3480 * we should not accept disable-connected-check.
3482 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3484 "%s is directly connected peer, cannot accept disable-"
3485 "connected-check\n",
3487 return CMD_WARNING_CONFIG_FAILED
;
3490 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3491 peer_tx_shutdown_message_unset(peer
);
3494 ret
= peer_flag_set(peer
, flag
);
3496 ret
= peer_flag_unset(peer
, flag
);
3498 return bgp_vty_return(vty
, ret
);
3501 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3503 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3506 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3509 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3512 /* neighbor passive. */
3513 DEFUN (neighbor_passive
,
3514 neighbor_passive_cmd
,
3515 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3518 "Don't send open messages to this neighbor\n")
3521 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3524 DEFUN (no_neighbor_passive
,
3525 no_neighbor_passive_cmd
,
3526 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3530 "Don't send open messages to this neighbor\n")
3533 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3536 /* neighbor shutdown. */
3537 DEFUN (neighbor_shutdown_msg
,
3538 neighbor_shutdown_msg_cmd
,
3539 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3542 "Administratively shut down this neighbor\n"
3543 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3544 "Shutdown message\n")
3550 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3554 return CMD_WARNING_CONFIG_FAILED
;
3555 message
= argv_concat(argv
, argc
, 4);
3556 peer_tx_shutdown_message_set(peer
, message
);
3557 XFREE(MTYPE_TMP
, message
);
3560 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3563 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3564 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3565 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3566 "Administratively shut down this neighbor\n")
3568 DEFUN (no_neighbor_shutdown_msg
,
3569 no_neighbor_shutdown_msg_cmd
,
3570 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3574 "Administratively shut down this neighbor\n"
3575 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3576 "Shutdown message\n")
3580 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3581 PEER_FLAG_SHUTDOWN
);
3584 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3585 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3586 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3587 "Administratively shut down this neighbor\n")
3589 /* neighbor capability dynamic. */
3590 DEFUN (neighbor_capability_dynamic
,
3591 neighbor_capability_dynamic_cmd
,
3592 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3595 "Advertise capability to the peer\n"
3596 "Advertise dynamic capability to this neighbor\n")
3599 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3600 PEER_FLAG_DYNAMIC_CAPABILITY
);
3603 DEFUN (no_neighbor_capability_dynamic
,
3604 no_neighbor_capability_dynamic_cmd
,
3605 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3609 "Advertise capability to the peer\n"
3610 "Advertise dynamic capability to this neighbor\n")
3613 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3614 PEER_FLAG_DYNAMIC_CAPABILITY
);
3617 /* neighbor dont-capability-negotiate */
3618 DEFUN (neighbor_dont_capability_negotiate
,
3619 neighbor_dont_capability_negotiate_cmd
,
3620 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3623 "Do not perform capability negotiation\n")
3626 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3627 PEER_FLAG_DONT_CAPABILITY
);
3630 DEFUN (no_neighbor_dont_capability_negotiate
,
3631 no_neighbor_dont_capability_negotiate_cmd
,
3632 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3636 "Do not perform capability negotiation\n")
3639 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3640 PEER_FLAG_DONT_CAPABILITY
);
3643 /* neighbor capability extended next hop encoding */
3644 DEFUN (neighbor_capability_enhe
,
3645 neighbor_capability_enhe_cmd
,
3646 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3649 "Advertise capability to the peer\n"
3650 "Advertise extended next-hop capability to the peer\n")
3653 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3654 PEER_FLAG_CAPABILITY_ENHE
);
3657 DEFUN (no_neighbor_capability_enhe
,
3658 no_neighbor_capability_enhe_cmd
,
3659 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3663 "Advertise capability to the peer\n"
3664 "Advertise extended next-hop capability to the peer\n")
3667 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3668 PEER_FLAG_CAPABILITY_ENHE
);
3671 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3672 afi_t afi
, safi_t safi
, uint32_t flag
,
3678 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3680 return CMD_WARNING_CONFIG_FAILED
;
3683 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3685 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3687 return bgp_vty_return(vty
, ret
);
3690 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3691 afi_t afi
, safi_t safi
, uint32_t flag
)
3693 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3696 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3697 afi_t afi
, safi_t safi
, uint32_t flag
)
3699 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3702 /* neighbor capability orf prefix-list. */
3703 DEFUN (neighbor_capability_orf_prefix
,
3704 neighbor_capability_orf_prefix_cmd
,
3705 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3708 "Advertise capability to the peer\n"
3709 "Advertise ORF capability to the peer\n"
3710 "Advertise prefixlist ORF capability to this neighbor\n"
3711 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3712 "Capability to RECEIVE the ORF from this neighbor\n"
3713 "Capability to SEND the ORF to this neighbor\n")
3716 int idx_send_recv
= 5;
3719 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3720 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3721 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3722 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3723 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3724 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3726 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3727 return CMD_WARNING_CONFIG_FAILED
;
3730 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3731 bgp_node_safi(vty
), flag
);
3735 neighbor_capability_orf_prefix
,
3736 neighbor_capability_orf_prefix_hidden_cmd
,
3737 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3738 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3739 "Advertise capability to the peer\n"
3740 "Advertise ORF capability to the peer\n"
3741 "Advertise prefixlist ORF capability to this neighbor\n"
3742 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3743 "Capability to RECEIVE the ORF from this neighbor\n"
3744 "Capability to SEND the ORF to this neighbor\n")
3746 DEFUN (no_neighbor_capability_orf_prefix
,
3747 no_neighbor_capability_orf_prefix_cmd
,
3748 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3752 "Advertise capability to the peer\n"
3753 "Advertise ORF capability to the peer\n"
3754 "Advertise prefixlist ORF capability to this neighbor\n"
3755 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3756 "Capability to RECEIVE the ORF from this neighbor\n"
3757 "Capability to SEND the ORF to this neighbor\n")
3760 int idx_send_recv
= 6;
3763 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3764 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3765 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3766 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3767 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3768 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3770 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3771 return CMD_WARNING_CONFIG_FAILED
;
3774 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3775 bgp_node_afi(vty
), bgp_node_safi(vty
),
3780 no_neighbor_capability_orf_prefix
,
3781 no_neighbor_capability_orf_prefix_hidden_cmd
,
3782 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3783 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3784 "Advertise capability to the peer\n"
3785 "Advertise ORF capability to the peer\n"
3786 "Advertise prefixlist ORF capability to this neighbor\n"
3787 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3788 "Capability to RECEIVE the ORF from this neighbor\n"
3789 "Capability to SEND the ORF to this neighbor\n")
3791 /* neighbor next-hop-self. */
3792 DEFUN (neighbor_nexthop_self
,
3793 neighbor_nexthop_self_cmd
,
3794 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3797 "Disable the next hop calculation for this neighbor\n")
3800 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3801 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3804 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3805 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3806 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3807 "Disable the next hop calculation for this neighbor\n")
3809 /* neighbor next-hop-self. */
3810 DEFUN (neighbor_nexthop_self_force
,
3811 neighbor_nexthop_self_force_cmd
,
3812 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3815 "Disable the next hop calculation for this neighbor\n"
3816 "Set the next hop to self for reflected routes\n")
3819 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3821 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3824 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3825 neighbor_nexthop_self_force_hidden_cmd
,
3826 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3827 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3828 "Disable the next hop calculation for this neighbor\n"
3829 "Set the next hop to self for reflected routes\n")
3831 DEFUN (no_neighbor_nexthop_self
,
3832 no_neighbor_nexthop_self_cmd
,
3833 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3837 "Disable the next hop calculation for this neighbor\n")
3840 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3841 bgp_node_afi(vty
), bgp_node_safi(vty
),
3842 PEER_FLAG_NEXTHOP_SELF
);
3845 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3846 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3847 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3848 "Disable the next hop calculation for this neighbor\n")
3850 DEFUN (no_neighbor_nexthop_self_force
,
3851 no_neighbor_nexthop_self_force_cmd
,
3852 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3856 "Disable the next hop calculation for this neighbor\n"
3857 "Set the next hop to self for reflected routes\n")
3860 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3861 bgp_node_afi(vty
), bgp_node_safi(vty
),
3862 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3865 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3866 no_neighbor_nexthop_self_force_hidden_cmd
,
3867 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3868 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3869 "Disable the next hop calculation for this neighbor\n"
3870 "Set the next hop to self for reflected routes\n")
3872 /* neighbor as-override */
3873 DEFUN (neighbor_as_override
,
3874 neighbor_as_override_cmd
,
3875 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3878 "Override ASNs in outbound updates if aspath equals remote-as\n")
3881 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3882 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3885 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3886 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3887 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3888 "Override ASNs in outbound updates if aspath equals remote-as\n")
3890 DEFUN (no_neighbor_as_override
,
3891 no_neighbor_as_override_cmd
,
3892 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3896 "Override ASNs in outbound updates if aspath equals remote-as\n")
3899 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3900 bgp_node_afi(vty
), bgp_node_safi(vty
),
3901 PEER_FLAG_AS_OVERRIDE
);
3904 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3905 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3906 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3907 "Override ASNs in outbound updates if aspath equals remote-as\n")
3909 /* neighbor remove-private-AS. */
3910 DEFUN (neighbor_remove_private_as
,
3911 neighbor_remove_private_as_cmd
,
3912 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3915 "Remove private ASNs in outbound updates\n")
3918 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3920 PEER_FLAG_REMOVE_PRIVATE_AS
);
3923 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3924 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3925 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3926 "Remove private ASNs in outbound updates\n")
3928 DEFUN (neighbor_remove_private_as_all
,
3929 neighbor_remove_private_as_all_cmd
,
3930 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3933 "Remove private ASNs in outbound updates\n"
3934 "Apply to all AS numbers\n")
3937 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3939 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3942 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3943 neighbor_remove_private_as_all_hidden_cmd
,
3944 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3945 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3946 "Remove private ASNs in outbound updates\n"
3947 "Apply to all AS numbers")
3949 DEFUN (neighbor_remove_private_as_replace_as
,
3950 neighbor_remove_private_as_replace_as_cmd
,
3951 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3954 "Remove private ASNs in outbound updates\n"
3955 "Replace private ASNs with our ASN in outbound updates\n")
3958 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3960 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3963 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3964 neighbor_remove_private_as_replace_as_hidden_cmd
,
3965 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3966 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3967 "Remove private ASNs in outbound updates\n"
3968 "Replace private ASNs with our ASN in outbound updates\n")
3970 DEFUN (neighbor_remove_private_as_all_replace_as
,
3971 neighbor_remove_private_as_all_replace_as_cmd
,
3972 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3975 "Remove private ASNs in outbound updates\n"
3976 "Apply to all AS numbers\n"
3977 "Replace private ASNs with our ASN in outbound updates\n")
3980 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3982 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3986 neighbor_remove_private_as_all_replace_as
,
3987 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3988 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3989 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3990 "Remove private ASNs in outbound updates\n"
3991 "Apply to all AS numbers\n"
3992 "Replace private ASNs with our ASN in outbound updates\n")
3994 DEFUN (no_neighbor_remove_private_as
,
3995 no_neighbor_remove_private_as_cmd
,
3996 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4000 "Remove private ASNs in outbound updates\n")
4003 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4004 bgp_node_afi(vty
), bgp_node_safi(vty
),
4005 PEER_FLAG_REMOVE_PRIVATE_AS
);
4008 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4009 no_neighbor_remove_private_as_hidden_cmd
,
4010 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4011 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4012 "Remove private ASNs in outbound updates\n")
4014 DEFUN (no_neighbor_remove_private_as_all
,
4015 no_neighbor_remove_private_as_all_cmd
,
4016 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4020 "Remove private ASNs in outbound updates\n"
4021 "Apply to all AS numbers\n")
4024 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4025 bgp_node_afi(vty
), bgp_node_safi(vty
),
4026 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4029 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4030 no_neighbor_remove_private_as_all_hidden_cmd
,
4031 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4032 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4033 "Remove private ASNs in outbound updates\n"
4034 "Apply to all AS numbers\n")
4036 DEFUN (no_neighbor_remove_private_as_replace_as
,
4037 no_neighbor_remove_private_as_replace_as_cmd
,
4038 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4042 "Remove private ASNs in outbound updates\n"
4043 "Replace private ASNs with our ASN in outbound updates\n")
4046 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4047 bgp_node_afi(vty
), bgp_node_safi(vty
),
4048 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4051 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4052 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4053 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4054 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4055 "Remove private ASNs in outbound updates\n"
4056 "Replace private ASNs with our ASN in outbound updates\n")
4058 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4059 no_neighbor_remove_private_as_all_replace_as_cmd
,
4060 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4064 "Remove private ASNs in outbound updates\n"
4065 "Apply to all AS numbers\n"
4066 "Replace private ASNs with our ASN in outbound updates\n")
4069 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4070 bgp_node_afi(vty
), bgp_node_safi(vty
),
4071 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4075 no_neighbor_remove_private_as_all_replace_as
,
4076 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4077 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4078 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4079 "Remove private ASNs in outbound updates\n"
4080 "Apply to all AS numbers\n"
4081 "Replace private ASNs with our ASN in outbound updates\n")
4084 /* neighbor send-community. */
4085 DEFUN (neighbor_send_community
,
4086 neighbor_send_community_cmd
,
4087 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4090 "Send Community attribute to this neighbor\n")
4094 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4096 PEER_FLAG_SEND_COMMUNITY
);
4099 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4100 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4101 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4102 "Send Community attribute to this neighbor\n")
4104 DEFUN (no_neighbor_send_community
,
4105 no_neighbor_send_community_cmd
,
4106 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4110 "Send Community attribute to this neighbor\n")
4114 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4115 bgp_node_afi(vty
), bgp_node_safi(vty
),
4116 PEER_FLAG_SEND_COMMUNITY
);
4119 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4120 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4121 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4122 "Send Community attribute to this neighbor\n")
4124 /* neighbor send-community extended. */
4125 DEFUN (neighbor_send_community_type
,
4126 neighbor_send_community_type_cmd
,
4127 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4130 "Send Community attribute to this neighbor\n"
4131 "Send Standard and Extended Community attributes\n"
4132 "Send Standard, Large and Extended Community attributes\n"
4133 "Send Extended Community attributes\n"
4134 "Send Standard Community attributes\n"
4135 "Send Large Community attributes\n")
4139 const char *type
= argv
[argc
- 1]->text
;
4141 if (strmatch(type
, "standard")) {
4142 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4143 } else if (strmatch(type
, "extended")) {
4144 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4145 } else if (strmatch(type
, "large")) {
4146 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4147 } else if (strmatch(type
, "both")) {
4148 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4149 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4150 } else { /* if (strmatch(type, "all")) */
4151 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4152 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4153 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4156 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4157 bgp_node_safi(vty
), flag
);
4161 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4162 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4163 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4164 "Send Community attribute to this neighbor\n"
4165 "Send Standard and Extended Community attributes\n"
4166 "Send Standard, Large and Extended Community attributes\n"
4167 "Send Extended Community attributes\n"
4168 "Send Standard Community attributes\n"
4169 "Send Large Community attributes\n")
4171 DEFUN (no_neighbor_send_community_type
,
4172 no_neighbor_send_community_type_cmd
,
4173 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4177 "Send Community attribute to this neighbor\n"
4178 "Send Standard and Extended Community attributes\n"
4179 "Send Standard, Large and Extended Community attributes\n"
4180 "Send Extended Community attributes\n"
4181 "Send Standard Community attributes\n"
4182 "Send Large Community attributes\n")
4186 const char *type
= argv
[argc
- 1]->text
;
4188 if (strmatch(type
, "standard")) {
4189 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4190 } else if (strmatch(type
, "extended")) {
4191 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4192 } else if (strmatch(type
, "large")) {
4193 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4194 } else if (strmatch(type
, "both")) {
4195 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4196 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4197 } else { /* if (strmatch(type, "all")) */
4198 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4199 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4200 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4203 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4204 bgp_node_afi(vty
), bgp_node_safi(vty
),
4209 no_neighbor_send_community_type
,
4210 no_neighbor_send_community_type_hidden_cmd
,
4211 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4212 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4213 "Send Community attribute to this neighbor\n"
4214 "Send Standard and Extended Community attributes\n"
4215 "Send Standard, Large and Extended Community attributes\n"
4216 "Send Extended Community attributes\n"
4217 "Send Standard Community attributes\n"
4218 "Send Large Community attributes\n")
4220 /* neighbor soft-reconfig. */
4221 DEFUN (neighbor_soft_reconfiguration
,
4222 neighbor_soft_reconfiguration_cmd
,
4223 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4226 "Per neighbor soft reconfiguration\n"
4227 "Allow inbound soft reconfiguration for this neighbor\n")
4230 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4232 PEER_FLAG_SOFT_RECONFIG
);
4235 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4236 neighbor_soft_reconfiguration_hidden_cmd
,
4237 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4238 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4239 "Per neighbor soft reconfiguration\n"
4240 "Allow inbound soft reconfiguration for this neighbor\n")
4242 DEFUN (no_neighbor_soft_reconfiguration
,
4243 no_neighbor_soft_reconfiguration_cmd
,
4244 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4248 "Per neighbor soft reconfiguration\n"
4249 "Allow inbound soft reconfiguration for this neighbor\n")
4252 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4253 bgp_node_afi(vty
), bgp_node_safi(vty
),
4254 PEER_FLAG_SOFT_RECONFIG
);
4257 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4258 no_neighbor_soft_reconfiguration_hidden_cmd
,
4259 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4260 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4261 "Per neighbor soft reconfiguration\n"
4262 "Allow inbound soft reconfiguration for this neighbor\n")
4264 DEFUN (neighbor_route_reflector_client
,
4265 neighbor_route_reflector_client_cmd
,
4266 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4269 "Configure a neighbor as Route Reflector client\n")
4275 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4277 return CMD_WARNING_CONFIG_FAILED
;
4279 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4281 PEER_FLAG_REFLECTOR_CLIENT
);
4284 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4285 neighbor_route_reflector_client_hidden_cmd
,
4286 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4287 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4288 "Configure a neighbor as Route Reflector client\n")
4290 DEFUN (no_neighbor_route_reflector_client
,
4291 no_neighbor_route_reflector_client_cmd
,
4292 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4296 "Configure a neighbor as Route Reflector client\n")
4299 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4300 bgp_node_afi(vty
), bgp_node_safi(vty
),
4301 PEER_FLAG_REFLECTOR_CLIENT
);
4304 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4305 no_neighbor_route_reflector_client_hidden_cmd
,
4306 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4307 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4308 "Configure a neighbor as Route Reflector client\n")
4310 /* neighbor route-server-client. */
4311 DEFUN (neighbor_route_server_client
,
4312 neighbor_route_server_client_cmd
,
4313 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4316 "Configure a neighbor as Route Server client\n")
4321 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4323 return CMD_WARNING_CONFIG_FAILED
;
4324 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4326 PEER_FLAG_RSERVER_CLIENT
);
4329 ALIAS_HIDDEN(neighbor_route_server_client
,
4330 neighbor_route_server_client_hidden_cmd
,
4331 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4332 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4333 "Configure a neighbor as Route Server client\n")
4335 DEFUN (no_neighbor_route_server_client
,
4336 no_neighbor_route_server_client_cmd
,
4337 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4341 "Configure a neighbor as Route Server client\n")
4344 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4345 bgp_node_afi(vty
), bgp_node_safi(vty
),
4346 PEER_FLAG_RSERVER_CLIENT
);
4349 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4350 no_neighbor_route_server_client_hidden_cmd
,
4351 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4352 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4353 "Configure a neighbor as Route Server client\n")
4355 DEFUN (neighbor_nexthop_local_unchanged
,
4356 neighbor_nexthop_local_unchanged_cmd
,
4357 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4360 "Configure treatment of outgoing link-local nexthop attribute\n"
4361 "Leave link-local nexthop unchanged for this peer\n")
4364 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4366 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4369 DEFUN (no_neighbor_nexthop_local_unchanged
,
4370 no_neighbor_nexthop_local_unchanged_cmd
,
4371 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4375 "Configure treatment of outgoing link-local-nexthop attribute\n"
4376 "Leave link-local nexthop unchanged for this peer\n")
4379 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4380 bgp_node_afi(vty
), bgp_node_safi(vty
),
4381 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4384 DEFUN (neighbor_attr_unchanged
,
4385 neighbor_attr_unchanged_cmd
,
4386 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4389 "BGP attribute is propagated unchanged to this neighbor\n"
4390 "As-path attribute\n"
4391 "Nexthop attribute\n"
4395 char *peer_str
= argv
[1]->arg
;
4398 afi_t afi
= bgp_node_afi(vty
);
4399 safi_t safi
= bgp_node_safi(vty
);
4401 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4403 return CMD_WARNING_CONFIG_FAILED
;
4405 if (argv_find(argv
, argc
, "as-path", &idx
))
4406 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4408 if (argv_find(argv
, argc
, "next-hop", &idx
))
4409 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4411 if (argv_find(argv
, argc
, "med", &idx
))
4412 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4414 /* no flags means all of them! */
4416 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4417 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4418 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4420 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4421 && peer_af_flag_check(peer
, afi
, safi
,
4422 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4423 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4424 PEER_FLAG_AS_PATH_UNCHANGED
);
4427 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4428 && peer_af_flag_check(peer
, afi
, safi
,
4429 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4430 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4431 PEER_FLAG_NEXTHOP_UNCHANGED
);
4434 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4435 && peer_af_flag_check(peer
, afi
, safi
,
4436 PEER_FLAG_MED_UNCHANGED
)) {
4437 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4438 PEER_FLAG_MED_UNCHANGED
);
4442 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4446 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4447 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4448 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4449 "BGP attribute is propagated unchanged to this neighbor\n"
4450 "As-path attribute\n"
4451 "Nexthop attribute\n"
4454 DEFUN (no_neighbor_attr_unchanged
,
4455 no_neighbor_attr_unchanged_cmd
,
4456 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4460 "BGP attribute is propagated unchanged to this neighbor\n"
4461 "As-path attribute\n"
4462 "Nexthop attribute\n"
4466 char *peer
= argv
[2]->arg
;
4469 if (argv_find(argv
, argc
, "as-path", &idx
))
4470 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4472 if (argv_find(argv
, argc
, "next-hop", &idx
))
4473 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4475 if (argv_find(argv
, argc
, "med", &idx
))
4476 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4478 if (!flags
) // no flags means all of them!
4480 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4481 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4482 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4485 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4486 bgp_node_safi(vty
), flags
);
4490 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4491 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4492 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4493 "BGP attribute is propagated unchanged to this neighbor\n"
4494 "As-path attribute\n"
4495 "Nexthop attribute\n"
4498 /* EBGP multihop configuration. */
4499 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4500 const char *ttl_str
)
4505 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4507 return CMD_WARNING_CONFIG_FAILED
;
4510 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4515 ttl
= strtoul(ttl_str
, NULL
, 10);
4517 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4520 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4524 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4526 return CMD_WARNING_CONFIG_FAILED
;
4528 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4531 /* neighbor ebgp-multihop. */
4532 DEFUN (neighbor_ebgp_multihop
,
4533 neighbor_ebgp_multihop_cmd
,
4534 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4537 "Allow EBGP neighbors not on directly connected networks\n")
4540 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4543 DEFUN (neighbor_ebgp_multihop_ttl
,
4544 neighbor_ebgp_multihop_ttl_cmd
,
4545 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4548 "Allow EBGP neighbors not on directly connected networks\n"
4549 "maximum hop count\n")
4553 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4554 argv
[idx_number
]->arg
);
4557 DEFUN (no_neighbor_ebgp_multihop
,
4558 no_neighbor_ebgp_multihop_cmd
,
4559 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4563 "Allow EBGP neighbors not on directly connected networks\n"
4564 "maximum hop count\n")
4567 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4571 /* disable-connected-check */
4572 DEFUN (neighbor_disable_connected_check
,
4573 neighbor_disable_connected_check_cmd
,
4574 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4577 "one-hop away EBGP peer using loopback address\n"
4578 "Enforce EBGP neighbors perform multihop\n")
4581 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4582 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4585 DEFUN (no_neighbor_disable_connected_check
,
4586 no_neighbor_disable_connected_check_cmd
,
4587 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4591 "one-hop away EBGP peer using loopback address\n"
4592 "Enforce EBGP neighbors perform multihop\n")
4595 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4596 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4600 /* enforce-first-as */
4601 DEFUN (neighbor_enforce_first_as
,
4602 neighbor_enforce_first_as_cmd
,
4603 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4606 "Enforce the first AS for EBGP routes\n")
4610 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4611 PEER_FLAG_ENFORCE_FIRST_AS
);
4614 DEFUN (no_neighbor_enforce_first_as
,
4615 no_neighbor_enforce_first_as_cmd
,
4616 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4620 "Enforce the first AS for EBGP routes\n")
4624 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4625 PEER_FLAG_ENFORCE_FIRST_AS
);
4629 DEFUN (neighbor_description
,
4630 neighbor_description_cmd
,
4631 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4634 "Neighbor specific description\n"
4635 "Up to 80 characters describing this neighbor\n")
4642 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4644 return CMD_WARNING_CONFIG_FAILED
;
4646 str
= argv_concat(argv
, argc
, idx_line
);
4648 peer_description_set(peer
, str
);
4650 XFREE(MTYPE_TMP
, str
);
4655 DEFUN (no_neighbor_description
,
4656 no_neighbor_description_cmd
,
4657 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4661 "Neighbor specific description\n")
4666 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4668 return CMD_WARNING_CONFIG_FAILED
;
4670 peer_description_unset(peer
);
4675 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4676 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4677 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4678 "Neighbor specific description\n"
4679 "Up to 80 characters describing this neighbor\n")
4681 /* Neighbor update-source. */
4682 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4683 const char *source_str
)
4689 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4691 return CMD_WARNING_CONFIG_FAILED
;
4697 if (str2sockunion(source_str
, &su
) == 0)
4698 peer_update_source_addr_set(peer
, &su
);
4700 if (str2prefix(source_str
, &p
)) {
4702 "%% Invalid update-source, remove prefix length \n");
4703 return CMD_WARNING_CONFIG_FAILED
;
4705 peer_update_source_if_set(peer
, source_str
);
4708 peer_update_source_unset(peer
);
4713 #define BGP_UPDATE_SOURCE_HELP_STR \
4716 "Interface name (requires zebra to be running)\n"
4718 DEFUN (neighbor_update_source
,
4719 neighbor_update_source_cmd
,
4720 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4723 "Source of routing updates\n"
4724 BGP_UPDATE_SOURCE_HELP_STR
)
4728 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4729 argv
[idx_peer_2
]->arg
);
4732 DEFUN (no_neighbor_update_source
,
4733 no_neighbor_update_source_cmd
,
4734 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4738 "Source of routing updates\n"
4739 BGP_UPDATE_SOURCE_HELP_STR
)
4742 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4745 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4746 afi_t afi
, safi_t safi
,
4747 const char *rmap
, int set
)
4752 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4754 return CMD_WARNING_CONFIG_FAILED
;
4757 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4759 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4761 return bgp_vty_return(vty
, ret
);
4764 /* neighbor default-originate. */
4765 DEFUN (neighbor_default_originate
,
4766 neighbor_default_originate_cmd
,
4767 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4770 "Originate default route to this neighbor\n")
4773 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4775 bgp_node_safi(vty
), NULL
, 1);
4778 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4779 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4780 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4781 "Originate default route to this neighbor\n")
4783 DEFUN (neighbor_default_originate_rmap
,
4784 neighbor_default_originate_rmap_cmd
,
4785 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4788 "Originate default route to this neighbor\n"
4789 "Route-map to specify criteria to originate default\n"
4794 return peer_default_originate_set_vty(
4795 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4796 argv
[idx_word
]->arg
, 1);
4800 neighbor_default_originate_rmap
,
4801 neighbor_default_originate_rmap_hidden_cmd
,
4802 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4803 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4804 "Originate default route to this neighbor\n"
4805 "Route-map to specify criteria to originate default\n"
4808 DEFUN (no_neighbor_default_originate
,
4809 no_neighbor_default_originate_cmd
,
4810 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4814 "Originate default route to this neighbor\n"
4815 "Route-map to specify criteria to originate default\n"
4819 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4821 bgp_node_safi(vty
), NULL
, 0);
4825 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4826 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4827 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4828 "Originate default route to this neighbor\n"
4829 "Route-map to specify criteria to originate default\n"
4833 /* Set neighbor's BGP port. */
4834 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4835 const char *port_str
)
4841 peer
= peer_lookup_vty(vty
, ip_str
);
4843 return CMD_WARNING_CONFIG_FAILED
;
4846 sp
= getservbyname("bgp", "tcp");
4847 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4849 port
= strtoul(port_str
, NULL
, 10);
4852 peer_port_set(peer
, port
);
4857 /* Set specified peer's BGP port. */
4858 DEFUN (neighbor_port
,
4860 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4863 "Neighbor's BGP port\n"
4864 "TCP port number\n")
4868 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4869 argv
[idx_number
]->arg
);
4872 DEFUN (no_neighbor_port
,
4873 no_neighbor_port_cmd
,
4874 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4878 "Neighbor's BGP port\n"
4879 "TCP port number\n")
4882 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4886 /* neighbor weight. */
4887 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4888 safi_t safi
, const char *weight_str
)
4892 unsigned long weight
;
4894 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4896 return CMD_WARNING_CONFIG_FAILED
;
4898 weight
= strtoul(weight_str
, NULL
, 10);
4900 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4901 return bgp_vty_return(vty
, ret
);
4904 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4910 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4912 return CMD_WARNING_CONFIG_FAILED
;
4914 ret
= peer_weight_unset(peer
, afi
, safi
);
4915 return bgp_vty_return(vty
, ret
);
4918 DEFUN (neighbor_weight
,
4919 neighbor_weight_cmd
,
4920 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4923 "Set default weight for routes from this neighbor\n"
4928 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4929 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4932 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4933 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4934 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4935 "Set default weight for routes from this neighbor\n"
4938 DEFUN (no_neighbor_weight
,
4939 no_neighbor_weight_cmd
,
4940 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4944 "Set default weight for routes from this neighbor\n"
4948 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4949 bgp_node_afi(vty
), bgp_node_safi(vty
));
4952 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4953 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4954 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4955 "Set default weight for routes from this neighbor\n"
4959 /* Override capability negotiation. */
4960 DEFUN (neighbor_override_capability
,
4961 neighbor_override_capability_cmd
,
4962 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4965 "Override capability negotiation result\n")
4968 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4969 PEER_FLAG_OVERRIDE_CAPABILITY
);
4972 DEFUN (no_neighbor_override_capability
,
4973 no_neighbor_override_capability_cmd
,
4974 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4978 "Override capability negotiation result\n")
4981 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4982 PEER_FLAG_OVERRIDE_CAPABILITY
);
4985 DEFUN (neighbor_strict_capability
,
4986 neighbor_strict_capability_cmd
,
4987 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
4990 "Strict capability negotiation match\n")
4994 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4995 PEER_FLAG_STRICT_CAP_MATCH
);
4998 DEFUN (no_neighbor_strict_capability
,
4999 no_neighbor_strict_capability_cmd
,
5000 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5004 "Strict capability negotiation match\n")
5008 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5009 PEER_FLAG_STRICT_CAP_MATCH
);
5012 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5013 const char *keep_str
, const char *hold_str
)
5020 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5022 return CMD_WARNING_CONFIG_FAILED
;
5024 keepalive
= strtoul(keep_str
, NULL
, 10);
5025 holdtime
= strtoul(hold_str
, NULL
, 10);
5027 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5029 return bgp_vty_return(vty
, ret
);
5032 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5037 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5039 return CMD_WARNING_CONFIG_FAILED
;
5041 ret
= peer_timers_unset(peer
);
5043 return bgp_vty_return(vty
, ret
);
5046 DEFUN (neighbor_timers
,
5047 neighbor_timers_cmd
,
5048 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5051 "BGP per neighbor timers\n"
5052 "Keepalive interval\n"
5057 int idx_number_2
= 4;
5058 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5059 argv
[idx_number
]->arg
,
5060 argv
[idx_number_2
]->arg
);
5063 DEFUN (no_neighbor_timers
,
5064 no_neighbor_timers_cmd
,
5065 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5069 "BGP per neighbor timers\n"
5070 "Keepalive interval\n"
5074 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5078 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5079 const char *time_str
)
5085 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5087 return CMD_WARNING_CONFIG_FAILED
;
5089 connect
= strtoul(time_str
, NULL
, 10);
5091 ret
= peer_timers_connect_set(peer
, connect
);
5093 return bgp_vty_return(vty
, ret
);
5096 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5101 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5103 return CMD_WARNING_CONFIG_FAILED
;
5105 ret
= peer_timers_connect_unset(peer
);
5107 return bgp_vty_return(vty
, ret
);
5110 DEFUN (neighbor_timers_connect
,
5111 neighbor_timers_connect_cmd
,
5112 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5115 "BGP per neighbor timers\n"
5116 "BGP connect timer\n"
5121 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5122 argv
[idx_number
]->arg
);
5125 DEFUN (no_neighbor_timers_connect
,
5126 no_neighbor_timers_connect_cmd
,
5127 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5131 "BGP per neighbor timers\n"
5132 "BGP connect timer\n"
5136 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5140 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5141 const char *time_str
, int set
)
5145 uint32_t routeadv
= 0;
5147 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5149 return CMD_WARNING_CONFIG_FAILED
;
5152 routeadv
= strtoul(time_str
, NULL
, 10);
5155 ret
= peer_advertise_interval_set(peer
, routeadv
);
5157 ret
= peer_advertise_interval_unset(peer
);
5159 return bgp_vty_return(vty
, ret
);
5162 DEFUN (neighbor_advertise_interval
,
5163 neighbor_advertise_interval_cmd
,
5164 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5167 "Minimum interval between sending BGP routing updates\n"
5168 "time in seconds\n")
5172 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5173 argv
[idx_number
]->arg
, 1);
5176 DEFUN (no_neighbor_advertise_interval
,
5177 no_neighbor_advertise_interval_cmd
,
5178 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5182 "Minimum interval between sending BGP routing updates\n"
5183 "time in seconds\n")
5186 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5190 /* Time to wait before processing route-map updates */
5191 DEFUN (bgp_set_route_map_delay_timer
,
5192 bgp_set_route_map_delay_timer_cmd
,
5193 "bgp route-map delay-timer (0-600)",
5195 "BGP route-map delay timer\n"
5196 "Time in secs to wait before processing route-map changes\n"
5197 "0 disables the timer, no route updates happen when route-maps change\n")
5200 uint32_t rmap_delay_timer
;
5202 if (argv
[idx_number
]->arg
) {
5203 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5204 bm
->rmap_update_timer
= rmap_delay_timer
;
5206 /* if the dynamic update handling is being disabled, and a timer
5208 * running, stop the timer and act as if the timer has already
5211 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5212 BGP_TIMER_OFF(bm
->t_rmap_update
);
5213 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5218 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5219 return CMD_WARNING_CONFIG_FAILED
;
5223 DEFUN (no_bgp_set_route_map_delay_timer
,
5224 no_bgp_set_route_map_delay_timer_cmd
,
5225 "no bgp route-map delay-timer [(0-600)]",
5228 "Default BGP route-map delay timer\n"
5229 "Reset to default time to wait for processing route-map changes\n"
5230 "0 disables the timer, no route updates happen when route-maps change\n")
5233 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5239 /* neighbor interface */
5240 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5245 peer
= peer_lookup_vty(vty
, ip_str
);
5246 if (!peer
|| peer
->conf_if
) {
5247 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5248 return CMD_WARNING_CONFIG_FAILED
;
5252 peer_interface_set(peer
, str
);
5254 peer_interface_unset(peer
);
5259 DEFUN (neighbor_interface
,
5260 neighbor_interface_cmd
,
5261 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5269 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5272 DEFUN (no_neighbor_interface
,
5273 no_neighbor_interface_cmd
,
5274 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5282 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5285 DEFUN (neighbor_distribute_list
,
5286 neighbor_distribute_list_cmd
,
5287 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5290 "Filter updates to/from this neighbor\n"
5291 "IP access-list number\n"
5292 "IP access-list number (expanded range)\n"
5293 "IP Access-list name\n"
5294 "Filter incoming updates\n"
5295 "Filter outgoing updates\n")
5302 const char *pstr
= argv
[idx_peer
]->arg
;
5303 const char *acl
= argv
[idx_acl
]->arg
;
5304 const char *inout
= argv
[argc
- 1]->text
;
5306 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5308 return CMD_WARNING_CONFIG_FAILED
;
5310 /* Check filter direction. */
5311 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5312 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5315 return bgp_vty_return(vty
, ret
);
5319 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5320 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5321 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5322 "Filter updates to/from this neighbor\n"
5323 "IP access-list number\n"
5324 "IP access-list number (expanded range)\n"
5325 "IP Access-list name\n"
5326 "Filter incoming updates\n"
5327 "Filter outgoing updates\n")
5329 DEFUN (no_neighbor_distribute_list
,
5330 no_neighbor_distribute_list_cmd
,
5331 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5335 "Filter updates to/from this neighbor\n"
5336 "IP access-list number\n"
5337 "IP access-list number (expanded range)\n"
5338 "IP Access-list name\n"
5339 "Filter incoming updates\n"
5340 "Filter outgoing updates\n")
5346 const char *pstr
= argv
[idx_peer
]->arg
;
5347 const char *inout
= argv
[argc
- 1]->text
;
5349 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5351 return CMD_WARNING_CONFIG_FAILED
;
5353 /* Check filter direction. */
5354 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5355 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5358 return bgp_vty_return(vty
, ret
);
5362 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5363 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5364 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5365 "Filter updates to/from this neighbor\n"
5366 "IP access-list number\n"
5367 "IP access-list number (expanded range)\n"
5368 "IP Access-list name\n"
5369 "Filter incoming updates\n"
5370 "Filter outgoing updates\n")
5372 /* Set prefix list to the peer. */
5373 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5374 afi_t afi
, safi_t safi
,
5375 const char *name_str
,
5376 const char *direct_str
)
5379 int direct
= FILTER_IN
;
5382 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5384 return CMD_WARNING_CONFIG_FAILED
;
5386 /* Check filter direction. */
5387 if (strncmp(direct_str
, "i", 1) == 0)
5389 else if (strncmp(direct_str
, "o", 1) == 0)
5390 direct
= FILTER_OUT
;
5392 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5394 return bgp_vty_return(vty
, ret
);
5397 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5398 afi_t afi
, safi_t safi
,
5399 const char *direct_str
)
5403 int direct
= FILTER_IN
;
5405 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5407 return CMD_WARNING_CONFIG_FAILED
;
5409 /* Check filter direction. */
5410 if (strncmp(direct_str
, "i", 1) == 0)
5412 else if (strncmp(direct_str
, "o", 1) == 0)
5413 direct
= FILTER_OUT
;
5415 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5417 return bgp_vty_return(vty
, ret
);
5420 DEFUN (neighbor_prefix_list
,
5421 neighbor_prefix_list_cmd
,
5422 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5425 "Filter updates to/from this neighbor\n"
5426 "Name of a prefix list\n"
5427 "Filter incoming updates\n"
5428 "Filter outgoing updates\n")
5433 return peer_prefix_list_set_vty(
5434 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5435 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5438 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5439 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5440 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5441 "Filter updates to/from this neighbor\n"
5442 "Name of a prefix list\n"
5443 "Filter incoming updates\n"
5444 "Filter outgoing updates\n")
5446 DEFUN (no_neighbor_prefix_list
,
5447 no_neighbor_prefix_list_cmd
,
5448 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5452 "Filter updates to/from this neighbor\n"
5453 "Name of a prefix list\n"
5454 "Filter incoming updates\n"
5455 "Filter outgoing updates\n")
5459 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5460 bgp_node_afi(vty
), bgp_node_safi(vty
),
5461 argv
[idx_in_out
]->arg
);
5464 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5465 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5466 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5467 "Filter updates to/from this neighbor\n"
5468 "Name of a prefix list\n"
5469 "Filter incoming updates\n"
5470 "Filter outgoing updates\n")
5472 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5473 safi_t safi
, const char *name_str
,
5474 const char *direct_str
)
5478 int direct
= FILTER_IN
;
5480 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5482 return CMD_WARNING_CONFIG_FAILED
;
5484 /* Check filter direction. */
5485 if (strncmp(direct_str
, "i", 1) == 0)
5487 else if (strncmp(direct_str
, "o", 1) == 0)
5488 direct
= FILTER_OUT
;
5490 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5492 return bgp_vty_return(vty
, ret
);
5495 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5496 safi_t safi
, const char *direct_str
)
5500 int direct
= FILTER_IN
;
5502 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5504 return CMD_WARNING_CONFIG_FAILED
;
5506 /* Check filter direction. */
5507 if (strncmp(direct_str
, "i", 1) == 0)
5509 else if (strncmp(direct_str
, "o", 1) == 0)
5510 direct
= FILTER_OUT
;
5512 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5514 return bgp_vty_return(vty
, ret
);
5517 DEFUN (neighbor_filter_list
,
5518 neighbor_filter_list_cmd
,
5519 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5522 "Establish BGP filters\n"
5523 "AS path access-list name\n"
5524 "Filter incoming routes\n"
5525 "Filter outgoing routes\n")
5530 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5531 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5532 argv
[idx_in_out
]->arg
);
5535 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5536 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5537 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5538 "Establish BGP filters\n"
5539 "AS path access-list name\n"
5540 "Filter incoming routes\n"
5541 "Filter outgoing routes\n")
5543 DEFUN (no_neighbor_filter_list
,
5544 no_neighbor_filter_list_cmd
,
5545 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5549 "Establish BGP filters\n"
5550 "AS path access-list name\n"
5551 "Filter incoming routes\n"
5552 "Filter outgoing routes\n")
5556 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5557 bgp_node_afi(vty
), bgp_node_safi(vty
),
5558 argv
[idx_in_out
]->arg
);
5561 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5562 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5563 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5564 "Establish BGP filters\n"
5565 "AS path access-list name\n"
5566 "Filter incoming routes\n"
5567 "Filter outgoing routes\n")
5569 /* Set route-map to the peer. */
5570 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5571 afi_t afi
, safi_t safi
, const char *name_str
,
5572 const char *direct_str
)
5576 int direct
= RMAP_IN
;
5578 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5580 return CMD_WARNING_CONFIG_FAILED
;
5582 /* Check filter direction. */
5583 if (strncmp(direct_str
, "in", 2) == 0)
5585 else if (strncmp(direct_str
, "o", 1) == 0)
5588 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5590 return bgp_vty_return(vty
, ret
);
5593 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5594 afi_t afi
, safi_t safi
,
5595 const char *direct_str
)
5599 int direct
= RMAP_IN
;
5601 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5603 return CMD_WARNING_CONFIG_FAILED
;
5605 /* Check filter direction. */
5606 if (strncmp(direct_str
, "in", 2) == 0)
5608 else if (strncmp(direct_str
, "o", 1) == 0)
5611 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5613 return bgp_vty_return(vty
, ret
);
5616 DEFUN (neighbor_route_map
,
5617 neighbor_route_map_cmd
,
5618 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5621 "Apply route map to neighbor\n"
5622 "Name of route map\n"
5623 "Apply map to incoming routes\n"
5624 "Apply map to outbound routes\n")
5629 return peer_route_map_set_vty(
5630 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5631 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5634 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5635 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5636 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5637 "Apply route map to neighbor\n"
5638 "Name of route map\n"
5639 "Apply map to incoming routes\n"
5640 "Apply map to outbound routes\n")
5642 DEFUN (no_neighbor_route_map
,
5643 no_neighbor_route_map_cmd
,
5644 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5648 "Apply route map to neighbor\n"
5649 "Name of route map\n"
5650 "Apply map to incoming routes\n"
5651 "Apply map to outbound routes\n")
5655 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5656 bgp_node_afi(vty
), bgp_node_safi(vty
),
5657 argv
[idx_in_out
]->arg
);
5660 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5661 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5662 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5663 "Apply route map to neighbor\n"
5664 "Name of route map\n"
5665 "Apply map to incoming routes\n"
5666 "Apply map to outbound routes\n")
5668 /* Set unsuppress-map to the peer. */
5669 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5670 afi_t afi
, safi_t safi
,
5671 const char *name_str
)
5676 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5678 return CMD_WARNING_CONFIG_FAILED
;
5680 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5682 return bgp_vty_return(vty
, ret
);
5685 /* Unset route-map from the peer. */
5686 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5687 afi_t afi
, safi_t safi
)
5692 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5694 return CMD_WARNING_CONFIG_FAILED
;
5696 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5698 return bgp_vty_return(vty
, ret
);
5701 DEFUN (neighbor_unsuppress_map
,
5702 neighbor_unsuppress_map_cmd
,
5703 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5706 "Route-map to selectively unsuppress suppressed routes\n"
5707 "Name of route map\n")
5711 return peer_unsuppress_map_set_vty(
5712 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5713 argv
[idx_word
]->arg
);
5716 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5717 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5718 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5719 "Route-map to selectively unsuppress suppressed routes\n"
5720 "Name of route map\n")
5722 DEFUN (no_neighbor_unsuppress_map
,
5723 no_neighbor_unsuppress_map_cmd
,
5724 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5728 "Route-map to selectively unsuppress suppressed routes\n"
5729 "Name of route map\n")
5732 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5734 bgp_node_safi(vty
));
5737 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5738 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5739 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5740 "Route-map to selectively unsuppress suppressed routes\n"
5741 "Name of route map\n")
5743 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5744 afi_t afi
, safi_t safi
,
5745 const char *num_str
,
5746 const char *threshold_str
, int warning
,
5747 const char *restart_str
)
5755 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5757 return CMD_WARNING_CONFIG_FAILED
;
5759 max
= strtoul(num_str
, NULL
, 10);
5761 threshold
= atoi(threshold_str
);
5763 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5766 restart
= atoi(restart_str
);
5770 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5773 return bgp_vty_return(vty
, ret
);
5776 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5777 afi_t afi
, safi_t safi
)
5782 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5784 return CMD_WARNING_CONFIG_FAILED
;
5786 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5788 return bgp_vty_return(vty
, ret
);
5791 /* Maximum number of prefix configuration. prefix count is different
5792 for each peer configuration. So this configuration can be set for
5793 each peer configuration. */
5794 DEFUN (neighbor_maximum_prefix
,
5795 neighbor_maximum_prefix_cmd
,
5796 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5799 "Maximum number of prefix accept from this peer\n"
5800 "maximum no. of prefix limit\n")
5804 return peer_maximum_prefix_set_vty(
5805 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5806 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5809 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5810 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5811 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5812 "Maximum number of prefix accept from this peer\n"
5813 "maximum no. of prefix limit\n")
5815 DEFUN (neighbor_maximum_prefix_threshold
,
5816 neighbor_maximum_prefix_threshold_cmd
,
5817 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5820 "Maximum number of prefix accept from this peer\n"
5821 "maximum no. of prefix limit\n"
5822 "Threshold value (%) at which to generate a warning msg\n")
5826 int idx_number_2
= 4;
5827 return peer_maximum_prefix_set_vty(
5828 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5829 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5833 neighbor_maximum_prefix_threshold
,
5834 neighbor_maximum_prefix_threshold_hidden_cmd
,
5835 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5836 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5837 "Maximum number of prefix accept from this peer\n"
5838 "maximum no. of prefix limit\n"
5839 "Threshold value (%) at which to generate a warning msg\n")
5841 DEFUN (neighbor_maximum_prefix_warning
,
5842 neighbor_maximum_prefix_warning_cmd
,
5843 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5846 "Maximum number of prefix accept from this peer\n"
5847 "maximum no. of prefix limit\n"
5848 "Only give warning message when limit is exceeded\n")
5852 return peer_maximum_prefix_set_vty(
5853 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5854 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5858 neighbor_maximum_prefix_warning
,
5859 neighbor_maximum_prefix_warning_hidden_cmd
,
5860 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5861 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5862 "Maximum number of prefix accept from this peer\n"
5863 "maximum no. of prefix limit\n"
5864 "Only give warning message when limit is exceeded\n")
5866 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5867 neighbor_maximum_prefix_threshold_warning_cmd
,
5868 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5871 "Maximum number of prefix accept from this peer\n"
5872 "maximum no. of prefix limit\n"
5873 "Threshold value (%) at which to generate a warning msg\n"
5874 "Only give warning message when limit is exceeded\n")
5878 int idx_number_2
= 4;
5879 return peer_maximum_prefix_set_vty(
5880 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5881 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5885 neighbor_maximum_prefix_threshold_warning
,
5886 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5887 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5888 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5889 "Maximum number of prefix accept from this peer\n"
5890 "maximum no. of prefix limit\n"
5891 "Threshold value (%) at which to generate a warning msg\n"
5892 "Only give warning message when limit is exceeded\n")
5894 DEFUN (neighbor_maximum_prefix_restart
,
5895 neighbor_maximum_prefix_restart_cmd
,
5896 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5899 "Maximum number of prefix accept from this peer\n"
5900 "maximum no. of prefix limit\n"
5901 "Restart bgp connection after limit is exceeded\n"
5902 "Restart interval in minutes\n")
5906 int idx_number_2
= 5;
5907 return peer_maximum_prefix_set_vty(
5908 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5909 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5913 neighbor_maximum_prefix_restart
,
5914 neighbor_maximum_prefix_restart_hidden_cmd
,
5915 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5916 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5917 "Maximum number of prefix accept from this peer\n"
5918 "maximum no. of prefix limit\n"
5919 "Restart bgp connection after limit is exceeded\n"
5920 "Restart interval in minutes\n")
5922 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5923 neighbor_maximum_prefix_threshold_restart_cmd
,
5924 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5927 "Maximum number of prefixes to accept from this peer\n"
5928 "maximum no. of prefix limit\n"
5929 "Threshold value (%) at which to generate a warning msg\n"
5930 "Restart bgp connection after limit is exceeded\n"
5931 "Restart interval in minutes\n")
5935 int idx_number_2
= 4;
5936 int idx_number_3
= 6;
5937 return peer_maximum_prefix_set_vty(
5938 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5939 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5940 argv
[idx_number_3
]->arg
);
5944 neighbor_maximum_prefix_threshold_restart
,
5945 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5946 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5947 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5948 "Maximum number of prefixes to accept from this peer\n"
5949 "maximum no. of prefix limit\n"
5950 "Threshold value (%) at which to generate a warning msg\n"
5951 "Restart bgp connection after limit is exceeded\n"
5952 "Restart interval in minutes\n")
5954 DEFUN (no_neighbor_maximum_prefix
,
5955 no_neighbor_maximum_prefix_cmd
,
5956 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5960 "Maximum number of prefixes to accept from this peer\n"
5961 "maximum no. of prefix limit\n"
5962 "Threshold value (%) at which to generate a warning msg\n"
5963 "Restart bgp connection after limit is exceeded\n"
5964 "Restart interval in minutes\n"
5965 "Only give warning message when limit is exceeded\n")
5968 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5970 bgp_node_safi(vty
));
5974 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5975 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5976 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5977 "Maximum number of prefixes to accept from this peer\n"
5978 "maximum no. of prefix limit\n"
5979 "Threshold value (%) at which to generate a warning msg\n"
5980 "Restart bgp connection after limit is exceeded\n"
5981 "Restart interval in minutes\n"
5982 "Only give warning message when limit is exceeded\n")
5985 /* "neighbor allowas-in" */
5986 DEFUN (neighbor_allowas_in
,
5987 neighbor_allowas_in_cmd
,
5988 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5991 "Accept as-path with my AS present in it\n"
5992 "Number of occurances of AS number\n"
5993 "Only accept my AS in the as-path if the route was originated in my AS\n")
5996 int idx_number_origin
= 3;
6002 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6004 return CMD_WARNING_CONFIG_FAILED
;
6006 if (argc
<= idx_number_origin
)
6009 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6012 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6015 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6018 return bgp_vty_return(vty
, ret
);
6022 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6023 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6024 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6025 "Accept as-path with my AS present in it\n"
6026 "Number of occurances of AS number\n"
6027 "Only accept my AS in the as-path if the route was originated in my AS\n")
6029 DEFUN (no_neighbor_allowas_in
,
6030 no_neighbor_allowas_in_cmd
,
6031 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6035 "allow local ASN appears in aspath attribute\n"
6036 "Number of occurances of AS number\n"
6037 "Only accept my AS in the as-path if the route was originated in my AS\n")
6043 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6045 return CMD_WARNING_CONFIG_FAILED
;
6047 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6048 bgp_node_safi(vty
));
6050 return bgp_vty_return(vty
, ret
);
6054 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6055 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6056 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6057 "allow local ASN appears in aspath attribute\n"
6058 "Number of occurances of AS number\n"
6059 "Only accept my AS in the as-path if the route was originated in my AS\n")
6061 DEFUN (neighbor_ttl_security
,
6062 neighbor_ttl_security_cmd
,
6063 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6066 "BGP ttl-security parameters\n"
6067 "Specify the maximum number of hops to the BGP peer\n"
6068 "Number of hops to BGP peer\n")
6075 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6077 return CMD_WARNING_CONFIG_FAILED
;
6079 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6082 * If 'neighbor swpX', then this is for directly connected peers,
6083 * we should not accept a ttl-security hops value greater than 1.
6085 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6087 "%s is directly connected peer, hops cannot exceed 1\n",
6088 argv
[idx_peer
]->arg
);
6089 return CMD_WARNING_CONFIG_FAILED
;
6092 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6095 DEFUN (no_neighbor_ttl_security
,
6096 no_neighbor_ttl_security_cmd
,
6097 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6101 "BGP ttl-security parameters\n"
6102 "Specify the maximum number of hops to the BGP peer\n"
6103 "Number of hops to BGP peer\n")
6108 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6110 return CMD_WARNING_CONFIG_FAILED
;
6112 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6115 DEFUN (neighbor_addpath_tx_all_paths
,
6116 neighbor_addpath_tx_all_paths_cmd
,
6117 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6120 "Use addpath to advertise all paths to a neighbor\n")
6125 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6127 return CMD_WARNING_CONFIG_FAILED
;
6129 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6131 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6134 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6135 neighbor_addpath_tx_all_paths_hidden_cmd
,
6136 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6137 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6138 "Use addpath to advertise all paths to a neighbor\n")
6140 DEFUN (no_neighbor_addpath_tx_all_paths
,
6141 no_neighbor_addpath_tx_all_paths_cmd
,
6142 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6146 "Use addpath to advertise all paths to a neighbor\n")
6149 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6150 bgp_node_afi(vty
), bgp_node_safi(vty
),
6151 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6154 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6155 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6156 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6157 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6158 "Use addpath to advertise all paths to a neighbor\n")
6160 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6161 neighbor_addpath_tx_bestpath_per_as_cmd
,
6162 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6165 "Use addpath to advertise the bestpath per each neighboring AS\n")
6170 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6172 return CMD_WARNING_CONFIG_FAILED
;
6174 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6176 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6179 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6180 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6181 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6182 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6183 "Use addpath to advertise the bestpath per each neighboring AS\n")
6185 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6186 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6187 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6191 "Use addpath to advertise the bestpath per each neighboring AS\n")
6194 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6195 bgp_node_afi(vty
), bgp_node_safi(vty
),
6196 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6199 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6200 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6201 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6202 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6203 "Use addpath to advertise the bestpath per each neighboring AS\n")
6205 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6206 struct ecommunity
**list
)
6208 struct ecommunity
*ecom
= NULL
;
6209 struct ecommunity
*ecomadd
;
6211 for (; argc
; --argc
, ++argv
) {
6213 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6214 ECOMMUNITY_ROUTE_TARGET
, 0);
6216 vty_out(vty
, "Malformed community-list value\n");
6218 ecommunity_free(&ecom
);
6219 return CMD_WARNING_CONFIG_FAILED
;
6223 ecommunity_merge(ecom
, ecomadd
);
6224 ecommunity_free(&ecomadd
);
6231 ecommunity_free(&*list
);
6239 * v2vimport is true if we are handling a `import vrf ...` command
6241 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6245 switch (vty
->node
) {
6254 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6259 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6260 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6261 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6262 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6264 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6268 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6269 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6270 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6271 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6273 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6280 DEFPY (af_rd_vpn_export
,
6281 af_rd_vpn_export_cmd
,
6282 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6284 "Specify route distinguisher\n"
6285 "Between current address-family and vpn\n"
6286 "For routes leaked from current address-family to vpn\n"
6287 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6289 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6290 struct prefix_rd prd
;
6296 if (argv_find(argv
, argc
, "no", &idx
))
6300 ret
= str2prefix_rd(rd_str
, &prd
);
6302 vty_out(vty
, "%% Malformed rd\n");
6303 return CMD_WARNING_CONFIG_FAILED
;
6307 afi
= vpn_policy_getafi(vty
, bgp
, false);
6309 return CMD_WARNING_CONFIG_FAILED
;
6312 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6314 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6315 bgp_get_default(), bgp
);
6318 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6319 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6320 BGP_VPN_POLICY_TOVPN_RD_SET
);
6322 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6323 BGP_VPN_POLICY_TOVPN_RD_SET
);
6326 /* post-change: re-export vpn routes */
6327 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6328 bgp_get_default(), bgp
);
6333 ALIAS (af_rd_vpn_export
,
6334 af_no_rd_vpn_export_cmd
,
6337 "Specify route distinguisher\n"
6338 "Between current address-family and vpn\n"
6339 "For routes leaked from current address-family to vpn\n")
6341 DEFPY (af_label_vpn_export
,
6342 af_label_vpn_export_cmd
,
6343 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6345 "label value for VRF\n"
6346 "Between current address-family and vpn\n"
6347 "For routes leaked from current address-family to vpn\n"
6348 "Label Value <0-1048575>\n"
6349 "Automatically assign a label\n")
6351 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6352 mpls_label_t label
= MPLS_LABEL_NONE
;
6357 if (argv_find(argv
, argc
, "no", &idx
))
6360 /* If "no ...", squash trailing parameter */
6366 label
= label_val
; /* parser should force unsigned */
6369 afi
= vpn_policy_getafi(vty
, bgp
, false);
6371 return CMD_WARNING_CONFIG_FAILED
;
6374 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6375 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6380 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6382 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6383 bgp_get_default(), bgp
);
6385 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6386 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6388 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6391 * label has previously been automatically
6392 * assigned by labelpool: release it
6394 * NB if tovpn_label == MPLS_LABEL_NONE it
6395 * means the automatic assignment is in flight
6396 * and therefore the labelpool callback must
6397 * detect that the auto label is not needed.
6400 bgp_lp_release(LP_TYPE_VRF
,
6401 &bgp
->vpn_policy
[afi
],
6402 bgp
->vpn_policy
[afi
].tovpn_label
);
6404 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6405 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6408 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6410 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6411 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6412 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6413 vpn_leak_label_callback
);
6416 /* post-change: re-export vpn routes */
6417 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6418 bgp_get_default(), bgp
);
6423 ALIAS (af_label_vpn_export
,
6424 af_no_label_vpn_export_cmd
,
6425 "no label vpn export",
6427 "label value for VRF\n"
6428 "Between current address-family and vpn\n"
6429 "For routes leaked from current address-family to vpn\n")
6431 DEFPY (af_nexthop_vpn_export
,
6432 af_nexthop_vpn_export_cmd
,
6433 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6435 "Specify next hop to use for VRF advertised prefixes\n"
6436 "Between current address-family and vpn\n"
6437 "For routes leaked from current address-family to vpn\n"
6441 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6447 if (argv_find(argv
, argc
, "no", &idx
))
6451 if (!sockunion2hostprefix(nexthop_str
, &p
))
6452 return CMD_WARNING_CONFIG_FAILED
;
6455 afi
= vpn_policy_getafi(vty
, bgp
, false);
6457 return CMD_WARNING_CONFIG_FAILED
;
6460 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6462 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6463 bgp_get_default(), bgp
);
6466 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6467 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6468 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6470 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6471 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6474 /* post-change: re-export vpn routes */
6475 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6476 bgp_get_default(), bgp
);
6481 ALIAS (af_nexthop_vpn_export
,
6482 af_no_nexthop_vpn_export_cmd
,
6483 "no nexthop vpn export",
6485 "Specify next hop to use for VRF advertised prefixes\n"
6486 "Between current address-family and vpn\n"
6487 "For routes leaked from current address-family to vpn\n")
6489 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6491 if (!strcmp(dstr
, "import")) {
6492 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6493 } else if (!strcmp(dstr
, "export")) {
6494 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6495 } else if (!strcmp(dstr
, "both")) {
6496 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6497 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6499 vty_out(vty
, "%% direction parse error\n");
6500 return CMD_WARNING_CONFIG_FAILED
;
6505 DEFPY (af_rt_vpn_imexport
,
6506 af_rt_vpn_imexport_cmd
,
6507 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6509 "Specify route target list\n"
6510 "Specify route target list\n"
6511 "Between current address-family and vpn\n"
6512 "For routes leaked from vpn to current address-family: match any\n"
6513 "For routes leaked from current address-family to vpn: set\n"
6514 "both import: match any and export: set\n"
6515 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6517 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6519 struct ecommunity
*ecom
= NULL
;
6520 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6521 vpn_policy_direction_t dir
;
6526 if (argv_find(argv
, argc
, "no", &idx
))
6529 afi
= vpn_policy_getafi(vty
, bgp
, false);
6531 return CMD_WARNING_CONFIG_FAILED
;
6533 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6534 if (ret
!= CMD_SUCCESS
)
6538 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6539 vty_out(vty
, "%% Missing RTLIST\n");
6540 return CMD_WARNING_CONFIG_FAILED
;
6542 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6543 if (ret
!= CMD_SUCCESS
) {
6548 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6552 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6555 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6557 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6558 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6559 ecommunity_dup(ecom
);
6561 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6563 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6564 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6567 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6571 ecommunity_free(&ecom
);
6576 ALIAS (af_rt_vpn_imexport
,
6577 af_no_rt_vpn_imexport_cmd
,
6578 "no <rt|route-target> vpn <import|export|both>$direction_str",
6580 "Specify route target list\n"
6581 "Specify route target list\n"
6582 "Between current address-family and vpn\n"
6583 "For routes leaked from vpn to current address-family\n"
6584 "For routes leaked from current address-family to vpn\n"
6585 "both import and export\n")
6587 DEFPY (af_route_map_vpn_imexport
,
6588 af_route_map_vpn_imexport_cmd
,
6589 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6590 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6592 "Specify route map\n"
6593 "Between current address-family and vpn\n"
6594 "For routes leaked from vpn to current address-family\n"
6595 "For routes leaked from current address-family to vpn\n"
6596 "name of route-map\n")
6598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6600 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6601 vpn_policy_direction_t dir
;
6606 if (argv_find(argv
, argc
, "no", &idx
))
6609 afi
= vpn_policy_getafi(vty
, bgp
, false);
6611 return CMD_WARNING_CONFIG_FAILED
;
6613 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6614 if (ret
!= CMD_SUCCESS
)
6617 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6621 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6624 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6625 XFREE(MTYPE_ROUTE_MAP_NAME
,
6626 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6627 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6628 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6629 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6630 route_map_lookup_by_name(rmap_str
);
6631 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6634 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6635 XFREE(MTYPE_ROUTE_MAP_NAME
,
6636 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6637 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6638 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6641 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6647 ALIAS (af_route_map_vpn_imexport
,
6648 af_no_route_map_vpn_imexport_cmd
,
6649 "no route-map vpn <import|export>$direction_str",
6651 "Specify route map\n"
6652 "Between current address-family and vpn\n"
6653 "For routes leaked from vpn to current address-family\n"
6654 "For routes leaked from current address-family to vpn\n")
6656 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6657 "[no] import vrf route-map RMAP$rmap_str",
6659 "Import routes from another VRF\n"
6660 "Vrf routes being filtered\n"
6661 "Specify route map\n"
6662 "name of route-map\n")
6664 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6665 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6669 struct bgp
*bgp_default
;
6671 if (argv_find(argv
, argc
, "no", &idx
))
6674 afi
= vpn_policy_getafi(vty
, bgp
, true);
6676 return CMD_WARNING_CONFIG_FAILED
;
6678 bgp_default
= bgp_get_default();
6683 /* Auto-create assuming the same AS */
6684 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6685 BGP_INSTANCE_TYPE_DEFAULT
);
6689 "VRF default is not configured as a bgp instance\n");
6694 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6697 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6698 XFREE(MTYPE_ROUTE_MAP_NAME
,
6699 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6700 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6701 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6702 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6703 route_map_lookup_by_name(rmap_str
);
6704 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6707 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6708 XFREE(MTYPE_ROUTE_MAP_NAME
,
6709 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6710 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6711 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6714 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6719 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6720 "no import vrf route-map",
6722 "Import routes from another VRF\n"
6723 "Vrf routes being filtered\n"
6724 "Specify route map\n")
6726 DEFPY (bgp_imexport_vrf
,
6727 bgp_imexport_vrf_cmd
,
6728 "[no] import vrf NAME$import_name",
6730 "Import routes from another VRF\n"
6731 "VRF to import from\n"
6732 "The name of the VRF\n")
6734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6735 struct listnode
*node
;
6736 struct bgp
*vrf_bgp
, *bgp_default
;
6739 bool remove
= false;
6742 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6746 if (import_name
== NULL
) {
6747 vty_out(vty
, "%% Missing import name\n");
6751 if (argv_find(argv
, argc
, "no", &idx
))
6754 afi
= vpn_policy_getafi(vty
, bgp
, true);
6756 return CMD_WARNING_CONFIG_FAILED
;
6758 safi
= bgp_node_safi(vty
);
6760 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6761 && (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0))
6762 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6763 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6764 remove
? "unimport" : "import", import_name
);
6768 bgp_default
= bgp_get_default();
6770 /* Auto-create assuming the same AS */
6771 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6772 BGP_INSTANCE_TYPE_DEFAULT
);
6776 "VRF default is not configured as a bgp instance\n");
6781 vrf_bgp
= bgp_lookup_by_name(import_name
);
6783 if (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0)
6784 vrf_bgp
= bgp_default
;
6786 /* Auto-create assuming the same AS */
6787 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6791 "VRF %s is not configured as a bgp instance\n",
6798 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6800 /* Already importing from "import_vrf"? */
6801 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6803 if (strcmp(vname
, import_name
) == 0)
6807 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6813 /* This command is valid only in a bgp vrf instance or the default instance */
6814 DEFPY (bgp_imexport_vpn
,
6815 bgp_imexport_vpn_cmd
,
6816 "[no] <import|export>$direction_str vpn",
6818 "Import routes to this address-family\n"
6819 "Export routes from this address-family\n"
6820 "to/from default instance VPN RIB\n")
6822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6829 vpn_policy_direction_t dir
;
6831 if (argv_find(argv
, argc
, "no", &idx
))
6834 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6835 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6837 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6838 return CMD_WARNING_CONFIG_FAILED
;
6841 afi
= bgp_node_afi(vty
);
6842 safi
= bgp_node_safi(vty
);
6843 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6844 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6845 return CMD_WARNING_CONFIG_FAILED
;
6848 if (!strcmp(direction_str
, "import")) {
6849 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6850 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6851 } else if (!strcmp(direction_str
, "export")) {
6852 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6853 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6855 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6856 return CMD_WARNING_CONFIG_FAILED
;
6859 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6862 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6863 if (!previous_state
) {
6864 /* trigger export current vrf */
6865 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6868 if (previous_state
) {
6869 /* trigger un-export current vrf */
6870 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6872 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6878 DEFPY (af_routetarget_import
,
6879 af_routetarget_import_cmd
,
6880 "[no] <rt|route-target> redirect import RTLIST...",
6882 "Specify route target list\n"
6883 "Specify route target list\n"
6884 "Flow-spec redirect type route target\n"
6885 "Import routes to this address-family\n"
6886 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6890 struct ecommunity
*ecom
= NULL
;
6895 if (argv_find(argv
, argc
, "no", &idx
))
6898 afi
= vpn_policy_getafi(vty
, bgp
, false);
6900 return CMD_WARNING_CONFIG_FAILED
;
6903 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6904 vty_out(vty
, "%% Missing RTLIST\n");
6905 return CMD_WARNING_CONFIG_FAILED
;
6907 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6908 if (ret
!= CMD_SUCCESS
)
6913 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6914 ecommunity_free(&bgp
->vpn_policy
[afi
]
6915 .import_redirect_rtlist
);
6916 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
6917 ecommunity_dup(ecom
);
6919 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6920 ecommunity_free(&bgp
->vpn_policy
[afi
]
6921 .import_redirect_rtlist
);
6922 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
6926 ecommunity_free(&ecom
);
6931 DEFUN_NOSH (address_family_ipv4_safi
,
6932 address_family_ipv4_safi_cmd
,
6933 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6934 "Enter Address Family command mode\n"
6936 BGP_SAFI_WITH_LABEL_HELP_STR
)
6940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6941 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6942 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6943 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6944 && safi
!= SAFI_EVPN
) {
6946 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6947 return CMD_WARNING_CONFIG_FAILED
;
6949 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6951 vty
->node
= BGP_IPV4_NODE
;
6956 DEFUN_NOSH (address_family_ipv6_safi
,
6957 address_family_ipv6_safi_cmd
,
6958 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6959 "Enter Address Family command mode\n"
6961 BGP_SAFI_WITH_LABEL_HELP_STR
)
6964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6965 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6966 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6967 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6968 && safi
!= SAFI_EVPN
) {
6970 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6971 return CMD_WARNING_CONFIG_FAILED
;
6973 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6975 vty
->node
= BGP_IPV6_NODE
;
6980 #ifdef KEEP_OLD_VPN_COMMANDS
6981 DEFUN_NOSH (address_family_vpnv4
,
6982 address_family_vpnv4_cmd
,
6983 "address-family vpnv4 [unicast]",
6984 "Enter Address Family command mode\n"
6986 "Address Family modifier\n")
6988 vty
->node
= BGP_VPNV4_NODE
;
6992 DEFUN_NOSH (address_family_vpnv6
,
6993 address_family_vpnv6_cmd
,
6994 "address-family vpnv6 [unicast]",
6995 "Enter Address Family command mode\n"
6997 "Address Family modifier\n")
6999 vty
->node
= BGP_VPNV6_NODE
;
7004 DEFUN_NOSH (address_family_evpn
,
7005 address_family_evpn_cmd
,
7006 "address-family l2vpn evpn",
7007 "Enter Address Family command mode\n"
7009 "Address Family modifier\n")
7011 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7012 vty
->node
= BGP_EVPN_NODE
;
7016 DEFUN_NOSH (exit_address_family
,
7017 exit_address_family_cmd
,
7018 "exit-address-family",
7019 "Exit from Address Family configuration mode\n")
7021 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7022 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7023 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7024 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7025 || vty
->node
== BGP_EVPN_NODE
7026 || vty
->node
== BGP_FLOWSPECV4_NODE
7027 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7028 vty
->node
= BGP_NODE
;
7032 /* Recalculate bestpath and re-advertise a prefix */
7033 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7034 const char *ip_str
, afi_t afi
, safi_t safi
,
7035 struct prefix_rd
*prd
)
7038 struct prefix match
;
7039 struct bgp_node
*rn
;
7040 struct bgp_node
*rm
;
7042 struct bgp_table
*table
;
7043 struct bgp_table
*rib
;
7045 /* BGP structure lookup. */
7047 bgp
= bgp_lookup_by_name(view_name
);
7049 vty_out(vty
, "%% Can't find BGP instance %s\n",
7054 bgp
= bgp_get_default();
7056 vty_out(vty
, "%% No BGP process is configured\n");
7061 /* Check IP address argument. */
7062 ret
= str2prefix(ip_str
, &match
);
7064 vty_out(vty
, "%% address is malformed\n");
7068 match
.family
= afi2family(afi
);
7069 rib
= bgp
->rib
[afi
][safi
];
7071 if (safi
== SAFI_MPLS_VPN
) {
7072 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7073 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7076 if ((table
= rn
->info
) != NULL
) {
7077 if ((rm
= bgp_node_match(table
, &match
))
7080 == match
.prefixlen
) {
7082 BGP_NODE_USER_CLEAR
);
7083 bgp_process(bgp
, rm
, afi
, safi
);
7085 bgp_unlock_node(rm
);
7090 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7091 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7092 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7093 bgp_process(bgp
, rn
, afi
, safi
);
7095 bgp_unlock_node(rn
);
7102 /* one clear bgp command to rule them all */
7103 DEFUN (clear_ip_bgp_all
,
7104 clear_ip_bgp_all_cmd
,
7105 "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>]",
7109 BGP_INSTANCE_HELP_STR
7111 BGP_SAFI_WITH_LABEL_HELP_STR
7113 "BGP neighbor address to clear\n"
7114 "BGP IPv6 neighbor to clear\n"
7115 "BGP neighbor on interface to clear\n"
7116 "Clear peers with the AS number\n"
7117 "Clear all external peers\n"
7118 "Clear all members of peer-group\n"
7119 "BGP peer-group name\n"
7124 "Push out prefix-list ORF and do inbound soft reconfig\n"
7129 afi_t afi
= AFI_IP6
;
7130 safi_t safi
= SAFI_UNICAST
;
7131 enum clear_sort clr_sort
= clear_peer
;
7132 enum bgp_clear_type clr_type
;
7133 char *clr_arg
= NULL
;
7137 /* clear [ip] bgp */
7138 if (argv_find(argv
, argc
, "ip", &idx
))
7141 /* [<view|vrf> VIEWVRFNAME] */
7142 if (argv_find(argv
, argc
, "view", &idx
)
7143 || argv_find(argv
, argc
, "vrf", &idx
)) {
7144 vrf
= argv
[idx
+ 1]->arg
;
7148 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7149 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7150 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7152 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7153 if (argv_find(argv
, argc
, "*", &idx
)) {
7154 clr_sort
= clear_all
;
7155 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7156 clr_sort
= clear_peer
;
7157 clr_arg
= argv
[idx
]->arg
;
7158 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7159 clr_sort
= clear_peer
;
7160 clr_arg
= argv
[idx
]->arg
;
7161 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7162 clr_sort
= clear_group
;
7164 clr_arg
= argv
[idx
]->arg
;
7165 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7166 clr_sort
= clear_peer
;
7167 clr_arg
= argv
[idx
]->arg
;
7168 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7169 clr_sort
= clear_as
;
7170 clr_arg
= argv
[idx
]->arg
;
7171 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7172 clr_sort
= clear_external
;
7175 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7176 if (argv_find(argv
, argc
, "soft", &idx
)) {
7177 if (argv_find(argv
, argc
, "in", &idx
)
7178 || argv_find(argv
, argc
, "out", &idx
))
7179 clr_type
= strmatch(argv
[idx
]->text
, "in")
7181 : BGP_CLEAR_SOFT_OUT
;
7183 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7184 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7185 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7186 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7187 : BGP_CLEAR_SOFT_IN
;
7188 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7189 clr_type
= BGP_CLEAR_SOFT_OUT
;
7191 clr_type
= BGP_CLEAR_SOFT_NONE
;
7193 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7196 DEFUN (clear_ip_bgp_prefix
,
7197 clear_ip_bgp_prefix_cmd
,
7198 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7202 BGP_INSTANCE_HELP_STR
7203 "Clear bestpath and re-advertise\n"
7207 char *prefix
= NULL
;
7211 /* [<view|vrf> VIEWVRFNAME] */
7212 if (argv_find(argv
, argc
, "VIEWVRFNAME", &idx
))
7213 vrf
= argv
[idx
]->arg
;
7215 prefix
= argv
[argc
- 1]->arg
;
7217 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7220 DEFUN (clear_bgp_ipv6_safi_prefix
,
7221 clear_bgp_ipv6_safi_prefix_cmd
,
7222 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7228 "Clear bestpath and re-advertise\n"
7232 int idx_ipv6_prefix
= 0;
7233 safi_t safi
= SAFI_UNICAST
;
7234 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7235 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7237 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7238 return bgp_clear_prefix(
7239 vty
, NULL
, prefix
, AFI_IP6
,
7243 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7244 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7245 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7249 BGP_INSTANCE_HELP_STR
7252 "Clear bestpath and re-advertise\n"
7257 int idx_ipv6_prefix
= 0;
7258 safi_t safi
= SAFI_UNICAST
;
7259 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7260 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7261 /* [<view|vrf> VIEWVRFNAME] */
7262 char *vrfview
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx_word
) ?
7263 argv
[idx_word
]->arg
: NULL
;
7265 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7267 return bgp_clear_prefix(
7268 vty
, vrfview
, prefix
,
7269 AFI_IP6
, safi
, NULL
);
7272 DEFUN (show_bgp_views
,
7274 "show [ip] bgp views",
7278 "Show the defined BGP views\n")
7280 struct list
*inst
= bm
->bgp
;
7281 struct listnode
*node
;
7284 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7285 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7289 vty_out(vty
, "Defined BGP views:\n");
7290 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7292 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7294 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7301 DEFUN (show_bgp_vrfs
,
7303 "show [ip] bgp vrfs [json]",
7310 char buf
[ETHER_ADDR_STRLEN
];
7311 struct list
*inst
= bm
->bgp
;
7312 struct listnode
*node
;
7314 uint8_t uj
= use_json(argc
, argv
);
7315 json_object
*json
= NULL
;
7316 json_object
*json_vrfs
= NULL
;
7319 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7320 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7325 json
= json_object_new_object();
7326 json_vrfs
= json_object_new_object();
7329 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7330 const char *name
, *type
;
7332 struct listnode
*node
, *nnode
;
7333 int peers_cfg
, peers_estb
;
7334 json_object
*json_vrf
= NULL
;
7337 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7341 if (!uj
&& count
== 1)
7343 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7344 "Type", "Id", "routerId", "#PeersVfg",
7345 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7347 peers_cfg
= peers_estb
= 0;
7349 json_vrf
= json_object_new_object();
7352 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7353 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7356 if (peer
->status
== Established
)
7360 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7370 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7372 : (int64_t)bgp
->vrf_id
;
7373 json_object_string_add(json_vrf
, "type", type
);
7374 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7375 json_object_string_add(json_vrf
, "routerId",
7376 inet_ntoa(bgp
->router_id
));
7377 json_object_int_add(json_vrf
, "numConfiguredPeers",
7379 json_object_int_add(json_vrf
, "numEstablishedPeers",
7382 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7383 json_object_string_add(
7385 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7386 json_object_object_add(json_vrfs
, name
, json_vrf
);
7389 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7391 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7393 inet_ntoa(bgp
->router_id
), peers_cfg
,
7394 peers_estb
, name
, bgp
->l3vni
,
7395 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7399 json_object_object_add(json
, "vrfs", json_vrfs
);
7401 json_object_int_add(json
, "totalVrfs", count
);
7403 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7404 json
, JSON_C_TO_STRING_PRETTY
));
7405 json_object_free(json
);
7409 "\nTotal number of VRFs (including default): %d\n",
7416 static void show_address_entry(struct hash_backet
*backet
, void *args
)
7418 struct vty
*vty
= (struct vty
*)args
;
7419 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
7421 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
7425 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7427 struct vty
*vty
= (struct vty
*)args
;
7428 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7430 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7434 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7436 vty_out(vty
, "self nexthop database:\n");
7437 hash_iterate(bgp
->address_hash
,
7438 (void (*)(struct hash_backet
*, void *))show_address_entry
,
7441 vty_out(vty
, "Tunnel-ip database:\n");
7442 hash_iterate(bgp
->tip_hash
,
7443 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7447 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7448 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7449 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7450 "martian next-hops\n"
7451 "martian next-hop database\n")
7453 struct bgp
*bgp
= NULL
;
7456 if (argv_find(argv
, argc
, "view", &idx
)
7457 || argv_find(argv
, argc
, "vrf", &idx
))
7458 bgp
= bgp_lookup_by_name(argv
[idx
+ 1]->arg
);
7460 bgp
= bgp_get_default();
7463 vty_out(vty
, "%% No BGP process is configured\n");
7466 bgp_show_martian_nexthops(vty
, bgp
);
7471 DEFUN (show_bgp_memory
,
7472 show_bgp_memory_cmd
,
7473 "show [ip] bgp memory",
7477 "Global BGP memory statistics\n")
7479 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7480 unsigned long count
;
7482 /* RIB related usage stats */
7483 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7484 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7485 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7486 count
* sizeof(struct bgp_node
)));
7488 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7489 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7490 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7491 count
* sizeof(struct bgp_info
)));
7492 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7493 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7495 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7496 count
* sizeof(struct bgp_info_extra
)));
7498 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7499 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7500 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7501 count
* sizeof(struct bgp_static
)));
7503 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7504 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7505 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7506 count
* sizeof(struct bpacket
)));
7509 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7510 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7511 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7512 count
* sizeof(struct bgp_adj_in
)));
7513 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7514 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7515 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7516 count
* sizeof(struct bgp_adj_out
)));
7518 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7519 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7521 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7522 count
* sizeof(struct bgp_nexthop_cache
)));
7524 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7525 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7527 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7528 count
* sizeof(struct bgp_damp_info
)));
7531 count
= attr_count();
7532 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7533 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7534 count
* sizeof(struct attr
)));
7536 if ((count
= attr_unknown_count()))
7537 vty_out(vty
, "%ld unknown attributes\n", count
);
7539 /* AS_PATH attributes */
7540 count
= aspath_count();
7541 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7542 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7543 count
* sizeof(struct aspath
)));
7545 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7546 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7547 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7548 count
* sizeof(struct assegment
)));
7550 /* Other attributes */
7551 if ((count
= community_count()))
7552 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7553 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7554 count
* sizeof(struct community
)));
7555 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7556 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7557 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7558 count
* sizeof(struct ecommunity
)));
7559 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7561 "%ld BGP large-community entries, using %s of memory\n",
7562 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7563 count
* sizeof(struct lcommunity
)));
7565 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7566 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7567 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7568 count
* sizeof(struct cluster_list
)));
7570 /* Peer related usage */
7571 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7572 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7573 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7574 count
* sizeof(struct peer
)));
7576 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7577 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7578 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7579 count
* sizeof(struct peer_group
)));
7582 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7583 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7584 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7585 count
* sizeof(struct hash
)));
7586 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7587 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7588 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7589 count
* sizeof(struct hash_backet
)));
7590 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7591 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7592 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7593 count
* sizeof(regex_t
)));
7597 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7599 json_object
*bestpath
= json_object_new_object();
7601 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7602 json_object_string_add(bestpath
, "asPath", "ignore");
7604 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7605 json_object_string_add(bestpath
, "asPath", "confed");
7607 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7608 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7609 json_object_string_add(bestpath
, "multiPathRelax",
7612 json_object_string_add(bestpath
, "multiPathRelax",
7615 json_object_string_add(bestpath
, "multiPathRelax", "false");
7617 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7618 json_object_string_add(bestpath
, "compareRouterId", "true");
7619 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7620 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7621 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7622 json_object_string_add(bestpath
, "med", "confed");
7623 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7624 json_object_string_add(bestpath
, "med",
7625 "missing-as-worst");
7627 json_object_string_add(bestpath
, "med", "true");
7630 json_object_object_add(json
, "bestPath", bestpath
);
7633 /* Show BGP peer's summary information. */
7634 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7635 uint8_t use_json
, json_object
*json
)
7638 struct listnode
*node
, *nnode
;
7639 unsigned int count
= 0, dn_count
= 0;
7640 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7641 char neighbor_buf
[VTY_BUFSIZ
];
7642 int neighbor_col_default_width
= 16;
7644 int max_neighbor_width
= 0;
7646 json_object
*json_peer
= NULL
;
7647 json_object
*json_peers
= NULL
;
7649 /* labeled-unicast routes are installed in the unicast table so in order
7651 * display the correct PfxRcd value we must look at SAFI_UNICAST
7653 if (safi
== SAFI_LABELED_UNICAST
)
7654 pfx_rcd_safi
= SAFI_UNICAST
;
7656 pfx_rcd_safi
= safi
;
7660 json
= json_object_new_object();
7662 json_peers
= json_object_new_object();
7664 /* Loop over all neighbors that will be displayed to determine
7666 * characters are needed for the Neighbor column
7668 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7669 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7672 if (peer
->afc
[afi
][safi
]) {
7673 memset(dn_flag
, '\0', sizeof(dn_flag
));
7674 if (peer_dynamic_neighbor(peer
))
7678 && bgp_flag_check(bgp
,
7679 BGP_FLAG_SHOW_HOSTNAME
))
7680 sprintf(neighbor_buf
, "%s%s(%s) ",
7681 dn_flag
, peer
->hostname
,
7684 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7687 len
= strlen(neighbor_buf
);
7689 if (len
> max_neighbor_width
)
7690 max_neighbor_width
= len
;
7694 /* Originally we displayed the Neighbor column as 16
7695 * characters wide so make that the default
7697 if (max_neighbor_width
< neighbor_col_default_width
)
7698 max_neighbor_width
= neighbor_col_default_width
;
7701 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7702 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7705 if (!peer
->afc
[afi
][safi
])
7710 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7713 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7715 : (int64_t)bgp
->vrf_id
;
7717 /* Usage summary and header */
7719 json_object_string_add(
7721 inet_ntoa(bgp
->router_id
));
7722 json_object_int_add(json
, "as", bgp
->as
);
7723 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7724 json_object_string_add(
7727 == BGP_INSTANCE_TYPE_DEFAULT
)
7732 "BGP router identifier %s, local AS number %u vrf-id %d",
7733 inet_ntoa(bgp
->router_id
), bgp
->as
,
7734 bgp
->vrf_id
== VRF_UNKNOWN
7736 : (int)bgp
->vrf_id
);
7740 if (bgp_update_delay_configured(bgp
)) {
7742 json_object_int_add(
7743 json
, "updateDelayLimit",
7744 bgp
->v_update_delay
);
7746 if (bgp
->v_update_delay
7747 != bgp
->v_establish_wait
)
7748 json_object_int_add(
7750 "updateDelayEstablishWait",
7751 bgp
->v_establish_wait
);
7753 if (bgp_update_delay_active(bgp
)) {
7754 json_object_string_add(
7756 "updateDelayFirstNeighbor",
7757 bgp
->update_delay_begin_time
);
7758 json_object_boolean_true_add(
7760 "updateDelayInProgress");
7762 if (bgp
->update_delay_over
) {
7763 json_object_string_add(
7765 "updateDelayFirstNeighbor",
7766 bgp
->update_delay_begin_time
);
7767 json_object_string_add(
7769 "updateDelayBestpathResumed",
7770 bgp
->update_delay_end_time
);
7771 json_object_string_add(
7773 "updateDelayZebraUpdateResume",
7774 bgp
->update_delay_zebra_resume_time
);
7775 json_object_string_add(
7777 "updateDelayPeerUpdateResume",
7778 bgp
->update_delay_peers_resume_time
);
7783 "Read-only mode update-delay limit: %d seconds\n",
7784 bgp
->v_update_delay
);
7785 if (bgp
->v_update_delay
7786 != bgp
->v_establish_wait
)
7788 " Establish wait: %d seconds\n",
7789 bgp
->v_establish_wait
);
7791 if (bgp_update_delay_active(bgp
)) {
7793 " First neighbor established: %s\n",
7794 bgp
->update_delay_begin_time
);
7796 " Delay in progress\n");
7798 if (bgp
->update_delay_over
) {
7800 " First neighbor established: %s\n",
7801 bgp
->update_delay_begin_time
);
7803 " Best-paths resumed: %s\n",
7804 bgp
->update_delay_end_time
);
7806 " zebra update resumed: %s\n",
7807 bgp
->update_delay_zebra_resume_time
);
7809 " peers update resumed: %s\n",
7810 bgp
->update_delay_peers_resume_time
);
7817 if (bgp_maxmed_onstartup_configured(bgp
)
7818 && bgp
->maxmed_active
)
7819 json_object_boolean_true_add(
7820 json
, "maxMedOnStartup");
7821 if (bgp
->v_maxmed_admin
)
7822 json_object_boolean_true_add(
7823 json
, "maxMedAdministrative");
7825 json_object_int_add(
7826 json
, "tableVersion",
7827 bgp_table_version(bgp
->rib
[afi
][safi
]));
7829 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7830 json_object_int_add(json
, "ribCount", ents
);
7831 json_object_int_add(
7833 ents
* sizeof(struct bgp_node
));
7835 ents
= listcount(bgp
->peer
);
7836 json_object_int_add(json
, "peerCount", ents
);
7837 json_object_int_add(json
, "peerMemory",
7838 ents
* sizeof(struct peer
));
7840 if ((ents
= listcount(bgp
->group
))) {
7841 json_object_int_add(
7842 json
, "peerGroupCount", ents
);
7843 json_object_int_add(
7844 json
, "peerGroupMemory",
7845 ents
* sizeof(struct
7849 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7850 BGP_CONFIG_DAMPENING
))
7851 json_object_boolean_true_add(
7852 json
, "dampeningEnabled");
7854 if (bgp_maxmed_onstartup_configured(bgp
)
7855 && bgp
->maxmed_active
)
7857 "Max-med on-startup active\n");
7858 if (bgp
->v_maxmed_admin
)
7860 "Max-med administrative active\n");
7862 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7863 bgp_table_version(bgp
->rib
[afi
][safi
]));
7865 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7867 "RIB entries %ld, using %s of memory\n",
7869 mtype_memstr(memstrbuf
,
7871 ents
* sizeof(struct
7874 /* Peer related usage */
7875 ents
= listcount(bgp
->peer
);
7876 vty_out(vty
, "Peers %ld, using %s of memory\n",
7879 memstrbuf
, sizeof(memstrbuf
),
7880 ents
* sizeof(struct peer
)));
7882 if ((ents
= listcount(bgp
->group
)))
7884 "Peer groups %ld, using %s of memory\n",
7889 ents
* sizeof(struct
7892 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7893 BGP_CONFIG_DAMPENING
))
7894 vty_out(vty
, "Dampening enabled.\n");
7897 /* Subtract 8 here because 'Neighbor' is
7899 vty_out(vty
, "Neighbor");
7900 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7903 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7910 json_peer
= json_object_new_object();
7912 if (peer_dynamic_neighbor(peer
))
7913 json_object_boolean_true_add(json_peer
,
7917 json_object_string_add(json_peer
, "hostname",
7920 if (peer
->domainname
)
7921 json_object_string_add(json_peer
, "domainname",
7924 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7925 json_object_int_add(json_peer
, "version", 4);
7926 json_object_int_add(json_peer
, "msgRcvd",
7927 PEER_TOTAL_RX(peer
));
7928 json_object_int_add(json_peer
, "msgSent",
7929 PEER_TOTAL_TX(peer
));
7931 json_object_int_add(json_peer
, "tableVersion",
7932 peer
->version
[afi
][safi
]);
7933 json_object_int_add(json_peer
, "outq",
7935 json_object_int_add(json_peer
, "inq", 0);
7936 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7937 use_json
, json_peer
);
7938 json_object_int_add(json_peer
, "prefixReceivedCount",
7939 peer
->pcount
[afi
][pfx_rcd_safi
]);
7941 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7942 json_object_string_add(json_peer
, "state",
7944 else if (peer
->afc_recv
[afi
][safi
])
7945 json_object_string_add(
7947 lookup_msg(bgp_status_msg
, peer
->status
,
7949 else if (CHECK_FLAG(peer
->sflags
,
7950 PEER_STATUS_PREFIX_OVERFLOW
))
7951 json_object_string_add(json_peer
, "state",
7954 json_object_string_add(
7956 lookup_msg(bgp_status_msg
, peer
->status
,
7960 json_object_string_add(json_peer
, "idType",
7962 else if (peer
->su
.sa
.sa_family
== AF_INET
)
7963 json_object_string_add(json_peer
, "idType",
7965 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
7966 json_object_string_add(json_peer
, "idType",
7969 json_object_object_add(json_peers
, peer
->host
,
7972 memset(dn_flag
, '\0', sizeof(dn_flag
));
7973 if (peer_dynamic_neighbor(peer
)) {
7979 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7980 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7981 peer
->hostname
, peer
->host
);
7983 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7985 /* pad the neighbor column with spaces */
7986 if (len
< max_neighbor_width
)
7987 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7990 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
7991 peer
->as
, PEER_TOTAL_RX(peer
),
7992 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
7993 0, peer
->obuf
->count
,
7994 peer_uptime(peer
->uptime
, timebuf
,
7995 BGP_UPTIME_LEN
, 0, NULL
));
7997 if (peer
->status
== Established
)
7998 if (peer
->afc_recv
[afi
][safi
])
7999 vty_out(vty
, " %12ld",
8003 vty_out(vty
, " NoNeg");
8005 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8006 vty_out(vty
, " Idle (Admin)");
8007 else if (CHECK_FLAG(
8009 PEER_STATUS_PREFIX_OVERFLOW
))
8010 vty_out(vty
, " Idle (PfxCt)");
8012 vty_out(vty
, " %12s",
8013 lookup_msg(bgp_status_msg
,
8014 peer
->status
, NULL
));
8021 json_object_object_add(json
, "peers", json_peers
);
8023 json_object_int_add(json
, "totalPeers", count
);
8024 json_object_int_add(json
, "dynamicPeers", dn_count
);
8026 bgp_show_bestpath_json(bgp
, json
);
8028 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8029 json
, JSON_C_TO_STRING_PRETTY
));
8030 json_object_free(json
);
8033 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8035 vty_out(vty
, "No %s neighbor is configured\n",
8036 afi_safi_print(afi
, safi
));
8040 vty_out(vty
, "* - dynamic neighbor\n");
8041 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8042 dn_count
, bgp
->dynamic_neighbors_limit
);
8049 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8050 int safi
, uint8_t use_json
,
8054 int afi_wildcard
= (afi
== AFI_MAX
);
8055 int safi_wildcard
= (safi
== SAFI_MAX
);
8056 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8057 bool json_output
= false;
8059 if (use_json
&& is_wildcard
)
8060 vty_out(vty
, "{\n");
8062 afi
= 1; /* AFI_IP */
8063 while (afi
< AFI_MAX
) {
8065 safi
= 1; /* SAFI_UNICAST */
8066 while (safi
< SAFI_MAX
) {
8067 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8071 * So limit output to those afi/safi
8073 * actualy have something interesting in
8077 json
= json_object_new_object();
8080 vty_out(vty
, ",\n");
8084 vty_out(vty
, "\"%s\":",
8088 vty_out(vty
, "\n%s Summary:\n",
8093 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8105 if (use_json
&& is_wildcard
)
8106 vty_out(vty
, "}\n");
8107 else if (use_json
&& !json_output
)
8108 vty_out(vty
, "{}\n");
8111 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8112 safi_t safi
, uint8_t use_json
)
8114 struct listnode
*node
, *nnode
;
8116 json_object
*json
= NULL
;
8120 vty_out(vty
, "{\n");
8122 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8124 json
= json_object_new_object();
8127 vty_out(vty
, ",\n");
8131 vty_out(vty
, "\"%s\":",
8132 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8136 vty_out(vty
, "\nInstance %s:\n",
8137 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8141 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8145 vty_out(vty
, "}\n");
8148 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8149 safi_t safi
, uint8_t use_json
)
8154 if (strmatch(name
, "all")) {
8155 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8159 bgp
= bgp_lookup_by_name(name
);
8163 vty_out(vty
, "{}\n");
8166 "%% No such BGP instance exist\n");
8170 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8176 bgp
= bgp_get_default();
8179 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8184 /* `show [ip] bgp summary' commands. */
8185 DEFUN (show_ip_bgp_summary
,
8186 show_ip_bgp_summary_cmd
,
8187 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8191 BGP_INSTANCE_HELP_STR
8193 BGP_SAFI_WITH_LABEL_HELP_STR
8194 "Summary of BGP neighbor status\n"
8198 afi_t afi
= AFI_MAX
;
8199 safi_t safi
= SAFI_MAX
;
8204 if (argv_find(argv
, argc
, "ip", &idx
))
8206 /* [<view|vrf> VIEWVRFNAME] */
8207 if (argv_find(argv
, argc
, "view", &idx
)
8208 || argv_find(argv
, argc
, "vrf", &idx
))
8209 vrf
= argv
[++idx
]->arg
;
8210 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8211 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8212 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8215 int uj
= use_json(argc
, argv
);
8217 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8220 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8222 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8223 return "IPv4 Unicast";
8224 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8225 return "IPv4 Multicast";
8226 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8227 return "IPv4 Labeled Unicast";
8228 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8230 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8231 return "IPv4 Encap";
8232 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8233 return "IPv4 Flowspec";
8234 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8235 return "IPv6 Unicast";
8236 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8237 return "IPv6 Multicast";
8238 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8239 return "IPv6 Labeled Unicast";
8240 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8242 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8243 return "IPv6 Encap";
8244 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8245 return "IPv6 Flowspec";
8246 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8247 return "L2VPN EVPN";
8253 * Please note that we have intentionally camelCased
8254 * the return strings here. So if you want
8255 * to use this function, please ensure you
8256 * are doing this within json output
8258 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8260 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8261 return "ipv4Unicast";
8262 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8263 return "ipv4Multicast";
8264 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8265 return "ipv4LabeledUnicast";
8266 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8268 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8270 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8271 return "ipv4Flowspec";
8272 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8273 return "ipv6Unicast";
8274 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8275 return "ipv6Multicast";
8276 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8277 return "ipv6LabeledUnicast";
8278 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8280 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8282 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8283 return "ipv6Flowspec";
8284 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8290 /* Show BGP peer's information. */
8291 enum show_type
{ show_all
, show_peer
};
8293 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8294 afi_t afi
, safi_t safi
,
8295 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8296 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8297 uint8_t use_json
, json_object
*json_pref
)
8300 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8301 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8303 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8304 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8305 json_object_string_add(json_pref
, "sendMode",
8306 "advertisedAndReceived");
8307 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8308 json_object_string_add(json_pref
, "sendMode",
8310 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8311 json_object_string_add(json_pref
, "sendMode",
8314 vty_out(vty
, " Send-mode: ");
8315 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8316 vty_out(vty
, "advertised");
8317 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8318 vty_out(vty
, "%sreceived",
8319 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8328 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8329 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8331 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8332 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8333 json_object_string_add(json_pref
, "recvMode",
8334 "advertisedAndReceived");
8335 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8336 json_object_string_add(json_pref
, "recvMode",
8338 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8339 json_object_string_add(json_pref
, "recvMode",
8342 vty_out(vty
, " Receive-mode: ");
8343 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8344 vty_out(vty
, "advertised");
8345 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8346 vty_out(vty
, "%sreceived",
8347 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8356 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8357 safi_t safi
, uint8_t use_json
,
8358 json_object
*json_neigh
)
8360 struct bgp_filter
*filter
;
8361 struct peer_af
*paf
;
8362 char orf_pfx_name
[BUFSIZ
];
8364 json_object
*json_af
= NULL
;
8365 json_object
*json_prefA
= NULL
;
8366 json_object
*json_prefB
= NULL
;
8367 json_object
*json_addr
= NULL
;
8370 json_addr
= json_object_new_object();
8371 json_af
= json_object_new_object();
8372 filter
= &p
->filter
[afi
][safi
];
8374 if (peer_group_active(p
))
8375 json_object_string_add(json_addr
, "peerGroupMember",
8378 paf
= peer_af_find(p
, afi
, safi
);
8379 if (paf
&& PAF_SUBGRP(paf
)) {
8380 json_object_int_add(json_addr
, "updateGroupId",
8381 PAF_UPDGRP(paf
)->id
);
8382 json_object_int_add(json_addr
, "subGroupId",
8383 PAF_SUBGRP(paf
)->id
);
8384 json_object_int_add(json_addr
, "packetQueueLength",
8385 bpacket_queue_virtual_length(paf
));
8388 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8389 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8390 PEER_CAP_ORF_PREFIX_SM_RCV
)
8391 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8392 PEER_CAP_ORF_PREFIX_RM_ADV
)
8393 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8394 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8395 json_object_int_add(json_af
, "orfType",
8397 json_prefA
= json_object_new_object();
8398 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8399 PEER_CAP_ORF_PREFIX_SM_ADV
,
8400 PEER_CAP_ORF_PREFIX_RM_ADV
,
8401 PEER_CAP_ORF_PREFIX_SM_RCV
,
8402 PEER_CAP_ORF_PREFIX_RM_RCV
,
8403 use_json
, json_prefA
);
8404 json_object_object_add(json_af
, "orfPrefixList",
8408 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8409 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8410 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8411 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8412 PEER_CAP_ORF_PREFIX_RM_ADV
)
8413 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8414 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8415 json_object_int_add(json_af
, "orfOldType",
8416 ORF_TYPE_PREFIX_OLD
);
8417 json_prefB
= json_object_new_object();
8418 bgp_show_peer_afi_orf_cap(
8419 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8420 PEER_CAP_ORF_PREFIX_RM_ADV
,
8421 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8422 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8424 json_object_object_add(json_af
, "orfOldPrefixList",
8428 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8429 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8430 PEER_CAP_ORF_PREFIX_SM_RCV
)
8431 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8432 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8433 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8434 PEER_CAP_ORF_PREFIX_RM_ADV
)
8435 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8436 PEER_CAP_ORF_PREFIX_RM_RCV
)
8437 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8438 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8439 json_object_object_add(json_addr
, "afDependentCap",
8442 json_object_free(json_af
);
8444 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8445 orf_pfx_count
= prefix_bgp_show_prefix_list(
8446 NULL
, afi
, orf_pfx_name
, use_json
);
8448 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8449 PEER_STATUS_ORF_PREFIX_SEND
)
8451 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8452 PEER_STATUS_ORF_PREFIX_SEND
))
8453 json_object_boolean_true_add(json_neigh
,
8456 json_object_int_add(json_addr
, "orfRecvCounter",
8459 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8460 PEER_STATUS_ORF_WAIT_REFRESH
))
8461 json_object_string_add(
8462 json_addr
, "orfFirstUpdate",
8463 "deferredUntilORFOrRouteRefreshRecvd");
8465 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8466 PEER_FLAG_REFLECTOR_CLIENT
))
8467 json_object_boolean_true_add(json_addr
,
8468 "routeReflectorClient");
8469 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8470 PEER_FLAG_RSERVER_CLIENT
))
8471 json_object_boolean_true_add(json_addr
,
8472 "routeServerClient");
8473 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8474 json_object_boolean_true_add(json_addr
,
8475 "inboundSoftConfigPermit");
8477 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8478 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8479 json_object_boolean_true_add(
8481 "privateAsNumsAllReplacedInUpdatesToNbr");
8482 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8483 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8484 json_object_boolean_true_add(
8486 "privateAsNumsReplacedInUpdatesToNbr");
8487 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8488 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8489 json_object_boolean_true_add(
8491 "privateAsNumsAllRemovedInUpdatesToNbr");
8492 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8493 PEER_FLAG_REMOVE_PRIVATE_AS
))
8494 json_object_boolean_true_add(
8496 "privateAsNumsRemovedInUpdatesToNbr");
8498 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8499 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8500 json_object_boolean_true_add(json_addr
,
8501 "addpathTxAllPaths");
8503 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8504 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8505 json_object_boolean_true_add(json_addr
,
8506 "addpathTxBestpathPerAS");
8508 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8509 json_object_string_add(json_addr
,
8510 "overrideASNsInOutboundUpdates",
8511 "ifAspathEqualRemoteAs");
8513 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8514 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8515 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8516 json_object_boolean_true_add(json_addr
,
8517 "routerAlwaysNextHop");
8518 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8519 PEER_FLAG_AS_PATH_UNCHANGED
))
8520 json_object_boolean_true_add(
8521 json_addr
, "unchangedAsPathPropogatedToNbr");
8522 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8523 PEER_FLAG_NEXTHOP_UNCHANGED
))
8524 json_object_boolean_true_add(
8525 json_addr
, "unchangedNextHopPropogatedToNbr");
8526 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8527 json_object_boolean_true_add(
8528 json_addr
, "unchangedMedPropogatedToNbr");
8529 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8530 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8531 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8532 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8533 PEER_FLAG_SEND_COMMUNITY
)
8534 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8535 PEER_FLAG_SEND_EXT_COMMUNITY
))
8536 json_object_string_add(json_addr
,
8537 "commAttriSentToNbr",
8538 "extendedAndStandard");
8539 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8540 PEER_FLAG_SEND_EXT_COMMUNITY
))
8541 json_object_string_add(json_addr
,
8542 "commAttriSentToNbr",
8545 json_object_string_add(json_addr
,
8546 "commAttriSentToNbr",
8549 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8550 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8551 if (p
->default_rmap
[afi
][safi
].name
)
8552 json_object_string_add(
8553 json_addr
, "defaultRouteMap",
8554 p
->default_rmap
[afi
][safi
].name
);
8556 if (paf
&& PAF_SUBGRP(paf
)
8557 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8558 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8559 json_object_boolean_true_add(json_addr
,
8562 json_object_boolean_true_add(json_addr
,
8566 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8567 if (is_evpn_enabled())
8568 json_object_boolean_true_add(
8569 json_addr
, "advertiseAllVnis");
8572 if (filter
->plist
[FILTER_IN
].name
8573 || filter
->dlist
[FILTER_IN
].name
8574 || filter
->aslist
[FILTER_IN
].name
8575 || filter
->map
[RMAP_IN
].name
)
8576 json_object_boolean_true_add(json_addr
,
8577 "inboundPathPolicyConfig");
8578 if (filter
->plist
[FILTER_OUT
].name
8579 || filter
->dlist
[FILTER_OUT
].name
8580 || filter
->aslist
[FILTER_OUT
].name
8581 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8582 json_object_boolean_true_add(
8583 json_addr
, "outboundPathPolicyConfig");
8586 if (filter
->plist
[FILTER_IN
].name
)
8587 json_object_string_add(json_addr
,
8588 "incomingUpdatePrefixFilterList",
8589 filter
->plist
[FILTER_IN
].name
);
8590 if (filter
->plist
[FILTER_OUT
].name
)
8591 json_object_string_add(json_addr
,
8592 "outgoingUpdatePrefixFilterList",
8593 filter
->plist
[FILTER_OUT
].name
);
8595 /* distribute-list */
8596 if (filter
->dlist
[FILTER_IN
].name
)
8597 json_object_string_add(
8598 json_addr
, "incomingUpdateNetworkFilterList",
8599 filter
->dlist
[FILTER_IN
].name
);
8600 if (filter
->dlist
[FILTER_OUT
].name
)
8601 json_object_string_add(
8602 json_addr
, "outgoingUpdateNetworkFilterList",
8603 filter
->dlist
[FILTER_OUT
].name
);
8606 if (filter
->aslist
[FILTER_IN
].name
)
8607 json_object_string_add(json_addr
,
8608 "incomingUpdateAsPathFilterList",
8609 filter
->aslist
[FILTER_IN
].name
);
8610 if (filter
->aslist
[FILTER_OUT
].name
)
8611 json_object_string_add(json_addr
,
8612 "outgoingUpdateAsPathFilterList",
8613 filter
->aslist
[FILTER_OUT
].name
);
8616 if (filter
->map
[RMAP_IN
].name
)
8617 json_object_string_add(
8618 json_addr
, "routeMapForIncomingAdvertisements",
8619 filter
->map
[RMAP_IN
].name
);
8620 if (filter
->map
[RMAP_OUT
].name
)
8621 json_object_string_add(
8622 json_addr
, "routeMapForOutgoingAdvertisements",
8623 filter
->map
[RMAP_OUT
].name
);
8625 /* unsuppress-map */
8626 if (filter
->usmap
.name
)
8627 json_object_string_add(json_addr
,
8628 "selectiveUnsuppressRouteMap",
8629 filter
->usmap
.name
);
8631 /* Receive prefix count */
8632 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8633 p
->pcount
[afi
][safi
]);
8635 /* Maximum prefix */
8636 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8637 json_object_int_add(json_addr
, "prefixAllowedMax",
8638 p
->pmax
[afi
][safi
]);
8639 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8640 PEER_FLAG_MAX_PREFIX_WARNING
))
8641 json_object_boolean_true_add(
8642 json_addr
, "prefixAllowedMaxWarning");
8643 json_object_int_add(json_addr
,
8644 "prefixAllowedWarningThresh",
8645 p
->pmax_threshold
[afi
][safi
]);
8646 if (p
->pmax_restart
[afi
][safi
])
8647 json_object_int_add(
8649 "prefixAllowedRestartIntervalMsecs",
8650 p
->pmax_restart
[afi
][safi
] * 60000);
8652 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8656 filter
= &p
->filter
[afi
][safi
];
8658 vty_out(vty
, " For address family: %s\n",
8659 afi_safi_print(afi
, safi
));
8661 if (peer_group_active(p
))
8662 vty_out(vty
, " %s peer-group member\n",
8665 paf
= peer_af_find(p
, afi
, safi
);
8666 if (paf
&& PAF_SUBGRP(paf
)) {
8667 vty_out(vty
, " Update group %" PRIu64
8668 ", subgroup %" PRIu64
"\n",
8669 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8670 vty_out(vty
, " Packet Queue length %d\n",
8671 bpacket_queue_virtual_length(paf
));
8673 vty_out(vty
, " Not part of any update group\n");
8675 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8676 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8677 PEER_CAP_ORF_PREFIX_SM_RCV
)
8678 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8679 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8680 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8681 PEER_CAP_ORF_PREFIX_RM_ADV
)
8682 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8683 PEER_CAP_ORF_PREFIX_RM_RCV
)
8684 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8685 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8686 vty_out(vty
, " AF-dependant capabilities:\n");
8688 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8689 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8690 PEER_CAP_ORF_PREFIX_SM_RCV
)
8691 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8692 PEER_CAP_ORF_PREFIX_RM_ADV
)
8693 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8694 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8696 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8698 bgp_show_peer_afi_orf_cap(
8699 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8700 PEER_CAP_ORF_PREFIX_RM_ADV
,
8701 PEER_CAP_ORF_PREFIX_SM_RCV
,
8702 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8704 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8705 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8706 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8707 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8708 PEER_CAP_ORF_PREFIX_RM_ADV
)
8709 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8710 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8712 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8713 ORF_TYPE_PREFIX_OLD
);
8714 bgp_show_peer_afi_orf_cap(
8715 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8716 PEER_CAP_ORF_PREFIX_RM_ADV
,
8717 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8718 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8721 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8722 orf_pfx_count
= prefix_bgp_show_prefix_list(
8723 NULL
, afi
, orf_pfx_name
, use_json
);
8725 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8726 PEER_STATUS_ORF_PREFIX_SEND
)
8728 vty_out(vty
, " Outbound Route Filter (ORF):");
8729 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8730 PEER_STATUS_ORF_PREFIX_SEND
))
8731 vty_out(vty
, " sent;");
8733 vty_out(vty
, " received (%d entries)",
8737 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8738 PEER_STATUS_ORF_WAIT_REFRESH
))
8740 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8742 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8743 PEER_FLAG_REFLECTOR_CLIENT
))
8744 vty_out(vty
, " Route-Reflector Client\n");
8745 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8746 PEER_FLAG_RSERVER_CLIENT
))
8747 vty_out(vty
, " Route-Server Client\n");
8748 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8750 " Inbound soft reconfiguration allowed\n");
8752 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8753 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8755 " Private AS numbers (all) replaced in updates to this neighbor\n");
8756 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8757 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8759 " Private AS numbers replaced in updates to this neighbor\n");
8760 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8761 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8763 " Private AS numbers (all) removed in updates to this neighbor\n");
8764 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8765 PEER_FLAG_REMOVE_PRIVATE_AS
))
8767 " Private AS numbers removed in updates to this neighbor\n");
8769 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8770 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8771 vty_out(vty
, " Advertise all paths via addpath\n");
8773 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8774 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8776 " Advertise bestpath per AS via addpath\n");
8778 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8780 " Override ASNs in outbound updates if aspath equals remote-as\n");
8782 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8783 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8784 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8785 vty_out(vty
, " NEXT_HOP is always this router\n");
8786 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8787 PEER_FLAG_AS_PATH_UNCHANGED
))
8789 " AS_PATH is propagated unchanged to this neighbor\n");
8790 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8791 PEER_FLAG_NEXTHOP_UNCHANGED
))
8793 " NEXT_HOP is propagated unchanged to this neighbor\n");
8794 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8796 " MED is propagated unchanged to this neighbor\n");
8797 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8798 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8799 PEER_FLAG_SEND_EXT_COMMUNITY
)
8800 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8801 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8803 " Community attribute sent to this neighbor");
8804 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8805 PEER_FLAG_SEND_COMMUNITY
)
8806 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8807 PEER_FLAG_SEND_EXT_COMMUNITY
)
8808 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8809 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8810 vty_out(vty
, "(all)\n");
8811 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8812 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8813 vty_out(vty
, "(large)\n");
8814 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8815 PEER_FLAG_SEND_EXT_COMMUNITY
))
8816 vty_out(vty
, "(extended)\n");
8818 vty_out(vty
, "(standard)\n");
8820 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8821 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8822 vty_out(vty
, " Default information originate,");
8824 if (p
->default_rmap
[afi
][safi
].name
)
8825 vty_out(vty
, " default route-map %s%s,",
8826 p
->default_rmap
[afi
][safi
].map
? "*"
8828 p
->default_rmap
[afi
][safi
].name
);
8829 if (paf
&& PAF_SUBGRP(paf
)
8830 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8831 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8832 vty_out(vty
, " default sent\n");
8834 vty_out(vty
, " default not sent\n");
8837 /* advertise-vni-all */
8838 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8839 if (is_evpn_enabled())
8840 vty_out(vty
, " advertise-all-vni\n");
8843 if (filter
->plist
[FILTER_IN
].name
8844 || filter
->dlist
[FILTER_IN
].name
8845 || filter
->aslist
[FILTER_IN
].name
8846 || filter
->map
[RMAP_IN
].name
)
8847 vty_out(vty
, " Inbound path policy configured\n");
8848 if (filter
->plist
[FILTER_OUT
].name
8849 || filter
->dlist
[FILTER_OUT
].name
8850 || filter
->aslist
[FILTER_OUT
].name
8851 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8852 vty_out(vty
, " Outbound path policy configured\n");
8855 if (filter
->plist
[FILTER_IN
].name
)
8857 " Incoming update prefix filter list is %s%s\n",
8858 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8859 filter
->plist
[FILTER_IN
].name
);
8860 if (filter
->plist
[FILTER_OUT
].name
)
8862 " Outgoing update prefix filter list is %s%s\n",
8863 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8864 filter
->plist
[FILTER_OUT
].name
);
8866 /* distribute-list */
8867 if (filter
->dlist
[FILTER_IN
].name
)
8869 " Incoming update network filter list is %s%s\n",
8870 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8871 filter
->dlist
[FILTER_IN
].name
);
8872 if (filter
->dlist
[FILTER_OUT
].name
)
8874 " Outgoing update network filter list is %s%s\n",
8875 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8876 filter
->dlist
[FILTER_OUT
].name
);
8879 if (filter
->aslist
[FILTER_IN
].name
)
8881 " Incoming update AS path filter list is %s%s\n",
8882 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8883 filter
->aslist
[FILTER_IN
].name
);
8884 if (filter
->aslist
[FILTER_OUT
].name
)
8886 " Outgoing update AS path filter list is %s%s\n",
8887 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8888 filter
->aslist
[FILTER_OUT
].name
);
8891 if (filter
->map
[RMAP_IN
].name
)
8893 " Route map for incoming advertisements is %s%s\n",
8894 filter
->map
[RMAP_IN
].map
? "*" : "",
8895 filter
->map
[RMAP_IN
].name
);
8896 if (filter
->map
[RMAP_OUT
].name
)
8898 " Route map for outgoing advertisements is %s%s\n",
8899 filter
->map
[RMAP_OUT
].map
? "*" : "",
8900 filter
->map
[RMAP_OUT
].name
);
8902 /* unsuppress-map */
8903 if (filter
->usmap
.name
)
8905 " Route map for selective unsuppress is %s%s\n",
8906 filter
->usmap
.map
? "*" : "",
8907 filter
->usmap
.name
);
8909 /* Receive prefix count */
8910 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8912 /* Maximum prefix */
8913 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8914 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8916 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8917 PEER_FLAG_MAX_PREFIX_WARNING
)
8920 vty_out(vty
, " Threshold for warning message %d%%",
8921 p
->pmax_threshold
[afi
][safi
]);
8922 if (p
->pmax_restart
[afi
][safi
])
8923 vty_out(vty
, ", restart interval %d min",
8924 p
->pmax_restart
[afi
][safi
]);
8932 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, uint8_t use_json
,
8936 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8937 char timebuf
[BGP_UPTIME_LEN
];
8939 const char *subcode_str
;
8940 const char *code_str
;
8945 json_object
*json_neigh
= NULL
;
8951 json_neigh
= json_object_new_object();
8953 memset(dn_flag
, '\0', sizeof(dn_flag
));
8954 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
8958 if (p
->conf_if
) /* Configured interface name. */
8959 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
8960 BGP_PEER_SU_UNSPEC(p
)
8962 : sockunion2str(&p
->su
, buf
,
8964 else /* Configured IP address. */
8965 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
8970 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
8971 json_object_string_add(json_neigh
, "bgpNeighborAddr",
8973 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
8974 json_object_string_add(
8975 json_neigh
, "bgpNeighborAddr",
8976 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
8978 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8980 if (p
->change_local_as
)
8981 json_object_int_add(json_neigh
, "localAs",
8982 p
->change_local_as
);
8984 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8986 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8987 json_object_boolean_true_add(json_neigh
,
8988 "localAsNoPrepend");
8990 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8991 json_object_boolean_true_add(json_neigh
,
8992 "localAsReplaceAs");
8994 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
8995 || (p
->as_type
== AS_INTERNAL
))
8996 vty_out(vty
, "remote AS %u, ", p
->as
);
8998 vty_out(vty
, "remote AS Unspecified, ");
8999 vty_out(vty
, "local AS %u%s%s, ",
9000 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9001 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9004 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9008 /* peer type internal, external, confed-internal or confed-external */
9009 if (p
->as
== p
->local_as
) {
9011 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9012 json_object_boolean_true_add(
9013 json_neigh
, "nbrConfedInternalLink");
9015 json_object_boolean_true_add(json_neigh
,
9018 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9019 vty_out(vty
, "confed-internal link\n");
9021 vty_out(vty
, "internal link\n");
9025 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9026 json_object_boolean_true_add(
9027 json_neigh
, "nbrConfedExternalLink");
9029 json_object_boolean_true_add(json_neigh
,
9032 if (bgp_confederation_peers_check(bgp
, p
->as
))
9033 vty_out(vty
, "confed-external link\n");
9035 vty_out(vty
, "external link\n");
9042 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9044 vty_out(vty
, " Description: %s\n", p
->desc
);
9050 json_object_string_add(json_neigh
, "hostname",
9054 json_object_string_add(json_neigh
, "domainname",
9057 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9058 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9061 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9068 json_object_string_add(json_neigh
, "peerGroup",
9072 struct prefix prefix
, *range
= NULL
;
9074 sockunion2hostprefix(&(p
->su
), &prefix
);
9075 range
= peer_group_lookup_dynamic_neighbor_range(
9079 prefix2str(range
, buf1
, sizeof(buf1
));
9080 json_object_string_add(
9082 "peerSubnetRangeGroup", buf1
);
9087 " Member of peer-group %s for session parameters\n",
9091 struct prefix prefix
, *range
= NULL
;
9093 sockunion2hostprefix(&(p
->su
), &prefix
);
9094 range
= peer_group_lookup_dynamic_neighbor_range(
9098 prefix2str(range
, buf1
, sizeof(buf1
));
9100 " Belongs to the subnet range group: %s\n",
9108 /* Administrative shutdown. */
9109 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9110 json_object_boolean_true_add(json_neigh
,
9114 json_object_int_add(json_neigh
, "bgpVersion", 4);
9115 json_object_string_add(
9116 json_neigh
, "remoteRouterId",
9117 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9118 json_object_string_add(
9119 json_neigh
, "localRouterId",
9120 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9124 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9125 && bgp_confederation_peers_check(bgp
, p
->as
))
9126 json_object_boolean_true_add(json_neigh
,
9130 json_object_string_add(
9131 json_neigh
, "bgpState",
9132 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9134 if (p
->status
== Established
) {
9137 uptime
= bgp_clock();
9138 uptime
-= p
->uptime
;
9139 epoch_tbuf
= time(NULL
) - uptime
;
9141 #if defined(VERSION_TYPE_DEV) && CONFDATE > 20200101
9143 "bgpTimerUp should be deprecated and can be removed now");
9146 * bgpTimerUp was miliseconds that was accurate
9147 * up to 1 day, then the value returned
9148 * became garbage. So in order to provide
9149 * some level of backwards compatability,
9150 * we still provde the data, but now
9151 * we are returning the correct value
9152 * and also adding a new bgpTimerUpMsec
9153 * which will allow us to deprecate
9156 json_object_int_add(json_neigh
, "bgpTimerUp",
9158 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9160 json_object_string_add(json_neigh
, "bgpTimerUpString",
9161 peer_uptime(p
->uptime
, timebuf
,
9164 json_object_int_add(json_neigh
,
9165 "bgpTimerUpEstablishedEpoch",
9169 else if (p
->status
== Active
) {
9170 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9171 json_object_string_add(json_neigh
, "bgpStateIs",
9173 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9174 json_object_string_add(json_neigh
, "bgpStateIs",
9182 uptime
= bgp_clock();
9183 uptime
-= p
->readtime
;
9184 tm
= gmtime(&uptime
);
9185 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9186 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9187 + (tm
->tm_hour
* 3600000));
9189 uptime
= bgp_clock();
9190 uptime
-= p
->last_write
;
9191 tm
= gmtime(&uptime
);
9192 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9193 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9194 + (tm
->tm_hour
* 3600000));
9196 uptime
= bgp_clock();
9197 uptime
-= p
->update_time
;
9198 tm
= gmtime(&uptime
);
9199 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9200 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9201 + (tm
->tm_hour
* 3600000));
9203 /* Configured timer values. */
9204 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9205 p
->v_holdtime
* 1000);
9206 json_object_int_add(json_neigh
,
9207 "bgpTimerKeepAliveIntervalMsecs",
9208 p
->v_keepalive
* 1000);
9209 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9210 json_object_int_add(json_neigh
,
9211 "bgpTimerConfiguredHoldTimeMsecs",
9212 p
->holdtime
* 1000);
9213 json_object_int_add(
9215 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9216 p
->keepalive
* 1000);
9217 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9218 || (bgp
->default_keepalive
9219 != BGP_DEFAULT_KEEPALIVE
)) {
9220 json_object_int_add(json_neigh
,
9221 "bgpTimerConfiguredHoldTimeMsecs",
9222 bgp
->default_holdtime
);
9223 json_object_int_add(
9225 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9226 bgp
->default_keepalive
);
9229 /* Administrative shutdown. */
9230 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9231 vty_out(vty
, " Administratively shut down\n");
9234 vty_out(vty
, " BGP version 4");
9235 vty_out(vty
, ", remote router ID %s",
9236 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9237 vty_out(vty
, ", local router ID %s\n",
9238 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9242 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9243 && bgp_confederation_peers_check(bgp
, p
->as
))
9245 " Neighbor under common administration\n");
9248 vty_out(vty
, " BGP state = %s",
9249 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9251 if (p
->status
== Established
)
9252 vty_out(vty
, ", up for %8s",
9253 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9256 else if (p
->status
== Active
) {
9257 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9258 vty_out(vty
, " (passive)");
9259 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9260 vty_out(vty
, " (NSF passive)");
9265 vty_out(vty
, " Last read %s",
9266 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9268 vty_out(vty
, ", Last write %s\n",
9269 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9272 /* Configured timer values. */
9274 " Hold time is %d, keepalive interval is %d seconds\n",
9275 p
->v_holdtime
, p
->v_keepalive
);
9276 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9277 vty_out(vty
, " Configured hold time is %d",
9279 vty_out(vty
, ", keepalive interval is %d seconds\n",
9281 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9282 || (bgp
->default_keepalive
9283 != BGP_DEFAULT_KEEPALIVE
)) {
9284 vty_out(vty
, " Configured hold time is %d",
9285 bgp
->default_holdtime
);
9286 vty_out(vty
, ", keepalive interval is %d seconds\n",
9287 bgp
->default_keepalive
);
9291 if (p
->status
== Established
) {
9292 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9293 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9294 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9295 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9296 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9297 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9298 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9299 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9300 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9301 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9302 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9303 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9304 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9305 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9306 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9307 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9308 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9309 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9310 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9311 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9313 json_object
*json_cap
= NULL
;
9315 json_cap
= json_object_new_object();
9318 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9319 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9320 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9321 && CHECK_FLAG(p
->cap
,
9323 json_object_string_add(
9324 json_cap
, "4byteAs",
9325 "advertisedAndReceived");
9326 else if (CHECK_FLAG(p
->cap
,
9328 json_object_string_add(
9329 json_cap
, "4byteAs",
9331 else if (CHECK_FLAG(p
->cap
,
9333 json_object_string_add(
9334 json_cap
, "4byteAs",
9339 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9340 || CHECK_FLAG(p
->cap
,
9341 PEER_CAP_ADDPATH_ADV
)) {
9342 json_object
*json_add
= NULL
;
9343 const char *print_store
;
9345 json_add
= json_object_new_object();
9347 FOREACH_AFI_SAFI (afi
, safi
) {
9348 json_object
*json_sub
= NULL
;
9350 json_object_new_object();
9351 print_store
= afi_safi_print(
9357 PEER_CAP_ADDPATH_AF_TX_ADV
)
9361 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9366 PEER_CAP_ADDPATH_AF_TX_ADV
)
9371 PEER_CAP_ADDPATH_AF_TX_RCV
))
9372 json_object_boolean_true_add(
9374 "txAdvertisedAndReceived");
9380 PEER_CAP_ADDPATH_AF_TX_ADV
))
9381 json_object_boolean_true_add(
9389 PEER_CAP_ADDPATH_AF_TX_RCV
))
9390 json_object_boolean_true_add(
9398 PEER_CAP_ADDPATH_AF_RX_ADV
)
9402 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9407 PEER_CAP_ADDPATH_AF_RX_ADV
)
9412 PEER_CAP_ADDPATH_AF_RX_RCV
))
9413 json_object_boolean_true_add(
9415 "rxAdvertisedAndReceived");
9421 PEER_CAP_ADDPATH_AF_RX_ADV
))
9422 json_object_boolean_true_add(
9430 PEER_CAP_ADDPATH_AF_RX_RCV
))
9431 json_object_boolean_true_add(
9439 PEER_CAP_ADDPATH_AF_TX_ADV
)
9443 PEER_CAP_ADDPATH_AF_TX_RCV
)
9447 PEER_CAP_ADDPATH_AF_RX_ADV
)
9451 PEER_CAP_ADDPATH_AF_RX_RCV
))
9452 json_object_object_add(
9461 json_object_object_add(
9462 json_cap
, "addPath", json_add
);
9466 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9467 || CHECK_FLAG(p
->cap
,
9468 PEER_CAP_DYNAMIC_ADV
)) {
9469 if (CHECK_FLAG(p
->cap
,
9470 PEER_CAP_DYNAMIC_ADV
)
9471 && CHECK_FLAG(p
->cap
,
9472 PEER_CAP_DYNAMIC_RCV
))
9473 json_object_string_add(
9474 json_cap
, "dynamic",
9475 "advertisedAndReceived");
9476 else if (CHECK_FLAG(
9478 PEER_CAP_DYNAMIC_ADV
))
9479 json_object_string_add(
9480 json_cap
, "dynamic",
9482 else if (CHECK_FLAG(
9484 PEER_CAP_DYNAMIC_RCV
))
9485 json_object_string_add(
9486 json_cap
, "dynamic",
9490 /* Extended nexthop */
9491 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9492 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9493 json_object
*json_nxt
= NULL
;
9494 const char *print_store
;
9497 if (CHECK_FLAG(p
->cap
,
9499 && CHECK_FLAG(p
->cap
,
9501 json_object_string_add(
9504 "advertisedAndReceived");
9505 else if (CHECK_FLAG(p
->cap
,
9507 json_object_string_add(
9511 else if (CHECK_FLAG(p
->cap
,
9513 json_object_string_add(
9518 if (CHECK_FLAG(p
->cap
,
9519 PEER_CAP_ENHE_RCV
)) {
9521 json_object_new_object();
9523 for (safi
= SAFI_UNICAST
;
9524 safi
< SAFI_MAX
; safi
++) {
9529 PEER_CAP_ENHE_AF_RCV
)) {
9530 print_store
= afi_safi_print(
9533 json_object_string_add(
9539 json_object_object_add(
9541 "extendedNexthopFamililesByPeer",
9547 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9548 || CHECK_FLAG(p
->cap
,
9549 PEER_CAP_REFRESH_NEW_RCV
)
9550 || CHECK_FLAG(p
->cap
,
9551 PEER_CAP_REFRESH_OLD_RCV
)) {
9552 if (CHECK_FLAG(p
->cap
,
9553 PEER_CAP_REFRESH_ADV
)
9556 PEER_CAP_REFRESH_NEW_RCV
)
9559 PEER_CAP_REFRESH_OLD_RCV
))) {
9562 PEER_CAP_REFRESH_OLD_RCV
)
9565 PEER_CAP_REFRESH_NEW_RCV
))
9566 json_object_string_add(
9569 "advertisedAndReceivedOldNew");
9573 PEER_CAP_REFRESH_OLD_RCV
))
9574 json_object_string_add(
9577 "advertisedAndReceivedOld");
9579 json_object_string_add(
9582 "advertisedAndReceivedNew");
9587 PEER_CAP_REFRESH_ADV
))
9588 json_object_string_add(
9595 PEER_CAP_REFRESH_NEW_RCV
)
9598 PEER_CAP_REFRESH_OLD_RCV
))
9599 json_object_string_add(
9605 /* Multiprotocol Extensions */
9606 json_object
*json_multi
= NULL
;
9607 json_multi
= json_object_new_object();
9609 FOREACH_AFI_SAFI (afi
, safi
) {
9610 if (p
->afc_adv
[afi
][safi
]
9611 || p
->afc_recv
[afi
][safi
]) {
9612 json_object
*json_exten
= NULL
;
9614 json_object_new_object();
9616 if (p
->afc_adv
[afi
][safi
]
9617 && p
->afc_recv
[afi
][safi
])
9618 json_object_boolean_true_add(
9620 "advertisedAndReceived");
9621 else if (p
->afc_adv
[afi
][safi
])
9622 json_object_boolean_true_add(
9625 else if (p
->afc_recv
[afi
][safi
])
9626 json_object_boolean_true_add(
9630 json_object_object_add(
9637 json_object_object_add(
9638 json_cap
, "multiprotocolExtensions",
9641 /* Hostname capabilities */
9642 json_object
*json_hname
= NULL
;
9644 json_hname
= json_object_new_object();
9646 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9647 json_object_string_add(
9648 json_hname
, "advHostName",
9649 bgp
->peer_self
->hostname
9653 json_object_string_add(
9654 json_hname
, "advDomainName",
9655 bgp
->peer_self
->domainname
9662 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9663 json_object_string_add(
9664 json_hname
, "rcvHostName",
9665 p
->hostname
? p
->hostname
9667 json_object_string_add(
9668 json_hname
, "rcvDomainName",
9669 p
->domainname
? p
->domainname
9673 json_object_object_add(json_cap
, "hostName",
9676 /* Gracefull Restart */
9677 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9678 || CHECK_FLAG(p
->cap
,
9679 PEER_CAP_RESTART_ADV
)) {
9680 if (CHECK_FLAG(p
->cap
,
9681 PEER_CAP_RESTART_ADV
)
9682 && CHECK_FLAG(p
->cap
,
9683 PEER_CAP_RESTART_RCV
))
9684 json_object_string_add(
9687 "advertisedAndReceived");
9688 else if (CHECK_FLAG(
9690 PEER_CAP_RESTART_ADV
))
9691 json_object_string_add(
9693 "gracefulRestartCapability",
9695 else if (CHECK_FLAG(
9697 PEER_CAP_RESTART_RCV
))
9698 json_object_string_add(
9700 "gracefulRestartCapability",
9703 if (CHECK_FLAG(p
->cap
,
9704 PEER_CAP_RESTART_RCV
)) {
9705 int restart_af_count
= 0;
9706 json_object
*json_restart
=
9709 json_object_new_object();
9711 json_object_int_add(
9713 "gracefulRestartRemoteTimerMsecs",
9714 p
->v_gr_restart
* 1000);
9716 FOREACH_AFI_SAFI (afi
, safi
) {
9721 PEER_CAP_RESTART_AF_RCV
)) {
9726 json_object_new_object();
9732 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9733 json_object_boolean_true_add(
9737 json_object_object_add(
9745 if (!restart_af_count
) {
9746 json_object_string_add(
9748 "addressFamiliesByPeer",
9753 json_object_object_add(
9755 "addressFamiliesByPeer",
9759 json_object_object_add(json_neigh
,
9760 "neighborCapabilities",
9763 vty_out(vty
, " Neighbor capabilities:\n");
9766 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9767 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9768 vty_out(vty
, " 4 Byte AS:");
9769 if (CHECK_FLAG(p
->cap
,
9771 vty_out(vty
, " advertised");
9772 if (CHECK_FLAG(p
->cap
,
9774 vty_out(vty
, " %sreceived",
9784 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9785 || CHECK_FLAG(p
->cap
,
9786 PEER_CAP_ADDPATH_ADV
)) {
9787 vty_out(vty
, " AddPath:\n");
9789 FOREACH_AFI_SAFI (afi
, safi
) {
9793 PEER_CAP_ADDPATH_AF_TX_ADV
)
9797 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9808 PEER_CAP_ADDPATH_AF_TX_ADV
))
9819 PEER_CAP_ADDPATH_AF_TX_RCV
))
9826 PEER_CAP_ADDPATH_AF_TX_ADV
)
9836 PEER_CAP_ADDPATH_AF_RX_ADV
)
9840 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9851 PEER_CAP_ADDPATH_AF_RX_ADV
))
9862 PEER_CAP_ADDPATH_AF_RX_RCV
))
9869 PEER_CAP_ADDPATH_AF_RX_ADV
)
9879 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9880 || CHECK_FLAG(p
->cap
,
9881 PEER_CAP_DYNAMIC_ADV
)) {
9882 vty_out(vty
, " Dynamic:");
9883 if (CHECK_FLAG(p
->cap
,
9884 PEER_CAP_DYNAMIC_ADV
))
9885 vty_out(vty
, " advertised");
9886 if (CHECK_FLAG(p
->cap
,
9887 PEER_CAP_DYNAMIC_RCV
))
9888 vty_out(vty
, " %sreceived",
9891 PEER_CAP_DYNAMIC_ADV
)
9897 /* Extended nexthop */
9898 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9899 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9900 vty_out(vty
, " Extended nexthop:");
9901 if (CHECK_FLAG(p
->cap
,
9903 vty_out(vty
, " advertised");
9904 if (CHECK_FLAG(p
->cap
,
9906 vty_out(vty
, " %sreceived",
9914 if (CHECK_FLAG(p
->cap
,
9915 PEER_CAP_ENHE_RCV
)) {
9917 " Address families by peer:\n ");
9918 for (safi
= SAFI_UNICAST
;
9919 safi
< SAFI_MAX
; safi
++)
9924 PEER_CAP_ENHE_AF_RCV
))
9934 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9935 || CHECK_FLAG(p
->cap
,
9936 PEER_CAP_REFRESH_NEW_RCV
)
9937 || CHECK_FLAG(p
->cap
,
9938 PEER_CAP_REFRESH_OLD_RCV
)) {
9939 vty_out(vty
, " Route refresh:");
9940 if (CHECK_FLAG(p
->cap
,
9941 PEER_CAP_REFRESH_ADV
))
9942 vty_out(vty
, " advertised");
9943 if (CHECK_FLAG(p
->cap
,
9944 PEER_CAP_REFRESH_NEW_RCV
)
9947 PEER_CAP_REFRESH_OLD_RCV
))
9948 vty_out(vty
, " %sreceived(%s)",
9951 PEER_CAP_REFRESH_ADV
)
9956 PEER_CAP_REFRESH_OLD_RCV
)
9959 PEER_CAP_REFRESH_NEW_RCV
))
9963 PEER_CAP_REFRESH_OLD_RCV
)
9970 /* Multiprotocol Extensions */
9971 FOREACH_AFI_SAFI (afi
, safi
)
9972 if (p
->afc_adv
[afi
][safi
]
9973 || p
->afc_recv
[afi
][safi
]) {
9975 " Address Family %s:",
9978 if (p
->afc_adv
[afi
][safi
])
9981 if (p
->afc_recv
[afi
][safi
])
9991 /* Hostname capability */
9992 vty_out(vty
, " Hostname Capability:");
9994 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9996 " advertised (name: %s,domain name: %s)",
9997 bgp
->peer_self
->hostname
10001 bgp
->peer_self
->domainname
10006 vty_out(vty
, " not advertised");
10009 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10011 " received (name: %s,domain name: %s)",
10012 p
->hostname
? p
->hostname
10014 p
->domainname
? p
->domainname
10017 vty_out(vty
, " not received");
10020 vty_out(vty
, "\n");
10022 /* Gracefull Restart */
10023 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10024 || CHECK_FLAG(p
->cap
,
10025 PEER_CAP_RESTART_ADV
)) {
10027 " Graceful Restart Capabilty:");
10028 if (CHECK_FLAG(p
->cap
,
10029 PEER_CAP_RESTART_ADV
))
10030 vty_out(vty
, " advertised");
10031 if (CHECK_FLAG(p
->cap
,
10032 PEER_CAP_RESTART_RCV
))
10033 vty_out(vty
, " %sreceived",
10036 PEER_CAP_RESTART_ADV
)
10039 vty_out(vty
, "\n");
10041 if (CHECK_FLAG(p
->cap
,
10042 PEER_CAP_RESTART_RCV
)) {
10043 int restart_af_count
= 0;
10046 " Remote Restart timer is %d seconds\n",
10049 " Address families by peer:\n ");
10051 FOREACH_AFI_SAFI (afi
, safi
)
10056 PEER_CAP_RESTART_AF_RCV
)) {
10069 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10071 : "not preserved");
10072 restart_af_count
++;
10074 if (!restart_af_count
)
10075 vty_out(vty
, "none");
10076 vty_out(vty
, "\n");
10083 /* graceful restart information */
10084 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10085 || p
->t_gr_stale
) {
10086 json_object
*json_grace
= NULL
;
10087 json_object
*json_grace_send
= NULL
;
10088 json_object
*json_grace_recv
= NULL
;
10089 int eor_send_af_count
= 0;
10090 int eor_receive_af_count
= 0;
10093 json_grace
= json_object_new_object();
10094 json_grace_send
= json_object_new_object();
10095 json_grace_recv
= json_object_new_object();
10097 if (p
->status
== Established
) {
10098 FOREACH_AFI_SAFI (afi
, safi
) {
10099 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10100 PEER_STATUS_EOR_SEND
)) {
10101 json_object_boolean_true_add(
10103 afi_safi_print(afi
,
10105 eor_send_af_count
++;
10108 FOREACH_AFI_SAFI (afi
, safi
) {
10110 p
->af_sflags
[afi
][safi
],
10111 PEER_STATUS_EOR_RECEIVED
)) {
10112 json_object_boolean_true_add(
10114 afi_safi_print(afi
,
10116 eor_receive_af_count
++;
10121 json_object_object_add(json_grace
, "endOfRibSend",
10123 json_object_object_add(json_grace
, "endOfRibRecv",
10126 if (p
->t_gr_restart
)
10127 json_object_int_add(json_grace
,
10128 "gracefulRestartTimerMsecs",
10129 thread_timer_remain_second(
10134 json_object_int_add(
10136 "gracefulStalepathTimerMsecs",
10137 thread_timer_remain_second(
10141 json_object_object_add(
10142 json_neigh
, "gracefulRestartInfo", json_grace
);
10144 vty_out(vty
, " Graceful restart informations:\n");
10145 if (p
->status
== Established
) {
10146 vty_out(vty
, " End-of-RIB send: ");
10147 FOREACH_AFI_SAFI (afi
, safi
) {
10148 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10149 PEER_STATUS_EOR_SEND
)) {
10150 vty_out(vty
, "%s%s",
10151 eor_send_af_count
? ", "
10153 afi_safi_print(afi
,
10155 eor_send_af_count
++;
10158 vty_out(vty
, "\n");
10159 vty_out(vty
, " End-of-RIB received: ");
10160 FOREACH_AFI_SAFI (afi
, safi
) {
10162 p
->af_sflags
[afi
][safi
],
10163 PEER_STATUS_EOR_RECEIVED
)) {
10164 vty_out(vty
, "%s%s",
10165 eor_receive_af_count
10168 afi_safi_print(afi
,
10170 eor_receive_af_count
++;
10173 vty_out(vty
, "\n");
10176 if (p
->t_gr_restart
)
10178 " The remaining time of restart timer is %ld\n",
10179 thread_timer_remain_second(
10184 " The remaining time of stalepath timer is %ld\n",
10185 thread_timer_remain_second(
10190 json_object
*json_stat
= NULL
;
10191 json_stat
= json_object_new_object();
10192 /* Packet counts. */
10193 json_object_int_add(json_stat
, "depthInq", 0);
10194 json_object_int_add(json_stat
, "depthOutq",
10195 (unsigned long)p
->obuf
->count
);
10196 json_object_int_add(json_stat
, "opensSent",
10197 atomic_load_explicit(&p
->open_out
,
10198 memory_order_relaxed
));
10199 json_object_int_add(json_stat
, "opensRecv",
10200 atomic_load_explicit(&p
->open_in
,
10201 memory_order_relaxed
));
10202 json_object_int_add(json_stat
, "notificationsSent",
10203 atomic_load_explicit(&p
->notify_out
,
10204 memory_order_relaxed
));
10205 json_object_int_add(json_stat
, "notificationsRecv",
10206 atomic_load_explicit(&p
->notify_in
,
10207 memory_order_relaxed
));
10208 json_object_int_add(json_stat
, "updatesSent",
10209 atomic_load_explicit(&p
->update_out
,
10210 memory_order_relaxed
));
10211 json_object_int_add(json_stat
, "updatesRecv",
10212 atomic_load_explicit(&p
->update_in
,
10213 memory_order_relaxed
));
10214 json_object_int_add(json_stat
, "keepalivesSent",
10215 atomic_load_explicit(&p
->keepalive_out
,
10216 memory_order_relaxed
));
10217 json_object_int_add(json_stat
, "keepalivesRecv",
10218 atomic_load_explicit(&p
->keepalive_in
,
10219 memory_order_relaxed
));
10220 json_object_int_add(json_stat
, "routeRefreshSent",
10221 atomic_load_explicit(&p
->refresh_out
,
10222 memory_order_relaxed
));
10223 json_object_int_add(json_stat
, "routeRefreshRecv",
10224 atomic_load_explicit(&p
->refresh_in
,
10225 memory_order_relaxed
));
10226 json_object_int_add(json_stat
, "capabilitySent",
10227 atomic_load_explicit(&p
->dynamic_cap_out
,
10228 memory_order_relaxed
));
10229 json_object_int_add(json_stat
, "capabilityRecv",
10230 atomic_load_explicit(&p
->dynamic_cap_in
,
10231 memory_order_relaxed
));
10232 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10233 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10234 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10236 /* Packet counts. */
10237 vty_out(vty
, " Message statistics:\n");
10238 vty_out(vty
, " Inq depth is 0\n");
10239 vty_out(vty
, " Outq depth is %lu\n",
10240 (unsigned long)p
->obuf
->count
);
10241 vty_out(vty
, " Sent Rcvd\n");
10242 vty_out(vty
, " Opens: %10d %10d\n",
10243 atomic_load_explicit(&p
->open_out
,
10244 memory_order_relaxed
),
10245 atomic_load_explicit(&p
->open_in
,
10246 memory_order_relaxed
));
10247 vty_out(vty
, " Notifications: %10d %10d\n",
10248 atomic_load_explicit(&p
->notify_out
,
10249 memory_order_relaxed
),
10250 atomic_load_explicit(&p
->notify_in
,
10251 memory_order_relaxed
));
10252 vty_out(vty
, " Updates: %10d %10d\n",
10253 atomic_load_explicit(&p
->update_out
,
10254 memory_order_relaxed
),
10255 atomic_load_explicit(&p
->update_in
,
10256 memory_order_relaxed
));
10257 vty_out(vty
, " Keepalives: %10d %10d\n",
10258 atomic_load_explicit(&p
->keepalive_out
,
10259 memory_order_relaxed
),
10260 atomic_load_explicit(&p
->keepalive_in
,
10261 memory_order_relaxed
));
10262 vty_out(vty
, " Route Refresh: %10d %10d\n",
10263 atomic_load_explicit(&p
->refresh_out
,
10264 memory_order_relaxed
),
10265 atomic_load_explicit(&p
->refresh_in
,
10266 memory_order_relaxed
));
10267 vty_out(vty
, " Capability: %10d %10d\n",
10268 atomic_load_explicit(&p
->dynamic_cap_out
,
10269 memory_order_relaxed
),
10270 atomic_load_explicit(&p
->dynamic_cap_in
,
10271 memory_order_relaxed
));
10272 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10277 /* advertisement-interval */
10278 json_object_int_add(json_neigh
,
10279 "minBtwnAdvertisementRunsTimerMsecs",
10280 p
->v_routeadv
* 1000);
10282 /* Update-source. */
10283 if (p
->update_if
|| p
->update_source
) {
10285 json_object_string_add(json_neigh
,
10288 else if (p
->update_source
)
10289 json_object_string_add(
10290 json_neigh
, "updateSource",
10291 sockunion2str(p
->update_source
, buf1
,
10295 /* advertisement-interval */
10297 " Minimum time between advertisement runs is %d seconds\n",
10300 /* Update-source. */
10301 if (p
->update_if
|| p
->update_source
) {
10302 vty_out(vty
, " Update source is ");
10304 vty_out(vty
, "%s", p
->update_if
);
10305 else if (p
->update_source
)
10307 sockunion2str(p
->update_source
, buf1
,
10309 vty_out(vty
, "\n");
10312 vty_out(vty
, "\n");
10315 /* Address Family Information */
10316 json_object
*json_hold
= NULL
;
10319 json_hold
= json_object_new_object();
10321 FOREACH_AFI_SAFI (afi
, safi
)
10322 if (p
->afc
[afi
][safi
])
10323 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10327 json_object_object_add(json_neigh
, "addressFamilyInfo",
10329 json_object_int_add(json_neigh
, "connectionsEstablished",
10331 json_object_int_add(json_neigh
, "connectionsDropped",
10334 vty_out(vty
, " Connections established %d; dropped %d\n",
10335 p
->established
, p
->dropped
);
10337 if (!p
->last_reset
) {
10339 json_object_string_add(json_neigh
, "lastReset",
10342 vty_out(vty
, " Last reset never\n");
10348 uptime
= bgp_clock();
10349 uptime
-= p
->resettime
;
10350 tm
= gmtime(&uptime
);
10351 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10352 (tm
->tm_sec
* 1000)
10353 + (tm
->tm_min
* 60000)
10354 + (tm
->tm_hour
* 3600000));
10355 json_object_string_add(
10356 json_neigh
, "lastResetDueTo",
10357 peer_down_str
[(int)p
->last_reset
]);
10358 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10359 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10360 char errorcodesubcode_hexstr
[5];
10361 char errorcodesubcode_str
[256];
10363 code_str
= bgp_notify_code_str(p
->notify
.code
);
10364 subcode_str
= bgp_notify_subcode_str(
10365 p
->notify
.code
, p
->notify
.subcode
);
10367 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10368 p
->notify
.code
, p
->notify
.subcode
);
10369 json_object_string_add(json_neigh
,
10370 "lastErrorCodeSubcode",
10371 errorcodesubcode_hexstr
);
10372 snprintf(errorcodesubcode_str
, 255, "%s%s",
10373 code_str
, subcode_str
);
10374 json_object_string_add(json_neigh
,
10375 "lastNotificationReason",
10376 errorcodesubcode_str
);
10377 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10378 && p
->notify
.code
== BGP_NOTIFY_CEASE
10379 && (p
->notify
.subcode
10380 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10381 || p
->notify
.subcode
10382 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10383 && p
->notify
.length
) {
10385 const char *msg_str
;
10387 msg_str
= bgp_notify_admin_message(
10388 msgbuf
, sizeof(msgbuf
),
10389 (uint8_t *)p
->notify
.data
,
10392 json_object_string_add(
10394 "lastShutdownDescription",
10399 vty_out(vty
, " Last reset %s, ",
10400 peer_uptime(p
->resettime
, timebuf
,
10401 BGP_UPTIME_LEN
, 0, NULL
));
10403 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10404 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10405 code_str
= bgp_notify_code_str(p
->notify
.code
);
10406 subcode_str
= bgp_notify_subcode_str(
10407 p
->notify
.code
, p
->notify
.subcode
);
10408 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10409 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10412 code_str
, subcode_str
);
10413 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10414 && p
->notify
.code
== BGP_NOTIFY_CEASE
10415 && (p
->notify
.subcode
10416 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10417 || p
->notify
.subcode
10418 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10419 && p
->notify
.length
) {
10421 const char *msg_str
;
10423 msg_str
= bgp_notify_admin_message(
10424 msgbuf
, sizeof(msgbuf
),
10425 (uint8_t *)p
->notify
.data
,
10429 " Message: \"%s\"\n",
10433 vty_out(vty
, "due to %s\n",
10434 peer_down_str
[(int)p
->last_reset
]);
10437 if (p
->last_reset_cause_size
) {
10438 msg
= p
->last_reset_cause
;
10440 " Message received that caused BGP to send a NOTIFICATION:\n ");
10441 for (i
= 1; i
<= p
->last_reset_cause_size
;
10443 vty_out(vty
, "%02X", *msg
++);
10445 if (i
!= p
->last_reset_cause_size
) {
10447 vty_out(vty
, "\n ");
10448 } else if (i
% 4 == 0) {
10453 vty_out(vty
, "\n");
10458 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10460 json_object_boolean_true_add(json_neigh
,
10461 "prefixesConfigExceedMax");
10464 " Peer had exceeded the max. no. of prefixes configured.\n");
10466 if (p
->t_pmax_restart
) {
10468 json_object_boolean_true_add(
10469 json_neigh
, "reducePrefixNumFrom");
10470 json_object_int_add(json_neigh
,
10471 "restartInTimerMsec",
10472 thread_timer_remain_second(
10477 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10478 p
->host
, thread_timer_remain_second(
10479 p
->t_pmax_restart
));
10482 json_object_boolean_true_add(
10484 "reducePrefixNumAndClearIpBgp");
10487 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10492 /* EBGP Multihop and GTSM */
10493 if (p
->sort
!= BGP_PEER_IBGP
) {
10495 if (p
->gtsm_hops
> 0)
10496 json_object_int_add(json_neigh
,
10497 "externalBgpNbrMaxHopsAway",
10499 else if (p
->ttl
> 1)
10500 json_object_int_add(json_neigh
,
10501 "externalBgpNbrMaxHopsAway",
10504 if (p
->gtsm_hops
> 0)
10506 " External BGP neighbor may be up to %d hops away.\n",
10508 else if (p
->ttl
> 1)
10510 " External BGP neighbor may be up to %d hops away.\n",
10514 if (p
->gtsm_hops
> 0) {
10516 json_object_int_add(json_neigh
,
10517 "internalBgpNbrMaxHopsAway",
10521 " Internal BGP neighbor may be up to %d hops away.\n",
10526 /* Local address. */
10529 json_object_string_add(json_neigh
, "hostLocal",
10530 sockunion2str(p
->su_local
, buf1
,
10532 json_object_int_add(json_neigh
, "portLocal",
10533 ntohs(p
->su_local
->sin
.sin_port
));
10535 vty_out(vty
, "Local host: %s, Local port: %d\n",
10536 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10537 ntohs(p
->su_local
->sin
.sin_port
));
10540 /* Remote address. */
10541 if (p
->su_remote
) {
10543 json_object_string_add(json_neigh
, "hostForeign",
10544 sockunion2str(p
->su_remote
, buf1
,
10546 json_object_int_add(json_neigh
, "portForeign",
10547 ntohs(p
->su_remote
->sin
.sin_port
));
10549 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10550 sockunion2str(p
->su_remote
, buf1
,
10552 ntohs(p
->su_remote
->sin
.sin_port
));
10555 /* Nexthop display. */
10558 json_object_string_add(json_neigh
, "nexthop",
10560 &p
->nexthop
.v4
, buf1
,
10562 json_object_string_add(json_neigh
, "nexthopGlobal",
10563 inet_ntop(AF_INET6
,
10564 &p
->nexthop
.v6_global
,
10565 buf1
, sizeof(buf1
)));
10566 json_object_string_add(json_neigh
, "nexthopLocal",
10567 inet_ntop(AF_INET6
,
10568 &p
->nexthop
.v6_local
,
10569 buf1
, sizeof(buf1
)));
10570 if (p
->shared_network
)
10571 json_object_string_add(json_neigh
,
10575 json_object_string_add(json_neigh
,
10577 "nonSharedNetwork");
10579 vty_out(vty
, "Nexthop: %s\n",
10580 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10582 vty_out(vty
, "Nexthop global: %s\n",
10583 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10585 vty_out(vty
, "Nexthop local: %s\n",
10586 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10588 vty_out(vty
, "BGP connection: %s\n",
10589 p
->shared_network
? "shared network"
10590 : "non shared network");
10594 /* Timer information. */
10596 json_object_int_add(json_neigh
, "connectRetryTimer",
10598 if (p
->status
== Established
&& p
->rtt
)
10599 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10602 json_object_int_add(
10603 json_neigh
, "nextStartTimerDueInMsecs",
10604 thread_timer_remain_second(p
->t_start
) * 1000);
10606 json_object_int_add(
10607 json_neigh
, "nextConnectTimerDueInMsecs",
10608 thread_timer_remain_second(p
->t_connect
)
10610 if (p
->t_routeadv
) {
10611 json_object_int_add(json_neigh
, "mraiInterval",
10613 json_object_int_add(
10614 json_neigh
, "mraiTimerExpireInMsecs",
10615 thread_timer_remain_second(p
->t_routeadv
)
10619 json_object_int_add(json_neigh
, "authenticationEnabled",
10623 json_object_string_add(json_neigh
, "readThread", "on");
10625 json_object_string_add(json_neigh
, "readThread", "off");
10627 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10628 json_object_string_add(json_neigh
, "writeThread", "on");
10630 json_object_string_add(json_neigh
, "writeThread",
10633 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10635 if (p
->status
== Established
&& p
->rtt
)
10636 vty_out(vty
, "Estimated round trip time: %d ms\n",
10639 vty_out(vty
, "Next start timer due in %ld seconds\n",
10640 thread_timer_remain_second(p
->t_start
));
10642 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10643 thread_timer_remain_second(p
->t_connect
));
10646 "MRAI (interval %u) timer expires in %ld seconds\n",
10648 thread_timer_remain_second(p
->t_routeadv
));
10650 vty_out(vty
, "Peer Authentication Enabled\n");
10652 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10653 p
->t_read
? "on" : "off",
10654 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10659 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10660 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10661 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10664 vty_out(vty
, "\n");
10666 /* BFD information. */
10667 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10670 if (p
->conf_if
) /* Configured interface name. */
10671 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10672 else /* Configured IP address. */
10673 json_object_object_add(json
, p
->host
, json_neigh
);
10677 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10678 enum show_type type
, union sockunion
*su
,
10679 const char *conf_if
, uint8_t use_json
,
10682 struct listnode
*node
, *nnode
;
10686 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10687 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10692 bgp_show_peer(vty
, peer
, use_json
, json
);
10697 && !strcmp(peer
->conf_if
, conf_if
))
10699 && !strcmp(peer
->hostname
, conf_if
))) {
10701 bgp_show_peer(vty
, peer
, use_json
,
10705 if (sockunion_same(&peer
->su
, su
)) {
10707 bgp_show_peer(vty
, peer
, use_json
,
10715 if (type
== show_peer
&& !find
) {
10717 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10719 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10723 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10724 json
, JSON_C_TO_STRING_PRETTY
));
10725 json_object_free(json
);
10727 vty_out(vty
, "\n");
10730 return CMD_SUCCESS
;
10733 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10734 enum show_type type
,
10735 const char *ip_str
,
10738 struct listnode
*node
, *nnode
;
10740 union sockunion su
;
10741 json_object
*json
= NULL
;
10742 int ret
, is_first
= 1;
10745 vty_out(vty
, "{\n");
10747 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10749 if (!(json
= json_object_new_object())) {
10751 "Unable to allocate memory for JSON object");
10753 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10757 json_object_int_add(json
, "vrfId",
10758 (bgp
->vrf_id
== VRF_UNKNOWN
)
10760 : (int64_t)bgp
->vrf_id
);
10761 json_object_string_add(
10763 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10768 vty_out(vty
, ",\n");
10772 vty_out(vty
, "\"%s\":",
10773 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10777 vty_out(vty
, "\nInstance %s:\n",
10778 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10783 if (type
== show_peer
) {
10784 ret
= str2sockunion(ip_str
, &su
);
10786 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10789 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10792 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10798 vty_out(vty
, "}\n");
10801 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10802 enum show_type type
, const char *ip_str
,
10807 union sockunion su
;
10808 json_object
*json
= NULL
;
10811 if (strmatch(name
, "all")) {
10812 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10814 return CMD_SUCCESS
;
10816 bgp
= bgp_lookup_by_name(name
);
10819 json
= json_object_new_object();
10820 json_object_boolean_true_add(
10821 json
, "bgpNoSuchInstance");
10822 vty_out(vty
, "%s\n",
10823 json_object_to_json_string_ext(
10825 JSON_C_TO_STRING_PRETTY
));
10826 json_object_free(json
);
10829 "%% No such BGP instance exist\n");
10831 return CMD_WARNING
;
10835 bgp
= bgp_get_default();
10839 json
= json_object_new_object();
10841 ret
= str2sockunion(ip_str
, &su
);
10843 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10846 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10849 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10852 json_object_free(json
);
10855 return CMD_SUCCESS
;
10858 /* "show [ip] bgp neighbors" commands. */
10859 DEFUN (show_ip_bgp_neighbors
,
10860 show_ip_bgp_neighbors_cmd
,
10861 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10865 BGP_INSTANCE_HELP_STR
10868 "Detailed information on TCP and BGP neighbor connections\n"
10869 "Neighbor to display information about\n"
10870 "Neighbor to display information about\n"
10871 "Neighbor on BGP configured interface\n"
10875 char *sh_arg
= NULL
;
10876 enum show_type sh_type
;
10878 uint8_t uj
= use_json(argc
, argv
);
10882 if (argv_find(argv
, argc
, "view", &idx
)
10883 || argv_find(argv
, argc
, "vrf", &idx
))
10884 vrf
= argv
[idx
+ 1]->arg
;
10887 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10888 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10889 || argv_find(argv
, argc
, "WORD", &idx
)) {
10890 sh_type
= show_peer
;
10891 sh_arg
= argv
[idx
]->arg
;
10893 sh_type
= show_all
;
10895 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10898 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10899 paths' and `show ip mbgp paths'. Those functions results are the
10901 DEFUN (show_ip_bgp_paths
,
10902 show_ip_bgp_paths_cmd
,
10903 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10908 "Path information\n")
10910 vty_out(vty
, "Address Refcnt Path\n");
10911 aspath_print_all_vty(vty
);
10912 return CMD_SUCCESS
;
10917 static void community_show_all_iterator(struct hash_backet
*backet
,
10920 struct community
*com
;
10922 com
= (struct community
*)backet
->data
;
10923 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10924 community_str(com
, false));
10927 /* Show BGP's community internal data. */
10928 DEFUN (show_ip_bgp_community_info
,
10929 show_ip_bgp_community_info_cmd
,
10930 "show [ip] bgp community-info",
10934 "List all bgp community information\n")
10936 vty_out(vty
, "Address Refcnt Community\n");
10938 hash_iterate(community_hash(),
10939 (void (*)(struct hash_backet
*,
10940 void *))community_show_all_iterator
,
10943 return CMD_SUCCESS
;
10946 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
10949 struct lcommunity
*lcom
;
10951 lcom
= (struct lcommunity
*)backet
->data
;
10952 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
10953 lcommunity_str(lcom
, false));
10956 /* Show BGP's community internal data. */
10957 DEFUN (show_ip_bgp_lcommunity_info
,
10958 show_ip_bgp_lcommunity_info_cmd
,
10959 "show ip bgp large-community-info",
10963 "List all bgp large-community information\n")
10965 vty_out(vty
, "Address Refcnt Large-community\n");
10967 hash_iterate(lcommunity_hash(),
10968 (void (*)(struct hash_backet
*,
10969 void *))lcommunity_show_all_iterator
,
10972 return CMD_SUCCESS
;
10976 DEFUN (show_ip_bgp_attr_info
,
10977 show_ip_bgp_attr_info_cmd
,
10978 "show [ip] bgp attribute-info",
10982 "List all bgp attribute information\n")
10984 attr_show_all(vty
);
10985 return CMD_SUCCESS
;
10988 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
10989 afi_t afi
, safi_t safi
)
10992 struct listnode
*node
;
10994 char buf1
[INET6_ADDRSTRLEN
];
10996 vpn_policy_direction_t dir
;
10999 bgp
= bgp_lookup_by_name(name
);
11001 vty_out(vty
, "%% No such BGP instance exist\n");
11002 return CMD_WARNING
;
11005 bgp
= bgp_get_default();
11008 "%% Default BGP instance does not exist\n");
11009 return CMD_WARNING
;
11013 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11014 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11016 "This VRF is not importing %s routes from any other VRF\n",
11017 afi_safi_print(afi
, safi
));
11020 "This VRF is importing %s routes from the following VRFs:\n",
11021 afi_safi_print(afi
, safi
));
11022 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
11024 vty_out(vty
, " %s\n", vname
);
11026 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11027 ecom_str
= ecommunity_ecom2str(
11028 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11029 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11030 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11031 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11034 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11035 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11037 "This VRF is not exporting %s routes to any other VRF\n",
11038 afi_safi_print(afi
, safi
));
11041 "This VRF is exporting %s routes to the following VRFs:\n",
11042 afi_safi_print(afi
, safi
));
11043 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].export_vrf
, node
,
11045 vty_out(vty
, " %s\n", vname
);
11047 vty_out(vty
, "RD: %s\n",
11048 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11049 buf1
, RD_ADDRSTRLEN
));
11050 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11051 ecom_str
= ecommunity_ecom2str(
11052 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11053 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11054 vty_out(vty
, "Emport RT: %s\n", ecom_str
);
11055 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11058 return CMD_SUCCESS
;
11061 /* "show [ip] bgp route-leak" command. */
11062 DEFUN (show_ip_bgp_route_leak
,
11063 show_ip_bgp_route_leak_cmd
,
11064 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak",
11068 BGP_INSTANCE_HELP_STR
11071 "Route leaking information\n")
11074 afi_t afi
= AFI_MAX
;
11075 safi_t safi
= SAFI_MAX
;
11079 /* show [ip] bgp */
11080 if (argv_find(argv
, argc
, "ip", &idx
)) {
11082 safi
= SAFI_UNICAST
;
11084 /* [vrf VIEWVRFNAME] */
11085 if (argv_find(argv
, argc
, "view", &idx
)) {
11087 "%% This command is not applicable to BGP views\n");
11088 return CMD_WARNING
;
11091 if (argv_find(argv
, argc
, "vrf", &idx
))
11092 vrf
= argv
[++idx
]->arg
;
11093 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11094 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11095 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11098 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11100 "%% This command is applicable only for unicast ipv4|ipv6\n");
11101 return CMD_WARNING
;
11104 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
);
11107 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11110 struct listnode
*node
, *nnode
;
11113 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11114 vty_out(vty
, "\nInstance %s:\n",
11115 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11118 update_group_show(bgp
, afi
, safi
, vty
, 0);
11122 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11123 int safi
, uint64_t subgrp_id
)
11128 if (strmatch(name
, "all")) {
11129 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11130 return CMD_SUCCESS
;
11132 bgp
= bgp_lookup_by_name(name
);
11135 bgp
= bgp_get_default();
11139 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11140 return CMD_SUCCESS
;
11143 DEFUN (show_ip_bgp_updgrps
,
11144 show_ip_bgp_updgrps_cmd
,
11145 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11149 BGP_INSTANCE_HELP_STR
11151 BGP_SAFI_WITH_LABEL_HELP_STR
11152 "Detailed info about dynamic update groups\n"
11153 "Specific subgroup to display detailed info for\n")
11156 afi_t afi
= AFI_IP6
;
11157 safi_t safi
= SAFI_UNICAST
;
11158 uint64_t subgrp_id
= 0;
11162 /* show [ip] bgp */
11163 if (argv_find(argv
, argc
, "ip", &idx
))
11165 /* [<view|vrf> VIEWVRFNAME] */
11166 if (argv_find(argv
, argc
, "view", &idx
)
11167 || argv_find(argv
, argc
, "vrf", &idx
))
11168 vrf
= argv
[++idx
]->arg
;
11169 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11170 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11171 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11174 /* get subgroup id, if provided */
11176 if (argv
[idx
]->type
== VARIABLE_TKN
)
11177 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11179 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11182 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11183 show_bgp_instance_all_ipv6_updgrps_cmd
,
11184 "show [ip] bgp <view|vrf> all update-groups",
11188 BGP_INSTANCE_ALL_HELP_STR
11189 "Detailed info about dynamic update groups\n")
11191 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11192 return CMD_SUCCESS
;
11195 DEFUN (show_bgp_updgrps_stats
,
11196 show_bgp_updgrps_stats_cmd
,
11197 "show [ip] bgp update-groups statistics",
11201 "Detailed info about dynamic update groups\n"
11206 bgp
= bgp_get_default();
11208 update_group_show_stats(bgp
, vty
);
11210 return CMD_SUCCESS
;
11213 DEFUN (show_bgp_instance_updgrps_stats
,
11214 show_bgp_instance_updgrps_stats_cmd
,
11215 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11219 BGP_INSTANCE_HELP_STR
11220 "Detailed info about dynamic update groups\n"
11226 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11228 update_group_show_stats(bgp
, vty
);
11230 return CMD_SUCCESS
;
11233 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11234 afi_t afi
, safi_t safi
,
11235 const char *what
, uint64_t subgrp_id
)
11240 bgp
= bgp_lookup_by_name(name
);
11242 bgp
= bgp_get_default();
11245 if (!strcmp(what
, "advertise-queue"))
11246 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11248 else if (!strcmp(what
, "advertised-routes"))
11249 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11251 else if (!strcmp(what
, "packet-queue"))
11252 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11257 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11258 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11259 "show [ip]$ip bgp [<view|vrf> VIEWVRFNAME$vrf] [<ipv4|ipv6>$afi <unicast|multicast|vpn>$safi] update-groups [SUBGROUP-ID]$sgid <advertise-queue|advertised-routes|packet-queue>$rtq",
11260 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11262 "Detailed info about dynamic update groups\n"
11263 "Specific subgroup to display info for\n"
11264 "Advertisement queue\n"
11265 "Announced routes\n"
11268 uint64_t subgrp_id
= 0;
11272 subgrp_id
= strtoull(sgid
, NULL
, 10);
11277 afiz
= bgp_vty_afi_from_str(afi
);
11281 afiz
= bgp_vty_afi_from_str(afi
);
11282 if (afiz
!= AFI_IP
)
11284 "%% Cannot specify both 'ip' and 'ipv6'\n");
11285 return CMD_WARNING
;
11288 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11290 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11291 return CMD_SUCCESS
;
11294 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11296 struct listnode
*node
, *nnode
;
11297 struct prefix
*range
;
11300 char buf
[PREFIX2STR_BUFFER
];
11303 const char *peer_status
;
11304 const char *af_str
;
11309 conf
= group
->conf
;
11311 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11312 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11314 } else if (conf
->as_type
== AS_INTERNAL
) {
11315 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11318 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11321 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11322 vty_out(vty
, " Peer-group type is internal\n");
11324 vty_out(vty
, " Peer-group type is external\n");
11326 /* Display AFs configured. */
11327 vty_out(vty
, " Configured address-families:");
11328 FOREACH_AFI_SAFI (afi
, safi
) {
11329 if (conf
->afc
[afi
][safi
]) {
11331 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11335 vty_out(vty
, " none\n");
11337 vty_out(vty
, "\n");
11339 /* Display listen ranges (for dynamic neighbors), if any */
11340 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11343 else if (afi
== AFI_IP6
)
11347 lr_count
= listcount(group
->listen_range
[afi
]);
11349 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11353 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11355 prefix2str(range
, buf
, sizeof(buf
));
11356 vty_out(vty
, " %s\n", buf
);
11361 /* Display group members and their status */
11362 if (listcount(group
->peer
)) {
11363 vty_out(vty
, " Peer-group members:\n");
11364 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11365 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11366 peer_status
= "Idle (Admin)";
11367 else if (CHECK_FLAG(peer
->sflags
,
11368 PEER_STATUS_PREFIX_OVERFLOW
))
11369 peer_status
= "Idle (PfxCt)";
11371 peer_status
= lookup_msg(bgp_status_msg
,
11372 peer
->status
, NULL
);
11374 dynamic
= peer_dynamic_neighbor(peer
);
11375 vty_out(vty
, " %s %s %s \n", peer
->host
,
11376 dynamic
? "(dynamic)" : "", peer_status
);
11380 return CMD_SUCCESS
;
11383 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11384 const char *group_name
)
11387 struct listnode
*node
, *nnode
;
11388 struct peer_group
*group
;
11389 bool found
= false;
11391 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11394 vty_out(vty
, "%% No such BGP instance exists\n");
11395 return CMD_WARNING
;
11398 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11400 if (strmatch(group
->name
, group_name
)) {
11401 bgp_show_one_peer_group(vty
, group
);
11406 bgp_show_one_peer_group(vty
, group
);
11410 if (group_name
&& !found
)
11411 vty_out(vty
, "%% No such peer-group\n");
11413 return CMD_SUCCESS
;
11416 DEFUN (show_ip_bgp_peer_groups
,
11417 show_ip_bgp_peer_groups_cmd
,
11418 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11422 BGP_INSTANCE_HELP_STR
11423 "Detailed information on BGP peer groups\n"
11424 "Peer group name\n")
11429 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11431 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11433 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11437 /* Redistribute VTY commands. */
11439 DEFUN (bgp_redistribute_ipv4
,
11440 bgp_redistribute_ipv4_cmd
,
11441 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11442 "Redistribute information from another routing protocol\n"
11443 FRR_IP_REDIST_HELP_STR_BGPD
)
11445 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11446 int idx_protocol
= 1;
11449 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11451 vty_out(vty
, "%% Invalid route type\n");
11452 return CMD_WARNING_CONFIG_FAILED
;
11455 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11456 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11460 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11461 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11462 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11464 DEFUN (bgp_redistribute_ipv4_rmap
,
11465 bgp_redistribute_ipv4_rmap_cmd
,
11466 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11467 "Redistribute information from another routing protocol\n"
11468 FRR_IP_REDIST_HELP_STR_BGPD
11469 "Route map reference\n"
11470 "Pointer to route-map entries\n")
11472 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11473 int idx_protocol
= 1;
11476 struct bgp_redist
*red
;
11478 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11480 vty_out(vty
, "%% Invalid route type\n");
11481 return CMD_WARNING_CONFIG_FAILED
;
11484 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11485 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11486 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11490 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11491 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11492 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11493 "Route map reference\n"
11494 "Pointer to route-map entries\n")
11496 DEFUN (bgp_redistribute_ipv4_metric
,
11497 bgp_redistribute_ipv4_metric_cmd
,
11498 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11499 "Redistribute information from another routing protocol\n"
11500 FRR_IP_REDIST_HELP_STR_BGPD
11501 "Metric for redistributed routes\n"
11502 "Default metric\n")
11504 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11505 int idx_protocol
= 1;
11506 int idx_number
= 3;
11509 struct bgp_redist
*red
;
11511 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11513 vty_out(vty
, "%% Invalid route type\n");
11514 return CMD_WARNING_CONFIG_FAILED
;
11516 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11518 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11519 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11520 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11524 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11525 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11526 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11527 "Metric for redistributed routes\n"
11528 "Default metric\n")
11530 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11531 bgp_redistribute_ipv4_rmap_metric_cmd
,
11532 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11533 "Redistribute information from another routing protocol\n"
11534 FRR_IP_REDIST_HELP_STR_BGPD
11535 "Route map reference\n"
11536 "Pointer to route-map entries\n"
11537 "Metric for redistributed routes\n"
11538 "Default metric\n")
11540 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11541 int idx_protocol
= 1;
11543 int idx_number
= 5;
11546 struct bgp_redist
*red
;
11548 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11550 vty_out(vty
, "%% Invalid route type\n");
11551 return CMD_WARNING_CONFIG_FAILED
;
11553 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11555 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11556 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11557 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11558 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11562 bgp_redistribute_ipv4_rmap_metric
,
11563 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11564 "redistribute " FRR_IP_REDIST_STR_BGPD
11565 " route-map WORD metric (0-4294967295)",
11566 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11567 "Route map reference\n"
11568 "Pointer to route-map entries\n"
11569 "Metric for redistributed routes\n"
11570 "Default metric\n")
11572 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11573 bgp_redistribute_ipv4_metric_rmap_cmd
,
11574 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11575 "Redistribute information from another routing protocol\n"
11576 FRR_IP_REDIST_HELP_STR_BGPD
11577 "Metric for redistributed routes\n"
11579 "Route map reference\n"
11580 "Pointer to route-map entries\n")
11582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11583 int idx_protocol
= 1;
11584 int idx_number
= 3;
11588 struct bgp_redist
*red
;
11590 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11592 vty_out(vty
, "%% Invalid route type\n");
11593 return CMD_WARNING_CONFIG_FAILED
;
11595 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11597 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11598 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11599 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11600 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11604 bgp_redistribute_ipv4_metric_rmap
,
11605 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11606 "redistribute " FRR_IP_REDIST_STR_BGPD
11607 " metric (0-4294967295) route-map WORD",
11608 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11609 "Metric for redistributed routes\n"
11611 "Route map reference\n"
11612 "Pointer to route-map entries\n")
11614 DEFUN (bgp_redistribute_ipv4_ospf
,
11615 bgp_redistribute_ipv4_ospf_cmd
,
11616 "redistribute <ospf|table> (1-65535)",
11617 "Redistribute information from another routing protocol\n"
11618 "Open Shortest Path First (OSPFv2)\n"
11619 "Non-main Kernel Routing Table\n"
11620 "Instance ID/Table ID\n")
11622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11623 int idx_ospf_table
= 1;
11624 int idx_number
= 2;
11625 unsigned short instance
;
11626 unsigned short protocol
;
11628 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11630 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11631 protocol
= ZEBRA_ROUTE_OSPF
;
11633 protocol
= ZEBRA_ROUTE_TABLE
;
11635 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11636 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11639 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11640 "redistribute <ospf|table> (1-65535)",
11641 "Redistribute information from another routing protocol\n"
11642 "Open Shortest Path First (OSPFv2)\n"
11643 "Non-main Kernel Routing Table\n"
11644 "Instance ID/Table ID\n")
11646 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11647 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11648 "redistribute <ospf|table> (1-65535) route-map WORD",
11649 "Redistribute information from another routing protocol\n"
11650 "Open Shortest Path First (OSPFv2)\n"
11651 "Non-main Kernel Routing Table\n"
11652 "Instance ID/Table ID\n"
11653 "Route map reference\n"
11654 "Pointer to route-map entries\n")
11656 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11657 int idx_ospf_table
= 1;
11658 int idx_number
= 2;
11660 struct bgp_redist
*red
;
11661 unsigned short instance
;
11664 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11665 protocol
= ZEBRA_ROUTE_OSPF
;
11667 protocol
= ZEBRA_ROUTE_TABLE
;
11669 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11670 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11671 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11672 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11675 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11676 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11677 "redistribute <ospf|table> (1-65535) route-map WORD",
11678 "Redistribute information from another routing protocol\n"
11679 "Open Shortest Path First (OSPFv2)\n"
11680 "Non-main Kernel Routing Table\n"
11681 "Instance ID/Table ID\n"
11682 "Route map reference\n"
11683 "Pointer to route-map entries\n")
11685 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11686 bgp_redistribute_ipv4_ospf_metric_cmd
,
11687 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11688 "Redistribute information from another routing protocol\n"
11689 "Open Shortest Path First (OSPFv2)\n"
11690 "Non-main Kernel Routing Table\n"
11691 "Instance ID/Table ID\n"
11692 "Metric for redistributed routes\n"
11693 "Default metric\n")
11695 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11696 int idx_ospf_table
= 1;
11697 int idx_number
= 2;
11698 int idx_number_2
= 4;
11700 struct bgp_redist
*red
;
11701 unsigned short instance
;
11704 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11705 protocol
= ZEBRA_ROUTE_OSPF
;
11707 protocol
= ZEBRA_ROUTE_TABLE
;
11709 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11710 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11712 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11713 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11714 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11717 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11718 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11719 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11720 "Redistribute information from another routing protocol\n"
11721 "Open Shortest Path First (OSPFv2)\n"
11722 "Non-main Kernel Routing Table\n"
11723 "Instance ID/Table ID\n"
11724 "Metric for redistributed routes\n"
11725 "Default metric\n")
11727 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11728 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11729 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11730 "Redistribute information from another routing protocol\n"
11731 "Open Shortest Path First (OSPFv2)\n"
11732 "Non-main Kernel Routing Table\n"
11733 "Instance ID/Table ID\n"
11734 "Route map reference\n"
11735 "Pointer to route-map entries\n"
11736 "Metric for redistributed routes\n"
11737 "Default metric\n")
11739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11740 int idx_ospf_table
= 1;
11741 int idx_number
= 2;
11743 int idx_number_2
= 6;
11745 struct bgp_redist
*red
;
11746 unsigned short instance
;
11749 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11750 protocol
= ZEBRA_ROUTE_OSPF
;
11752 protocol
= ZEBRA_ROUTE_TABLE
;
11754 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11755 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11757 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11758 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11759 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11760 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11764 bgp_redistribute_ipv4_ospf_rmap_metric
,
11765 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11766 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11767 "Redistribute information from another routing protocol\n"
11768 "Open Shortest Path First (OSPFv2)\n"
11769 "Non-main Kernel Routing Table\n"
11770 "Instance ID/Table ID\n"
11771 "Route map reference\n"
11772 "Pointer to route-map entries\n"
11773 "Metric for redistributed routes\n"
11774 "Default metric\n")
11776 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11777 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11778 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11779 "Redistribute information from another routing protocol\n"
11780 "Open Shortest Path First (OSPFv2)\n"
11781 "Non-main Kernel Routing Table\n"
11782 "Instance ID/Table ID\n"
11783 "Metric for redistributed routes\n"
11785 "Route map reference\n"
11786 "Pointer to route-map entries\n")
11788 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11789 int idx_ospf_table
= 1;
11790 int idx_number
= 2;
11791 int idx_number_2
= 4;
11794 struct bgp_redist
*red
;
11795 unsigned short instance
;
11798 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11799 protocol
= ZEBRA_ROUTE_OSPF
;
11801 protocol
= ZEBRA_ROUTE_TABLE
;
11803 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11804 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11806 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11807 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11808 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11809 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11813 bgp_redistribute_ipv4_ospf_metric_rmap
,
11814 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11815 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11816 "Redistribute information from another routing protocol\n"
11817 "Open Shortest Path First (OSPFv2)\n"
11818 "Non-main Kernel Routing Table\n"
11819 "Instance ID/Table ID\n"
11820 "Metric for redistributed routes\n"
11822 "Route map reference\n"
11823 "Pointer to route-map entries\n")
11825 DEFUN (no_bgp_redistribute_ipv4_ospf
,
11826 no_bgp_redistribute_ipv4_ospf_cmd
,
11827 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11829 "Redistribute information from another routing protocol\n"
11830 "Open Shortest Path First (OSPFv2)\n"
11831 "Non-main Kernel Routing Table\n"
11832 "Instance ID/Table ID\n"
11833 "Metric for redistributed routes\n"
11835 "Route map reference\n"
11836 "Pointer to route-map entries\n")
11838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11839 int idx_ospf_table
= 2;
11840 int idx_number
= 3;
11841 unsigned short instance
;
11844 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11845 protocol
= ZEBRA_ROUTE_OSPF
;
11847 protocol
= ZEBRA_ROUTE_TABLE
;
11849 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11850 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
11854 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
11855 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11857 "Redistribute information from another routing protocol\n"
11858 "Open Shortest Path First (OSPFv2)\n"
11859 "Non-main Kernel Routing Table\n"
11860 "Instance ID/Table ID\n"
11861 "Metric for redistributed routes\n"
11863 "Route map reference\n"
11864 "Pointer to route-map entries\n")
11866 DEFUN (no_bgp_redistribute_ipv4
,
11867 no_bgp_redistribute_ipv4_cmd
,
11868 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11870 "Redistribute information from another routing protocol\n"
11871 FRR_IP_REDIST_HELP_STR_BGPD
11872 "Metric for redistributed routes\n"
11874 "Route map reference\n"
11875 "Pointer to route-map entries\n")
11877 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11878 int idx_protocol
= 2;
11881 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11883 vty_out(vty
, "%% Invalid route type\n");
11884 return CMD_WARNING_CONFIG_FAILED
;
11886 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
11890 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
11891 "no redistribute " FRR_IP_REDIST_STR_BGPD
11892 " [metric (0-4294967295)] [route-map WORD]",
11894 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11895 "Metric for redistributed routes\n"
11897 "Route map reference\n"
11898 "Pointer to route-map entries\n")
11900 DEFUN (bgp_redistribute_ipv6
,
11901 bgp_redistribute_ipv6_cmd
,
11902 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11903 "Redistribute information from another routing protocol\n"
11904 FRR_IP6_REDIST_HELP_STR_BGPD
)
11906 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11907 int idx_protocol
= 1;
11910 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11912 vty_out(vty
, "%% Invalid route type\n");
11913 return CMD_WARNING_CONFIG_FAILED
;
11916 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11917 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11920 DEFUN (bgp_redistribute_ipv6_rmap
,
11921 bgp_redistribute_ipv6_rmap_cmd
,
11922 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
11923 "Redistribute information from another routing protocol\n"
11924 FRR_IP6_REDIST_HELP_STR_BGPD
11925 "Route map reference\n"
11926 "Pointer to route-map entries\n")
11928 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11929 int idx_protocol
= 1;
11932 struct bgp_redist
*red
;
11934 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11936 vty_out(vty
, "%% Invalid route type\n");
11937 return CMD_WARNING_CONFIG_FAILED
;
11940 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11941 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11942 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11945 DEFUN (bgp_redistribute_ipv6_metric
,
11946 bgp_redistribute_ipv6_metric_cmd
,
11947 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
11948 "Redistribute information from another routing protocol\n"
11949 FRR_IP6_REDIST_HELP_STR_BGPD
11950 "Metric for redistributed routes\n"
11951 "Default metric\n")
11953 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11954 int idx_protocol
= 1;
11955 int idx_number
= 3;
11958 struct bgp_redist
*red
;
11960 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11962 vty_out(vty
, "%% Invalid route type\n");
11963 return CMD_WARNING_CONFIG_FAILED
;
11965 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11967 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11968 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11969 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11972 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
11973 bgp_redistribute_ipv6_rmap_metric_cmd
,
11974 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11975 "Redistribute information from another routing protocol\n"
11976 FRR_IP6_REDIST_HELP_STR_BGPD
11977 "Route map reference\n"
11978 "Pointer to route-map entries\n"
11979 "Metric for redistributed routes\n"
11980 "Default metric\n")
11982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11983 int idx_protocol
= 1;
11985 int idx_number
= 5;
11988 struct bgp_redist
*red
;
11990 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11992 vty_out(vty
, "%% Invalid route type\n");
11993 return CMD_WARNING_CONFIG_FAILED
;
11995 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11997 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11998 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11999 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12000 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12003 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12004 bgp_redistribute_ipv6_metric_rmap_cmd
,
12005 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12006 "Redistribute information from another routing protocol\n"
12007 FRR_IP6_REDIST_HELP_STR_BGPD
12008 "Metric for redistributed routes\n"
12010 "Route map reference\n"
12011 "Pointer to route-map entries\n")
12013 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12014 int idx_protocol
= 1;
12015 int idx_number
= 3;
12019 struct bgp_redist
*red
;
12021 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12023 vty_out(vty
, "%% Invalid route type\n");
12024 return CMD_WARNING_CONFIG_FAILED
;
12026 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12028 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12029 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
12030 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12031 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12034 DEFUN (no_bgp_redistribute_ipv6
,
12035 no_bgp_redistribute_ipv6_cmd
,
12036 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12038 "Redistribute information from another routing protocol\n"
12039 FRR_IP6_REDIST_HELP_STR_BGPD
12040 "Metric for redistributed routes\n"
12042 "Route map reference\n"
12043 "Pointer to route-map entries\n")
12045 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12046 int idx_protocol
= 2;
12049 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12051 vty_out(vty
, "%% Invalid route type\n");
12052 return CMD_WARNING_CONFIG_FAILED
;
12055 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12058 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12063 /* Unicast redistribution only. */
12064 if (safi
!= SAFI_UNICAST
)
12067 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12068 /* Redistribute BGP does not make sense. */
12069 if (i
!= ZEBRA_ROUTE_BGP
) {
12070 struct list
*red_list
;
12071 struct listnode
*node
;
12072 struct bgp_redist
*red
;
12074 red_list
= bgp
->redist
[afi
][i
];
12078 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12079 /* "redistribute" configuration. */
12080 vty_out(vty
, " redistribute %s",
12081 zebra_route_string(i
));
12083 vty_out(vty
, " %d", red
->instance
);
12084 if (red
->redist_metric_flag
)
12085 vty_out(vty
, " metric %u",
12086 red
->redist_metric
);
12087 if (red
->rmap
.name
)
12088 vty_out(vty
, " route-map %s",
12090 vty_out(vty
, "\n");
12096 /* This is part of the address-family block (unicast only) */
12097 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12102 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
])
12103 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12104 bgp
->vpn_policy
[afi
]
12105 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12107 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12108 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12109 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12110 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12113 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12114 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12116 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12119 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12120 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12121 bgp
->vpn_policy
[afi
].tovpn_label
);
12124 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12125 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12126 char buf
[RD_ADDRSTRLEN
];
12127 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12128 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12131 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12132 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12134 char buf
[PREFIX_STRLEN
];
12135 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12136 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12139 vty_out(vty
, "%*snexthop vpn export %s\n",
12143 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12144 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12146 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12147 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12149 char *b
= ecommunity_ecom2str(
12150 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12151 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12152 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12153 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12155 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12156 char *b
= ecommunity_ecom2str(
12157 bgp
->vpn_policy
[afi
]
12158 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12159 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12160 ECOMMUNITY_ROUTE_TARGET
);
12161 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12162 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12164 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12165 char *b
= ecommunity_ecom2str(
12166 bgp
->vpn_policy
[afi
]
12167 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12168 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12169 ECOMMUNITY_ROUTE_TARGET
);
12170 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12171 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12175 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12176 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12177 bgp
->vpn_policy
[afi
]
12178 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12180 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12181 char *b
= ecommunity_ecom2str(
12182 bgp
->vpn_policy
[afi
]
12183 .import_redirect_rtlist
,
12184 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12185 ECOMMUNITY_ROUTE_TARGET
);
12187 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12188 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12193 /* BGP node structure. */
12194 static struct cmd_node bgp_node
= {
12195 BGP_NODE
, "%s(config-router)# ", 1,
12198 static struct cmd_node bgp_ipv4_unicast_node
= {
12199 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12202 static struct cmd_node bgp_ipv4_multicast_node
= {
12203 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12206 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12207 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12210 static struct cmd_node bgp_ipv6_unicast_node
= {
12211 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12214 static struct cmd_node bgp_ipv6_multicast_node
= {
12215 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12218 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12219 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12222 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12223 "%s(config-router-af)# ", 1};
12225 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12226 "%s(config-router-af-vpnv6)# ", 1};
12228 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12229 "%s(config-router-evpn)# ", 1};
12231 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12232 "%s(config-router-af-vni)# ", 1};
12234 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12235 "%s(config-router-af)# ", 1};
12237 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12238 "%s(config-router-af-vpnv6)# ", 1};
12240 static void community_list_vty(void);
12242 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12246 struct listnode
*lnbgp
, *lnpeer
;
12248 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12249 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12250 /* only provide suggestions on the appropriate input
12252 * they'll otherwise show up multiple times */
12253 enum cmd_token_type match_type
;
12254 char *name
= peer
->host
;
12256 if (peer
->conf_if
) {
12257 match_type
= VARIABLE_TKN
;
12258 name
= peer
->conf_if
;
12259 } else if (strchr(peer
->host
, ':'))
12260 match_type
= IPV6_TKN
;
12262 match_type
= IPV4_TKN
;
12264 if (token
->type
!= match_type
)
12267 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12272 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12273 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12274 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12275 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12276 {.completions
= NULL
}};
12278 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12281 struct peer_group
*group
;
12282 struct listnode
*lnbgp
, *lnpeer
;
12284 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12285 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12286 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12291 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12292 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12293 {.completions
= NULL
} };
12295 void bgp_vty_init(void)
12297 cmd_variable_handler_register(bgp_var_neighbor
);
12298 cmd_variable_handler_register(bgp_var_peergroup
);
12300 /* Install bgp top node. */
12301 install_node(&bgp_node
, bgp_config_write
);
12302 install_node(&bgp_ipv4_unicast_node
, NULL
);
12303 install_node(&bgp_ipv4_multicast_node
, NULL
);
12304 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12305 install_node(&bgp_ipv6_unicast_node
, NULL
);
12306 install_node(&bgp_ipv6_multicast_node
, NULL
);
12307 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12308 install_node(&bgp_vpnv4_node
, NULL
);
12309 install_node(&bgp_vpnv6_node
, NULL
);
12310 install_node(&bgp_evpn_node
, NULL
);
12311 install_node(&bgp_evpn_vni_node
, NULL
);
12312 install_node(&bgp_flowspecv4_node
, NULL
);
12313 install_node(&bgp_flowspecv6_node
, NULL
);
12315 /* Install default VTY commands to new nodes. */
12316 install_default(BGP_NODE
);
12317 install_default(BGP_IPV4_NODE
);
12318 install_default(BGP_IPV4M_NODE
);
12319 install_default(BGP_IPV4L_NODE
);
12320 install_default(BGP_IPV6_NODE
);
12321 install_default(BGP_IPV6M_NODE
);
12322 install_default(BGP_IPV6L_NODE
);
12323 install_default(BGP_VPNV4_NODE
);
12324 install_default(BGP_VPNV6_NODE
);
12325 install_default(BGP_FLOWSPECV4_NODE
);
12326 install_default(BGP_FLOWSPECV6_NODE
);
12327 install_default(BGP_EVPN_NODE
);
12328 install_default(BGP_EVPN_VNI_NODE
);
12330 /* "bgp multiple-instance" commands. */
12331 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12332 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12334 /* "bgp config-type" commands. */
12335 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12336 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12338 /* bgp route-map delay-timer commands. */
12339 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12340 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12342 /* Dummy commands (Currently not supported) */
12343 install_element(BGP_NODE
, &no_synchronization_cmd
);
12344 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12346 /* "router bgp" commands. */
12347 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12349 /* "no router bgp" commands. */
12350 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12352 /* "bgp router-id" commands. */
12353 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12354 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12356 /* "bgp cluster-id" commands. */
12357 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12358 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12360 /* "bgp confederation" commands. */
12361 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12362 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12364 /* "bgp confederation peers" commands. */
12365 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12366 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12368 /* bgp max-med command */
12369 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12370 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12371 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12372 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12373 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12375 /* bgp disable-ebgp-connected-nh-check */
12376 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12377 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12379 /* bgp update-delay command */
12380 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12381 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12382 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12384 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12385 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12386 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12387 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12389 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12390 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12392 /* "maximum-paths" commands. */
12393 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12394 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12395 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12396 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12397 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12398 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12399 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12400 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12401 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12402 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12403 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12404 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12405 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12406 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12407 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12409 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12410 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12411 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12412 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12413 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12415 /* "timers bgp" commands. */
12416 install_element(BGP_NODE
, &bgp_timers_cmd
);
12417 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12419 /* route-map delay-timer commands - per instance for backwards compat.
12421 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12422 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12424 /* "bgp client-to-client reflection" commands */
12425 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12426 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12428 /* "bgp always-compare-med" commands */
12429 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12430 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12432 /* "bgp deterministic-med" commands */
12433 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12434 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12436 /* "bgp graceful-restart" commands */
12437 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12438 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12439 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12440 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12441 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12442 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12444 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12445 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12447 /* "bgp graceful-shutdown" commands */
12448 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12449 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12451 /* "bgp fast-external-failover" commands */
12452 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12453 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12455 /* "bgp enforce-first-as" commands */
12456 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12458 /* "bgp bestpath compare-routerid" commands */
12459 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12460 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12462 /* "bgp bestpath as-path ignore" commands */
12463 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12464 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12466 /* "bgp bestpath as-path confed" commands */
12467 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12468 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12470 /* "bgp bestpath as-path multipath-relax" commands */
12471 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12472 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12474 /* "bgp log-neighbor-changes" commands */
12475 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12476 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12478 /* "bgp bestpath med" commands */
12479 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12480 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12482 /* "no bgp default ipv4-unicast" commands. */
12483 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12484 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12486 /* "bgp network import-check" commands. */
12487 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12488 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12489 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12491 /* "bgp default local-preference" commands. */
12492 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12493 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12495 /* bgp default show-hostname */
12496 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12497 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12499 /* "bgp default subgroup-pkt-queue-max" commands. */
12500 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12501 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12503 /* bgp ibgp-allow-policy-mods command */
12504 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12505 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12507 /* "bgp listen limit" commands. */
12508 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12509 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12511 /* "bgp listen range" commands. */
12512 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12513 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12515 /* "bgp default shutdown" command */
12516 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12518 /* "neighbor remote-as" commands. */
12519 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12520 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12521 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12522 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12523 install_element(BGP_NODE
,
12524 &neighbor_interface_v6only_config_remote_as_cmd
);
12525 install_element(BGP_NODE
, &no_neighbor_cmd
);
12526 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12528 /* "neighbor peer-group" commands. */
12529 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12530 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12531 install_element(BGP_NODE
,
12532 &no_neighbor_interface_peer_group_remote_as_cmd
);
12534 /* "neighbor local-as" commands. */
12535 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12536 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12537 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12538 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12540 /* "neighbor solo" commands. */
12541 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12542 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12544 /* "neighbor password" commands. */
12545 install_element(BGP_NODE
, &neighbor_password_cmd
);
12546 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12548 /* "neighbor activate" commands. */
12549 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12550 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12551 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12552 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12553 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12554 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12555 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12556 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12557 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12558 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12559 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12560 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12562 /* "no neighbor activate" commands. */
12563 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12564 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12565 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12566 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12567 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12568 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12569 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12570 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12571 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12572 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12573 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12574 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12576 /* "neighbor peer-group" set commands. */
12577 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12578 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12579 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12580 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12581 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12582 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12583 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12584 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12585 install_element(BGP_FLOWSPECV4_NODE
,
12586 &neighbor_set_peer_group_hidden_cmd
);
12587 install_element(BGP_FLOWSPECV6_NODE
,
12588 &neighbor_set_peer_group_hidden_cmd
);
12590 /* "no neighbor peer-group unset" commands. */
12591 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12592 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12593 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12594 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12595 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12596 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12597 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12598 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12599 install_element(BGP_FLOWSPECV4_NODE
,
12600 &no_neighbor_set_peer_group_hidden_cmd
);
12601 install_element(BGP_FLOWSPECV6_NODE
,
12602 &no_neighbor_set_peer_group_hidden_cmd
);
12604 /* "neighbor softreconfiguration inbound" commands.*/
12605 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12606 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12607 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12608 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12609 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12610 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12611 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12612 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12613 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12614 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12615 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12616 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12617 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12618 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12619 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12620 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12621 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12622 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12623 install_element(BGP_FLOWSPECV4_NODE
,
12624 &neighbor_soft_reconfiguration_cmd
);
12625 install_element(BGP_FLOWSPECV4_NODE
,
12626 &no_neighbor_soft_reconfiguration_cmd
);
12627 install_element(BGP_FLOWSPECV6_NODE
,
12628 &neighbor_soft_reconfiguration_cmd
);
12629 install_element(BGP_FLOWSPECV6_NODE
,
12630 &no_neighbor_soft_reconfiguration_cmd
);
12632 /* "neighbor attribute-unchanged" commands. */
12633 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12634 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12635 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12636 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12637 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12638 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12639 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12640 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12641 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12642 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12643 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12644 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12645 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12646 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12647 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12648 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12649 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12650 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12652 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12653 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12655 /* "nexthop-local unchanged" commands */
12656 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12657 install_element(BGP_IPV6_NODE
,
12658 &no_neighbor_nexthop_local_unchanged_cmd
);
12660 /* "neighbor next-hop-self" commands. */
12661 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12662 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12663 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12664 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12665 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12666 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12667 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12668 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12669 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12670 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12671 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12672 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12673 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12674 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12675 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12676 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12677 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12678 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12679 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
12680 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
12682 /* "neighbor next-hop-self force" commands. */
12683 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12684 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12685 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12686 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12687 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12688 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12689 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12690 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12691 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12692 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12693 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12694 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12695 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12696 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12697 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12698 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12699 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12700 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12702 /* "neighbor as-override" commands. */
12703 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12704 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12705 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12706 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12707 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12708 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12709 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12710 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12711 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12712 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12713 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12714 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12715 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12716 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12717 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12718 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12719 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12720 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12722 /* "neighbor remove-private-AS" commands. */
12723 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12724 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12725 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12726 install_element(BGP_NODE
,
12727 &no_neighbor_remove_private_as_all_hidden_cmd
);
12728 install_element(BGP_NODE
,
12729 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12730 install_element(BGP_NODE
,
12731 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12732 install_element(BGP_NODE
,
12733 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12736 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12737 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12738 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12739 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12740 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12741 install_element(BGP_IPV4_NODE
,
12742 &neighbor_remove_private_as_replace_as_cmd
);
12743 install_element(BGP_IPV4_NODE
,
12744 &no_neighbor_remove_private_as_replace_as_cmd
);
12745 install_element(BGP_IPV4_NODE
,
12746 &neighbor_remove_private_as_all_replace_as_cmd
);
12747 install_element(BGP_IPV4_NODE
,
12748 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12749 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12750 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12751 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12752 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12753 install_element(BGP_IPV4M_NODE
,
12754 &neighbor_remove_private_as_replace_as_cmd
);
12755 install_element(BGP_IPV4M_NODE
,
12756 &no_neighbor_remove_private_as_replace_as_cmd
);
12757 install_element(BGP_IPV4M_NODE
,
12758 &neighbor_remove_private_as_all_replace_as_cmd
);
12759 install_element(BGP_IPV4M_NODE
,
12760 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12761 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12762 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12763 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12764 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12765 install_element(BGP_IPV4L_NODE
,
12766 &neighbor_remove_private_as_replace_as_cmd
);
12767 install_element(BGP_IPV4L_NODE
,
12768 &no_neighbor_remove_private_as_replace_as_cmd
);
12769 install_element(BGP_IPV4L_NODE
,
12770 &neighbor_remove_private_as_all_replace_as_cmd
);
12771 install_element(BGP_IPV4L_NODE
,
12772 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12773 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12774 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12775 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12776 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12777 install_element(BGP_IPV6_NODE
,
12778 &neighbor_remove_private_as_replace_as_cmd
);
12779 install_element(BGP_IPV6_NODE
,
12780 &no_neighbor_remove_private_as_replace_as_cmd
);
12781 install_element(BGP_IPV6_NODE
,
12782 &neighbor_remove_private_as_all_replace_as_cmd
);
12783 install_element(BGP_IPV6_NODE
,
12784 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12785 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12786 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12787 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12788 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12789 install_element(BGP_IPV6M_NODE
,
12790 &neighbor_remove_private_as_replace_as_cmd
);
12791 install_element(BGP_IPV6M_NODE
,
12792 &no_neighbor_remove_private_as_replace_as_cmd
);
12793 install_element(BGP_IPV6M_NODE
,
12794 &neighbor_remove_private_as_all_replace_as_cmd
);
12795 install_element(BGP_IPV6M_NODE
,
12796 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12797 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12798 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12799 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12800 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12801 install_element(BGP_IPV6L_NODE
,
12802 &neighbor_remove_private_as_replace_as_cmd
);
12803 install_element(BGP_IPV6L_NODE
,
12804 &no_neighbor_remove_private_as_replace_as_cmd
);
12805 install_element(BGP_IPV6L_NODE
,
12806 &neighbor_remove_private_as_all_replace_as_cmd
);
12807 install_element(BGP_IPV6L_NODE
,
12808 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12809 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
12810 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12811 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12812 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12813 install_element(BGP_VPNV4_NODE
,
12814 &neighbor_remove_private_as_replace_as_cmd
);
12815 install_element(BGP_VPNV4_NODE
,
12816 &no_neighbor_remove_private_as_replace_as_cmd
);
12817 install_element(BGP_VPNV4_NODE
,
12818 &neighbor_remove_private_as_all_replace_as_cmd
);
12819 install_element(BGP_VPNV4_NODE
,
12820 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12821 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
12822 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12823 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12824 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12825 install_element(BGP_VPNV6_NODE
,
12826 &neighbor_remove_private_as_replace_as_cmd
);
12827 install_element(BGP_VPNV6_NODE
,
12828 &no_neighbor_remove_private_as_replace_as_cmd
);
12829 install_element(BGP_VPNV6_NODE
,
12830 &neighbor_remove_private_as_all_replace_as_cmd
);
12831 install_element(BGP_VPNV6_NODE
,
12832 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12834 /* "neighbor send-community" commands.*/
12835 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
12836 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
12837 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
12838 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
12839 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
12840 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
12841 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
12842 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
12843 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
12844 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
12845 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
12846 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
12847 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
12848 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
12849 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
12850 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
12851 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
12852 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
12853 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
12854 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
12855 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
12856 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
12857 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
12858 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
12859 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
12860 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
12861 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
12862 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
12863 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
12864 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
12865 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
12866 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
12867 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
12868 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
12869 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
12870 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
12872 /* "neighbor route-reflector" commands.*/
12873 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
12874 install_element(BGP_NODE
,
12875 &no_neighbor_route_reflector_client_hidden_cmd
);
12876 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
12877 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
12878 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
12879 install_element(BGP_IPV4M_NODE
,
12880 &no_neighbor_route_reflector_client_cmd
);
12881 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
12882 install_element(BGP_IPV4L_NODE
,
12883 &no_neighbor_route_reflector_client_cmd
);
12884 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
12885 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
12886 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
12887 install_element(BGP_IPV6M_NODE
,
12888 &no_neighbor_route_reflector_client_cmd
);
12889 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
12890 install_element(BGP_IPV6L_NODE
,
12891 &no_neighbor_route_reflector_client_cmd
);
12892 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
12893 install_element(BGP_VPNV4_NODE
,
12894 &no_neighbor_route_reflector_client_cmd
);
12895 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
12896 install_element(BGP_VPNV6_NODE
,
12897 &no_neighbor_route_reflector_client_cmd
);
12898 install_element(BGP_FLOWSPECV4_NODE
,
12899 &neighbor_route_reflector_client_cmd
);
12900 install_element(BGP_FLOWSPECV4_NODE
,
12901 &no_neighbor_route_reflector_client_cmd
);
12902 install_element(BGP_FLOWSPECV6_NODE
,
12903 &neighbor_route_reflector_client_cmd
);
12904 install_element(BGP_FLOWSPECV6_NODE
,
12905 &no_neighbor_route_reflector_client_cmd
);
12906 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
12907 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
12909 /* "neighbor route-server" commands.*/
12910 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
12911 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
12912 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
12913 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
12914 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
12915 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
12916 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
12917 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
12918 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
12919 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
12920 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
12921 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
12922 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
12923 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
12924 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
12925 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
12926 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
12927 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
12928 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
12929 install_element(BGP_FLOWSPECV4_NODE
,
12930 &no_neighbor_route_server_client_cmd
);
12931 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
12932 install_element(BGP_FLOWSPECV6_NODE
,
12933 &no_neighbor_route_server_client_cmd
);
12935 /* "neighbor addpath-tx-all-paths" commands.*/
12936 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
12937 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
12938 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12939 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12940 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12941 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12942 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12943 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12944 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12945 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12946 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12947 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12948 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12949 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12950 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12951 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12952 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12953 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12955 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
12956 install_element(BGP_NODE
,
12957 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12958 install_element(BGP_NODE
,
12959 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12960 install_element(BGP_IPV4_NODE
,
12961 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12962 install_element(BGP_IPV4_NODE
,
12963 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12964 install_element(BGP_IPV4M_NODE
,
12965 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12966 install_element(BGP_IPV4M_NODE
,
12967 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12968 install_element(BGP_IPV4L_NODE
,
12969 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12970 install_element(BGP_IPV4L_NODE
,
12971 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12972 install_element(BGP_IPV6_NODE
,
12973 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12974 install_element(BGP_IPV6_NODE
,
12975 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12976 install_element(BGP_IPV6M_NODE
,
12977 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12978 install_element(BGP_IPV6M_NODE
,
12979 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12980 install_element(BGP_IPV6L_NODE
,
12981 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12982 install_element(BGP_IPV6L_NODE
,
12983 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12984 install_element(BGP_VPNV4_NODE
,
12985 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12986 install_element(BGP_VPNV4_NODE
,
12987 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12988 install_element(BGP_VPNV6_NODE
,
12989 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12990 install_element(BGP_VPNV6_NODE
,
12991 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12993 /* "neighbor passive" commands. */
12994 install_element(BGP_NODE
, &neighbor_passive_cmd
);
12995 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
12998 /* "neighbor shutdown" commands. */
12999 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13000 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13001 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13002 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13004 /* "neighbor capability extended-nexthop" commands.*/
13005 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13006 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13008 /* "neighbor capability orf prefix-list" commands.*/
13009 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13010 install_element(BGP_NODE
,
13011 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13012 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13013 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13014 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13015 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13016 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13017 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13018 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13019 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13020 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13021 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13022 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13023 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13025 /* "neighbor capability dynamic" commands.*/
13026 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13027 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13029 /* "neighbor dont-capability-negotiate" commands. */
13030 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13031 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13033 /* "neighbor ebgp-multihop" commands. */
13034 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13035 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13036 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13038 /* "neighbor disable-connected-check" commands. */
13039 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13040 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13042 /* "neighbor enforce-first-as" commands. */
13043 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13044 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13046 /* "neighbor description" commands. */
13047 install_element(BGP_NODE
, &neighbor_description_cmd
);
13048 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13049 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13051 /* "neighbor update-source" commands. "*/
13052 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13053 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13055 /* "neighbor default-originate" commands. */
13056 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13057 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13058 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13059 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13060 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13061 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13062 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13063 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13064 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13065 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13066 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13067 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13068 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13069 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13070 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13071 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13072 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13073 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13074 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13075 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13076 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13078 /* "neighbor port" commands. */
13079 install_element(BGP_NODE
, &neighbor_port_cmd
);
13080 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13082 /* "neighbor weight" commands. */
13083 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13084 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13086 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13087 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13088 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13089 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13090 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13091 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13092 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13093 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13094 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13095 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13096 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13097 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13098 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13099 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13100 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13101 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13103 /* "neighbor override-capability" commands. */
13104 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13105 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13107 /* "neighbor strict-capability-match" commands. */
13108 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13109 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13111 /* "neighbor timers" commands. */
13112 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13113 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13115 /* "neighbor timers connect" commands. */
13116 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13117 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13119 /* "neighbor advertisement-interval" commands. */
13120 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13121 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13123 /* "neighbor interface" commands. */
13124 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13125 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13127 /* "neighbor distribute" commands. */
13128 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13129 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13130 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13131 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13132 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13133 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13134 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13135 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13136 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13137 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13138 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13139 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13140 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13141 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13142 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13143 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13144 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13145 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13147 /* "neighbor prefix-list" commands. */
13148 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13149 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13150 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13151 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13152 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13153 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13154 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13155 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13156 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13157 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13158 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13159 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13160 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13161 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13162 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13163 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13164 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13165 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13166 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13167 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13168 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13169 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13171 /* "neighbor filter-list" commands. */
13172 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13173 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13174 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13175 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13176 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13177 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13178 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13179 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13180 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13181 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13182 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13183 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13184 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13185 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13186 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13187 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13188 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13189 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13190 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13191 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13192 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13193 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13195 /* "neighbor route-map" commands. */
13196 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13197 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13198 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13199 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13200 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13201 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13202 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13203 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13204 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13205 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13206 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13207 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13208 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13209 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13210 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13211 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13212 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13213 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13214 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13215 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13216 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13217 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13218 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13219 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13221 /* "neighbor unsuppress-map" commands. */
13222 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13223 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13224 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13225 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13226 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13227 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13228 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13229 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13230 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13231 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13232 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13233 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13234 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13235 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13236 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13237 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13238 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13239 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13241 /* "neighbor maximum-prefix" commands. */
13242 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13243 install_element(BGP_NODE
,
13244 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13245 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13246 install_element(BGP_NODE
,
13247 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13248 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13249 install_element(BGP_NODE
,
13250 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13251 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13252 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13253 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13254 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13255 install_element(BGP_IPV4_NODE
,
13256 &neighbor_maximum_prefix_threshold_warning_cmd
);
13257 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13258 install_element(BGP_IPV4_NODE
,
13259 &neighbor_maximum_prefix_threshold_restart_cmd
);
13260 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13261 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13262 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13263 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13264 install_element(BGP_IPV4M_NODE
,
13265 &neighbor_maximum_prefix_threshold_warning_cmd
);
13266 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13267 install_element(BGP_IPV4M_NODE
,
13268 &neighbor_maximum_prefix_threshold_restart_cmd
);
13269 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13270 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13271 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13272 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13273 install_element(BGP_IPV4L_NODE
,
13274 &neighbor_maximum_prefix_threshold_warning_cmd
);
13275 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13276 install_element(BGP_IPV4L_NODE
,
13277 &neighbor_maximum_prefix_threshold_restart_cmd
);
13278 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13279 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13280 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13281 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13282 install_element(BGP_IPV6_NODE
,
13283 &neighbor_maximum_prefix_threshold_warning_cmd
);
13284 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13285 install_element(BGP_IPV6_NODE
,
13286 &neighbor_maximum_prefix_threshold_restart_cmd
);
13287 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13288 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13289 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13290 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13291 install_element(BGP_IPV6M_NODE
,
13292 &neighbor_maximum_prefix_threshold_warning_cmd
);
13293 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13294 install_element(BGP_IPV6M_NODE
,
13295 &neighbor_maximum_prefix_threshold_restart_cmd
);
13296 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13297 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13298 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13299 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13300 install_element(BGP_IPV6L_NODE
,
13301 &neighbor_maximum_prefix_threshold_warning_cmd
);
13302 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13303 install_element(BGP_IPV6L_NODE
,
13304 &neighbor_maximum_prefix_threshold_restart_cmd
);
13305 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13306 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13307 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13308 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13309 install_element(BGP_VPNV4_NODE
,
13310 &neighbor_maximum_prefix_threshold_warning_cmd
);
13311 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13312 install_element(BGP_VPNV4_NODE
,
13313 &neighbor_maximum_prefix_threshold_restart_cmd
);
13314 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13315 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13316 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13317 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13318 install_element(BGP_VPNV6_NODE
,
13319 &neighbor_maximum_prefix_threshold_warning_cmd
);
13320 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13321 install_element(BGP_VPNV6_NODE
,
13322 &neighbor_maximum_prefix_threshold_restart_cmd
);
13323 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13325 /* "neighbor allowas-in" */
13326 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13327 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13328 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13329 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13330 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13331 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13332 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13333 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13334 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13335 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13336 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13337 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13338 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13339 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13340 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13341 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13342 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13343 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13344 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13345 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13347 /* address-family commands. */
13348 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13349 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13350 #ifdef KEEP_OLD_VPN_COMMANDS
13351 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13352 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13353 #endif /* KEEP_OLD_VPN_COMMANDS */
13355 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13357 /* "exit-address-family" command. */
13358 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13359 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13360 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13361 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13362 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13363 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13364 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13365 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13366 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13367 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13368 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13370 /* "clear ip bgp commands" */
13371 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13373 /* clear ip bgp prefix */
13374 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13375 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13376 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13378 /* "show [ip] bgp summary" commands. */
13379 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13380 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13381 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13382 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13383 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13384 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13386 /* "show [ip] bgp neighbors" commands. */
13387 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13389 /* "show [ip] bgp peer-group" commands. */
13390 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13392 /* "show [ip] bgp paths" commands. */
13393 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13395 /* "show [ip] bgp community" commands. */
13396 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13398 /* "show ip bgp large-community" commands. */
13399 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13400 /* "show [ip] bgp attribute-info" commands. */
13401 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13402 /* "show [ip] bgp route-leak" command */
13403 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13405 /* "redistribute" commands. */
13406 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13407 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13408 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13409 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13410 install_element(BGP_NODE
,
13411 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13412 install_element(BGP_NODE
,
13413 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13414 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13415 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13416 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13417 install_element(BGP_NODE
,
13418 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13419 install_element(BGP_NODE
,
13420 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13421 install_element(BGP_NODE
,
13422 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13423 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13424 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13425 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13426 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13427 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13428 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13429 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13430 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13431 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13432 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13433 install_element(BGP_IPV4_NODE
,
13434 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13435 install_element(BGP_IPV4_NODE
,
13436 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13437 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13438 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13439 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13440 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13441 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13442 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13444 /* import|export vpn [route-map WORD] */
13445 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13446 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13448 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13449 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13451 /* ttl_security commands */
13452 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13453 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13455 /* "show [ip] bgp memory" commands. */
13456 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13458 /* "show bgp martian next-hop" */
13459 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13461 /* "show [ip] bgp views" commands. */
13462 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13464 /* "show [ip] bgp vrfs" commands. */
13465 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13467 /* Community-list. */
13468 community_list_vty();
13470 /* vpn-policy commands */
13471 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13472 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13473 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13474 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13475 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13476 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13477 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13478 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13479 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13480 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13481 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13482 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13484 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13485 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13487 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13488 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13489 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13490 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13491 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13492 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13493 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13494 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13495 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13496 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13497 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13498 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13501 #include "memory.h"
13502 #include "bgp_regex.h"
13503 #include "bgp_clist.h"
13504 #include "bgp_ecommunity.h"
13506 /* VTY functions. */
13508 /* Direction value to string conversion. */
13509 static const char *community_direct_str(int direct
)
13512 case COMMUNITY_DENY
:
13514 case COMMUNITY_PERMIT
:
13521 /* Display error string. */
13522 static void community_list_perror(struct vty
*vty
, int ret
)
13525 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13526 vty_out(vty
, "%% Can't find community-list\n");
13528 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13529 vty_out(vty
, "%% Malformed community-list value\n");
13531 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13533 "%% Community name conflict, previously defined as standard community\n");
13535 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13537 "%% Community name conflict, previously defined as expanded community\n");
13542 /* "community-list" keyword help string. */
13543 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13545 /* ip community-list standard */
13546 DEFUN (ip_community_list_standard
,
13547 ip_community_list_standard_cmd
,
13548 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13551 "Community list number (standard)\n"
13552 "Add an standard community-list entry\n"
13553 "Community list name\n"
13554 "Specify community to reject\n"
13555 "Specify community to accept\n"
13558 char *cl_name_or_number
= NULL
;
13560 int style
= COMMUNITY_LIST_STANDARD
;
13563 argv_find(argv
, argc
, "(1-99)", &idx
);
13564 argv_find(argv
, argc
, "WORD", &idx
);
13565 cl_name_or_number
= argv
[idx
]->arg
;
13566 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13568 argv_find(argv
, argc
, "AA:NN", &idx
);
13569 char *str
= argv_concat(argv
, argc
, idx
);
13571 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13574 XFREE(MTYPE_TMP
, str
);
13577 /* Display error string. */
13578 community_list_perror(vty
, ret
);
13579 return CMD_WARNING_CONFIG_FAILED
;
13582 return CMD_SUCCESS
;
13585 DEFUN (no_ip_community_list_standard_all
,
13586 no_ip_community_list_standard_all_cmd
,
13587 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13591 "Community list number (standard)\n"
13592 "Add an standard community-list entry\n"
13593 "Community list name\n"
13594 "Specify community to reject\n"
13595 "Specify community to accept\n"
13598 char *cl_name_or_number
= NULL
;
13600 int style
= COMMUNITY_LIST_STANDARD
;
13603 argv_find(argv
, argc
, "(1-99)", &idx
);
13604 argv_find(argv
, argc
, "WORD", &idx
);
13605 cl_name_or_number
= argv
[idx
]->arg
;
13606 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13608 argv_find(argv
, argc
, "AA:NN", &idx
);
13609 char *str
= argv_concat(argv
, argc
, idx
);
13611 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13614 XFREE(MTYPE_TMP
, str
);
13617 community_list_perror(vty
, ret
);
13618 return CMD_WARNING_CONFIG_FAILED
;
13621 return CMD_SUCCESS
;
13624 /* ip community-list expanded */
13625 DEFUN (ip_community_list_expanded_all
,
13626 ip_community_list_expanded_all_cmd
,
13627 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13630 "Community list number (expanded)\n"
13631 "Add an expanded community-list entry\n"
13632 "Community list name\n"
13633 "Specify community to reject\n"
13634 "Specify community to accept\n"
13637 char *cl_name_or_number
= NULL
;
13639 int style
= COMMUNITY_LIST_EXPANDED
;
13642 argv_find(argv
, argc
, "(100-500)", &idx
);
13643 argv_find(argv
, argc
, "WORD", &idx
);
13644 cl_name_or_number
= argv
[idx
]->arg
;
13645 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13647 argv_find(argv
, argc
, "AA:NN", &idx
);
13648 char *str
= argv_concat(argv
, argc
, idx
);
13650 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13653 XFREE(MTYPE_TMP
, str
);
13656 /* Display error string. */
13657 community_list_perror(vty
, ret
);
13658 return CMD_WARNING_CONFIG_FAILED
;
13661 return CMD_SUCCESS
;
13664 DEFUN (no_ip_community_list_expanded_all
,
13665 no_ip_community_list_expanded_all_cmd
,
13666 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13670 "Community list number (expanded)\n"
13671 "Add an expanded community-list entry\n"
13672 "Community list name\n"
13673 "Specify community to reject\n"
13674 "Specify community to accept\n"
13677 char *cl_name_or_number
= NULL
;
13679 int style
= COMMUNITY_LIST_EXPANDED
;
13682 argv_find(argv
, argc
, "(100-500)", &idx
);
13683 argv_find(argv
, argc
, "WORD", &idx
);
13684 cl_name_or_number
= argv
[idx
]->arg
;
13685 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13687 argv_find(argv
, argc
, "AA:NN", &idx
);
13688 char *str
= argv_concat(argv
, argc
, idx
);
13690 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13693 XFREE(MTYPE_TMP
, str
);
13696 community_list_perror(vty
, ret
);
13697 return CMD_WARNING_CONFIG_FAILED
;
13700 return CMD_SUCCESS
;
13703 /* Return configuration string of community-list entry. */
13704 static const char *community_list_config_str(struct community_entry
*entry
)
13711 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13712 str
= community_str(entry
->u
.com
, false);
13713 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
13714 str
= lcommunity_str(entry
->u
.lcom
, false);
13716 str
= entry
->config
;
13721 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13723 struct community_entry
*entry
;
13725 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13726 if (entry
== list
->head
) {
13727 if (all_digit(list
->name
))
13728 vty_out(vty
, "Community %s list %s\n",
13729 entry
->style
== COMMUNITY_LIST_STANDARD
13731 : "(expanded) access",
13734 vty_out(vty
, "Named Community %s list %s\n",
13735 entry
->style
== COMMUNITY_LIST_STANDARD
13741 vty_out(vty
, " %s\n",
13742 community_direct_str(entry
->direct
));
13744 vty_out(vty
, " %s %s\n",
13745 community_direct_str(entry
->direct
),
13746 community_list_config_str(entry
));
13750 DEFUN (show_ip_community_list
,
13751 show_ip_community_list_cmd
,
13752 "show ip community-list",
13755 "List community-list\n")
13757 struct community_list
*list
;
13758 struct community_list_master
*cm
;
13760 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13762 return CMD_SUCCESS
;
13764 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13765 community_list_show(vty
, list
);
13767 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13768 community_list_show(vty
, list
);
13770 return CMD_SUCCESS
;
13773 DEFUN (show_ip_community_list_arg
,
13774 show_ip_community_list_arg_cmd
,
13775 "show ip community-list <(1-500)|WORD>",
13778 "List community-list\n"
13779 "Community-list number\n"
13780 "Community-list name\n")
13782 int idx_comm_list
= 3;
13783 struct community_list
*list
;
13785 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13786 COMMUNITY_LIST_MASTER
);
13788 vty_out(vty
, "%% Can't find community-list\n");
13789 return CMD_WARNING
;
13792 community_list_show(vty
, list
);
13794 return CMD_SUCCESS
;
13798 * Large Community code.
13800 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
13801 struct cmd_token
**argv
, int style
,
13802 int reject_all_digit_name
)
13810 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13813 /* All digit name check. */
13815 argv_find(argv
, argc
, "WORD", &idx
);
13816 argv_find(argv
, argc
, "(1-99)", &idx
);
13817 argv_find(argv
, argc
, "(100-500)", &idx
);
13818 cl_name
= argv
[idx
]->arg
;
13819 if (reject_all_digit_name
&& all_digit(cl_name
)) {
13820 vty_out(vty
, "%% Community name cannot have all digits\n");
13821 return CMD_WARNING_CONFIG_FAILED
;
13825 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
13826 argv_find(argv
, argc
, "LINE", &idx
);
13827 /* Concat community string argument. */
13829 str
= argv_concat(argv
, argc
, idx
);
13833 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
13835 /* Free temporary community list string allocated by
13838 XFREE(MTYPE_TMP
, str
);
13841 community_list_perror(vty
, ret
);
13842 return CMD_WARNING_CONFIG_FAILED
;
13844 return CMD_SUCCESS
;
13847 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
13848 struct cmd_token
**argv
, int style
)
13855 argv_find(argv
, argc
, "permit", &idx
);
13856 argv_find(argv
, argc
, "deny", &idx
);
13859 /* Check the list direct. */
13860 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
13861 direct
= COMMUNITY_PERMIT
;
13863 direct
= COMMUNITY_DENY
;
13866 argv_find(argv
, argc
, "LINE", &idx
);
13867 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
13868 /* Concat community string argument. */
13869 str
= argv_concat(argv
, argc
, idx
);
13873 argv_find(argv
, argc
, "(1-99)", &idx
);
13874 argv_find(argv
, argc
, "(100-500)", &idx
);
13875 argv_find(argv
, argc
, "WORD", &idx
);
13877 /* Unset community list. */
13878 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
13881 /* Free temporary community list string allocated by
13884 XFREE(MTYPE_TMP
, str
);
13887 community_list_perror(vty
, ret
);
13888 return CMD_WARNING_CONFIG_FAILED
;
13891 return CMD_SUCCESS
;
13894 /* "large-community-list" keyword help string. */
13895 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
13896 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
13898 DEFUN (ip_lcommunity_list_standard
,
13899 ip_lcommunity_list_standard_cmd
,
13900 "ip large-community-list (1-99) <deny|permit>",
13902 LCOMMUNITY_LIST_STR
13903 "Large Community list number (standard)\n"
13904 "Specify large community to reject\n"
13905 "Specify large community to accept\n")
13907 return lcommunity_list_set_vty(vty
, argc
, argv
,
13908 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13911 DEFUN (ip_lcommunity_list_standard1
,
13912 ip_lcommunity_list_standard1_cmd
,
13913 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
13915 LCOMMUNITY_LIST_STR
13916 "Large Community list number (standard)\n"
13917 "Specify large community to reject\n"
13918 "Specify large community to accept\n"
13919 LCOMMUNITY_VAL_STR
)
13921 return lcommunity_list_set_vty(vty
, argc
, argv
,
13922 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13925 DEFUN (ip_lcommunity_list_expanded
,
13926 ip_lcommunity_list_expanded_cmd
,
13927 "ip large-community-list (100-500) <deny|permit> LINE...",
13929 LCOMMUNITY_LIST_STR
13930 "Large Community list number (expanded)\n"
13931 "Specify large community to reject\n"
13932 "Specify large community to accept\n"
13933 "An ordered list as a regular-expression\n")
13935 return lcommunity_list_set_vty(vty
, argc
, argv
,
13936 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
13939 DEFUN (ip_lcommunity_list_name_standard
,
13940 ip_lcommunity_list_name_standard_cmd
,
13941 "ip large-community-list standard WORD <deny|permit>",
13943 LCOMMUNITY_LIST_STR
13944 "Specify standard large-community-list\n"
13945 "Large Community list name\n"
13946 "Specify large community to reject\n"
13947 "Specify large community to accept\n")
13949 return lcommunity_list_set_vty(vty
, argc
, argv
,
13950 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13953 DEFUN (ip_lcommunity_list_name_standard1
,
13954 ip_lcommunity_list_name_standard1_cmd
,
13955 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
13957 LCOMMUNITY_LIST_STR
13958 "Specify standard large-community-list\n"
13959 "Large Community list name\n"
13960 "Specify large community to reject\n"
13961 "Specify large community to accept\n"
13962 LCOMMUNITY_VAL_STR
)
13964 return lcommunity_list_set_vty(vty
, argc
, argv
,
13965 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13968 DEFUN (ip_lcommunity_list_name_expanded
,
13969 ip_lcommunity_list_name_expanded_cmd
,
13970 "ip large-community-list expanded WORD <deny|permit> LINE...",
13972 LCOMMUNITY_LIST_STR
13973 "Specify expanded large-community-list\n"
13974 "Large Community list name\n"
13975 "Specify large community to reject\n"
13976 "Specify large community to accept\n"
13977 "An ordered list as a regular-expression\n")
13979 return lcommunity_list_set_vty(vty
, argc
, argv
,
13980 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
13983 DEFUN (no_ip_lcommunity_list_standard_all
,
13984 no_ip_lcommunity_list_standard_all_cmd
,
13985 "no ip large-community-list <(1-99)|(100-500)|WORD>",
13988 LCOMMUNITY_LIST_STR
13989 "Large Community list number (standard)\n"
13990 "Large Community list number (expanded)\n"
13991 "Large Community list name\n")
13993 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13994 LARGE_COMMUNITY_LIST_STANDARD
);
13997 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
13998 no_ip_lcommunity_list_name_expanded_all_cmd
,
13999 "no ip large-community-list expanded WORD",
14002 LCOMMUNITY_LIST_STR
14003 "Specify expanded large-community-list\n"
14004 "Large Community list name\n")
14006 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14007 LARGE_COMMUNITY_LIST_EXPANDED
);
14010 DEFUN (no_ip_lcommunity_list_standard
,
14011 no_ip_lcommunity_list_standard_cmd
,
14012 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14015 LCOMMUNITY_LIST_STR
14016 "Large Community list number (standard)\n"
14017 "Specify large community to reject\n"
14018 "Specify large community to accept\n"
14019 LCOMMUNITY_VAL_STR
)
14021 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14022 LARGE_COMMUNITY_LIST_STANDARD
);
14025 DEFUN (no_ip_lcommunity_list_expanded
,
14026 no_ip_lcommunity_list_expanded_cmd
,
14027 "no ip large-community-list (100-500) <deny|permit> LINE...",
14030 LCOMMUNITY_LIST_STR
14031 "Large Community list number (expanded)\n"
14032 "Specify large community to reject\n"
14033 "Specify large community to accept\n"
14034 "An ordered list as a regular-expression\n")
14036 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14037 LARGE_COMMUNITY_LIST_EXPANDED
);
14040 DEFUN (no_ip_lcommunity_list_name_standard
,
14041 no_ip_lcommunity_list_name_standard_cmd
,
14042 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14045 LCOMMUNITY_LIST_STR
14046 "Specify standard large-community-list\n"
14047 "Large Community list name\n"
14048 "Specify large community to reject\n"
14049 "Specify large community to accept\n"
14050 LCOMMUNITY_VAL_STR
)
14052 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14053 LARGE_COMMUNITY_LIST_STANDARD
);
14056 DEFUN (no_ip_lcommunity_list_name_expanded
,
14057 no_ip_lcommunity_list_name_expanded_cmd
,
14058 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14061 LCOMMUNITY_LIST_STR
14062 "Specify expanded large-community-list\n"
14063 "Large community list name\n"
14064 "Specify large community to reject\n"
14065 "Specify large community to accept\n"
14066 "An ordered list as a regular-expression\n")
14068 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14069 LARGE_COMMUNITY_LIST_EXPANDED
);
14072 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14074 struct community_entry
*entry
;
14076 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14077 if (entry
== list
->head
) {
14078 if (all_digit(list
->name
))
14079 vty_out(vty
, "Large community %s list %s\n",
14080 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14082 : "(expanded) access",
14086 "Named large community %s list %s\n",
14087 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14093 vty_out(vty
, " %s\n",
14094 community_direct_str(entry
->direct
));
14096 vty_out(vty
, " %s %s\n",
14097 community_direct_str(entry
->direct
),
14098 community_list_config_str(entry
));
14102 DEFUN (show_ip_lcommunity_list
,
14103 show_ip_lcommunity_list_cmd
,
14104 "show ip large-community-list",
14107 "List large-community list\n")
14109 struct community_list
*list
;
14110 struct community_list_master
*cm
;
14112 cm
= community_list_master_lookup(bgp_clist
,
14113 LARGE_COMMUNITY_LIST_MASTER
);
14115 return CMD_SUCCESS
;
14117 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14118 lcommunity_list_show(vty
, list
);
14120 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14121 lcommunity_list_show(vty
, list
);
14123 return CMD_SUCCESS
;
14126 DEFUN (show_ip_lcommunity_list_arg
,
14127 show_ip_lcommunity_list_arg_cmd
,
14128 "show ip large-community-list <(1-500)|WORD>",
14131 "List large-community list\n"
14132 "large-community-list number\n"
14133 "large-community-list name\n")
14135 struct community_list
*list
;
14137 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14138 LARGE_COMMUNITY_LIST_MASTER
);
14140 vty_out(vty
, "%% Can't find extcommunity-list\n");
14141 return CMD_WARNING
;
14144 lcommunity_list_show(vty
, list
);
14146 return CMD_SUCCESS
;
14149 /* "extcommunity-list" keyword help string. */
14150 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14151 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14153 DEFUN (ip_extcommunity_list_standard
,
14154 ip_extcommunity_list_standard_cmd
,
14155 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14157 EXTCOMMUNITY_LIST_STR
14158 "Extended Community list number (standard)\n"
14159 "Specify standard extcommunity-list\n"
14160 "Community list name\n"
14161 "Specify community to reject\n"
14162 "Specify community to accept\n"
14163 EXTCOMMUNITY_VAL_STR
)
14165 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14167 char *cl_number_or_name
= NULL
;
14170 argv_find(argv
, argc
, "(1-99)", &idx
);
14171 argv_find(argv
, argc
, "WORD", &idx
);
14172 cl_number_or_name
= argv
[idx
]->arg
;
14173 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14175 argv_find(argv
, argc
, "AA:NN", &idx
);
14176 char *str
= argv_concat(argv
, argc
, idx
);
14178 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14181 XFREE(MTYPE_TMP
, str
);
14184 community_list_perror(vty
, ret
);
14185 return CMD_WARNING_CONFIG_FAILED
;
14188 return CMD_SUCCESS
;
14191 DEFUN (ip_extcommunity_list_name_expanded
,
14192 ip_extcommunity_list_name_expanded_cmd
,
14193 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14195 EXTCOMMUNITY_LIST_STR
14196 "Extended Community list number (expanded)\n"
14197 "Specify expanded extcommunity-list\n"
14198 "Extended Community list name\n"
14199 "Specify community to reject\n"
14200 "Specify community to accept\n"
14201 "An ordered list as a regular-expression\n")
14203 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14205 char *cl_number_or_name
= NULL
;
14208 argv_find(argv
, argc
, "(100-500)", &idx
);
14209 argv_find(argv
, argc
, "WORD", &idx
);
14210 cl_number_or_name
= argv
[idx
]->arg
;
14211 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14213 argv_find(argv
, argc
, "LINE", &idx
);
14214 char *str
= argv_concat(argv
, argc
, idx
);
14216 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14219 XFREE(MTYPE_TMP
, str
);
14222 community_list_perror(vty
, ret
);
14223 return CMD_WARNING_CONFIG_FAILED
;
14226 return CMD_SUCCESS
;
14229 DEFUN (no_ip_extcommunity_list_standard_all
,
14230 no_ip_extcommunity_list_standard_all_cmd
,
14231 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14234 EXTCOMMUNITY_LIST_STR
14235 "Extended Community list number (standard)\n"
14236 "Specify standard extcommunity-list\n"
14237 "Community list name\n"
14238 "Specify community to reject\n"
14239 "Specify community to accept\n"
14240 EXTCOMMUNITY_VAL_STR
)
14242 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14244 char *cl_number_or_name
= NULL
;
14247 argv_find(argv
, argc
, "(1-99)", &idx
);
14248 argv_find(argv
, argc
, "WORD", &idx
);
14249 cl_number_or_name
= argv
[idx
]->arg
;
14250 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14252 argv_find(argv
, argc
, "AA:NN", &idx
);
14253 char *str
= argv_concat(argv
, argc
, idx
);
14255 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14258 XFREE(MTYPE_TMP
, str
);
14261 community_list_perror(vty
, ret
);
14262 return CMD_WARNING_CONFIG_FAILED
;
14265 return CMD_SUCCESS
;
14268 DEFUN (no_ip_extcommunity_list_expanded_all
,
14269 no_ip_extcommunity_list_expanded_all_cmd
,
14270 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14273 EXTCOMMUNITY_LIST_STR
14274 "Extended Community list number (expanded)\n"
14275 "Specify expanded extcommunity-list\n"
14276 "Extended Community list name\n"
14277 "Specify community to reject\n"
14278 "Specify community to accept\n"
14279 "An ordered list as a regular-expression\n")
14281 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14283 char *cl_number_or_name
= NULL
;
14286 argv_find(argv
, argc
, "(100-500)", &idx
);
14287 argv_find(argv
, argc
, "WORD", &idx
);
14288 cl_number_or_name
= argv
[idx
]->arg
;
14289 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14291 argv_find(argv
, argc
, "LINE", &idx
);
14292 char *str
= argv_concat(argv
, argc
, idx
);
14294 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14297 XFREE(MTYPE_TMP
, str
);
14300 community_list_perror(vty
, ret
);
14301 return CMD_WARNING_CONFIG_FAILED
;
14304 return CMD_SUCCESS
;
14307 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14309 struct community_entry
*entry
;
14311 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14312 if (entry
== list
->head
) {
14313 if (all_digit(list
->name
))
14314 vty_out(vty
, "Extended community %s list %s\n",
14315 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14317 : "(expanded) access",
14321 "Named extended community %s list %s\n",
14322 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14328 vty_out(vty
, " %s\n",
14329 community_direct_str(entry
->direct
));
14331 vty_out(vty
, " %s %s\n",
14332 community_direct_str(entry
->direct
),
14333 community_list_config_str(entry
));
14337 DEFUN (show_ip_extcommunity_list
,
14338 show_ip_extcommunity_list_cmd
,
14339 "show ip extcommunity-list",
14342 "List extended-community list\n")
14344 struct community_list
*list
;
14345 struct community_list_master
*cm
;
14347 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14349 return CMD_SUCCESS
;
14351 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14352 extcommunity_list_show(vty
, list
);
14354 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14355 extcommunity_list_show(vty
, list
);
14357 return CMD_SUCCESS
;
14360 DEFUN (show_ip_extcommunity_list_arg
,
14361 show_ip_extcommunity_list_arg_cmd
,
14362 "show ip extcommunity-list <(1-500)|WORD>",
14365 "List extended-community list\n"
14366 "Extcommunity-list number\n"
14367 "Extcommunity-list name\n")
14369 int idx_comm_list
= 3;
14370 struct community_list
*list
;
14372 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14373 EXTCOMMUNITY_LIST_MASTER
);
14375 vty_out(vty
, "%% Can't find extcommunity-list\n");
14376 return CMD_WARNING
;
14379 extcommunity_list_show(vty
, list
);
14381 return CMD_SUCCESS
;
14384 /* Display community-list and extcommunity-list configuration. */
14385 static int community_list_config_write(struct vty
*vty
)
14387 struct community_list
*list
;
14388 struct community_entry
*entry
;
14389 struct community_list_master
*cm
;
14392 /* Community-list. */
14393 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14395 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14396 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14397 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
14398 community_direct_str(entry
->direct
),
14399 community_list_config_str(entry
));
14402 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14403 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14404 vty_out(vty
, "ip community-list %s %s %s %s\n",
14405 entry
->style
== COMMUNITY_LIST_STANDARD
14408 list
->name
, community_direct_str(entry
->direct
),
14409 community_list_config_str(entry
));
14413 /* Extcommunity-list. */
14414 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14416 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14417 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14418 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
14419 list
->name
, community_direct_str(entry
->direct
),
14420 community_list_config_str(entry
));
14423 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14424 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14425 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
14426 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14429 list
->name
, community_direct_str(entry
->direct
),
14430 community_list_config_str(entry
));
14435 /* lcommunity-list. */
14436 cm
= community_list_master_lookup(bgp_clist
,
14437 LARGE_COMMUNITY_LIST_MASTER
);
14439 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14440 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14441 vty_out(vty
, "ip large-community-list %s %s %s\n",
14442 list
->name
, community_direct_str(entry
->direct
),
14443 community_list_config_str(entry
));
14446 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14447 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14448 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
14449 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
14452 list
->name
, community_direct_str(entry
->direct
),
14453 community_list_config_str(entry
));
14460 static struct cmd_node community_list_node
= {
14461 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
14464 static void community_list_vty(void)
14466 install_node(&community_list_node
, community_list_config_write
);
14468 /* Community-list. */
14469 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
14470 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
14471 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
14472 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
14473 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
14474 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
14476 /* Extcommunity-list. */
14477 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
14478 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
14479 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
14480 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
14481 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
14482 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
14484 /* Large Community List */
14485 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
14486 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
14487 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
14488 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
14489 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
14490 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
14491 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
14492 install_element(CONFIG_NODE
,
14493 &no_ip_lcommunity_list_name_expanded_all_cmd
);
14494 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
14495 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
14496 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
14497 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
14498 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
14499 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);