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
25 #include "lib/zclient.h"
34 #include "memory_vty.h"
40 #include "bgpd/bgpd.h"
41 #include "bgpd/bgp_attr_evpn.h"
42 #include "bgpd/bgp_advertise.h"
43 #include "bgpd/bgp_attr.h"
44 #include "bgpd/bgp_aspath.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_lcommunity.h"
48 #include "bgpd/bgp_damp.h"
49 #include "bgpd/bgp_debug.h"
50 #include "bgpd/bgp_errors.h"
51 #include "bgpd/bgp_fsm.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_open.h"
54 #include "bgpd/bgp_regex.h"
55 #include "bgpd/bgp_route.h"
56 #include "bgpd/bgp_mplsvpn.h"
57 #include "bgpd/bgp_zebra.h"
58 #include "bgpd/bgp_table.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_packet.h"
62 #include "bgpd/bgp_updgrp.h"
63 #include "bgpd/bgp_bfd.h"
64 #include "bgpd/bgp_io.h"
65 #include "bgpd/bgp_evpn.h"
66 #include "bgpd/bgp_addpath.h"
67 #include "bgpd/bgp_mac.h"
69 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
70 struct prefix
*range
, int exact
);
72 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
81 return BGP_IPV4M_NODE
;
83 case SAFI_LABELED_UNICAST
:
84 return BGP_IPV4L_NODE
;
87 return BGP_VPNV4_NODE
;
90 return BGP_FLOWSPECV4_NODE
;
100 return BGP_IPV6_NODE
;
103 return BGP_IPV6M_NODE
;
105 case SAFI_LABELED_UNICAST
:
106 return BGP_IPV6L_NODE
;
109 return BGP_VPNV6_NODE
;
112 return BGP_FLOWSPECV6_NODE
;
115 return BGP_IPV4_NODE
;
120 return BGP_EVPN_NODE
;
123 // We should never be here but to clarify the switch statement..
124 return BGP_IPV4_NODE
;
128 // Impossible to happen
129 return BGP_IPV4_NODE
;
132 /* Utility function to get address family from current node. */
133 afi_t
bgp_node_afi(struct vty
*vty
)
141 case BGP_FLOWSPECV6_NODE
:
154 /* Utility function to get subsequent address family from current
156 safi_t
bgp_node_safi(struct vty
*vty
)
162 safi
= SAFI_MPLS_VPN
;
166 safi
= SAFI_MULTICAST
;
173 safi
= SAFI_LABELED_UNICAST
;
175 case BGP_FLOWSPECV4_NODE
:
176 case BGP_FLOWSPECV6_NODE
:
177 safi
= SAFI_FLOWSPEC
;
187 * Converts an AFI in string form to afi_t
189 * @param afi string, one of
193 * @return the corresponding afi_t
195 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
197 afi_t afi
= AFI_MAX
; /* unknown */
198 if (strmatch(afi_str
, "ipv4"))
200 else if (strmatch(afi_str
, "ipv6"))
202 else if (strmatch(afi_str
, "l2vpn"))
207 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
211 if (argv_find(argv
, argc
, "ipv4", index
)) {
215 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
223 /* supports <unicast|multicast|vpn|labeled-unicast> */
224 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
226 safi_t safi
= SAFI_MAX
; /* unknown */
227 if (strmatch(safi_str
, "multicast"))
228 safi
= SAFI_MULTICAST
;
229 else if (strmatch(safi_str
, "unicast"))
231 else if (strmatch(safi_str
, "vpn"))
232 safi
= SAFI_MPLS_VPN
;
233 else if (strmatch(safi_str
, "evpn"))
235 else if (strmatch(safi_str
, "labeled-unicast"))
236 safi
= SAFI_LABELED_UNICAST
;
237 else if (strmatch(safi_str
, "flowspec"))
238 safi
= SAFI_FLOWSPEC
;
242 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
246 if (argv_find(argv
, argc
, "unicast", index
)) {
249 *safi
= SAFI_UNICAST
;
250 } else if (argv_find(argv
, argc
, "multicast", index
)) {
253 *safi
= SAFI_MULTICAST
;
254 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
257 *safi
= SAFI_LABELED_UNICAST
;
258 } else if (argv_find(argv
, argc
, "vpn", index
)) {
261 *safi
= SAFI_MPLS_VPN
;
262 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
265 *safi
= SAFI_FLOWSPEC
;
271 * bgp_vty_find_and_parse_afi_safi_bgp
273 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
274 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
275 * to appropriate values for the calling function. This is to allow the
276 * calling function to make decisions appropriate for the show command
277 * that is being parsed.
279 * The show commands are generally of the form:
280 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
281 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
283 * Since we use argv_find if the show command in particular doesn't have:
285 * [<view|vrf> VIEWVRFNAME]
286 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
287 * The command parsing should still be ok.
289 * vty -> The vty for the command so we can output some useful data in
290 * the event of a parse error in the vrf.
291 * argv -> The command tokens
292 * argc -> How many command tokens we have
293 * idx -> The current place in the command, generally should be 0 for this
295 * afi -> The parsed afi if it was included in the show command, returned here
296 * safi -> The parsed safi if it was included in the show command, returned here
297 * bgp -> Pointer to the bgp data structure we need to fill in.
298 * use_json -> json is configured or not
300 * The function returns the correct location in the parse tree for the
303 * Returns 0 for failure to parse correctly, else the idx position of where
304 * it found the last token.
306 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
307 struct cmd_token
**argv
, int argc
,
308 int *idx
, afi_t
*afi
, safi_t
*safi
,
309 struct bgp
**bgp
, bool use_json
)
311 char *vrf_name
= NULL
;
317 if (argv_find(argv
, argc
, "ip", idx
))
320 if (argv_find(argv
, argc
, "view", idx
))
321 vrf_name
= argv
[*idx
+ 1]->arg
;
322 else if (argv_find(argv
, argc
, "vrf", idx
)) {
323 vrf_name
= argv
[*idx
+ 1]->arg
;
324 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
328 if (strmatch(vrf_name
, "all"))
331 *bgp
= bgp_lookup_by_name(vrf_name
);
334 json_object
*json
= NULL
;
335 json
= json_object_new_object();
336 json_object_string_add(
338 "View/Vrf is unknown");
340 json_object_to_json_string_ext(json
,
341 JSON_C_TO_STRING_PRETTY
));
342 json_object_free(json
);
345 vty_out(vty
, "View/Vrf %s is unknown\n",
352 *bgp
= bgp_get_default();
355 json_object
*json
= NULL
;
356 json
= json_object_new_object();
357 json_object_string_add(
359 "Default BGP instance not found");
361 json_object_to_json_string_ext(json
,
362 JSON_C_TO_STRING_PRETTY
));
363 json_object_free(json
);
367 "Default BGP instance not found\n");
373 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
374 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
380 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
382 struct interface
*ifp
= NULL
;
384 if (su
->sa
.sa_family
== AF_INET
)
385 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
386 else if (su
->sa
.sa_family
== AF_INET6
)
387 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
388 su
->sin6
.sin6_scope_id
,
397 /* Utility function for looking up peer from VTY. */
398 /* This is used only for configuration, so disallow if attempted on
399 * a dynamic neighbor.
401 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
403 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
412 ret
= str2sockunion(ip_str
, &su
);
414 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
416 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
419 "%% Malformed address or name: %s\n",
425 peer
= peer_lookup(bgp
, &su
);
428 "%% Specify remote-as or peer-group commands first\n");
431 if (peer_dynamic_neighbor(peer
)) {
433 "%% Operation not allowed on a dynamic neighbor\n");
440 /* Utility function for looking up peer or peer group. */
441 /* This is used only for configuration, so disallow if attempted on
442 * a dynamic neighbor.
444 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
446 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
449 struct peer
*peer
= NULL
;
450 struct peer_group
*group
= NULL
;
456 ret
= str2sockunion(peer_str
, &su
);
458 /* IP address, locate peer. */
459 peer
= peer_lookup(bgp
, &su
);
461 /* Not IP, could match either peer configured on interface or a
463 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
465 group
= peer_group_lookup(bgp
, peer_str
);
469 if (peer_dynamic_neighbor(peer
)) {
471 "%% Operation not allowed on a dynamic neighbor\n");
481 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
486 int bgp_vty_return(struct vty
*vty
, int ret
)
488 const char *str
= NULL
;
491 case BGP_ERR_INVALID_VALUE
:
492 str
= "Invalid value";
494 case BGP_ERR_INVALID_FLAG
:
495 str
= "Invalid flag";
497 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
498 str
= "Peer-group has been shutdown. Activate the peer-group first";
500 case BGP_ERR_PEER_FLAG_CONFLICT
:
501 str
= "Can't set override-capability and strict-capability-match at the same time";
503 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
504 str
= "Specify remote-as or peer-group remote AS first";
506 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
507 str
= "Cannot change the peer-group. Deconfigure first";
509 case BGP_ERR_PEER_GROUP_MISMATCH
:
510 str
= "Peer is not a member of this peer-group";
512 case BGP_ERR_PEER_FILTER_CONFLICT
:
513 str
= "Prefix/distribute list can not co-exist";
515 case BGP_ERR_NOT_INTERNAL_PEER
:
516 str
= "Invalid command. Not an internal neighbor";
518 case BGP_ERR_REMOVE_PRIVATE_AS
:
519 str
= "remove-private-AS cannot be configured for IBGP peers";
521 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
522 str
= "Local-AS allowed only for EBGP peers";
524 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
525 str
= "Cannot have local-as same as BGP AS number";
527 case BGP_ERR_TCPSIG_FAILED
:
528 str
= "Error while applying TCP-Sig to session(s)";
530 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
531 str
= "ebgp-multihop and ttl-security cannot be configured together";
533 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
534 str
= "ttl-security only allowed for EBGP peers";
536 case BGP_ERR_AS_OVERRIDE
:
537 str
= "as-override cannot be configured for IBGP peers";
539 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
540 str
= "Invalid limit for number of dynamic neighbors";
542 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
543 str
= "Dynamic neighbor listen range already exists";
545 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
546 str
= "Operation not allowed on a dynamic neighbor";
548 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
549 str
= "Operation not allowed on a directly connected neighbor";
551 case BGP_ERR_PEER_SAFI_CONFLICT
:
552 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
556 vty_out(vty
, "%% %s\n", str
);
557 return CMD_WARNING_CONFIG_FAILED
;
562 /* BGP clear sort. */
571 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
572 safi_t safi
, int error
)
575 case BGP_ERR_AF_UNCONFIGURED
:
577 "%%BGP: Enable %s address family for the neighbor %s\n",
578 afi_safi_print(afi
, safi
), peer
->host
);
580 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
582 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
590 /* `clear ip bgp' functions. */
591 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
592 enum clear_sort sort
, enum bgp_clear_type stype
,
598 struct listnode
*node
, *nnode
;
600 /* Clear all neighbors. */
602 * Pass along pointer to next node to peer_clear() when walking all
603 * nodes on the BGP instance as that may get freed if it is a
606 if (sort
== clear_all
) {
607 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
608 if (!peer
->afc
[afi
][safi
])
611 if (stype
== BGP_CLEAR_SOFT_NONE
)
612 ret
= peer_clear(peer
, &nnode
);
614 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
617 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
622 /* This is to apply read-only mode on this clear. */
623 if (stype
== BGP_CLEAR_SOFT_NONE
)
624 bgp
->update_delay_over
= 0;
627 vty_out(vty
, "%%BGP: No %s peer configured\n",
628 afi_safi_print(afi
, safi
));
633 /* Clear specified neighbor. */
634 if (sort
== clear_peer
) {
637 /* Make sockunion for lookup. */
638 ret
= str2sockunion(arg
, &su
);
640 peer
= peer_lookup_by_conf_if(bgp
, arg
);
642 peer
= peer_lookup_by_hostname(bgp
, arg
);
645 "Malformed address or name: %s\n",
651 peer
= peer_lookup(bgp
, &su
);
654 "%%BGP: Unknown neighbor - \"%s\"\n",
660 if (!peer
->afc
[afi
][safi
])
661 ret
= BGP_ERR_AF_UNCONFIGURED
;
662 else if (stype
== BGP_CLEAR_SOFT_NONE
)
663 ret
= peer_clear(peer
, NULL
);
665 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
668 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
673 /* Clear all neighbors belonging to a specific peer-group. */
674 if (sort
== clear_group
) {
675 struct peer_group
*group
;
677 group
= peer_group_lookup(bgp
, arg
);
679 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
683 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
684 if (!peer
->afc
[afi
][safi
])
687 if (stype
== BGP_CLEAR_SOFT_NONE
)
688 ret
= peer_clear(peer
, NULL
);
690 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
693 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
700 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
701 afi_safi_print(afi
, safi
), arg
);
706 /* Clear all external (eBGP) neighbors. */
707 if (sort
== clear_external
) {
708 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
709 if (peer
->sort
== BGP_PEER_IBGP
)
712 if (!peer
->afc
[afi
][safi
])
715 if (stype
== BGP_CLEAR_SOFT_NONE
)
716 ret
= peer_clear(peer
, &nnode
);
718 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
721 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
728 "%%BGP: No external %s peer is configured\n",
729 afi_safi_print(afi
, safi
));
734 /* Clear all neighbors belonging to a specific AS. */
735 if (sort
== clear_as
) {
736 as_t as
= strtoul(arg
, NULL
, 10);
738 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
742 if (!peer
->afc
[afi
][safi
])
743 ret
= BGP_ERR_AF_UNCONFIGURED
;
744 else if (stype
== BGP_CLEAR_SOFT_NONE
)
745 ret
= peer_clear(peer
, &nnode
);
747 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
750 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
757 "%%BGP: No %s peer is configured with AS %s\n",
758 afi_safi_print(afi
, safi
), arg
);
766 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
767 safi_t safi
, enum clear_sort sort
,
768 enum bgp_clear_type stype
, const char *arg
)
772 /* BGP structure lookup. */
774 bgp
= bgp_lookup_by_name(name
);
776 vty_out(vty
, "Can't find BGP instance %s\n", name
);
780 bgp
= bgp_get_default();
782 vty_out(vty
, "No BGP process is configured\n");
787 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
790 /* clear soft inbound */
791 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
796 FOREACH_AFI_SAFI (afi
, safi
)
797 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
798 BGP_CLEAR_SOFT_IN
, NULL
);
801 /* clear soft outbound */
802 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
807 FOREACH_AFI_SAFI (afi
, safi
)
808 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
809 BGP_CLEAR_SOFT_OUT
, NULL
);
813 #ifndef VTYSH_EXTRACT_PL
814 #include "bgpd/bgp_vty_clippy.c"
817 /* BGP global configuration. */
818 #if (CONFDATE > 20190601)
819 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
820 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
822 DEFUN_HIDDEN (bgp_multiple_instance_func
,
823 bgp_multiple_instance_cmd
,
824 "bgp multiple-instance",
826 "Enable bgp multiple instance\n")
828 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
832 DEFUN_HIDDEN (no_bgp_multiple_instance
,
833 no_bgp_multiple_instance_cmd
,
834 "no bgp multiple-instance",
837 "BGP multiple instance\n")
841 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
842 vty_out(vty
, "if you are using this please let the developers know\n");
843 zlog_info("Deprecated option: `bgp multiple-instance` being used");
844 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
846 vty_out(vty
, "%% There are more than two BGP instances\n");
847 return CMD_WARNING_CONFIG_FAILED
;
852 DEFUN_HIDDEN (bgp_local_mac
,
854 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
857 "VxLAN Network Identifier\n"
861 "mac-mobility sequence\n"
871 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
872 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
873 vty_out(vty
, "%% Malformed MAC address\n");
876 memset(&ip
, 0, sizeof(ip
));
877 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
879 bgp
= bgp_get_default();
881 vty_out(vty
, "Default BGP instance is not there\n");
885 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
887 vty_out(vty
, "Internal error\n");
894 DEFUN_HIDDEN (no_bgp_local_mac
,
895 no_bgp_local_mac_cmd
,
896 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
900 "VxLAN Network Identifier\n"
911 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
912 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
913 vty_out(vty
, "%% Malformed MAC address\n");
916 memset(&ip
, 0, sizeof(ip
));
918 bgp
= bgp_get_default();
920 vty_out(vty
, "Default BGP instance is not there\n");
924 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
926 vty_out(vty
, "Internal error\n");
933 #if (CONFDATE > 20190601)
934 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
935 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
937 DEFUN_HIDDEN (bgp_config_type
,
939 "bgp config-type <cisco|zebra>",
941 "Configuration type\n"
946 if (argv_find(argv
, argc
, "cisco", &idx
)) {
947 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
948 vty_out(vty
, "if you are using this please let the developers know!\n");
949 zlog_info("Deprecated option: `bgp config-type cisco` being used");
950 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
952 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
957 DEFUN_HIDDEN (no_bgp_config_type
,
958 no_bgp_config_type_cmd
,
959 "no bgp config-type [<cisco|zebra>]",
962 "Display configuration type\n"
966 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
971 DEFUN (no_synchronization
,
972 no_synchronization_cmd
,
973 "no synchronization",
975 "Perform IGP synchronization\n")
980 DEFUN (no_auto_summary
,
984 "Enable automatic network number summarization\n")
989 /* "router bgp" commands. */
990 DEFUN_NOSH (router_bgp
,
992 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
996 BGP_INSTANCE_HELP_STR
)
999 int idx_view_vrf
= 3;
1005 const char *name
= NULL
;
1006 enum bgp_instance_type inst_type
;
1008 // "router bgp" without an ASN
1010 // Pending: Make VRF option available for ASN less config
1011 bgp
= bgp_get_default();
1014 vty_out(vty
, "%% No BGP process is configured\n");
1015 return CMD_WARNING_CONFIG_FAILED
;
1018 if (listcount(bm
->bgp
) > 1) {
1019 vty_out(vty
, "%% Please specify ASN and VRF\n");
1020 return CMD_WARNING_CONFIG_FAILED
;
1026 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1028 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1030 name
= argv
[idx_vrf
]->arg
;
1032 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1033 if (strmatch(name
, VRF_DEFAULT_NAME
))
1036 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1037 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1038 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1041 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1042 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1044 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
1046 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
1048 "Please specify 'bgp multiple-instance' first\n");
1049 return CMD_WARNING_CONFIG_FAILED
;
1050 case BGP_ERR_AS_MISMATCH
:
1051 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1052 return CMD_WARNING_CONFIG_FAILED
;
1053 case BGP_ERR_INSTANCE_MISMATCH
:
1055 "BGP instance name and AS number mismatch\n");
1057 "BGP instance is already running; AS is %u\n",
1059 return CMD_WARNING_CONFIG_FAILED
;
1063 * If we just instantiated the default instance, complete
1064 * any pending VRF-VPN leaking that was configured via
1065 * earlier "router bgp X vrf FOO" blocks.
1067 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1068 vpn_leak_postchange_all();
1070 /* Pending: handle when user tries to change a view to vrf n vv.
1074 /* unset the auto created flag as the user config is now present */
1075 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1076 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1081 /* "no router bgp" commands. */
1082 DEFUN (no_router_bgp
,
1084 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
1089 BGP_INSTANCE_HELP_STR
)
1095 const char *name
= NULL
;
1097 // "no router bgp" without an ASN
1099 // Pending: Make VRF option available for ASN less config
1100 bgp
= bgp_get_default();
1103 vty_out(vty
, "%% No BGP process is configured\n");
1104 return CMD_WARNING_CONFIG_FAILED
;
1107 if (listcount(bm
->bgp
) > 1) {
1108 vty_out(vty
, "%% Please specify ASN and VRF\n");
1109 return CMD_WARNING_CONFIG_FAILED
;
1113 vty_out(vty
, "%% Please unconfigure l3vni %u",
1115 return CMD_WARNING_CONFIG_FAILED
;
1118 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1121 name
= argv
[idx_vrf
]->arg
;
1123 /* Lookup bgp structure. */
1124 bgp
= bgp_lookup(as
, name
);
1126 vty_out(vty
, "%% Can't find BGP instance\n");
1127 return CMD_WARNING_CONFIG_FAILED
;
1131 vty_out(vty
, "%% Please unconfigure l3vni %u",
1133 return CMD_WARNING_CONFIG_FAILED
;
1143 /* BGP router-id. */
1145 DEFPY (bgp_router_id
,
1147 "bgp router-id A.B.C.D",
1149 "Override configured router identifier\n"
1150 "Manually configured router identifier\n")
1152 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1153 bgp_router_id_static_set(bgp
, router_id
);
1157 DEFPY (no_bgp_router_id
,
1158 no_bgp_router_id_cmd
,
1159 "no bgp router-id [A.B.C.D]",
1162 "Override configured router identifier\n"
1163 "Manually configured router identifier\n")
1165 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1167 if (router_id_str
) {
1168 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1169 vty_out(vty
, "%% BGP router-id doesn't match\n");
1170 return CMD_WARNING_CONFIG_FAILED
;
1174 router_id
.s_addr
= 0;
1175 bgp_router_id_static_set(bgp
, router_id
);
1181 /* BGP Cluster ID. */
1182 DEFUN (bgp_cluster_id
,
1184 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1186 "Configure Route-Reflector Cluster-id\n"
1187 "Route-Reflector Cluster-id in IP address format\n"
1188 "Route-Reflector Cluster-id as 32 bit quantity\n")
1190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1193 struct in_addr cluster
;
1195 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1197 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1198 return CMD_WARNING_CONFIG_FAILED
;
1201 bgp_cluster_id_set(bgp
, &cluster
);
1202 bgp_clear_star_soft_out(vty
, bgp
->name
);
1207 DEFUN (no_bgp_cluster_id
,
1208 no_bgp_cluster_id_cmd
,
1209 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1212 "Configure Route-Reflector Cluster-id\n"
1213 "Route-Reflector Cluster-id in IP address format\n"
1214 "Route-Reflector Cluster-id as 32 bit quantity\n")
1216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1217 bgp_cluster_id_unset(bgp
);
1218 bgp_clear_star_soft_out(vty
, bgp
->name
);
1223 DEFUN (bgp_confederation_identifier
,
1224 bgp_confederation_identifier_cmd
,
1225 "bgp confederation identifier (1-4294967295)",
1226 "BGP specific commands\n"
1227 "AS confederation parameters\n"
1229 "Set routing domain confederation AS\n")
1231 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1235 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1237 bgp_confederation_id_set(bgp
, as
);
1242 DEFUN (no_bgp_confederation_identifier
,
1243 no_bgp_confederation_identifier_cmd
,
1244 "no bgp confederation identifier [(1-4294967295)]",
1246 "BGP specific commands\n"
1247 "AS confederation parameters\n"
1249 "Set routing domain confederation AS\n")
1251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1252 bgp_confederation_id_unset(bgp
);
1257 DEFUN (bgp_confederation_peers
,
1258 bgp_confederation_peers_cmd
,
1259 "bgp confederation peers (1-4294967295)...",
1260 "BGP specific commands\n"
1261 "AS confederation parameters\n"
1262 "Peer ASs in BGP confederation\n"
1265 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1270 for (i
= idx_asn
; i
< argc
; i
++) {
1271 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1273 if (bgp
->as
== as
) {
1275 "%% Local member-AS not allowed in confed peer list\n");
1279 bgp_confederation_peers_add(bgp
, as
);
1284 DEFUN (no_bgp_confederation_peers
,
1285 no_bgp_confederation_peers_cmd
,
1286 "no bgp confederation peers (1-4294967295)...",
1288 "BGP specific commands\n"
1289 "AS confederation parameters\n"
1290 "Peer ASs in BGP confederation\n"
1293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1298 for (i
= idx_asn
; i
< argc
; i
++) {
1299 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1301 bgp_confederation_peers_remove(bgp
, as
);
1307 * Central routine for maximum-paths configuration.
1308 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1309 * @set: 1 for setting values, 0 for removing the max-paths config.
1311 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1312 const char *mpaths
, uint16_t options
,
1315 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1316 uint16_t maxpaths
= 0;
1321 afi
= bgp_node_afi(vty
);
1322 safi
= bgp_node_safi(vty
);
1325 maxpaths
= strtol(mpaths
, NULL
, 10);
1326 if (maxpaths
> multipath_num
) {
1328 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1329 maxpaths
, multipath_num
);
1330 return CMD_WARNING_CONFIG_FAILED
;
1332 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1335 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1339 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1340 (set
== 1) ? "" : "un",
1341 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1342 maxpaths
, afi
, safi
);
1343 return CMD_WARNING_CONFIG_FAILED
;
1346 bgp_recalculate_all_bestpaths(bgp
);
1351 DEFUN (bgp_maxmed_admin
,
1352 bgp_maxmed_admin_cmd
,
1353 "bgp max-med administrative ",
1355 "Advertise routes with max-med\n"
1356 "Administratively applied, for an indefinite period\n")
1358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1360 bgp
->v_maxmed_admin
= 1;
1361 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1363 bgp_maxmed_update(bgp
);
1368 DEFUN (bgp_maxmed_admin_medv
,
1369 bgp_maxmed_admin_medv_cmd
,
1370 "bgp max-med administrative (0-4294967295)",
1372 "Advertise routes with max-med\n"
1373 "Administratively applied, for an indefinite period\n"
1374 "Max MED value to be used\n")
1376 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1379 bgp
->v_maxmed_admin
= 1;
1380 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1382 bgp_maxmed_update(bgp
);
1387 DEFUN (no_bgp_maxmed_admin
,
1388 no_bgp_maxmed_admin_cmd
,
1389 "no bgp max-med administrative [(0-4294967295)]",
1392 "Advertise routes with max-med\n"
1393 "Administratively applied, for an indefinite period\n"
1394 "Max MED value to be used\n")
1396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1397 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1398 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1399 bgp_maxmed_update(bgp
);
1404 DEFUN (bgp_maxmed_onstartup
,
1405 bgp_maxmed_onstartup_cmd
,
1406 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1408 "Advertise routes with max-med\n"
1409 "Effective on a startup\n"
1410 "Time (seconds) period for max-med\n"
1411 "Max MED value to be used\n")
1413 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1416 argv_find(argv
, argc
, "(5-86400)", &idx
);
1417 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1418 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1419 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1421 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1423 bgp_maxmed_update(bgp
);
1428 DEFUN (no_bgp_maxmed_onstartup
,
1429 no_bgp_maxmed_onstartup_cmd
,
1430 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1433 "Advertise routes with max-med\n"
1434 "Effective on a startup\n"
1435 "Time (seconds) period for max-med\n"
1436 "Max MED value to be used\n")
1438 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1440 /* Cancel max-med onstartup if its on */
1441 if (bgp
->t_maxmed_onstartup
) {
1442 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1443 bgp
->maxmed_onstartup_over
= 1;
1446 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1447 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1449 bgp_maxmed_update(bgp
);
1454 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1457 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1458 uint16_t update_delay
;
1459 uint16_t establish_wait
;
1461 update_delay
= strtoul(delay
, NULL
, 10);
1463 if (!wait
) /* update-delay <delay> */
1465 bgp
->v_update_delay
= update_delay
;
1466 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1470 /* update-delay <delay> <establish-wait> */
1471 establish_wait
= atoi(wait
);
1472 if (update_delay
< establish_wait
) {
1474 "%%Failed: update-delay less than the establish-wait!\n");
1475 return CMD_WARNING_CONFIG_FAILED
;
1478 bgp
->v_update_delay
= update_delay
;
1479 bgp
->v_establish_wait
= establish_wait
;
1484 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1486 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1488 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1489 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1494 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1496 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1497 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1498 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1499 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1505 /* Update-delay configuration */
1506 DEFUN (bgp_update_delay
,
1507 bgp_update_delay_cmd
,
1508 "update-delay (0-3600)",
1509 "Force initial delay for best-path and updates\n"
1513 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1516 DEFUN (bgp_update_delay_establish_wait
,
1517 bgp_update_delay_establish_wait_cmd
,
1518 "update-delay (0-3600) (1-3600)",
1519 "Force initial delay for best-path and updates\n"
1524 int idx_number_2
= 2;
1525 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1526 argv
[idx_number_2
]->arg
);
1529 /* Update-delay deconfiguration */
1530 DEFUN (no_bgp_update_delay
,
1531 no_bgp_update_delay_cmd
,
1532 "no update-delay [(0-3600) [(1-3600)]]",
1534 "Force initial delay for best-path and updates\n"
1538 return bgp_update_delay_deconfig_vty(vty
);
1542 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1545 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1548 uint32_t quanta
= strtoul(num
, NULL
, 10);
1549 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1550 memory_order_relaxed
);
1552 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1553 memory_order_relaxed
);
1559 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1562 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1565 uint32_t quanta
= strtoul(num
, NULL
, 10);
1566 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1567 memory_order_relaxed
);
1569 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1570 memory_order_relaxed
);
1576 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1579 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1580 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1581 vty_out(vty
, " write-quanta %d\n", quanta
);
1584 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1587 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1588 if (quanta
!= BGP_READ_PACKET_MAX
)
1589 vty_out(vty
, " read-quanta %d\n", quanta
);
1592 /* Packet quanta configuration */
1593 DEFUN (bgp_wpkt_quanta
,
1594 bgp_wpkt_quanta_cmd
,
1595 "write-quanta (1-10)",
1596 "How many packets to write to peer socket per run\n"
1597 "Number of packets\n")
1600 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1603 DEFUN (no_bgp_wpkt_quanta
,
1604 no_bgp_wpkt_quanta_cmd
,
1605 "no write-quanta (1-10)",
1607 "How many packets to write to peer socket per I/O cycle\n"
1608 "Number of packets\n")
1611 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1614 DEFUN (bgp_rpkt_quanta
,
1615 bgp_rpkt_quanta_cmd
,
1616 "read-quanta (1-10)",
1617 "How many packets to read from peer socket per I/O cycle\n"
1618 "Number of packets\n")
1621 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1624 DEFUN (no_bgp_rpkt_quanta
,
1625 no_bgp_rpkt_quanta_cmd
,
1626 "no read-quanta (1-10)",
1628 "How many packets to read from peer socket per I/O cycle\n"
1629 "Number of packets\n")
1632 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1635 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1637 if (!bgp
->heuristic_coalesce
)
1638 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1642 DEFUN (bgp_coalesce_time
,
1643 bgp_coalesce_time_cmd
,
1644 "coalesce-time (0-4294967295)",
1645 "Subgroup coalesce timer\n"
1646 "Subgroup coalesce timer value (in ms)\n")
1648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1651 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1652 bgp
->heuristic_coalesce
= false;
1653 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1657 DEFUN (no_bgp_coalesce_time
,
1658 no_bgp_coalesce_time_cmd
,
1659 "no coalesce-time (0-4294967295)",
1661 "Subgroup coalesce timer\n"
1662 "Subgroup coalesce timer value (in ms)\n")
1664 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1666 bgp
->heuristic_coalesce
= true;
1667 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1671 /* Maximum-paths configuration */
1672 DEFUN (bgp_maxpaths
,
1674 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1675 "Forward packets over multiple paths\n"
1676 "Number of paths\n")
1679 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1680 argv
[idx_number
]->arg
, 0, 1);
1683 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1684 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1685 "Forward packets over multiple paths\n"
1686 "Number of paths\n")
1688 DEFUN (bgp_maxpaths_ibgp
,
1689 bgp_maxpaths_ibgp_cmd
,
1690 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1691 "Forward packets over multiple paths\n"
1693 "Number of paths\n")
1696 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1697 argv
[idx_number
]->arg
, 0, 1);
1700 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1701 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1702 "Forward packets over multiple paths\n"
1704 "Number of paths\n")
1706 DEFUN (bgp_maxpaths_ibgp_cluster
,
1707 bgp_maxpaths_ibgp_cluster_cmd
,
1708 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1709 "Forward packets over multiple paths\n"
1712 "Match the cluster length\n")
1715 return bgp_maxpaths_config_vty(
1716 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1717 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1720 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1721 "maximum-paths ibgp " CMD_RANGE_STR(
1722 1, MULTIPATH_NUM
) " equal-cluster-length",
1723 "Forward packets over multiple paths\n"
1726 "Match the cluster length\n")
1728 DEFUN (no_bgp_maxpaths
,
1729 no_bgp_maxpaths_cmd
,
1730 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1732 "Forward packets over multiple paths\n"
1733 "Number of paths\n")
1735 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1738 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1739 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1740 "Forward packets over multiple paths\n"
1741 "Number of paths\n")
1743 DEFUN (no_bgp_maxpaths_ibgp
,
1744 no_bgp_maxpaths_ibgp_cmd
,
1745 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1747 "Forward packets over multiple paths\n"
1750 "Match the cluster length\n")
1752 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1755 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1756 "no maximum-paths ibgp [" CMD_RANGE_STR(
1757 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1759 "Forward packets over multiple paths\n"
1762 "Match the cluster length\n")
1764 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1767 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1768 vty_out(vty
, " maximum-paths %d\n",
1769 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1772 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1773 vty_out(vty
, " maximum-paths ibgp %d",
1774 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1775 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1776 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1777 vty_out(vty
, " equal-cluster-length");
1786 "timers bgp (0-65535) (0-65535)",
1787 "Adjust routing timers\n"
1789 "Keepalive interval\n"
1792 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1794 int idx_number_2
= 3;
1795 unsigned long keepalive
= 0;
1796 unsigned long holdtime
= 0;
1798 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1799 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1801 /* Holdtime value check. */
1802 if (holdtime
< 3 && holdtime
!= 0) {
1804 "%% hold time value must be either 0 or greater than 3\n");
1805 return CMD_WARNING_CONFIG_FAILED
;
1808 bgp_timers_set(bgp
, keepalive
, holdtime
);
1813 DEFUN (no_bgp_timers
,
1815 "no timers bgp [(0-65535) (0-65535)]",
1817 "Adjust routing timers\n"
1819 "Keepalive interval\n"
1822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1823 bgp_timers_unset(bgp
);
1829 DEFUN (bgp_client_to_client_reflection
,
1830 bgp_client_to_client_reflection_cmd
,
1831 "bgp client-to-client reflection",
1832 "BGP specific commands\n"
1833 "Configure client to client route reflection\n"
1834 "reflection of routes allowed\n")
1836 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1837 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1838 bgp_clear_star_soft_out(vty
, bgp
->name
);
1843 DEFUN (no_bgp_client_to_client_reflection
,
1844 no_bgp_client_to_client_reflection_cmd
,
1845 "no bgp client-to-client reflection",
1847 "BGP specific commands\n"
1848 "Configure client to client route reflection\n"
1849 "reflection of routes allowed\n")
1851 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1852 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1853 bgp_clear_star_soft_out(vty
, bgp
->name
);
1858 /* "bgp always-compare-med" configuration. */
1859 DEFUN (bgp_always_compare_med
,
1860 bgp_always_compare_med_cmd
,
1861 "bgp always-compare-med",
1862 "BGP specific commands\n"
1863 "Allow comparing MED from different neighbors\n")
1865 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1866 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1867 bgp_recalculate_all_bestpaths(bgp
);
1872 DEFUN (no_bgp_always_compare_med
,
1873 no_bgp_always_compare_med_cmd
,
1874 "no bgp always-compare-med",
1876 "BGP specific commands\n"
1877 "Allow comparing MED from different neighbors\n")
1879 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1880 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1881 bgp_recalculate_all_bestpaths(bgp
);
1887 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1888 "bgp ebgp-requires-policy",
1889 "BGP specific commands\n"
1890 "Require in and out policy for eBGP peers (RFC8212)\n")
1892 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1893 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1897 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1898 "no bgp ebgp-requires-policy",
1900 "BGP specific commands\n"
1901 "Require in and out policy for eBGP peers (RFC8212)\n")
1903 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1904 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1909 /* "bgp deterministic-med" configuration. */
1910 DEFUN (bgp_deterministic_med
,
1911 bgp_deterministic_med_cmd
,
1912 "bgp deterministic-med",
1913 "BGP specific commands\n"
1914 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1918 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1919 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1920 bgp_recalculate_all_bestpaths(bgp
);
1926 DEFUN (no_bgp_deterministic_med
,
1927 no_bgp_deterministic_med_cmd
,
1928 "no bgp deterministic-med",
1930 "BGP specific commands\n"
1931 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1933 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1934 int bestpath_per_as_used
;
1938 struct listnode
*node
, *nnode
;
1940 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1941 bestpath_per_as_used
= 0;
1943 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1944 FOREACH_AFI_SAFI (afi
, safi
)
1945 if (bgp_addpath_dmed_required(
1946 peer
->addpath_type
[afi
][safi
])) {
1947 bestpath_per_as_used
= 1;
1951 if (bestpath_per_as_used
)
1955 if (bestpath_per_as_used
) {
1957 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1958 return CMD_WARNING_CONFIG_FAILED
;
1960 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1961 bgp_recalculate_all_bestpaths(bgp
);
1968 /* "bgp graceful-restart" configuration. */
1969 DEFUN (bgp_graceful_restart
,
1970 bgp_graceful_restart_cmd
,
1971 "bgp graceful-restart",
1972 "BGP specific commands\n"
1973 "Graceful restart capability parameters\n")
1975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1976 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1980 DEFUN (no_bgp_graceful_restart
,
1981 no_bgp_graceful_restart_cmd
,
1982 "no bgp graceful-restart",
1984 "BGP specific commands\n"
1985 "Graceful restart capability parameters\n")
1987 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1988 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1992 DEFUN (bgp_graceful_restart_stalepath_time
,
1993 bgp_graceful_restart_stalepath_time_cmd
,
1994 "bgp graceful-restart stalepath-time (1-4095)",
1995 "BGP specific commands\n"
1996 "Graceful restart capability parameters\n"
1997 "Set the max time to hold onto restarting peer's stale paths\n"
1998 "Delay value (seconds)\n")
2000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2005 bgp
->stalepath_time
= stalepath
;
2009 DEFUN (bgp_graceful_restart_restart_time
,
2010 bgp_graceful_restart_restart_time_cmd
,
2011 "bgp graceful-restart restart-time (1-4095)",
2012 "BGP specific commands\n"
2013 "Graceful restart capability parameters\n"
2014 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2015 "Delay value (seconds)\n")
2017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2021 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2022 bgp
->restart_time
= restart
;
2026 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2027 no_bgp_graceful_restart_stalepath_time_cmd
,
2028 "no bgp graceful-restart stalepath-time [(1-4095)]",
2030 "BGP specific commands\n"
2031 "Graceful restart capability parameters\n"
2032 "Set the max time to hold onto restarting peer's stale paths\n"
2033 "Delay value (seconds)\n")
2035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2037 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2041 DEFUN (no_bgp_graceful_restart_restart_time
,
2042 no_bgp_graceful_restart_restart_time_cmd
,
2043 "no bgp graceful-restart restart-time [(1-4095)]",
2045 "BGP specific commands\n"
2046 "Graceful restart capability parameters\n"
2047 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2048 "Delay value (seconds)\n")
2050 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2052 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2056 DEFUN (bgp_graceful_restart_preserve_fw
,
2057 bgp_graceful_restart_preserve_fw_cmd
,
2058 "bgp graceful-restart preserve-fw-state",
2059 "BGP specific commands\n"
2060 "Graceful restart capability parameters\n"
2061 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2064 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2068 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2069 no_bgp_graceful_restart_preserve_fw_cmd
,
2070 "no bgp graceful-restart preserve-fw-state",
2072 "BGP specific commands\n"
2073 "Graceful restart capability parameters\n"
2074 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2076 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2077 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2081 /* "bgp graceful-shutdown" configuration */
2082 DEFUN (bgp_graceful_shutdown
,
2083 bgp_graceful_shutdown_cmd
,
2084 "bgp graceful-shutdown",
2086 "Graceful shutdown parameters\n")
2088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2090 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2091 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2092 bgp_static_redo_import_check(bgp
);
2093 bgp_redistribute_redo(bgp
);
2094 bgp_clear_star_soft_out(vty
, bgp
->name
);
2095 bgp_clear_star_soft_in(vty
, bgp
->name
);
2101 DEFUN (no_bgp_graceful_shutdown
,
2102 no_bgp_graceful_shutdown_cmd
,
2103 "no bgp graceful-shutdown",
2106 "Graceful shutdown parameters\n")
2108 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2110 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2111 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2112 bgp_static_redo_import_check(bgp
);
2113 bgp_redistribute_redo(bgp
);
2114 bgp_clear_star_soft_out(vty
, bgp
->name
);
2115 bgp_clear_star_soft_in(vty
, bgp
->name
);
2121 /* "bgp fast-external-failover" configuration. */
2122 DEFUN (bgp_fast_external_failover
,
2123 bgp_fast_external_failover_cmd
,
2124 "bgp fast-external-failover",
2126 "Immediately reset session if a link to a directly connected external peer goes down\n")
2128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2129 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2133 DEFUN (no_bgp_fast_external_failover
,
2134 no_bgp_fast_external_failover_cmd
,
2135 "no bgp fast-external-failover",
2138 "Immediately reset session if a link to a directly connected external peer goes down\n")
2140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2141 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2145 /* "bgp enforce-first-as" configuration. */
2146 #if CONFDATE > 20190517
2147 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2150 DEFUN_HIDDEN (bgp_enforce_first_as
,
2151 bgp_enforce_first_as_cmd
,
2152 "[no] bgp enforce-first-as",
2155 "Enforce the first AS for EBGP routes\n")
2157 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2159 if (strmatch(argv
[0]->text
, "no"))
2160 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2162 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2167 /* "bgp bestpath compare-routerid" configuration. */
2168 DEFUN (bgp_bestpath_compare_router_id
,
2169 bgp_bestpath_compare_router_id_cmd
,
2170 "bgp bestpath compare-routerid",
2171 "BGP specific commands\n"
2172 "Change the default bestpath selection\n"
2173 "Compare router-id for identical EBGP paths\n")
2175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2176 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2177 bgp_recalculate_all_bestpaths(bgp
);
2182 DEFUN (no_bgp_bestpath_compare_router_id
,
2183 no_bgp_bestpath_compare_router_id_cmd
,
2184 "no bgp bestpath compare-routerid",
2186 "BGP specific commands\n"
2187 "Change the default bestpath selection\n"
2188 "Compare router-id for identical EBGP paths\n")
2190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2191 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2192 bgp_recalculate_all_bestpaths(bgp
);
2197 /* "bgp bestpath as-path ignore" configuration. */
2198 DEFUN (bgp_bestpath_aspath_ignore
,
2199 bgp_bestpath_aspath_ignore_cmd
,
2200 "bgp bestpath as-path ignore",
2201 "BGP specific commands\n"
2202 "Change the default bestpath selection\n"
2203 "AS-path attribute\n"
2204 "Ignore as-path length in selecting a route\n")
2206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2207 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2208 bgp_recalculate_all_bestpaths(bgp
);
2213 DEFUN (no_bgp_bestpath_aspath_ignore
,
2214 no_bgp_bestpath_aspath_ignore_cmd
,
2215 "no bgp bestpath as-path ignore",
2217 "BGP specific commands\n"
2218 "Change the default bestpath selection\n"
2219 "AS-path attribute\n"
2220 "Ignore as-path length in selecting a route\n")
2222 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2223 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2224 bgp_recalculate_all_bestpaths(bgp
);
2229 /* "bgp bestpath as-path confed" configuration. */
2230 DEFUN (bgp_bestpath_aspath_confed
,
2231 bgp_bestpath_aspath_confed_cmd
,
2232 "bgp bestpath as-path confed",
2233 "BGP specific commands\n"
2234 "Change the default bestpath selection\n"
2235 "AS-path attribute\n"
2236 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2239 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2240 bgp_recalculate_all_bestpaths(bgp
);
2245 DEFUN (no_bgp_bestpath_aspath_confed
,
2246 no_bgp_bestpath_aspath_confed_cmd
,
2247 "no bgp bestpath as-path confed",
2249 "BGP specific commands\n"
2250 "Change the default bestpath selection\n"
2251 "AS-path attribute\n"
2252 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2254 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2255 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2256 bgp_recalculate_all_bestpaths(bgp
);
2261 /* "bgp bestpath as-path multipath-relax" configuration. */
2262 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2263 bgp_bestpath_aspath_multipath_relax_cmd
,
2264 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2265 "BGP specific commands\n"
2266 "Change the default bestpath selection\n"
2267 "AS-path attribute\n"
2268 "Allow load sharing across routes that have different AS paths (but same length)\n"
2269 "Generate an AS_SET\n"
2270 "Do not generate an AS_SET\n")
2272 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2274 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2276 /* no-as-set is now the default behavior so we can silently
2278 if (argv_find(argv
, argc
, "as-set", &idx
))
2279 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2281 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2283 bgp_recalculate_all_bestpaths(bgp
);
2288 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2289 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2290 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2292 "BGP specific commands\n"
2293 "Change the default bestpath selection\n"
2294 "AS-path attribute\n"
2295 "Allow load sharing across routes that have different AS paths (but same length)\n"
2296 "Generate an AS_SET\n"
2297 "Do not generate an AS_SET\n")
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2300 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2301 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2302 bgp_recalculate_all_bestpaths(bgp
);
2307 /* "bgp log-neighbor-changes" configuration. */
2308 DEFUN (bgp_log_neighbor_changes
,
2309 bgp_log_neighbor_changes_cmd
,
2310 "bgp log-neighbor-changes",
2311 "BGP specific commands\n"
2312 "Log neighbor up/down and reset reason\n")
2314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2315 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2319 DEFUN (no_bgp_log_neighbor_changes
,
2320 no_bgp_log_neighbor_changes_cmd
,
2321 "no bgp log-neighbor-changes",
2323 "BGP specific commands\n"
2324 "Log neighbor up/down and reset reason\n")
2326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2327 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2331 /* "bgp bestpath med" configuration. */
2332 DEFUN (bgp_bestpath_med
,
2333 bgp_bestpath_med_cmd
,
2334 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2335 "BGP specific commands\n"
2336 "Change the default bestpath selection\n"
2338 "Compare MED among confederation paths\n"
2339 "Treat missing MED as the least preferred one\n"
2340 "Treat missing MED as the least preferred one\n"
2341 "Compare MED among confederation paths\n")
2343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2346 if (argv_find(argv
, argc
, "confed", &idx
))
2347 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2349 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2350 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2352 bgp_recalculate_all_bestpaths(bgp
);
2357 DEFUN (no_bgp_bestpath_med
,
2358 no_bgp_bestpath_med_cmd
,
2359 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2361 "BGP specific commands\n"
2362 "Change the default bestpath selection\n"
2364 "Compare MED among confederation paths\n"
2365 "Treat missing MED as the least preferred one\n"
2366 "Treat missing MED as the least preferred one\n"
2367 "Compare MED among confederation paths\n")
2369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2372 if (argv_find(argv
, argc
, "confed", &idx
))
2373 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2375 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2376 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2378 bgp_recalculate_all_bestpaths(bgp
);
2383 /* "no bgp default ipv4-unicast". */
2384 DEFUN (no_bgp_default_ipv4_unicast
,
2385 no_bgp_default_ipv4_unicast_cmd
,
2386 "no bgp default ipv4-unicast",
2388 "BGP specific commands\n"
2389 "Configure BGP defaults\n"
2390 "Activate ipv4-unicast for a peer by default\n")
2392 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2393 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2397 DEFUN (bgp_default_ipv4_unicast
,
2398 bgp_default_ipv4_unicast_cmd
,
2399 "bgp default ipv4-unicast",
2400 "BGP specific commands\n"
2401 "Configure BGP defaults\n"
2402 "Activate ipv4-unicast for a peer by default\n")
2404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2405 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2409 /* Display hostname in certain command outputs */
2410 DEFUN (bgp_default_show_hostname
,
2411 bgp_default_show_hostname_cmd
,
2412 "bgp default show-hostname",
2413 "BGP specific commands\n"
2414 "Configure BGP defaults\n"
2415 "Show hostname in certain command outputs\n")
2417 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2418 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2422 DEFUN (no_bgp_default_show_hostname
,
2423 no_bgp_default_show_hostname_cmd
,
2424 "no bgp default show-hostname",
2426 "BGP specific commands\n"
2427 "Configure BGP defaults\n"
2428 "Show hostname in certain command outputs\n")
2430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2431 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2435 /* "bgp network import-check" configuration. */
2436 DEFUN (bgp_network_import_check
,
2437 bgp_network_import_check_cmd
,
2438 "bgp network import-check",
2439 "BGP specific commands\n"
2440 "BGP network command\n"
2441 "Check BGP network route exists in IGP\n")
2443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2444 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2445 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2446 bgp_static_redo_import_check(bgp
);
2452 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2453 "bgp network import-check exact",
2454 "BGP specific commands\n"
2455 "BGP network command\n"
2456 "Check BGP network route exists in IGP\n"
2457 "Match route precisely\n")
2459 DEFUN (no_bgp_network_import_check
,
2460 no_bgp_network_import_check_cmd
,
2461 "no bgp network import-check",
2463 "BGP specific commands\n"
2464 "BGP network command\n"
2465 "Check BGP network route exists in IGP\n")
2467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2468 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2469 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2470 bgp_static_redo_import_check(bgp
);
2476 DEFUN (bgp_default_local_preference
,
2477 bgp_default_local_preference_cmd
,
2478 "bgp default local-preference (0-4294967295)",
2479 "BGP specific commands\n"
2480 "Configure BGP defaults\n"
2481 "local preference (higher=more preferred)\n"
2482 "Configure default local preference value\n")
2484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2486 uint32_t local_pref
;
2488 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2490 bgp_default_local_preference_set(bgp
, local_pref
);
2491 bgp_clear_star_soft_in(vty
, bgp
->name
);
2496 DEFUN (no_bgp_default_local_preference
,
2497 no_bgp_default_local_preference_cmd
,
2498 "no bgp default local-preference [(0-4294967295)]",
2500 "BGP specific commands\n"
2501 "Configure BGP defaults\n"
2502 "local preference (higher=more preferred)\n"
2503 "Configure default local preference value\n")
2505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2506 bgp_default_local_preference_unset(bgp
);
2507 bgp_clear_star_soft_in(vty
, bgp
->name
);
2513 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2514 bgp_default_subgroup_pkt_queue_max_cmd
,
2515 "bgp default subgroup-pkt-queue-max (20-100)",
2516 "BGP specific commands\n"
2517 "Configure BGP defaults\n"
2518 "subgroup-pkt-queue-max\n"
2519 "Configure subgroup packet queue max\n")
2521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2525 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2527 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2532 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2533 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2534 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2536 "BGP specific commands\n"
2537 "Configure BGP defaults\n"
2538 "subgroup-pkt-queue-max\n"
2539 "Configure subgroup packet queue max\n")
2541 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2542 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2547 DEFUN (bgp_rr_allow_outbound_policy
,
2548 bgp_rr_allow_outbound_policy_cmd
,
2549 "bgp route-reflector allow-outbound-policy",
2550 "BGP specific commands\n"
2551 "Allow modifications made by out route-map\n"
2552 "on ibgp neighbors\n")
2554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2556 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2557 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2558 update_group_announce_rrclients(bgp
);
2559 bgp_clear_star_soft_out(vty
, bgp
->name
);
2565 DEFUN (no_bgp_rr_allow_outbound_policy
,
2566 no_bgp_rr_allow_outbound_policy_cmd
,
2567 "no bgp route-reflector allow-outbound-policy",
2569 "BGP specific commands\n"
2570 "Allow modifications made by out route-map\n"
2571 "on ibgp neighbors\n")
2573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2575 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2576 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2577 update_group_announce_rrclients(bgp
);
2578 bgp_clear_star_soft_out(vty
, bgp
->name
);
2584 DEFUN (bgp_listen_limit
,
2585 bgp_listen_limit_cmd
,
2586 "bgp listen limit (1-5000)",
2587 "BGP specific commands\n"
2588 "Configure BGP defaults\n"
2589 "maximum number of BGP Dynamic Neighbors that can be created\n"
2590 "Configure Dynamic Neighbors listen limit value\n")
2592 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2596 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2598 bgp_listen_limit_set(bgp
, listen_limit
);
2603 DEFUN (no_bgp_listen_limit
,
2604 no_bgp_listen_limit_cmd
,
2605 "no bgp listen limit [(1-5000)]",
2606 "BGP specific commands\n"
2607 "Configure BGP defaults\n"
2608 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2609 "Configure Dynamic Neighbors listen limit value to default\n"
2610 "Configure Dynamic Neighbors listen limit value\n")
2612 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2613 bgp_listen_limit_unset(bgp
);
2619 * Check if this listen range is already configured. Check for exact
2620 * match or overlap based on input.
2622 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2623 struct prefix
*range
, int exact
)
2625 struct listnode
*node
, *nnode
;
2626 struct listnode
*node1
, *nnode1
;
2627 struct peer_group
*group
;
2632 afi
= family2afi(range
->family
);
2633 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2634 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2637 match
= prefix_same(range
, lr
);
2639 match
= (prefix_match(range
, lr
)
2640 || prefix_match(lr
, range
));
2649 DEFUN (bgp_listen_range
,
2650 bgp_listen_range_cmd
,
2651 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2652 "BGP specific commands\n"
2653 "Configure BGP dynamic neighbors listen range\n"
2654 "Configure BGP dynamic neighbors listen range\n"
2656 "Member of the peer-group\n"
2657 "Peer-group name\n")
2659 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2660 struct prefix range
;
2661 struct peer_group
*group
, *existing_group
;
2666 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2667 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2668 char *prefix
= argv
[idx
]->arg
;
2669 argv_find(argv
, argc
, "PGNAME", &idx
);
2670 char *peergroup
= argv
[idx
]->arg
;
2672 /* Convert IP prefix string to struct prefix. */
2673 ret
= str2prefix(prefix
, &range
);
2675 vty_out(vty
, "%% Malformed listen range\n");
2676 return CMD_WARNING_CONFIG_FAILED
;
2679 afi
= family2afi(range
.family
);
2681 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2683 "%% Malformed listen range (link-local address)\n");
2684 return CMD_WARNING_CONFIG_FAILED
;
2689 /* Check if same listen range is already configured. */
2690 existing_group
= listen_range_exists(bgp
, &range
, 1);
2691 if (existing_group
) {
2692 if (strcmp(existing_group
->name
, peergroup
) == 0)
2696 "%% Same listen range is attached to peer-group %s\n",
2697 existing_group
->name
);
2698 return CMD_WARNING_CONFIG_FAILED
;
2702 /* Check if an overlapping listen range exists. */
2703 if (listen_range_exists(bgp
, &range
, 0)) {
2705 "%% Listen range overlaps with existing listen range\n");
2706 return CMD_WARNING_CONFIG_FAILED
;
2709 group
= peer_group_lookup(bgp
, peergroup
);
2711 vty_out(vty
, "%% Configure the peer-group first\n");
2712 return CMD_WARNING_CONFIG_FAILED
;
2715 ret
= peer_group_listen_range_add(group
, &range
);
2716 return bgp_vty_return(vty
, ret
);
2719 DEFUN (no_bgp_listen_range
,
2720 no_bgp_listen_range_cmd
,
2721 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2723 "BGP specific commands\n"
2724 "Unconfigure BGP dynamic neighbors listen range\n"
2725 "Unconfigure BGP dynamic neighbors listen range\n"
2727 "Member of the peer-group\n"
2728 "Peer-group name\n")
2730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2731 struct prefix range
;
2732 struct peer_group
*group
;
2737 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2738 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2739 char *prefix
= argv
[idx
]->arg
;
2740 argv_find(argv
, argc
, "WORD", &idx
);
2741 char *peergroup
= argv
[idx
]->arg
;
2743 /* Convert IP prefix string to struct prefix. */
2744 ret
= str2prefix(prefix
, &range
);
2746 vty_out(vty
, "%% Malformed listen range\n");
2747 return CMD_WARNING_CONFIG_FAILED
;
2750 afi
= family2afi(range
.family
);
2752 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2754 "%% Malformed listen range (link-local address)\n");
2755 return CMD_WARNING_CONFIG_FAILED
;
2760 group
= peer_group_lookup(bgp
, peergroup
);
2762 vty_out(vty
, "%% Peer-group does not exist\n");
2763 return CMD_WARNING_CONFIG_FAILED
;
2766 ret
= peer_group_listen_range_del(group
, &range
);
2767 return bgp_vty_return(vty
, ret
);
2770 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2772 struct peer_group
*group
;
2773 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2774 struct prefix
*range
;
2776 char buf
[PREFIX2STR_BUFFER
];
2778 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2779 vty_out(vty
, " bgp listen limit %d\n",
2780 bgp
->dynamic_neighbors_limit
);
2782 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2783 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2784 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2786 prefix2str(range
, buf
, sizeof(buf
));
2788 " bgp listen range %s peer-group %s\n",
2796 DEFUN (bgp_disable_connected_route_check
,
2797 bgp_disable_connected_route_check_cmd
,
2798 "bgp disable-ebgp-connected-route-check",
2799 "BGP specific commands\n"
2800 "Disable checking if nexthop is connected on ebgp sessions\n")
2802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2803 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2804 bgp_clear_star_soft_in(vty
, bgp
->name
);
2809 DEFUN (no_bgp_disable_connected_route_check
,
2810 no_bgp_disable_connected_route_check_cmd
,
2811 "no bgp disable-ebgp-connected-route-check",
2813 "BGP specific commands\n"
2814 "Disable checking if nexthop is connected on ebgp sessions\n")
2816 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2817 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2818 bgp_clear_star_soft_in(vty
, bgp
->name
);
2824 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2825 const char *as_str
, afi_t afi
, safi_t safi
)
2827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2830 int as_type
= AS_SPECIFIED
;
2833 if (as_str
[0] == 'i') {
2835 as_type
= AS_INTERNAL
;
2836 } else if (as_str
[0] == 'e') {
2838 as_type
= AS_EXTERNAL
;
2840 /* Get AS number. */
2841 as
= strtoul(as_str
, NULL
, 10);
2844 /* If peer is peer group or interface peer, call proper function. */
2845 ret
= str2sockunion(peer_str
, &su
);
2849 /* Check if existing interface peer */
2850 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2852 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2855 /* if not interface peer, check peer-group settings */
2856 if (ret
< 0 && !peer
) {
2857 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2860 "%% Create the peer-group or interface first\n");
2861 return CMD_WARNING_CONFIG_FAILED
;
2866 if (peer_address_self_check(bgp
, &su
)) {
2868 "%% Can not configure the local system as neighbor\n");
2869 return CMD_WARNING_CONFIG_FAILED
;
2871 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2874 /* This peer belongs to peer group. */
2876 case BGP_ERR_PEER_GROUP_MEMBER
:
2878 "%% Peer-group member cannot override remote-as of peer-group\n");
2879 return CMD_WARNING_CONFIG_FAILED
;
2880 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2882 "%% Peer-group members must be all internal or all external\n");
2883 return CMD_WARNING_CONFIG_FAILED
;
2885 return bgp_vty_return(vty
, ret
);
2888 DEFUN (bgp_default_shutdown
,
2889 bgp_default_shutdown_cmd
,
2890 "[no] bgp default shutdown",
2893 "Configure BGP defaults\n"
2894 "Apply administrative shutdown to newly configured peers\n")
2896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2897 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2901 DEFUN (neighbor_remote_as
,
2902 neighbor_remote_as_cmd
,
2903 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2906 "Specify a BGP neighbor\n"
2908 "Internal BGP peer\n"
2909 "External BGP peer\n")
2912 int idx_remote_as
= 3;
2913 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2914 argv
[idx_remote_as
]->arg
, AFI_IP
,
2918 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2919 afi_t afi
, safi_t safi
, int v6only
,
2920 const char *peer_group_name
,
2923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2925 int as_type
= AS_UNSPECIFIED
;
2927 struct peer_group
*group
;
2931 group
= peer_group_lookup(bgp
, conf_if
);
2934 vty_out(vty
, "%% Name conflict with peer-group \n");
2935 return CMD_WARNING_CONFIG_FAILED
;
2939 if (as_str
[0] == 'i') {
2940 as_type
= AS_INTERNAL
;
2941 } else if (as_str
[0] == 'e') {
2942 as_type
= AS_EXTERNAL
;
2944 /* Get AS number. */
2945 as
= strtoul(as_str
, NULL
, 10);
2946 as_type
= AS_SPECIFIED
;
2950 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2953 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2956 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2957 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2958 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2959 as_type
, 0, 0, NULL
);
2961 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2962 as_type
, afi
, safi
, NULL
);
2965 vty_out(vty
, "%% BGP failed to create peer\n");
2966 return CMD_WARNING_CONFIG_FAILED
;
2970 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2972 /* Request zebra to initiate IPv6 RAs on this interface. We do
2974 * any unnumbered peer in order to not worry about run-time
2976 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2978 * gets deleted later etc.)
2981 bgp_zebra_initiate_radv(bgp
, peer
);
2984 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2985 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2987 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2989 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2991 /* v6only flag changed. Reset bgp seesion */
2992 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2993 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2994 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2995 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2997 bgp_session_reset(peer
);
3000 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3001 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3002 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3003 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3006 if (peer_group_name
) {
3007 group
= peer_group_lookup(bgp
, peer_group_name
);
3009 vty_out(vty
, "%% Configure the peer-group first\n");
3010 return CMD_WARNING_CONFIG_FAILED
;
3013 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3016 return bgp_vty_return(vty
, ret
);
3019 DEFUN (neighbor_interface_config
,
3020 neighbor_interface_config_cmd
,
3021 "neighbor WORD interface [peer-group PGNAME]",
3023 "Interface name or neighbor tag\n"
3024 "Enable BGP on interface\n"
3025 "Member of the peer-group\n"
3026 "Peer-group name\n")
3029 int idx_peer_group_word
= 4;
3031 if (argc
> idx_peer_group_word
)
3032 return peer_conf_interface_get(
3033 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3034 argv
[idx_peer_group_word
]->arg
, NULL
);
3036 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3037 SAFI_UNICAST
, 0, NULL
, NULL
);
3040 DEFUN (neighbor_interface_config_v6only
,
3041 neighbor_interface_config_v6only_cmd
,
3042 "neighbor WORD interface v6only [peer-group PGNAME]",
3044 "Interface name or neighbor tag\n"
3045 "Enable BGP on interface\n"
3046 "Enable BGP with v6 link-local only\n"
3047 "Member of the peer-group\n"
3048 "Peer-group name\n")
3051 int idx_peer_group_word
= 5;
3053 if (argc
> idx_peer_group_word
)
3054 return peer_conf_interface_get(
3055 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3056 argv
[idx_peer_group_word
]->arg
, NULL
);
3058 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3059 SAFI_UNICAST
, 1, NULL
, NULL
);
3063 DEFUN (neighbor_interface_config_remote_as
,
3064 neighbor_interface_config_remote_as_cmd
,
3065 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3067 "Interface name or neighbor tag\n"
3068 "Enable BGP on interface\n"
3069 "Specify a BGP neighbor\n"
3071 "Internal BGP peer\n"
3072 "External BGP peer\n")
3075 int idx_remote_as
= 4;
3076 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3077 SAFI_UNICAST
, 0, NULL
,
3078 argv
[idx_remote_as
]->arg
);
3081 DEFUN (neighbor_interface_v6only_config_remote_as
,
3082 neighbor_interface_v6only_config_remote_as_cmd
,
3083 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3085 "Interface name or neighbor tag\n"
3086 "Enable BGP with v6 link-local only\n"
3087 "Enable BGP on interface\n"
3088 "Specify a BGP neighbor\n"
3090 "Internal BGP peer\n"
3091 "External BGP peer\n")
3094 int idx_remote_as
= 5;
3095 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3096 SAFI_UNICAST
, 1, NULL
,
3097 argv
[idx_remote_as
]->arg
);
3100 DEFUN (neighbor_peer_group
,
3101 neighbor_peer_group_cmd
,
3102 "neighbor WORD peer-group",
3104 "Interface name or neighbor tag\n"
3105 "Configure peer-group\n")
3107 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3110 struct peer_group
*group
;
3112 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3114 vty_out(vty
, "%% Name conflict with interface: \n");
3115 return CMD_WARNING_CONFIG_FAILED
;
3118 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3120 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3121 return CMD_WARNING_CONFIG_FAILED
;
3129 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3133 "Specify a BGP neighbor\n"
3135 "Internal BGP peer\n"
3136 "External BGP peer\n")
3138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3142 struct peer_group
*group
;
3146 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3148 /* look up for neighbor by interface name config. */
3149 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3151 /* Request zebra to terminate IPv6 RAs on this
3154 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3159 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3161 peer_group_delete(group
);
3163 vty_out(vty
, "%% Create the peer-group first\n");
3164 return CMD_WARNING_CONFIG_FAILED
;
3167 peer
= peer_lookup(bgp
, &su
);
3169 if (peer_dynamic_neighbor(peer
)) {
3171 "%% Operation not allowed on a dynamic neighbor\n");
3172 return CMD_WARNING_CONFIG_FAILED
;
3175 other
= peer
->doppelganger
;
3177 if (other
&& other
->status
!= Deleted
)
3185 DEFUN (no_neighbor_interface_config
,
3186 no_neighbor_interface_config_cmd
,
3187 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3191 "Configure BGP on interface\n"
3192 "Enable BGP with v6 link-local only\n"
3193 "Member of the peer-group\n"
3195 "Specify a BGP neighbor\n"
3197 "Internal BGP peer\n"
3198 "External BGP peer\n")
3200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3204 /* look up for neighbor by interface name config. */
3205 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3207 /* Request zebra to terminate IPv6 RAs on this interface. */
3209 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3212 vty_out(vty
, "%% Create the bgp interface first\n");
3213 return CMD_WARNING_CONFIG_FAILED
;
3218 DEFUN (no_neighbor_peer_group
,
3219 no_neighbor_peer_group_cmd
,
3220 "no neighbor WORD peer-group",
3224 "Configure peer-group\n")
3226 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3228 struct peer_group
*group
;
3230 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3232 peer_group_delete(group
);
3234 vty_out(vty
, "%% Create the peer-group first\n");
3235 return CMD_WARNING_CONFIG_FAILED
;
3240 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3241 no_neighbor_interface_peer_group_remote_as_cmd
,
3242 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3245 "Interface name or neighbor tag\n"
3246 "Specify a BGP neighbor\n"
3248 "Internal BGP peer\n"
3249 "External BGP peer\n")
3251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3253 struct peer_group
*group
;
3256 /* look up for neighbor by interface name config. */
3257 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3259 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3263 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3265 peer_group_remote_as_delete(group
);
3267 vty_out(vty
, "%% Create the peer-group or interface first\n");
3268 return CMD_WARNING_CONFIG_FAILED
;
3273 DEFUN (neighbor_local_as
,
3274 neighbor_local_as_cmd
,
3275 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3278 "Specify a local-as number\n"
3279 "AS number used as local AS\n")
3287 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3289 return CMD_WARNING_CONFIG_FAILED
;
3291 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3292 ret
= peer_local_as_set(peer
, as
, 0, 0);
3293 return bgp_vty_return(vty
, ret
);
3296 DEFUN (neighbor_local_as_no_prepend
,
3297 neighbor_local_as_no_prepend_cmd
,
3298 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3301 "Specify a local-as number\n"
3302 "AS number used as local AS\n"
3303 "Do not prepend local-as to updates from ebgp peers\n")
3311 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3313 return CMD_WARNING_CONFIG_FAILED
;
3315 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3316 ret
= peer_local_as_set(peer
, as
, 1, 0);
3317 return bgp_vty_return(vty
, ret
);
3320 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3321 neighbor_local_as_no_prepend_replace_as_cmd
,
3322 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3325 "Specify a local-as number\n"
3326 "AS number used as local AS\n"
3327 "Do not prepend local-as to updates from ebgp peers\n"
3328 "Do not prepend local-as to updates from ibgp peers\n")
3336 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3338 return CMD_WARNING_CONFIG_FAILED
;
3340 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3341 ret
= peer_local_as_set(peer
, as
, 1, 1);
3342 return bgp_vty_return(vty
, ret
);
3345 DEFUN (no_neighbor_local_as
,
3346 no_neighbor_local_as_cmd
,
3347 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3351 "Specify a local-as number\n"
3352 "AS number used as local AS\n"
3353 "Do not prepend local-as to updates from ebgp peers\n"
3354 "Do not prepend local-as to updates from ibgp peers\n")
3360 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3362 return CMD_WARNING_CONFIG_FAILED
;
3364 ret
= peer_local_as_unset(peer
);
3365 return bgp_vty_return(vty
, ret
);
3369 DEFUN (neighbor_solo
,
3371 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3374 "Solo peer - part of its own update group\n")
3380 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3382 return CMD_WARNING_CONFIG_FAILED
;
3384 ret
= update_group_adjust_soloness(peer
, 1);
3385 return bgp_vty_return(vty
, ret
);
3388 DEFUN (no_neighbor_solo
,
3389 no_neighbor_solo_cmd
,
3390 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3394 "Solo peer - part of its own update group\n")
3400 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3402 return CMD_WARNING_CONFIG_FAILED
;
3404 ret
= update_group_adjust_soloness(peer
, 0);
3405 return bgp_vty_return(vty
, ret
);
3408 DEFUN (neighbor_password
,
3409 neighbor_password_cmd
,
3410 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3421 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3423 return CMD_WARNING_CONFIG_FAILED
;
3425 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3426 return bgp_vty_return(vty
, ret
);
3429 DEFUN (no_neighbor_password
,
3430 no_neighbor_password_cmd
,
3431 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3442 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3444 return CMD_WARNING_CONFIG_FAILED
;
3446 ret
= peer_password_unset(peer
);
3447 return bgp_vty_return(vty
, ret
);
3450 DEFUN (neighbor_activate
,
3451 neighbor_activate_cmd
,
3452 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3455 "Enable the Address Family for this Neighbor\n")
3461 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3463 return CMD_WARNING_CONFIG_FAILED
;
3465 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3466 return bgp_vty_return(vty
, ret
);
3469 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3470 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3471 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3472 "Enable the Address Family for this Neighbor\n")
3474 DEFUN (no_neighbor_activate
,
3475 no_neighbor_activate_cmd
,
3476 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3480 "Enable the Address Family for this Neighbor\n")
3487 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3489 return CMD_WARNING_CONFIG_FAILED
;
3491 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3492 return bgp_vty_return(vty
, ret
);
3495 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3496 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3497 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3498 "Enable the Address Family for this Neighbor\n")
3500 DEFUN (neighbor_set_peer_group
,
3501 neighbor_set_peer_group_cmd
,
3502 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3505 "Member of the peer-group\n"
3506 "Peer-group name\n")
3508 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3515 struct peer_group
*group
;
3517 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3519 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3521 vty_out(vty
, "%% Malformed address or name: %s\n",
3522 argv
[idx_peer
]->arg
);
3523 return CMD_WARNING_CONFIG_FAILED
;
3526 if (peer_address_self_check(bgp
, &su
)) {
3528 "%% Can not configure the local system as neighbor\n");
3529 return CMD_WARNING_CONFIG_FAILED
;
3532 /* Disallow for dynamic neighbor. */
3533 peer
= peer_lookup(bgp
, &su
);
3534 if (peer
&& peer_dynamic_neighbor(peer
)) {
3536 "%% Operation not allowed on a dynamic neighbor\n");
3537 return CMD_WARNING_CONFIG_FAILED
;
3541 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3543 vty_out(vty
, "%% Configure the peer-group first\n");
3544 return CMD_WARNING_CONFIG_FAILED
;
3547 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3549 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3551 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3553 return CMD_WARNING_CONFIG_FAILED
;
3556 return bgp_vty_return(vty
, ret
);
3559 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3560 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3561 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3562 "Member of the peer-group\n"
3563 "Peer-group name\n")
3565 DEFUN (no_neighbor_set_peer_group
,
3566 no_neighbor_set_peer_group_cmd
,
3567 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3571 "Member of the peer-group\n"
3572 "Peer-group name\n")
3574 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3579 struct peer_group
*group
;
3581 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3583 return CMD_WARNING_CONFIG_FAILED
;
3585 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3587 vty_out(vty
, "%% Configure the peer-group first\n");
3588 return CMD_WARNING_CONFIG_FAILED
;
3591 ret
= peer_delete(peer
);
3593 return bgp_vty_return(vty
, ret
);
3596 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3597 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3598 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3599 "Member of the peer-group\n"
3600 "Peer-group name\n")
3602 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3603 uint32_t flag
, int set
)
3608 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3610 return CMD_WARNING_CONFIG_FAILED
;
3613 * If 'neighbor <interface>', then this is for directly connected peers,
3614 * we should not accept disable-connected-check.
3616 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3618 "%s is directly connected peer, cannot accept disable-"
3619 "connected-check\n",
3621 return CMD_WARNING_CONFIG_FAILED
;
3624 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3625 peer_tx_shutdown_message_unset(peer
);
3628 ret
= peer_flag_set(peer
, flag
);
3630 ret
= peer_flag_unset(peer
, flag
);
3632 return bgp_vty_return(vty
, ret
);
3635 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3637 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3640 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3643 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3646 /* neighbor passive. */
3647 DEFUN (neighbor_passive
,
3648 neighbor_passive_cmd
,
3649 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3652 "Don't send open messages to this neighbor\n")
3655 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3658 DEFUN (no_neighbor_passive
,
3659 no_neighbor_passive_cmd
,
3660 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3664 "Don't send open messages to this neighbor\n")
3667 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3670 /* neighbor shutdown. */
3671 DEFUN (neighbor_shutdown_msg
,
3672 neighbor_shutdown_msg_cmd
,
3673 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3676 "Administratively shut down this neighbor\n"
3677 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3678 "Shutdown message\n")
3684 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3688 return CMD_WARNING_CONFIG_FAILED
;
3689 message
= argv_concat(argv
, argc
, 4);
3690 peer_tx_shutdown_message_set(peer
, message
);
3691 XFREE(MTYPE_TMP
, message
);
3694 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3697 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3698 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3699 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3700 "Administratively shut down this neighbor\n")
3702 DEFUN (no_neighbor_shutdown_msg
,
3703 no_neighbor_shutdown_msg_cmd
,
3704 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3708 "Administratively shut down this neighbor\n"
3709 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3710 "Shutdown message\n")
3714 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3715 PEER_FLAG_SHUTDOWN
);
3718 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3719 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3720 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3721 "Administratively shut down this neighbor\n")
3723 /* neighbor capability dynamic. */
3724 DEFUN (neighbor_capability_dynamic
,
3725 neighbor_capability_dynamic_cmd
,
3726 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3729 "Advertise capability to the peer\n"
3730 "Advertise dynamic capability to this neighbor\n")
3733 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3734 PEER_FLAG_DYNAMIC_CAPABILITY
);
3737 DEFUN (no_neighbor_capability_dynamic
,
3738 no_neighbor_capability_dynamic_cmd
,
3739 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3743 "Advertise capability to the peer\n"
3744 "Advertise dynamic capability to this neighbor\n")
3747 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3748 PEER_FLAG_DYNAMIC_CAPABILITY
);
3751 /* neighbor dont-capability-negotiate */
3752 DEFUN (neighbor_dont_capability_negotiate
,
3753 neighbor_dont_capability_negotiate_cmd
,
3754 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3757 "Do not perform capability negotiation\n")
3760 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3761 PEER_FLAG_DONT_CAPABILITY
);
3764 DEFUN (no_neighbor_dont_capability_negotiate
,
3765 no_neighbor_dont_capability_negotiate_cmd
,
3766 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3770 "Do not perform capability negotiation\n")
3773 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3774 PEER_FLAG_DONT_CAPABILITY
);
3777 /* neighbor capability extended next hop encoding */
3778 DEFUN (neighbor_capability_enhe
,
3779 neighbor_capability_enhe_cmd
,
3780 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3783 "Advertise capability to the peer\n"
3784 "Advertise extended next-hop capability to the peer\n")
3787 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3788 PEER_FLAG_CAPABILITY_ENHE
);
3791 DEFUN (no_neighbor_capability_enhe
,
3792 no_neighbor_capability_enhe_cmd
,
3793 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3797 "Advertise capability to the peer\n"
3798 "Advertise extended next-hop capability to the peer\n")
3801 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3802 PEER_FLAG_CAPABILITY_ENHE
);
3805 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3806 afi_t afi
, safi_t safi
, uint32_t flag
,
3812 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3814 return CMD_WARNING_CONFIG_FAILED
;
3817 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3819 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3821 return bgp_vty_return(vty
, ret
);
3824 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3825 afi_t afi
, safi_t safi
, uint32_t flag
)
3827 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3830 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3831 afi_t afi
, safi_t safi
, uint32_t flag
)
3833 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3836 /* neighbor capability orf prefix-list. */
3837 DEFUN (neighbor_capability_orf_prefix
,
3838 neighbor_capability_orf_prefix_cmd
,
3839 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3842 "Advertise capability to the peer\n"
3843 "Advertise ORF capability to the peer\n"
3844 "Advertise prefixlist ORF capability to this neighbor\n"
3845 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3846 "Capability to RECEIVE the ORF from this neighbor\n"
3847 "Capability to SEND the ORF to this neighbor\n")
3850 int idx_send_recv
= 5;
3853 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3854 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3855 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3856 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3857 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3858 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3860 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3861 return CMD_WARNING_CONFIG_FAILED
;
3864 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3865 bgp_node_safi(vty
), flag
);
3869 neighbor_capability_orf_prefix
,
3870 neighbor_capability_orf_prefix_hidden_cmd
,
3871 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3872 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3873 "Advertise capability to the peer\n"
3874 "Advertise ORF capability to the peer\n"
3875 "Advertise prefixlist ORF capability to this neighbor\n"
3876 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3877 "Capability to RECEIVE the ORF from this neighbor\n"
3878 "Capability to SEND the ORF to this neighbor\n")
3880 DEFUN (no_neighbor_capability_orf_prefix
,
3881 no_neighbor_capability_orf_prefix_cmd
,
3882 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3886 "Advertise capability to the peer\n"
3887 "Advertise ORF capability to the peer\n"
3888 "Advertise prefixlist ORF capability to this neighbor\n"
3889 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3890 "Capability to RECEIVE the ORF from this neighbor\n"
3891 "Capability to SEND the ORF to this neighbor\n")
3894 int idx_send_recv
= 6;
3897 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3898 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3899 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3900 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3901 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3902 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3904 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3905 return CMD_WARNING_CONFIG_FAILED
;
3908 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3909 bgp_node_afi(vty
), bgp_node_safi(vty
),
3914 no_neighbor_capability_orf_prefix
,
3915 no_neighbor_capability_orf_prefix_hidden_cmd
,
3916 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3917 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3918 "Advertise capability to the peer\n"
3919 "Advertise ORF capability to the peer\n"
3920 "Advertise prefixlist ORF capability to this neighbor\n"
3921 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3922 "Capability to RECEIVE the ORF from this neighbor\n"
3923 "Capability to SEND the ORF to this neighbor\n")
3925 /* neighbor next-hop-self. */
3926 DEFUN (neighbor_nexthop_self
,
3927 neighbor_nexthop_self_cmd
,
3928 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3931 "Disable the next hop calculation for this neighbor\n")
3934 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3935 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3938 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3939 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3940 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3941 "Disable the next hop calculation for this neighbor\n")
3943 /* neighbor next-hop-self. */
3944 DEFUN (neighbor_nexthop_self_force
,
3945 neighbor_nexthop_self_force_cmd
,
3946 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3949 "Disable the next hop calculation for this neighbor\n"
3950 "Set the next hop to self for reflected routes\n")
3953 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3955 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3958 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3959 neighbor_nexthop_self_force_hidden_cmd
,
3960 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3961 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3962 "Disable the next hop calculation for this neighbor\n"
3963 "Set the next hop to self for reflected routes\n")
3965 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3966 neighbor_nexthop_self_all_hidden_cmd
,
3967 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3968 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3969 "Disable the next hop calculation for this neighbor\n"
3970 "Set the next hop to self for reflected routes\n")
3972 DEFUN (no_neighbor_nexthop_self
,
3973 no_neighbor_nexthop_self_cmd
,
3974 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3978 "Disable the next hop calculation for this neighbor\n")
3981 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3982 bgp_node_afi(vty
), bgp_node_safi(vty
),
3983 PEER_FLAG_NEXTHOP_SELF
);
3986 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3987 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3988 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3989 "Disable the next hop calculation for this neighbor\n")
3991 DEFUN (no_neighbor_nexthop_self_force
,
3992 no_neighbor_nexthop_self_force_cmd
,
3993 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3997 "Disable the next hop calculation for this neighbor\n"
3998 "Set the next hop to self for reflected routes\n")
4001 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4002 bgp_node_afi(vty
), bgp_node_safi(vty
),
4003 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4006 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4007 no_neighbor_nexthop_self_force_hidden_cmd
,
4008 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4009 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4010 "Disable the next hop calculation for this neighbor\n"
4011 "Set the next hop to self for reflected routes\n")
4013 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4014 no_neighbor_nexthop_self_all_hidden_cmd
,
4015 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4016 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4017 "Disable the next hop calculation for this neighbor\n"
4018 "Set the next hop to self for reflected routes\n")
4020 /* neighbor as-override */
4021 DEFUN (neighbor_as_override
,
4022 neighbor_as_override_cmd
,
4023 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4026 "Override ASNs in outbound updates if aspath equals remote-as\n")
4029 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4030 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4033 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4034 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4035 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4036 "Override ASNs in outbound updates if aspath equals remote-as\n")
4038 DEFUN (no_neighbor_as_override
,
4039 no_neighbor_as_override_cmd
,
4040 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4044 "Override ASNs in outbound updates if aspath equals remote-as\n")
4047 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4048 bgp_node_afi(vty
), bgp_node_safi(vty
),
4049 PEER_FLAG_AS_OVERRIDE
);
4052 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4053 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4054 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4055 "Override ASNs in outbound updates if aspath equals remote-as\n")
4057 /* neighbor remove-private-AS. */
4058 DEFUN (neighbor_remove_private_as
,
4059 neighbor_remove_private_as_cmd
,
4060 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4063 "Remove private ASNs in outbound updates\n")
4066 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4068 PEER_FLAG_REMOVE_PRIVATE_AS
);
4071 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4072 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4073 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4074 "Remove private ASNs in outbound updates\n")
4076 DEFUN (neighbor_remove_private_as_all
,
4077 neighbor_remove_private_as_all_cmd
,
4078 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4081 "Remove private ASNs in outbound updates\n"
4082 "Apply to all AS numbers\n")
4085 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4087 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4090 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4091 neighbor_remove_private_as_all_hidden_cmd
,
4092 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4093 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4094 "Remove private ASNs in outbound updates\n"
4095 "Apply to all AS numbers")
4097 DEFUN (neighbor_remove_private_as_replace_as
,
4098 neighbor_remove_private_as_replace_as_cmd
,
4099 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4102 "Remove private ASNs in outbound updates\n"
4103 "Replace private ASNs with our ASN in outbound updates\n")
4106 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4108 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4111 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4112 neighbor_remove_private_as_replace_as_hidden_cmd
,
4113 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4114 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4115 "Remove private ASNs in outbound updates\n"
4116 "Replace private ASNs with our ASN in outbound updates\n")
4118 DEFUN (neighbor_remove_private_as_all_replace_as
,
4119 neighbor_remove_private_as_all_replace_as_cmd
,
4120 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4123 "Remove private ASNs in outbound updates\n"
4124 "Apply to all AS numbers\n"
4125 "Replace private ASNs with our ASN in outbound updates\n")
4128 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4130 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4134 neighbor_remove_private_as_all_replace_as
,
4135 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4136 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4137 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4138 "Remove private ASNs in outbound updates\n"
4139 "Apply to all AS numbers\n"
4140 "Replace private ASNs with our ASN in outbound updates\n")
4142 DEFUN (no_neighbor_remove_private_as
,
4143 no_neighbor_remove_private_as_cmd
,
4144 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4148 "Remove private ASNs in outbound updates\n")
4151 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4152 bgp_node_afi(vty
), bgp_node_safi(vty
),
4153 PEER_FLAG_REMOVE_PRIVATE_AS
);
4156 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4157 no_neighbor_remove_private_as_hidden_cmd
,
4158 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4159 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4160 "Remove private ASNs in outbound updates\n")
4162 DEFUN (no_neighbor_remove_private_as_all
,
4163 no_neighbor_remove_private_as_all_cmd
,
4164 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4168 "Remove private ASNs in outbound updates\n"
4169 "Apply to all AS numbers\n")
4172 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4173 bgp_node_afi(vty
), bgp_node_safi(vty
),
4174 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4177 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4178 no_neighbor_remove_private_as_all_hidden_cmd
,
4179 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4180 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4181 "Remove private ASNs in outbound updates\n"
4182 "Apply to all AS numbers\n")
4184 DEFUN (no_neighbor_remove_private_as_replace_as
,
4185 no_neighbor_remove_private_as_replace_as_cmd
,
4186 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4190 "Remove private ASNs in outbound updates\n"
4191 "Replace private ASNs with our ASN in outbound updates\n")
4194 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4195 bgp_node_afi(vty
), bgp_node_safi(vty
),
4196 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4199 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4200 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4201 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4202 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4203 "Remove private ASNs in outbound updates\n"
4204 "Replace private ASNs with our ASN in outbound updates\n")
4206 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4207 no_neighbor_remove_private_as_all_replace_as_cmd
,
4208 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4212 "Remove private ASNs in outbound updates\n"
4213 "Apply to all AS numbers\n"
4214 "Replace private ASNs with our ASN in outbound updates\n")
4217 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4218 bgp_node_afi(vty
), bgp_node_safi(vty
),
4219 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4223 no_neighbor_remove_private_as_all_replace_as
,
4224 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4225 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4226 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4227 "Remove private ASNs in outbound updates\n"
4228 "Apply to all AS numbers\n"
4229 "Replace private ASNs with our ASN in outbound updates\n")
4232 /* neighbor send-community. */
4233 DEFUN (neighbor_send_community
,
4234 neighbor_send_community_cmd
,
4235 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4238 "Send Community attribute to this neighbor\n")
4242 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4244 PEER_FLAG_SEND_COMMUNITY
);
4247 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4248 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4249 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4250 "Send Community attribute to this neighbor\n")
4252 DEFUN (no_neighbor_send_community
,
4253 no_neighbor_send_community_cmd
,
4254 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4258 "Send Community attribute to this neighbor\n")
4262 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4263 bgp_node_afi(vty
), bgp_node_safi(vty
),
4264 PEER_FLAG_SEND_COMMUNITY
);
4267 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4268 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4269 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4270 "Send Community attribute to this neighbor\n")
4272 /* neighbor send-community extended. */
4273 DEFUN (neighbor_send_community_type
,
4274 neighbor_send_community_type_cmd
,
4275 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4278 "Send Community attribute to this neighbor\n"
4279 "Send Standard and Extended Community attributes\n"
4280 "Send Standard, Large and Extended Community attributes\n"
4281 "Send Extended Community attributes\n"
4282 "Send Standard Community attributes\n"
4283 "Send Large Community attributes\n")
4287 const char *type
= argv
[argc
- 1]->text
;
4289 if (strmatch(type
, "standard")) {
4290 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4291 } else if (strmatch(type
, "extended")) {
4292 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4293 } else if (strmatch(type
, "large")) {
4294 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4295 } else if (strmatch(type
, "both")) {
4296 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4297 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4298 } else { /* if (strmatch(type, "all")) */
4299 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4300 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4301 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4304 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4305 bgp_node_safi(vty
), flag
);
4309 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4310 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4311 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4312 "Send Community attribute to this neighbor\n"
4313 "Send Standard and Extended Community attributes\n"
4314 "Send Standard, Large and Extended Community attributes\n"
4315 "Send Extended Community attributes\n"
4316 "Send Standard Community attributes\n"
4317 "Send Large Community attributes\n")
4319 DEFUN (no_neighbor_send_community_type
,
4320 no_neighbor_send_community_type_cmd
,
4321 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4325 "Send Community attribute to this neighbor\n"
4326 "Send Standard and Extended Community attributes\n"
4327 "Send Standard, Large and Extended Community attributes\n"
4328 "Send Extended Community attributes\n"
4329 "Send Standard Community attributes\n"
4330 "Send Large Community attributes\n")
4334 const char *type
= argv
[argc
- 1]->text
;
4336 if (strmatch(type
, "standard")) {
4337 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4338 } else if (strmatch(type
, "extended")) {
4339 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4340 } else if (strmatch(type
, "large")) {
4341 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4342 } else if (strmatch(type
, "both")) {
4343 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4344 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4345 } else { /* if (strmatch(type, "all")) */
4346 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4347 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4348 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4351 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4352 bgp_node_afi(vty
), bgp_node_safi(vty
),
4357 no_neighbor_send_community_type
,
4358 no_neighbor_send_community_type_hidden_cmd
,
4359 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4360 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4361 "Send Community attribute to this neighbor\n"
4362 "Send Standard and Extended Community attributes\n"
4363 "Send Standard, Large and Extended Community attributes\n"
4364 "Send Extended Community attributes\n"
4365 "Send Standard Community attributes\n"
4366 "Send Large Community attributes\n")
4368 /* neighbor soft-reconfig. */
4369 DEFUN (neighbor_soft_reconfiguration
,
4370 neighbor_soft_reconfiguration_cmd
,
4371 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4374 "Per neighbor soft reconfiguration\n"
4375 "Allow inbound soft reconfiguration for this neighbor\n")
4378 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4380 PEER_FLAG_SOFT_RECONFIG
);
4383 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4384 neighbor_soft_reconfiguration_hidden_cmd
,
4385 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4386 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4387 "Per neighbor soft reconfiguration\n"
4388 "Allow inbound soft reconfiguration for this neighbor\n")
4390 DEFUN (no_neighbor_soft_reconfiguration
,
4391 no_neighbor_soft_reconfiguration_cmd
,
4392 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4396 "Per neighbor soft reconfiguration\n"
4397 "Allow inbound soft reconfiguration for this neighbor\n")
4400 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4401 bgp_node_afi(vty
), bgp_node_safi(vty
),
4402 PEER_FLAG_SOFT_RECONFIG
);
4405 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4406 no_neighbor_soft_reconfiguration_hidden_cmd
,
4407 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4408 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4409 "Per neighbor soft reconfiguration\n"
4410 "Allow inbound soft reconfiguration for this neighbor\n")
4412 DEFUN (neighbor_route_reflector_client
,
4413 neighbor_route_reflector_client_cmd
,
4414 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4417 "Configure a neighbor as Route Reflector client\n")
4423 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4425 return CMD_WARNING_CONFIG_FAILED
;
4427 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4429 PEER_FLAG_REFLECTOR_CLIENT
);
4432 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4433 neighbor_route_reflector_client_hidden_cmd
,
4434 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4435 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4436 "Configure a neighbor as Route Reflector client\n")
4438 DEFUN (no_neighbor_route_reflector_client
,
4439 no_neighbor_route_reflector_client_cmd
,
4440 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4444 "Configure a neighbor as Route Reflector client\n")
4447 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4448 bgp_node_afi(vty
), bgp_node_safi(vty
),
4449 PEER_FLAG_REFLECTOR_CLIENT
);
4452 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4453 no_neighbor_route_reflector_client_hidden_cmd
,
4454 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4455 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4456 "Configure a neighbor as Route Reflector client\n")
4458 /* neighbor route-server-client. */
4459 DEFUN (neighbor_route_server_client
,
4460 neighbor_route_server_client_cmd
,
4461 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4464 "Configure a neighbor as Route Server client\n")
4469 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4471 return CMD_WARNING_CONFIG_FAILED
;
4472 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4474 PEER_FLAG_RSERVER_CLIENT
);
4477 ALIAS_HIDDEN(neighbor_route_server_client
,
4478 neighbor_route_server_client_hidden_cmd
,
4479 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4480 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4481 "Configure a neighbor as Route Server client\n")
4483 DEFUN (no_neighbor_route_server_client
,
4484 no_neighbor_route_server_client_cmd
,
4485 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4489 "Configure a neighbor as Route Server client\n")
4492 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4493 bgp_node_afi(vty
), bgp_node_safi(vty
),
4494 PEER_FLAG_RSERVER_CLIENT
);
4497 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4498 no_neighbor_route_server_client_hidden_cmd
,
4499 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4500 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4501 "Configure a neighbor as Route Server client\n")
4503 DEFUN (neighbor_nexthop_local_unchanged
,
4504 neighbor_nexthop_local_unchanged_cmd
,
4505 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4508 "Configure treatment of outgoing link-local nexthop attribute\n"
4509 "Leave link-local nexthop unchanged for this peer\n")
4512 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4514 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4517 DEFUN (no_neighbor_nexthop_local_unchanged
,
4518 no_neighbor_nexthop_local_unchanged_cmd
,
4519 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4523 "Configure treatment of outgoing link-local-nexthop attribute\n"
4524 "Leave link-local nexthop unchanged for this peer\n")
4527 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4528 bgp_node_afi(vty
), bgp_node_safi(vty
),
4529 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4532 DEFUN (neighbor_attr_unchanged
,
4533 neighbor_attr_unchanged_cmd
,
4534 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4537 "BGP attribute is propagated unchanged to this neighbor\n"
4538 "As-path attribute\n"
4539 "Nexthop attribute\n"
4543 char *peer_str
= argv
[1]->arg
;
4546 afi_t afi
= bgp_node_afi(vty
);
4547 safi_t safi
= bgp_node_safi(vty
);
4549 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4551 return CMD_WARNING_CONFIG_FAILED
;
4553 if (argv_find(argv
, argc
, "as-path", &idx
))
4554 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4556 if (argv_find(argv
, argc
, "next-hop", &idx
))
4557 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4559 if (argv_find(argv
, argc
, "med", &idx
))
4560 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4562 /* no flags means all of them! */
4564 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4565 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4566 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4568 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4569 && peer_af_flag_check(peer
, afi
, safi
,
4570 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4571 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4572 PEER_FLAG_AS_PATH_UNCHANGED
);
4575 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4576 && peer_af_flag_check(peer
, afi
, safi
,
4577 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4578 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4579 PEER_FLAG_NEXTHOP_UNCHANGED
);
4582 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4583 && peer_af_flag_check(peer
, afi
, safi
,
4584 PEER_FLAG_MED_UNCHANGED
)) {
4585 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4586 PEER_FLAG_MED_UNCHANGED
);
4590 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4594 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4595 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4596 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4597 "BGP attribute is propagated unchanged to this neighbor\n"
4598 "As-path attribute\n"
4599 "Nexthop attribute\n"
4602 DEFUN (no_neighbor_attr_unchanged
,
4603 no_neighbor_attr_unchanged_cmd
,
4604 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4608 "BGP attribute is propagated unchanged to this neighbor\n"
4609 "As-path attribute\n"
4610 "Nexthop attribute\n"
4614 char *peer
= argv
[2]->arg
;
4617 if (argv_find(argv
, argc
, "as-path", &idx
))
4618 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4620 if (argv_find(argv
, argc
, "next-hop", &idx
))
4621 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4623 if (argv_find(argv
, argc
, "med", &idx
))
4624 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4626 if (!flags
) // no flags means all of them!
4628 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4629 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4630 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4633 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4634 bgp_node_safi(vty
), flags
);
4638 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4639 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4640 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4641 "BGP attribute is propagated unchanged to this neighbor\n"
4642 "As-path attribute\n"
4643 "Nexthop attribute\n"
4646 /* EBGP multihop configuration. */
4647 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4648 const char *ttl_str
)
4653 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4655 return CMD_WARNING_CONFIG_FAILED
;
4658 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4663 ttl
= strtoul(ttl_str
, NULL
, 10);
4665 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4668 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4672 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4674 return CMD_WARNING_CONFIG_FAILED
;
4676 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4679 /* neighbor ebgp-multihop. */
4680 DEFUN (neighbor_ebgp_multihop
,
4681 neighbor_ebgp_multihop_cmd
,
4682 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4685 "Allow EBGP neighbors not on directly connected networks\n")
4688 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4691 DEFUN (neighbor_ebgp_multihop_ttl
,
4692 neighbor_ebgp_multihop_ttl_cmd
,
4693 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4696 "Allow EBGP neighbors not on directly connected networks\n"
4697 "maximum hop count\n")
4701 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4702 argv
[idx_number
]->arg
);
4705 DEFUN (no_neighbor_ebgp_multihop
,
4706 no_neighbor_ebgp_multihop_cmd
,
4707 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4711 "Allow EBGP neighbors not on directly connected networks\n"
4712 "maximum hop count\n")
4715 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4719 /* disable-connected-check */
4720 DEFUN (neighbor_disable_connected_check
,
4721 neighbor_disable_connected_check_cmd
,
4722 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4725 "one-hop away EBGP peer using loopback address\n"
4726 "Enforce EBGP neighbors perform multihop\n")
4729 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4730 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4733 DEFUN (no_neighbor_disable_connected_check
,
4734 no_neighbor_disable_connected_check_cmd
,
4735 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4739 "one-hop away EBGP peer using loopback address\n"
4740 "Enforce EBGP neighbors perform multihop\n")
4743 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4744 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4748 /* enforce-first-as */
4749 DEFUN (neighbor_enforce_first_as
,
4750 neighbor_enforce_first_as_cmd
,
4751 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4754 "Enforce the first AS for EBGP routes\n")
4758 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4759 PEER_FLAG_ENFORCE_FIRST_AS
);
4762 DEFUN (no_neighbor_enforce_first_as
,
4763 no_neighbor_enforce_first_as_cmd
,
4764 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4768 "Enforce the first AS for EBGP routes\n")
4772 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4773 PEER_FLAG_ENFORCE_FIRST_AS
);
4777 DEFUN (neighbor_description
,
4778 neighbor_description_cmd
,
4779 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4782 "Neighbor specific description\n"
4783 "Up to 80 characters describing this neighbor\n")
4790 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4792 return CMD_WARNING_CONFIG_FAILED
;
4794 str
= argv_concat(argv
, argc
, idx_line
);
4796 peer_description_set(peer
, str
);
4798 XFREE(MTYPE_TMP
, str
);
4803 DEFUN (no_neighbor_description
,
4804 no_neighbor_description_cmd
,
4805 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4809 "Neighbor specific description\n")
4814 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4816 return CMD_WARNING_CONFIG_FAILED
;
4818 peer_description_unset(peer
);
4823 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4824 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4825 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4826 "Neighbor specific description\n"
4827 "Up to 80 characters describing this neighbor\n")
4829 /* Neighbor update-source. */
4830 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4831 const char *source_str
)
4837 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4839 return CMD_WARNING_CONFIG_FAILED
;
4845 if (str2sockunion(source_str
, &su
) == 0)
4846 peer_update_source_addr_set(peer
, &su
);
4848 if (str2prefix(source_str
, &p
)) {
4850 "%% Invalid update-source, remove prefix length \n");
4851 return CMD_WARNING_CONFIG_FAILED
;
4853 peer_update_source_if_set(peer
, source_str
);
4856 peer_update_source_unset(peer
);
4861 #define BGP_UPDATE_SOURCE_HELP_STR \
4864 "Interface name (requires zebra to be running)\n"
4866 DEFUN (neighbor_update_source
,
4867 neighbor_update_source_cmd
,
4868 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4871 "Source of routing updates\n"
4872 BGP_UPDATE_SOURCE_HELP_STR
)
4876 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4877 argv
[idx_peer_2
]->arg
);
4880 DEFUN (no_neighbor_update_source
,
4881 no_neighbor_update_source_cmd
,
4882 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4886 "Source of routing updates\n"
4887 BGP_UPDATE_SOURCE_HELP_STR
)
4890 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4893 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4894 afi_t afi
, safi_t safi
,
4895 const char *rmap
, int set
)
4899 struct route_map
*route_map
= NULL
;
4901 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4903 return CMD_WARNING_CONFIG_FAILED
;
4907 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4908 ret
= peer_default_originate_set(peer
, afi
, safi
,
4911 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4913 return bgp_vty_return(vty
, ret
);
4916 /* neighbor default-originate. */
4917 DEFUN (neighbor_default_originate
,
4918 neighbor_default_originate_cmd
,
4919 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4922 "Originate default route to this neighbor\n")
4925 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4927 bgp_node_safi(vty
), NULL
, 1);
4930 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4931 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4932 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4933 "Originate default route to this neighbor\n")
4935 DEFUN (neighbor_default_originate_rmap
,
4936 neighbor_default_originate_rmap_cmd
,
4937 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4940 "Originate default route to this neighbor\n"
4941 "Route-map to specify criteria to originate default\n"
4946 return peer_default_originate_set_vty(
4947 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4948 argv
[idx_word
]->arg
, 1);
4952 neighbor_default_originate_rmap
,
4953 neighbor_default_originate_rmap_hidden_cmd
,
4954 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4955 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4956 "Originate default route to this neighbor\n"
4957 "Route-map to specify criteria to originate default\n"
4960 DEFUN (no_neighbor_default_originate
,
4961 no_neighbor_default_originate_cmd
,
4962 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4966 "Originate default route to this neighbor\n"
4967 "Route-map to specify criteria to originate default\n"
4971 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4973 bgp_node_safi(vty
), NULL
, 0);
4977 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4978 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4979 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4980 "Originate default route to this neighbor\n"
4981 "Route-map to specify criteria to originate default\n"
4985 /* Set neighbor's BGP port. */
4986 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4987 const char *port_str
)
4993 peer
= peer_lookup_vty(vty
, ip_str
);
4995 return CMD_WARNING_CONFIG_FAILED
;
4998 sp
= getservbyname("bgp", "tcp");
4999 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5001 port
= strtoul(port_str
, NULL
, 10);
5004 peer_port_set(peer
, port
);
5009 /* Set specified peer's BGP port. */
5010 DEFUN (neighbor_port
,
5012 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5015 "Neighbor's BGP port\n"
5016 "TCP port number\n")
5020 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5021 argv
[idx_number
]->arg
);
5024 DEFUN (no_neighbor_port
,
5025 no_neighbor_port_cmd
,
5026 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5030 "Neighbor's BGP port\n"
5031 "TCP port number\n")
5034 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5038 /* neighbor weight. */
5039 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5040 safi_t safi
, const char *weight_str
)
5044 unsigned long weight
;
5046 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5048 return CMD_WARNING_CONFIG_FAILED
;
5050 weight
= strtoul(weight_str
, NULL
, 10);
5052 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5053 return bgp_vty_return(vty
, ret
);
5056 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5062 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5064 return CMD_WARNING_CONFIG_FAILED
;
5066 ret
= peer_weight_unset(peer
, afi
, safi
);
5067 return bgp_vty_return(vty
, ret
);
5070 DEFUN (neighbor_weight
,
5071 neighbor_weight_cmd
,
5072 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5075 "Set default weight for routes from this neighbor\n"
5080 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5081 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5084 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5085 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5086 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5087 "Set default weight for routes from this neighbor\n"
5090 DEFUN (no_neighbor_weight
,
5091 no_neighbor_weight_cmd
,
5092 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5096 "Set default weight for routes from this neighbor\n"
5100 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5101 bgp_node_afi(vty
), bgp_node_safi(vty
));
5104 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5105 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5106 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5107 "Set default weight for routes from this neighbor\n"
5111 /* Override capability negotiation. */
5112 DEFUN (neighbor_override_capability
,
5113 neighbor_override_capability_cmd
,
5114 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5117 "Override capability negotiation result\n")
5120 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5121 PEER_FLAG_OVERRIDE_CAPABILITY
);
5124 DEFUN (no_neighbor_override_capability
,
5125 no_neighbor_override_capability_cmd
,
5126 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5130 "Override capability negotiation result\n")
5133 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5134 PEER_FLAG_OVERRIDE_CAPABILITY
);
5137 DEFUN (neighbor_strict_capability
,
5138 neighbor_strict_capability_cmd
,
5139 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5142 "Strict capability negotiation match\n")
5146 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5147 PEER_FLAG_STRICT_CAP_MATCH
);
5150 DEFUN (no_neighbor_strict_capability
,
5151 no_neighbor_strict_capability_cmd
,
5152 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5156 "Strict capability negotiation match\n")
5160 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5161 PEER_FLAG_STRICT_CAP_MATCH
);
5164 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5165 const char *keep_str
, const char *hold_str
)
5172 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5174 return CMD_WARNING_CONFIG_FAILED
;
5176 keepalive
= strtoul(keep_str
, NULL
, 10);
5177 holdtime
= strtoul(hold_str
, NULL
, 10);
5179 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5181 return bgp_vty_return(vty
, ret
);
5184 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5189 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5191 return CMD_WARNING_CONFIG_FAILED
;
5193 ret
= peer_timers_unset(peer
);
5195 return bgp_vty_return(vty
, ret
);
5198 DEFUN (neighbor_timers
,
5199 neighbor_timers_cmd
,
5200 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5203 "BGP per neighbor timers\n"
5204 "Keepalive interval\n"
5209 int idx_number_2
= 4;
5210 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5211 argv
[idx_number
]->arg
,
5212 argv
[idx_number_2
]->arg
);
5215 DEFUN (no_neighbor_timers
,
5216 no_neighbor_timers_cmd
,
5217 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5221 "BGP per neighbor timers\n"
5222 "Keepalive interval\n"
5226 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5230 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5231 const char *time_str
)
5237 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5239 return CMD_WARNING_CONFIG_FAILED
;
5241 connect
= strtoul(time_str
, NULL
, 10);
5243 ret
= peer_timers_connect_set(peer
, connect
);
5245 return bgp_vty_return(vty
, ret
);
5248 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5253 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5255 return CMD_WARNING_CONFIG_FAILED
;
5257 ret
= peer_timers_connect_unset(peer
);
5259 return bgp_vty_return(vty
, ret
);
5262 DEFUN (neighbor_timers_connect
,
5263 neighbor_timers_connect_cmd
,
5264 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5267 "BGP per neighbor timers\n"
5268 "BGP connect timer\n"
5273 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5274 argv
[idx_number
]->arg
);
5277 DEFUN (no_neighbor_timers_connect
,
5278 no_neighbor_timers_connect_cmd
,
5279 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5283 "BGP per neighbor timers\n"
5284 "BGP connect timer\n"
5288 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5292 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5293 const char *time_str
, int set
)
5297 uint32_t routeadv
= 0;
5299 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5301 return CMD_WARNING_CONFIG_FAILED
;
5304 routeadv
= strtoul(time_str
, NULL
, 10);
5307 ret
= peer_advertise_interval_set(peer
, routeadv
);
5309 ret
= peer_advertise_interval_unset(peer
);
5311 return bgp_vty_return(vty
, ret
);
5314 DEFUN (neighbor_advertise_interval
,
5315 neighbor_advertise_interval_cmd
,
5316 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5319 "Minimum interval between sending BGP routing updates\n"
5320 "time in seconds\n")
5324 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5325 argv
[idx_number
]->arg
, 1);
5328 DEFUN (no_neighbor_advertise_interval
,
5329 no_neighbor_advertise_interval_cmd
,
5330 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5334 "Minimum interval between sending BGP routing updates\n"
5335 "time in seconds\n")
5338 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5342 /* Time to wait before processing route-map updates */
5343 DEFUN (bgp_set_route_map_delay_timer
,
5344 bgp_set_route_map_delay_timer_cmd
,
5345 "bgp route-map delay-timer (0-600)",
5347 "BGP route-map delay timer\n"
5348 "Time in secs to wait before processing route-map changes\n"
5349 "0 disables the timer, no route updates happen when route-maps change\n")
5352 uint32_t rmap_delay_timer
;
5354 if (argv
[idx_number
]->arg
) {
5355 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5356 bm
->rmap_update_timer
= rmap_delay_timer
;
5358 /* if the dynamic update handling is being disabled, and a timer
5360 * running, stop the timer and act as if the timer has already
5363 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5364 BGP_TIMER_OFF(bm
->t_rmap_update
);
5365 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5370 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5371 return CMD_WARNING_CONFIG_FAILED
;
5375 DEFUN (no_bgp_set_route_map_delay_timer
,
5376 no_bgp_set_route_map_delay_timer_cmd
,
5377 "no bgp route-map delay-timer [(0-600)]",
5380 "Default BGP route-map delay timer\n"
5381 "Reset to default time to wait for processing route-map changes\n"
5382 "0 disables the timer, no route updates happen when route-maps change\n")
5385 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5391 /* neighbor interface */
5392 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5397 peer
= peer_lookup_vty(vty
, ip_str
);
5398 if (!peer
|| peer
->conf_if
) {
5399 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5400 return CMD_WARNING_CONFIG_FAILED
;
5404 peer_interface_set(peer
, str
);
5406 peer_interface_unset(peer
);
5411 DEFUN (neighbor_interface
,
5412 neighbor_interface_cmd
,
5413 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5421 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5424 DEFUN (no_neighbor_interface
,
5425 no_neighbor_interface_cmd
,
5426 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5434 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5437 DEFUN (neighbor_distribute_list
,
5438 neighbor_distribute_list_cmd
,
5439 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5442 "Filter updates to/from this neighbor\n"
5443 "IP access-list number\n"
5444 "IP access-list number (expanded range)\n"
5445 "IP Access-list name\n"
5446 "Filter incoming updates\n"
5447 "Filter outgoing updates\n")
5454 const char *pstr
= argv
[idx_peer
]->arg
;
5455 const char *acl
= argv
[idx_acl
]->arg
;
5456 const char *inout
= argv
[argc
- 1]->text
;
5458 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5460 return CMD_WARNING_CONFIG_FAILED
;
5462 /* Check filter direction. */
5463 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5464 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5467 return bgp_vty_return(vty
, ret
);
5471 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5472 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5473 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5474 "Filter updates to/from this neighbor\n"
5475 "IP access-list number\n"
5476 "IP access-list number (expanded range)\n"
5477 "IP Access-list name\n"
5478 "Filter incoming updates\n"
5479 "Filter outgoing updates\n")
5481 DEFUN (no_neighbor_distribute_list
,
5482 no_neighbor_distribute_list_cmd
,
5483 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5487 "Filter updates to/from this neighbor\n"
5488 "IP access-list number\n"
5489 "IP access-list number (expanded range)\n"
5490 "IP Access-list name\n"
5491 "Filter incoming updates\n"
5492 "Filter outgoing updates\n")
5498 const char *pstr
= argv
[idx_peer
]->arg
;
5499 const char *inout
= argv
[argc
- 1]->text
;
5501 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5503 return CMD_WARNING_CONFIG_FAILED
;
5505 /* Check filter direction. */
5506 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5507 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5510 return bgp_vty_return(vty
, ret
);
5514 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5515 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5516 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5517 "Filter updates to/from this neighbor\n"
5518 "IP access-list number\n"
5519 "IP access-list number (expanded range)\n"
5520 "IP Access-list name\n"
5521 "Filter incoming updates\n"
5522 "Filter outgoing updates\n")
5524 /* Set prefix list to the peer. */
5525 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5526 afi_t afi
, safi_t safi
,
5527 const char *name_str
,
5528 const char *direct_str
)
5531 int direct
= FILTER_IN
;
5534 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5536 return CMD_WARNING_CONFIG_FAILED
;
5538 /* Check filter direction. */
5539 if (strncmp(direct_str
, "i", 1) == 0)
5541 else if (strncmp(direct_str
, "o", 1) == 0)
5542 direct
= FILTER_OUT
;
5544 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5546 return bgp_vty_return(vty
, ret
);
5549 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5550 afi_t afi
, safi_t safi
,
5551 const char *direct_str
)
5555 int direct
= FILTER_IN
;
5557 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5559 return CMD_WARNING_CONFIG_FAILED
;
5561 /* Check filter direction. */
5562 if (strncmp(direct_str
, "i", 1) == 0)
5564 else if (strncmp(direct_str
, "o", 1) == 0)
5565 direct
= FILTER_OUT
;
5567 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5569 return bgp_vty_return(vty
, ret
);
5572 DEFUN (neighbor_prefix_list
,
5573 neighbor_prefix_list_cmd
,
5574 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5577 "Filter updates to/from this neighbor\n"
5578 "Name of a prefix list\n"
5579 "Filter incoming updates\n"
5580 "Filter outgoing updates\n")
5585 return peer_prefix_list_set_vty(
5586 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5587 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5590 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5591 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5592 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5593 "Filter updates to/from this neighbor\n"
5594 "Name of a prefix list\n"
5595 "Filter incoming updates\n"
5596 "Filter outgoing updates\n")
5598 DEFUN (no_neighbor_prefix_list
,
5599 no_neighbor_prefix_list_cmd
,
5600 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5604 "Filter updates to/from this neighbor\n"
5605 "Name of a prefix list\n"
5606 "Filter incoming updates\n"
5607 "Filter outgoing updates\n")
5611 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5612 bgp_node_afi(vty
), bgp_node_safi(vty
),
5613 argv
[idx_in_out
]->arg
);
5616 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5617 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5618 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5619 "Filter updates to/from this neighbor\n"
5620 "Name of a prefix list\n"
5621 "Filter incoming updates\n"
5622 "Filter outgoing updates\n")
5624 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5625 safi_t safi
, const char *name_str
,
5626 const char *direct_str
)
5630 int direct
= FILTER_IN
;
5632 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5634 return CMD_WARNING_CONFIG_FAILED
;
5636 /* Check filter direction. */
5637 if (strncmp(direct_str
, "i", 1) == 0)
5639 else if (strncmp(direct_str
, "o", 1) == 0)
5640 direct
= FILTER_OUT
;
5642 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5644 return bgp_vty_return(vty
, ret
);
5647 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5648 safi_t safi
, const char *direct_str
)
5652 int direct
= FILTER_IN
;
5654 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5656 return CMD_WARNING_CONFIG_FAILED
;
5658 /* Check filter direction. */
5659 if (strncmp(direct_str
, "i", 1) == 0)
5661 else if (strncmp(direct_str
, "o", 1) == 0)
5662 direct
= FILTER_OUT
;
5664 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5666 return bgp_vty_return(vty
, ret
);
5669 DEFUN (neighbor_filter_list
,
5670 neighbor_filter_list_cmd
,
5671 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5674 "Establish BGP filters\n"
5675 "AS path access-list name\n"
5676 "Filter incoming routes\n"
5677 "Filter outgoing routes\n")
5682 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5683 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5684 argv
[idx_in_out
]->arg
);
5687 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5688 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5689 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5690 "Establish BGP filters\n"
5691 "AS path access-list name\n"
5692 "Filter incoming routes\n"
5693 "Filter outgoing routes\n")
5695 DEFUN (no_neighbor_filter_list
,
5696 no_neighbor_filter_list_cmd
,
5697 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5701 "Establish BGP filters\n"
5702 "AS path access-list name\n"
5703 "Filter incoming routes\n"
5704 "Filter outgoing routes\n")
5708 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5709 bgp_node_afi(vty
), bgp_node_safi(vty
),
5710 argv
[idx_in_out
]->arg
);
5713 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5714 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5715 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5716 "Establish BGP filters\n"
5717 "AS path access-list name\n"
5718 "Filter incoming routes\n"
5719 "Filter outgoing routes\n")
5721 /* Set route-map to the peer. */
5722 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5723 afi_t afi
, safi_t safi
, const char *name_str
,
5724 const char *direct_str
)
5728 int direct
= RMAP_IN
;
5729 struct route_map
*route_map
;
5731 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5733 return CMD_WARNING_CONFIG_FAILED
;
5735 /* Check filter direction. */
5736 if (strncmp(direct_str
, "in", 2) == 0)
5738 else if (strncmp(direct_str
, "o", 1) == 0)
5741 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5742 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5744 return bgp_vty_return(vty
, ret
);
5747 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5748 afi_t afi
, safi_t safi
,
5749 const char *direct_str
)
5753 int direct
= RMAP_IN
;
5755 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5757 return CMD_WARNING_CONFIG_FAILED
;
5759 /* Check filter direction. */
5760 if (strncmp(direct_str
, "in", 2) == 0)
5762 else if (strncmp(direct_str
, "o", 1) == 0)
5765 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5767 return bgp_vty_return(vty
, ret
);
5770 DEFUN (neighbor_route_map
,
5771 neighbor_route_map_cmd
,
5772 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5775 "Apply route map to neighbor\n"
5776 "Name of route map\n"
5777 "Apply map to incoming routes\n"
5778 "Apply map to outbound routes\n")
5783 return peer_route_map_set_vty(
5784 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5785 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5788 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5789 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5790 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5791 "Apply route map to neighbor\n"
5792 "Name of route map\n"
5793 "Apply map to incoming routes\n"
5794 "Apply map to outbound routes\n")
5796 DEFUN (no_neighbor_route_map
,
5797 no_neighbor_route_map_cmd
,
5798 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5802 "Apply route map to neighbor\n"
5803 "Name of route map\n"
5804 "Apply map to incoming routes\n"
5805 "Apply map to outbound routes\n")
5809 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5810 bgp_node_afi(vty
), bgp_node_safi(vty
),
5811 argv
[idx_in_out
]->arg
);
5814 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5815 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5816 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5817 "Apply route map to neighbor\n"
5818 "Name of route map\n"
5819 "Apply map to incoming routes\n"
5820 "Apply map to outbound routes\n")
5822 /* Set unsuppress-map to the peer. */
5823 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5824 afi_t afi
, safi_t safi
,
5825 const char *name_str
)
5829 struct route_map
*route_map
;
5831 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5833 return CMD_WARNING_CONFIG_FAILED
;
5835 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5836 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5838 return bgp_vty_return(vty
, ret
);
5841 /* Unset route-map from the peer. */
5842 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5843 afi_t afi
, safi_t safi
)
5848 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5850 return CMD_WARNING_CONFIG_FAILED
;
5852 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5854 return bgp_vty_return(vty
, ret
);
5857 DEFUN (neighbor_unsuppress_map
,
5858 neighbor_unsuppress_map_cmd
,
5859 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5862 "Route-map to selectively unsuppress suppressed routes\n"
5863 "Name of route map\n")
5867 return peer_unsuppress_map_set_vty(
5868 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5869 argv
[idx_word
]->arg
);
5872 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5873 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5874 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5875 "Route-map to selectively unsuppress suppressed routes\n"
5876 "Name of route map\n")
5878 DEFUN (no_neighbor_unsuppress_map
,
5879 no_neighbor_unsuppress_map_cmd
,
5880 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5884 "Route-map to selectively unsuppress suppressed routes\n"
5885 "Name of route map\n")
5888 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5890 bgp_node_safi(vty
));
5893 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5894 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5895 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5896 "Route-map to selectively unsuppress suppressed routes\n"
5897 "Name of route map\n")
5899 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5900 afi_t afi
, safi_t safi
,
5901 const char *num_str
,
5902 const char *threshold_str
, int warning
,
5903 const char *restart_str
)
5911 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5913 return CMD_WARNING_CONFIG_FAILED
;
5915 max
= strtoul(num_str
, NULL
, 10);
5917 threshold
= atoi(threshold_str
);
5919 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5922 restart
= atoi(restart_str
);
5926 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5929 return bgp_vty_return(vty
, ret
);
5932 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5933 afi_t afi
, safi_t safi
)
5938 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5940 return CMD_WARNING_CONFIG_FAILED
;
5942 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5944 return bgp_vty_return(vty
, ret
);
5947 /* Maximum number of prefix configuration. prefix count is different
5948 for each peer configuration. So this configuration can be set for
5949 each peer configuration. */
5950 DEFUN (neighbor_maximum_prefix
,
5951 neighbor_maximum_prefix_cmd
,
5952 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5955 "Maximum number of prefix accept from this peer\n"
5956 "maximum no. of prefix limit\n")
5960 return peer_maximum_prefix_set_vty(
5961 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5962 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5965 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5966 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5967 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5968 "Maximum number of prefix accept from this peer\n"
5969 "maximum no. of prefix limit\n")
5971 DEFUN (neighbor_maximum_prefix_threshold
,
5972 neighbor_maximum_prefix_threshold_cmd
,
5973 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5976 "Maximum number of prefix accept from this peer\n"
5977 "maximum no. of prefix limit\n"
5978 "Threshold value (%) at which to generate a warning msg\n")
5982 int idx_number_2
= 4;
5983 return peer_maximum_prefix_set_vty(
5984 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5985 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5989 neighbor_maximum_prefix_threshold
,
5990 neighbor_maximum_prefix_threshold_hidden_cmd
,
5991 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5992 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5993 "Maximum number of prefix accept from this peer\n"
5994 "maximum no. of prefix limit\n"
5995 "Threshold value (%) at which to generate a warning msg\n")
5997 DEFUN (neighbor_maximum_prefix_warning
,
5998 neighbor_maximum_prefix_warning_cmd
,
5999 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6002 "Maximum number of prefix accept from this peer\n"
6003 "maximum no. of prefix limit\n"
6004 "Only give warning message when limit is exceeded\n")
6008 return peer_maximum_prefix_set_vty(
6009 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6010 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6014 neighbor_maximum_prefix_warning
,
6015 neighbor_maximum_prefix_warning_hidden_cmd
,
6016 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6017 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6018 "Maximum number of prefix accept from this peer\n"
6019 "maximum no. of prefix limit\n"
6020 "Only give warning message when limit is exceeded\n")
6022 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6023 neighbor_maximum_prefix_threshold_warning_cmd
,
6024 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6027 "Maximum number of prefix accept from this peer\n"
6028 "maximum no. of prefix limit\n"
6029 "Threshold value (%) at which to generate a warning msg\n"
6030 "Only give warning message when limit is exceeded\n")
6034 int idx_number_2
= 4;
6035 return peer_maximum_prefix_set_vty(
6036 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6037 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6041 neighbor_maximum_prefix_threshold_warning
,
6042 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6043 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6044 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6045 "Maximum number of prefix accept from this peer\n"
6046 "maximum no. of prefix limit\n"
6047 "Threshold value (%) at which to generate a warning msg\n"
6048 "Only give warning message when limit is exceeded\n")
6050 DEFUN (neighbor_maximum_prefix_restart
,
6051 neighbor_maximum_prefix_restart_cmd
,
6052 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6055 "Maximum number of prefix accept from this peer\n"
6056 "maximum no. of prefix limit\n"
6057 "Restart bgp connection after limit is exceeded\n"
6058 "Restart interval in minutes\n")
6062 int idx_number_2
= 5;
6063 return peer_maximum_prefix_set_vty(
6064 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6065 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6069 neighbor_maximum_prefix_restart
,
6070 neighbor_maximum_prefix_restart_hidden_cmd
,
6071 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6072 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6073 "Maximum number of prefix accept from this peer\n"
6074 "maximum no. of prefix limit\n"
6075 "Restart bgp connection after limit is exceeded\n"
6076 "Restart interval in minutes\n")
6078 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6079 neighbor_maximum_prefix_threshold_restart_cmd
,
6080 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6083 "Maximum number of prefixes to accept from this peer\n"
6084 "maximum no. of prefix limit\n"
6085 "Threshold value (%) at which to generate a warning msg\n"
6086 "Restart bgp connection after limit is exceeded\n"
6087 "Restart interval in minutes\n")
6091 int idx_number_2
= 4;
6092 int idx_number_3
= 6;
6093 return peer_maximum_prefix_set_vty(
6094 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6095 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6096 argv
[idx_number_3
]->arg
);
6100 neighbor_maximum_prefix_threshold_restart
,
6101 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6102 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6103 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6104 "Maximum number of prefixes to accept from this peer\n"
6105 "maximum no. of prefix limit\n"
6106 "Threshold value (%) at which to generate a warning msg\n"
6107 "Restart bgp connection after limit is exceeded\n"
6108 "Restart interval in minutes\n")
6110 DEFUN (no_neighbor_maximum_prefix
,
6111 no_neighbor_maximum_prefix_cmd
,
6112 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6116 "Maximum number of prefixes to accept from this peer\n"
6117 "maximum no. of prefix limit\n"
6118 "Threshold value (%) at which to generate a warning msg\n"
6119 "Restart bgp connection after limit is exceeded\n"
6120 "Restart interval in minutes\n"
6121 "Only give warning message when limit is exceeded\n")
6124 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6126 bgp_node_safi(vty
));
6130 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6131 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6132 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6133 "Maximum number of prefixes to accept from this peer\n"
6134 "maximum no. of prefix limit\n"
6135 "Threshold value (%) at which to generate a warning msg\n"
6136 "Restart bgp connection after limit is exceeded\n"
6137 "Restart interval in minutes\n"
6138 "Only give warning message when limit is exceeded\n")
6141 /* "neighbor allowas-in" */
6142 DEFUN (neighbor_allowas_in
,
6143 neighbor_allowas_in_cmd
,
6144 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6147 "Accept as-path with my AS present in it\n"
6148 "Number of occurences of AS number\n"
6149 "Only accept my AS in the as-path if the route was originated in my AS\n")
6152 int idx_number_origin
= 3;
6158 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6160 return CMD_WARNING_CONFIG_FAILED
;
6162 if (argc
<= idx_number_origin
)
6165 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6168 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6171 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6174 return bgp_vty_return(vty
, ret
);
6178 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6179 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6180 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6181 "Accept as-path with my AS present in it\n"
6182 "Number of occurences of AS number\n"
6183 "Only accept my AS in the as-path if the route was originated in my AS\n")
6185 DEFUN (no_neighbor_allowas_in
,
6186 no_neighbor_allowas_in_cmd
,
6187 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6191 "allow local ASN appears in aspath attribute\n"
6192 "Number of occurences of AS number\n"
6193 "Only accept my AS in the as-path if the route was originated in my AS\n")
6199 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6201 return CMD_WARNING_CONFIG_FAILED
;
6203 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6204 bgp_node_safi(vty
));
6206 return bgp_vty_return(vty
, ret
);
6210 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6211 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6212 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6213 "allow local ASN appears in aspath attribute\n"
6214 "Number of occurences of AS number\n"
6215 "Only accept my AS in the as-path if the route was originated in my AS\n")
6217 DEFUN (neighbor_ttl_security
,
6218 neighbor_ttl_security_cmd
,
6219 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6222 "BGP ttl-security parameters\n"
6223 "Specify the maximum number of hops to the BGP peer\n"
6224 "Number of hops to BGP peer\n")
6231 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6233 return CMD_WARNING_CONFIG_FAILED
;
6235 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6238 * If 'neighbor swpX', then this is for directly connected peers,
6239 * we should not accept a ttl-security hops value greater than 1.
6241 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6243 "%s is directly connected peer, hops cannot exceed 1\n",
6244 argv
[idx_peer
]->arg
);
6245 return CMD_WARNING_CONFIG_FAILED
;
6248 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6251 DEFUN (no_neighbor_ttl_security
,
6252 no_neighbor_ttl_security_cmd
,
6253 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6257 "BGP ttl-security parameters\n"
6258 "Specify the maximum number of hops to the BGP peer\n"
6259 "Number of hops to BGP peer\n")
6264 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6266 return CMD_WARNING_CONFIG_FAILED
;
6268 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6271 DEFUN (neighbor_addpath_tx_all_paths
,
6272 neighbor_addpath_tx_all_paths_cmd
,
6273 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6276 "Use addpath to advertise all paths to a neighbor\n")
6281 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6283 return CMD_WARNING_CONFIG_FAILED
;
6285 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6290 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6291 neighbor_addpath_tx_all_paths_hidden_cmd
,
6292 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6293 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6294 "Use addpath to advertise all paths to a neighbor\n")
6296 DEFUN (no_neighbor_addpath_tx_all_paths
,
6297 no_neighbor_addpath_tx_all_paths_cmd
,
6298 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6302 "Use addpath to advertise all paths to a neighbor\n")
6307 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6309 return CMD_WARNING_CONFIG_FAILED
;
6311 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6312 != BGP_ADDPATH_ALL
) {
6314 "%% Peer not currently configured to transmit all paths.");
6315 return CMD_WARNING_CONFIG_FAILED
;
6318 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6324 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6325 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6326 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6327 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6328 "Use addpath to advertise all paths to a neighbor\n")
6330 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6331 neighbor_addpath_tx_bestpath_per_as_cmd
,
6332 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6335 "Use addpath to advertise the bestpath per each neighboring AS\n")
6340 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6342 return CMD_WARNING_CONFIG_FAILED
;
6344 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6345 BGP_ADDPATH_BEST_PER_AS
);
6350 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6351 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6352 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6353 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6354 "Use addpath to advertise the bestpath per each neighboring AS\n")
6356 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6357 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6358 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6362 "Use addpath to advertise the bestpath per each neighboring AS\n")
6367 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6369 return CMD_WARNING_CONFIG_FAILED
;
6371 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6372 != BGP_ADDPATH_BEST_PER_AS
) {
6374 "%% Peer not currently configured to transmit all best path per as.");
6375 return CMD_WARNING_CONFIG_FAILED
;
6378 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6384 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6385 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6386 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6387 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6388 "Use addpath to advertise the bestpath per each neighboring AS\n")
6390 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6391 struct ecommunity
**list
)
6393 struct ecommunity
*ecom
= NULL
;
6394 struct ecommunity
*ecomadd
;
6396 for (; argc
; --argc
, ++argv
) {
6398 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6399 ECOMMUNITY_ROUTE_TARGET
, 0);
6401 vty_out(vty
, "Malformed community-list value\n");
6403 ecommunity_free(&ecom
);
6404 return CMD_WARNING_CONFIG_FAILED
;
6408 ecommunity_merge(ecom
, ecomadd
);
6409 ecommunity_free(&ecomadd
);
6416 ecommunity_free(&*list
);
6424 * v2vimport is true if we are handling a `import vrf ...` command
6426 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6430 switch (vty
->node
) {
6439 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6444 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6445 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6446 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6447 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6449 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6453 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6454 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6455 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6456 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6458 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6465 DEFPY (af_rd_vpn_export
,
6466 af_rd_vpn_export_cmd
,
6467 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6469 "Specify route distinguisher\n"
6470 "Between current address-family and vpn\n"
6471 "For routes leaked from current address-family to vpn\n"
6472 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6474 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6475 struct prefix_rd prd
;
6481 if (argv_find(argv
, argc
, "no", &idx
))
6485 ret
= str2prefix_rd(rd_str
, &prd
);
6487 vty_out(vty
, "%% Malformed rd\n");
6488 return CMD_WARNING_CONFIG_FAILED
;
6492 afi
= vpn_policy_getafi(vty
, bgp
, false);
6494 return CMD_WARNING_CONFIG_FAILED
;
6497 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6499 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6500 bgp_get_default(), bgp
);
6503 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6504 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6505 BGP_VPN_POLICY_TOVPN_RD_SET
);
6507 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6508 BGP_VPN_POLICY_TOVPN_RD_SET
);
6511 /* post-change: re-export vpn routes */
6512 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6513 bgp_get_default(), bgp
);
6518 ALIAS (af_rd_vpn_export
,
6519 af_no_rd_vpn_export_cmd
,
6522 "Specify route distinguisher\n"
6523 "Between current address-family and vpn\n"
6524 "For routes leaked from current address-family to vpn\n")
6526 DEFPY (af_label_vpn_export
,
6527 af_label_vpn_export_cmd
,
6528 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6530 "label value for VRF\n"
6531 "Between current address-family and vpn\n"
6532 "For routes leaked from current address-family to vpn\n"
6533 "Label Value <0-1048575>\n"
6534 "Automatically assign a label\n")
6536 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6537 mpls_label_t label
= MPLS_LABEL_NONE
;
6542 if (argv_find(argv
, argc
, "no", &idx
))
6545 /* If "no ...", squash trailing parameter */
6551 label
= label_val
; /* parser should force unsigned */
6554 afi
= vpn_policy_getafi(vty
, bgp
, false);
6556 return CMD_WARNING_CONFIG_FAILED
;
6559 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6560 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6565 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6567 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6568 bgp_get_default(), bgp
);
6570 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6571 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6573 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6576 * label has previously been automatically
6577 * assigned by labelpool: release it
6579 * NB if tovpn_label == MPLS_LABEL_NONE it
6580 * means the automatic assignment is in flight
6581 * and therefore the labelpool callback must
6582 * detect that the auto label is not needed.
6585 bgp_lp_release(LP_TYPE_VRF
,
6586 &bgp
->vpn_policy
[afi
],
6587 bgp
->vpn_policy
[afi
].tovpn_label
);
6589 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6590 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6593 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6595 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6596 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6597 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6598 vpn_leak_label_callback
);
6601 /* post-change: re-export vpn routes */
6602 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6603 bgp_get_default(), bgp
);
6608 ALIAS (af_label_vpn_export
,
6609 af_no_label_vpn_export_cmd
,
6610 "no label vpn export",
6612 "label value for VRF\n"
6613 "Between current address-family and vpn\n"
6614 "For routes leaked from current address-family to vpn\n")
6616 DEFPY (af_nexthop_vpn_export
,
6617 af_nexthop_vpn_export_cmd
,
6618 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6620 "Specify next hop to use for VRF advertised prefixes\n"
6621 "Between current address-family and vpn\n"
6622 "For routes leaked from current address-family to vpn\n"
6626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6632 if (argv_find(argv
, argc
, "no", &idx
))
6636 if (!sockunion2hostprefix(nexthop_str
, &p
))
6637 return CMD_WARNING_CONFIG_FAILED
;
6640 afi
= vpn_policy_getafi(vty
, bgp
, false);
6642 return CMD_WARNING_CONFIG_FAILED
;
6645 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6647 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6648 bgp_get_default(), bgp
);
6651 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6652 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6653 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6655 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6656 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6659 /* post-change: re-export vpn routes */
6660 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6661 bgp_get_default(), bgp
);
6666 ALIAS (af_nexthop_vpn_export
,
6667 af_no_nexthop_vpn_export_cmd
,
6668 "no nexthop vpn export",
6670 "Specify next hop to use for VRF advertised prefixes\n"
6671 "Between current address-family and vpn\n"
6672 "For routes leaked from current address-family to vpn\n")
6674 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6676 if (!strcmp(dstr
, "import")) {
6677 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6678 } else if (!strcmp(dstr
, "export")) {
6679 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6680 } else if (!strcmp(dstr
, "both")) {
6681 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6682 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6684 vty_out(vty
, "%% direction parse error\n");
6685 return CMD_WARNING_CONFIG_FAILED
;
6690 DEFPY (af_rt_vpn_imexport
,
6691 af_rt_vpn_imexport_cmd
,
6692 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6694 "Specify route target list\n"
6695 "Specify route target list\n"
6696 "Between current address-family and vpn\n"
6697 "For routes leaked from vpn to current address-family: match any\n"
6698 "For routes leaked from current address-family to vpn: set\n"
6699 "both import: match any and export: set\n"
6700 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6704 struct ecommunity
*ecom
= NULL
;
6705 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6706 vpn_policy_direction_t dir
;
6711 if (argv_find(argv
, argc
, "no", &idx
))
6714 afi
= vpn_policy_getafi(vty
, bgp
, false);
6716 return CMD_WARNING_CONFIG_FAILED
;
6718 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6719 if (ret
!= CMD_SUCCESS
)
6723 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6724 vty_out(vty
, "%% Missing RTLIST\n");
6725 return CMD_WARNING_CONFIG_FAILED
;
6727 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6728 if (ret
!= CMD_SUCCESS
) {
6733 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6737 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6740 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6742 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6743 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6744 ecommunity_dup(ecom
);
6746 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6748 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6749 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6752 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6756 ecommunity_free(&ecom
);
6761 ALIAS (af_rt_vpn_imexport
,
6762 af_no_rt_vpn_imexport_cmd
,
6763 "no <rt|route-target> vpn <import|export|both>$direction_str",
6765 "Specify route target list\n"
6766 "Specify route target list\n"
6767 "Between current address-family and vpn\n"
6768 "For routes leaked from vpn to current address-family\n"
6769 "For routes leaked from current address-family to vpn\n"
6770 "both import and export\n")
6772 DEFPY (af_route_map_vpn_imexport
,
6773 af_route_map_vpn_imexport_cmd
,
6774 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6775 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6777 "Specify route map\n"
6778 "Between current address-family and vpn\n"
6779 "For routes leaked from vpn to current address-family\n"
6780 "For routes leaked from current address-family to vpn\n"
6781 "name of route-map\n")
6783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6785 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6786 vpn_policy_direction_t dir
;
6791 if (argv_find(argv
, argc
, "no", &idx
))
6794 afi
= vpn_policy_getafi(vty
, bgp
, false);
6796 return CMD_WARNING_CONFIG_FAILED
;
6798 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6799 if (ret
!= CMD_SUCCESS
)
6802 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6806 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6809 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6810 XFREE(MTYPE_ROUTE_MAP_NAME
,
6811 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6812 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6813 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6814 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6815 route_map_lookup_warn_noexist(vty
, rmap_str
);
6816 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6819 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6820 XFREE(MTYPE_ROUTE_MAP_NAME
,
6821 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6822 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6823 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6826 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6832 ALIAS (af_route_map_vpn_imexport
,
6833 af_no_route_map_vpn_imexport_cmd
,
6834 "no route-map vpn <import|export>$direction_str",
6836 "Specify route map\n"
6837 "Between current address-family and vpn\n"
6838 "For routes leaked from vpn to current address-family\n"
6839 "For routes leaked from current address-family to vpn\n")
6841 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6842 "[no] import vrf route-map RMAP$rmap_str",
6844 "Import routes from another VRF\n"
6845 "Vrf routes being filtered\n"
6846 "Specify route map\n"
6847 "name of route-map\n")
6849 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6850 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6854 struct bgp
*bgp_default
;
6856 if (argv_find(argv
, argc
, "no", &idx
))
6859 afi
= vpn_policy_getafi(vty
, bgp
, true);
6861 return CMD_WARNING_CONFIG_FAILED
;
6863 bgp_default
= bgp_get_default();
6868 /* Auto-create assuming the same AS */
6869 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6870 BGP_INSTANCE_TYPE_DEFAULT
);
6874 "VRF default is not configured as a bgp instance\n");
6879 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6882 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6883 XFREE(MTYPE_ROUTE_MAP_NAME
,
6884 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6885 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6886 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6887 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6888 route_map_lookup_warn_noexist(vty
, rmap_str
);
6889 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6892 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6893 XFREE(MTYPE_ROUTE_MAP_NAME
,
6894 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6895 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6896 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6899 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6904 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6905 "no import vrf route-map",
6907 "Import routes from another VRF\n"
6908 "Vrf routes being filtered\n"
6909 "Specify route map\n")
6911 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6912 "[no] import vrf VIEWVRFNAME$import_name",
6914 "Import routes from another VRF\n"
6915 "VRF to import from\n"
6916 "The name of the VRF\n")
6918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6919 struct listnode
*node
;
6920 struct bgp
*vrf_bgp
, *bgp_default
;
6923 bool remove
= false;
6926 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6930 if (import_name
== NULL
) {
6931 vty_out(vty
, "%% Missing import name\n");
6935 if (argv_find(argv
, argc
, "no", &idx
))
6938 afi
= vpn_policy_getafi(vty
, bgp
, true);
6940 return CMD_WARNING_CONFIG_FAILED
;
6942 safi
= bgp_node_safi(vty
);
6944 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6945 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6946 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6947 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6948 remove
? "unimport" : "import", import_name
);
6952 bgp_default
= bgp_get_default();
6954 /* Auto-create assuming the same AS */
6955 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6956 BGP_INSTANCE_TYPE_DEFAULT
);
6960 "VRF default is not configured as a bgp instance\n");
6965 vrf_bgp
= bgp_lookup_by_name(import_name
);
6967 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6968 vrf_bgp
= bgp_default
;
6970 /* Auto-create assuming the same AS */
6971 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6975 "VRF %s is not configured as a bgp instance\n",
6982 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6984 /* Already importing from "import_vrf"? */
6985 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6987 if (strcmp(vname
, import_name
) == 0)
6991 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6997 /* This command is valid only in a bgp vrf instance or the default instance */
6998 DEFPY (bgp_imexport_vpn
,
6999 bgp_imexport_vpn_cmd
,
7000 "[no] <import|export>$direction_str vpn",
7002 "Import routes to this address-family\n"
7003 "Export routes from this address-family\n"
7004 "to/from default instance VPN RIB\n")
7006 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7013 vpn_policy_direction_t dir
;
7015 if (argv_find(argv
, argc
, "no", &idx
))
7018 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7019 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7021 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7022 return CMD_WARNING_CONFIG_FAILED
;
7025 afi
= bgp_node_afi(vty
);
7026 safi
= bgp_node_safi(vty
);
7027 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7028 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7029 return CMD_WARNING_CONFIG_FAILED
;
7032 if (!strcmp(direction_str
, "import")) {
7033 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7034 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7035 } else if (!strcmp(direction_str
, "export")) {
7036 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7037 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7039 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7040 return CMD_WARNING_CONFIG_FAILED
;
7043 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7046 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7047 if (!previous_state
) {
7048 /* trigger export current vrf */
7049 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7052 if (previous_state
) {
7053 /* trigger un-export current vrf */
7054 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7056 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7062 DEFPY (af_routetarget_import
,
7063 af_routetarget_import_cmd
,
7064 "[no] <rt|route-target> redirect import RTLIST...",
7066 "Specify route target list\n"
7067 "Specify route target list\n"
7068 "Flow-spec redirect type route target\n"
7069 "Import routes to this address-family\n"
7070 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7074 struct ecommunity
*ecom
= NULL
;
7079 if (argv_find(argv
, argc
, "no", &idx
))
7082 afi
= vpn_policy_getafi(vty
, bgp
, false);
7084 return CMD_WARNING_CONFIG_FAILED
;
7087 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7088 vty_out(vty
, "%% Missing RTLIST\n");
7089 return CMD_WARNING_CONFIG_FAILED
;
7091 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7092 if (ret
!= CMD_SUCCESS
)
7097 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7098 ecommunity_free(&bgp
->vpn_policy
[afi
]
7099 .import_redirect_rtlist
);
7100 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7101 ecommunity_dup(ecom
);
7103 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7104 ecommunity_free(&bgp
->vpn_policy
[afi
]
7105 .import_redirect_rtlist
);
7106 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7110 ecommunity_free(&ecom
);
7115 DEFUN_NOSH (address_family_ipv4_safi
,
7116 address_family_ipv4_safi_cmd
,
7117 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7118 "Enter Address Family command mode\n"
7120 BGP_SAFI_WITH_LABEL_HELP_STR
)
7124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7125 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7126 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7127 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7128 && safi
!= SAFI_EVPN
) {
7130 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7131 return CMD_WARNING_CONFIG_FAILED
;
7133 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7135 vty
->node
= BGP_IPV4_NODE
;
7140 DEFUN_NOSH (address_family_ipv6_safi
,
7141 address_family_ipv6_safi_cmd
,
7142 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7143 "Enter Address Family command mode\n"
7145 BGP_SAFI_WITH_LABEL_HELP_STR
)
7148 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7149 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7150 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7151 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7152 && safi
!= SAFI_EVPN
) {
7154 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7155 return CMD_WARNING_CONFIG_FAILED
;
7157 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7159 vty
->node
= BGP_IPV6_NODE
;
7164 #ifdef KEEP_OLD_VPN_COMMANDS
7165 DEFUN_NOSH (address_family_vpnv4
,
7166 address_family_vpnv4_cmd
,
7167 "address-family vpnv4 [unicast]",
7168 "Enter Address Family command mode\n"
7170 "Address Family modifier\n")
7172 vty
->node
= BGP_VPNV4_NODE
;
7176 DEFUN_NOSH (address_family_vpnv6
,
7177 address_family_vpnv6_cmd
,
7178 "address-family vpnv6 [unicast]",
7179 "Enter Address Family command mode\n"
7181 "Address Family modifier\n")
7183 vty
->node
= BGP_VPNV6_NODE
;
7186 #endif /* KEEP_OLD_VPN_COMMANDS */
7188 DEFUN_NOSH (address_family_evpn
,
7189 address_family_evpn_cmd
,
7190 "address-family l2vpn evpn",
7191 "Enter Address Family command mode\n"
7193 "Address Family modifier\n")
7195 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7196 vty
->node
= BGP_EVPN_NODE
;
7200 DEFUN_NOSH (exit_address_family
,
7201 exit_address_family_cmd
,
7202 "exit-address-family",
7203 "Exit from Address Family configuration mode\n")
7205 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7206 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7207 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7208 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7209 || vty
->node
== BGP_EVPN_NODE
7210 || vty
->node
== BGP_FLOWSPECV4_NODE
7211 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7212 vty
->node
= BGP_NODE
;
7216 /* Recalculate bestpath and re-advertise a prefix */
7217 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7218 const char *ip_str
, afi_t afi
, safi_t safi
,
7219 struct prefix_rd
*prd
)
7222 struct prefix match
;
7223 struct bgp_node
*rn
;
7224 struct bgp_node
*rm
;
7226 struct bgp_table
*table
;
7227 struct bgp_table
*rib
;
7229 /* BGP structure lookup. */
7231 bgp
= bgp_lookup_by_name(view_name
);
7233 vty_out(vty
, "%% Can't find BGP instance %s\n",
7238 bgp
= bgp_get_default();
7240 vty_out(vty
, "%% No BGP process is configured\n");
7245 /* Check IP address argument. */
7246 ret
= str2prefix(ip_str
, &match
);
7248 vty_out(vty
, "%% address is malformed\n");
7252 match
.family
= afi2family(afi
);
7253 rib
= bgp
->rib
[afi
][safi
];
7255 if (safi
== SAFI_MPLS_VPN
) {
7256 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7257 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7260 table
= bgp_node_get_bgp_table_info(rn
);
7261 if (table
!= NULL
) {
7263 if ((rm
= bgp_node_match(table
, &match
))
7266 == match
.prefixlen
) {
7268 BGP_NODE_USER_CLEAR
);
7269 bgp_process(bgp
, rm
, afi
, safi
);
7271 bgp_unlock_node(rm
);
7276 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7277 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7278 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7279 bgp_process(bgp
, rn
, afi
, safi
);
7281 bgp_unlock_node(rn
);
7288 /* one clear bgp command to rule them all */
7289 DEFUN (clear_ip_bgp_all
,
7290 clear_ip_bgp_all_cmd
,
7291 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7295 BGP_INSTANCE_HELP_STR
7298 BGP_SAFI_WITH_LABEL_HELP_STR
7299 "Address Family modifier\n"
7301 "BGP neighbor address to clear\n"
7302 "BGP IPv6 neighbor to clear\n"
7303 "BGP neighbor on interface to clear\n"
7304 "Clear peers with the AS number\n"
7305 "Clear all external peers\n"
7306 "Clear all members of peer-group\n"
7307 "BGP peer-group name\n"
7312 "Push out prefix-list ORF and do inbound soft reconfig\n"
7317 afi_t afi
= AFI_IP6
;
7318 safi_t safi
= SAFI_UNICAST
;
7319 enum clear_sort clr_sort
= clear_peer
;
7320 enum bgp_clear_type clr_type
;
7321 char *clr_arg
= NULL
;
7325 /* clear [ip] bgp */
7326 if (argv_find(argv
, argc
, "ip", &idx
))
7329 /* [<vrf> VIEWVRFNAME] */
7330 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7331 vrf
= argv
[idx
+ 1]->arg
;
7333 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7335 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7336 /* [<view> VIEWVRFNAME] */
7337 vrf
= argv
[idx
+ 1]->arg
;
7340 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7341 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7342 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7344 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7345 if (argv_find(argv
, argc
, "*", &idx
)) {
7346 clr_sort
= clear_all
;
7347 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7348 clr_sort
= clear_peer
;
7349 clr_arg
= argv
[idx
]->arg
;
7350 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7351 clr_sort
= clear_peer
;
7352 clr_arg
= argv
[idx
]->arg
;
7353 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7354 clr_sort
= clear_group
;
7356 clr_arg
= argv
[idx
]->arg
;
7357 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7358 clr_sort
= clear_peer
;
7359 clr_arg
= argv
[idx
]->arg
;
7360 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7361 clr_sort
= clear_as
;
7362 clr_arg
= argv
[idx
]->arg
;
7363 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7364 clr_sort
= clear_external
;
7367 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7368 if (argv_find(argv
, argc
, "soft", &idx
)) {
7369 if (argv_find(argv
, argc
, "in", &idx
)
7370 || argv_find(argv
, argc
, "out", &idx
))
7371 clr_type
= strmatch(argv
[idx
]->text
, "in")
7373 : BGP_CLEAR_SOFT_OUT
;
7375 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7376 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7377 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7378 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7379 : BGP_CLEAR_SOFT_IN
;
7380 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7381 clr_type
= BGP_CLEAR_SOFT_OUT
;
7383 clr_type
= BGP_CLEAR_SOFT_NONE
;
7385 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7388 DEFUN (clear_ip_bgp_prefix
,
7389 clear_ip_bgp_prefix_cmd
,
7390 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7394 BGP_INSTANCE_HELP_STR
7395 "Clear bestpath and re-advertise\n"
7399 char *prefix
= NULL
;
7403 /* [<view|vrf> VIEWVRFNAME] */
7404 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7405 vrf
= argv
[idx
+ 1]->arg
;
7407 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7409 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7410 /* [<view> VIEWVRFNAME] */
7411 vrf
= argv
[idx
+ 1]->arg
;
7415 prefix
= argv
[argc
- 1]->arg
;
7417 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7420 DEFUN (clear_bgp_ipv6_safi_prefix
,
7421 clear_bgp_ipv6_safi_prefix_cmd
,
7422 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7428 "Clear bestpath and re-advertise\n"
7432 int idx_ipv6_prefix
= 0;
7433 safi_t safi
= SAFI_UNICAST
;
7434 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7435 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7437 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7438 return bgp_clear_prefix(
7439 vty
, NULL
, prefix
, AFI_IP6
,
7443 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7444 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7445 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7449 BGP_INSTANCE_HELP_STR
7452 "Clear bestpath and re-advertise\n"
7456 int idx_vrfview
= 0;
7457 int idx_ipv6_prefix
= 0;
7458 safi_t safi
= SAFI_UNICAST
;
7459 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7460 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7461 char *vrfview
= NULL
;
7463 /* [<view|vrf> VIEWVRFNAME] */
7464 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7465 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7466 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7468 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7469 /* [<view> VIEWVRFNAME] */
7470 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7472 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7474 return bgp_clear_prefix(
7475 vty
, vrfview
, prefix
,
7476 AFI_IP6
, safi
, NULL
);
7479 DEFUN (show_bgp_views
,
7481 "show [ip] bgp views",
7485 "Show the defined BGP views\n")
7487 struct list
*inst
= bm
->bgp
;
7488 struct listnode
*node
;
7491 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7492 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7496 vty_out(vty
, "Defined BGP views:\n");
7497 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7499 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7501 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7508 DEFUN (show_bgp_vrfs
,
7510 "show [ip] bgp vrfs [json]",
7517 char buf
[ETHER_ADDR_STRLEN
];
7518 struct list
*inst
= bm
->bgp
;
7519 struct listnode
*node
;
7521 bool uj
= use_json(argc
, argv
);
7522 json_object
*json
= NULL
;
7523 json_object
*json_vrfs
= NULL
;
7526 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7527 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7532 json
= json_object_new_object();
7533 json_vrfs
= json_object_new_object();
7536 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7537 const char *name
, *type
;
7539 struct listnode
*node2
, *nnode2
;
7540 int peers_cfg
, peers_estb
;
7541 json_object
*json_vrf
= NULL
;
7544 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7548 if (!uj
&& count
== 1)
7550 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7551 "Type", "Id", "routerId", "#PeersVfg",
7552 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7554 peers_cfg
= peers_estb
= 0;
7556 json_vrf
= json_object_new_object();
7559 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7560 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7563 if (peer
->status
== Established
)
7567 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7568 name
= VRF_DEFAULT_NAME
;
7577 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7579 : (int64_t)bgp
->vrf_id
;
7580 json_object_string_add(json_vrf
, "type", type
);
7581 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7582 json_object_string_add(json_vrf
, "routerId",
7583 inet_ntoa(bgp
->router_id
));
7584 json_object_int_add(json_vrf
, "numConfiguredPeers",
7586 json_object_int_add(json_vrf
, "numEstablishedPeers",
7589 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7590 json_object_string_add(
7592 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7593 json_object_object_add(json_vrfs
, name
, json_vrf
);
7596 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7598 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7600 inet_ntoa(bgp
->router_id
), peers_cfg
,
7601 peers_estb
, name
, bgp
->l3vni
,
7602 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7606 json_object_object_add(json
, "vrfs", json_vrfs
);
7608 json_object_int_add(json
, "totalVrfs", count
);
7610 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7611 json
, JSON_C_TO_STRING_PRETTY
));
7612 json_object_free(json
);
7616 "\nTotal number of VRFs (including default): %d\n",
7623 DEFUN (show_bgp_mac_hash
,
7624 show_bgp_mac_hash_cmd
,
7625 "show bgp mac hash",
7629 "Mac Address database\n")
7631 bgp_mac_dump_table(vty
);
7636 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7638 struct vty
*vty
= (struct vty
*)args
;
7639 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7641 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7645 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7647 vty_out(vty
, "self nexthop database:\n");
7648 bgp_nexthop_show_address_hash(vty
, bgp
);
7650 vty_out(vty
, "Tunnel-ip database:\n");
7651 hash_iterate(bgp
->tip_hash
,
7652 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7656 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7657 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7658 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7659 "martian next-hops\n"
7660 "martian next-hop database\n")
7662 struct bgp
*bgp
= NULL
;
7666 /* [<vrf> VIEWVRFNAME] */
7667 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7668 name
= argv
[idx
+ 1]->arg
;
7669 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7671 } else if (argv_find(argv
, argc
, "view", &idx
))
7672 /* [<view> VIEWVRFNAME] */
7673 name
= argv
[idx
+ 1]->arg
;
7675 bgp
= bgp_lookup_by_name(name
);
7677 bgp
= bgp_get_default();
7680 vty_out(vty
, "%% No BGP process is configured\n");
7683 bgp_show_martian_nexthops(vty
, bgp
);
7688 DEFUN (show_bgp_memory
,
7689 show_bgp_memory_cmd
,
7690 "show [ip] bgp memory",
7694 "Global BGP memory statistics\n")
7696 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7697 unsigned long count
;
7699 /* RIB related usage stats */
7700 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7701 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7702 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7703 count
* sizeof(struct bgp_node
)));
7705 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7706 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7707 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7708 count
* sizeof(struct bgp_path_info
)));
7709 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7710 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7713 memstrbuf
, sizeof(memstrbuf
),
7714 count
* sizeof(struct bgp_path_info_extra
)));
7716 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7717 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7718 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7719 count
* sizeof(struct bgp_static
)));
7721 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7722 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7723 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7724 count
* sizeof(struct bpacket
)));
7727 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7728 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7729 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7730 count
* sizeof(struct bgp_adj_in
)));
7731 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7732 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7733 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7734 count
* sizeof(struct bgp_adj_out
)));
7736 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7737 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7739 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7740 count
* sizeof(struct bgp_nexthop_cache
)));
7742 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7743 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7745 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7746 count
* sizeof(struct bgp_damp_info
)));
7749 count
= attr_count();
7750 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7751 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7752 count
* sizeof(struct attr
)));
7754 if ((count
= attr_unknown_count()))
7755 vty_out(vty
, "%ld unknown attributes\n", count
);
7757 /* AS_PATH attributes */
7758 count
= aspath_count();
7759 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7760 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7761 count
* sizeof(struct aspath
)));
7763 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7764 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7765 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7766 count
* sizeof(struct assegment
)));
7768 /* Other attributes */
7769 if ((count
= community_count()))
7770 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7771 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7772 count
* sizeof(struct community
)));
7773 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7774 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7775 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7776 count
* sizeof(struct ecommunity
)));
7777 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7779 "%ld BGP large-community entries, using %s of memory\n",
7780 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7781 count
* sizeof(struct lcommunity
)));
7783 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7784 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7785 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7786 count
* sizeof(struct cluster_list
)));
7788 /* Peer related usage */
7789 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7790 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7791 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7792 count
* sizeof(struct peer
)));
7794 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7795 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7796 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7797 count
* sizeof(struct peer_group
)));
7800 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7801 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7802 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7803 count
* sizeof(struct hash
)));
7804 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7805 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7806 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7807 count
* sizeof(struct hash_bucket
)));
7808 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7809 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7810 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7811 count
* sizeof(regex_t
)));
7815 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7817 json_object
*bestpath
= json_object_new_object();
7819 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7820 json_object_string_add(bestpath
, "asPath", "ignore");
7822 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7823 json_object_string_add(bestpath
, "asPath", "confed");
7825 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7826 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7827 json_object_string_add(bestpath
, "multiPathRelax",
7830 json_object_string_add(bestpath
, "multiPathRelax",
7833 json_object_string_add(bestpath
, "multiPathRelax", "false");
7835 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7836 json_object_string_add(bestpath
, "compareRouterId", "true");
7837 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7838 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7839 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7840 json_object_string_add(bestpath
, "med", "confed");
7841 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7842 json_object_string_add(bestpath
, "med",
7843 "missing-as-worst");
7845 json_object_string_add(bestpath
, "med", "true");
7848 json_object_object_add(json
, "bestPath", bestpath
);
7851 /* Show BGP peer's summary information. */
7852 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7853 bool use_json
, json_object
*json
)
7856 struct listnode
*node
, *nnode
;
7857 unsigned int count
= 0, dn_count
= 0;
7858 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7859 char neighbor_buf
[VTY_BUFSIZ
];
7860 int neighbor_col_default_width
= 16;
7862 int max_neighbor_width
= 0;
7864 json_object
*json_peer
= NULL
;
7865 json_object
*json_peers
= NULL
;
7866 struct peer_af
*paf
;
7868 /* labeled-unicast routes are installed in the unicast table so in order
7870 * display the correct PfxRcd value we must look at SAFI_UNICAST
7872 if (safi
== SAFI_LABELED_UNICAST
)
7873 pfx_rcd_safi
= SAFI_UNICAST
;
7875 pfx_rcd_safi
= safi
;
7879 json
= json_object_new_object();
7881 json_peers
= json_object_new_object();
7883 /* Loop over all neighbors that will be displayed to determine
7885 * characters are needed for the Neighbor column
7887 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7888 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7891 if (peer
->afc
[afi
][safi
]) {
7892 memset(dn_flag
, '\0', sizeof(dn_flag
));
7893 if (peer_dynamic_neighbor(peer
))
7897 && bgp_flag_check(bgp
,
7898 BGP_FLAG_SHOW_HOSTNAME
))
7899 sprintf(neighbor_buf
, "%s%s(%s) ",
7900 dn_flag
, peer
->hostname
,
7903 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7906 len
= strlen(neighbor_buf
);
7908 if (len
> max_neighbor_width
)
7909 max_neighbor_width
= len
;
7913 /* Originally we displayed the Neighbor column as 16
7914 * characters wide so make that the default
7916 if (max_neighbor_width
< neighbor_col_default_width
)
7917 max_neighbor_width
= neighbor_col_default_width
;
7920 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7921 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7924 if (!peer
->afc
[afi
][safi
])
7929 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7932 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7934 : (int64_t)bgp
->vrf_id
;
7936 /* Usage summary and header */
7938 json_object_string_add(
7940 inet_ntoa(bgp
->router_id
));
7941 json_object_int_add(json
, "as", bgp
->as
);
7942 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7943 json_object_string_add(
7946 == BGP_INSTANCE_TYPE_DEFAULT
)
7951 "BGP router identifier %s, local AS number %u vrf-id %d",
7952 inet_ntoa(bgp
->router_id
), bgp
->as
,
7953 bgp
->vrf_id
== VRF_UNKNOWN
7955 : (int)bgp
->vrf_id
);
7959 if (bgp_update_delay_configured(bgp
)) {
7961 json_object_int_add(
7962 json
, "updateDelayLimit",
7963 bgp
->v_update_delay
);
7965 if (bgp
->v_update_delay
7966 != bgp
->v_establish_wait
)
7967 json_object_int_add(
7969 "updateDelayEstablishWait",
7970 bgp
->v_establish_wait
);
7972 if (bgp_update_delay_active(bgp
)) {
7973 json_object_string_add(
7975 "updateDelayFirstNeighbor",
7976 bgp
->update_delay_begin_time
);
7977 json_object_boolean_true_add(
7979 "updateDelayInProgress");
7981 if (bgp
->update_delay_over
) {
7982 json_object_string_add(
7984 "updateDelayFirstNeighbor",
7985 bgp
->update_delay_begin_time
);
7986 json_object_string_add(
7988 "updateDelayBestpathResumed",
7989 bgp
->update_delay_end_time
);
7990 json_object_string_add(
7992 "updateDelayZebraUpdateResume",
7993 bgp
->update_delay_zebra_resume_time
);
7994 json_object_string_add(
7996 "updateDelayPeerUpdateResume",
7997 bgp
->update_delay_peers_resume_time
);
8002 "Read-only mode update-delay limit: %d seconds\n",
8003 bgp
->v_update_delay
);
8004 if (bgp
->v_update_delay
8005 != bgp
->v_establish_wait
)
8007 " Establish wait: %d seconds\n",
8008 bgp
->v_establish_wait
);
8010 if (bgp_update_delay_active(bgp
)) {
8012 " First neighbor established: %s\n",
8013 bgp
->update_delay_begin_time
);
8015 " Delay in progress\n");
8017 if (bgp
->update_delay_over
) {
8019 " First neighbor established: %s\n",
8020 bgp
->update_delay_begin_time
);
8022 " Best-paths resumed: %s\n",
8023 bgp
->update_delay_end_time
);
8025 " zebra update resumed: %s\n",
8026 bgp
->update_delay_zebra_resume_time
);
8028 " peers update resumed: %s\n",
8029 bgp
->update_delay_peers_resume_time
);
8036 if (bgp_maxmed_onstartup_configured(bgp
)
8037 && bgp
->maxmed_active
)
8038 json_object_boolean_true_add(
8039 json
, "maxMedOnStartup");
8040 if (bgp
->v_maxmed_admin
)
8041 json_object_boolean_true_add(
8042 json
, "maxMedAdministrative");
8044 json_object_int_add(
8045 json
, "tableVersion",
8046 bgp_table_version(bgp
->rib
[afi
][safi
]));
8048 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8049 json_object_int_add(json
, "ribCount", ents
);
8050 json_object_int_add(
8052 ents
* sizeof(struct bgp_node
));
8054 ents
= bgp
->af_peer_count
[afi
][safi
];
8055 json_object_int_add(json
, "peerCount", ents
);
8056 json_object_int_add(json
, "peerMemory",
8057 ents
* sizeof(struct peer
));
8059 if ((ents
= listcount(bgp
->group
))) {
8060 json_object_int_add(
8061 json
, "peerGroupCount", ents
);
8062 json_object_int_add(
8063 json
, "peerGroupMemory",
8064 ents
* sizeof(struct
8068 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8069 BGP_CONFIG_DAMPENING
))
8070 json_object_boolean_true_add(
8071 json
, "dampeningEnabled");
8073 if (bgp_maxmed_onstartup_configured(bgp
)
8074 && bgp
->maxmed_active
)
8076 "Max-med on-startup active\n");
8077 if (bgp
->v_maxmed_admin
)
8079 "Max-med administrative active\n");
8081 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8082 bgp_table_version(bgp
->rib
[afi
][safi
]));
8084 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8086 "RIB entries %ld, using %s of memory\n",
8088 mtype_memstr(memstrbuf
,
8090 ents
* sizeof(struct
8093 /* Peer related usage */
8094 ents
= bgp
->af_peer_count
[afi
][safi
];
8095 vty_out(vty
, "Peers %ld, using %s of memory\n",
8098 memstrbuf
, sizeof(memstrbuf
),
8099 ents
* sizeof(struct peer
)));
8101 if ((ents
= listcount(bgp
->group
)))
8103 "Peer groups %ld, using %s of memory\n",
8108 ents
* sizeof(struct
8111 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8112 BGP_CONFIG_DAMPENING
))
8113 vty_out(vty
, "Dampening enabled.\n");
8116 /* Subtract 8 here because 'Neighbor' is
8118 vty_out(vty
, "Neighbor");
8119 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8122 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8129 json_peer
= json_object_new_object();
8131 if (peer_dynamic_neighbor(peer
)) {
8133 json_object_boolean_true_add(json_peer
,
8138 json_object_string_add(json_peer
, "hostname",
8141 if (peer
->domainname
)
8142 json_object_string_add(json_peer
, "domainname",
8145 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8146 json_object_int_add(json_peer
, "version", 4);
8147 json_object_int_add(json_peer
, "msgRcvd",
8148 PEER_TOTAL_RX(peer
));
8149 json_object_int_add(json_peer
, "msgSent",
8150 PEER_TOTAL_TX(peer
));
8152 json_object_int_add(json_peer
, "tableVersion",
8153 peer
->version
[afi
][safi
]);
8154 json_object_int_add(json_peer
, "outq",
8156 json_object_int_add(json_peer
, "inq", 0);
8157 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8158 use_json
, json_peer
);
8161 * Adding "pfxRcd" field to match with the corresponding
8162 * CLI. "prefixReceivedCount" will be deprecated in
8165 json_object_int_add(json_peer
, "prefixReceivedCount",
8166 peer
->pcount
[afi
][pfx_rcd_safi
]);
8167 json_object_int_add(json_peer
, "pfxRcd",
8168 peer
->pcount
[afi
][pfx_rcd_safi
]);
8170 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8171 if (paf
&& PAF_SUBGRP(paf
))
8172 json_object_int_add(json_peer
,
8174 (PAF_SUBGRP(paf
))->scount
);
8176 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8177 json_object_string_add(json_peer
, "state",
8179 else if (peer
->afc_recv
[afi
][safi
])
8180 json_object_string_add(
8182 lookup_msg(bgp_status_msg
, peer
->status
,
8184 else if (CHECK_FLAG(peer
->sflags
,
8185 PEER_STATUS_PREFIX_OVERFLOW
))
8186 json_object_string_add(json_peer
, "state",
8189 json_object_string_add(
8191 lookup_msg(bgp_status_msg
, peer
->status
,
8195 json_object_string_add(json_peer
, "idType",
8197 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8198 json_object_string_add(json_peer
, "idType",
8200 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8201 json_object_string_add(json_peer
, "idType",
8204 json_object_object_add(json_peers
, peer
->host
,
8207 memset(dn_flag
, '\0', sizeof(dn_flag
));
8208 if (peer_dynamic_neighbor(peer
)) {
8214 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8215 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8216 peer
->hostname
, peer
->host
);
8218 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8220 /* pad the neighbor column with spaces */
8221 if (len
< max_neighbor_width
)
8222 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8225 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8226 peer
->as
, PEER_TOTAL_RX(peer
),
8227 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8228 0, peer
->obuf
->count
,
8229 peer_uptime(peer
->uptime
, timebuf
,
8230 BGP_UPTIME_LEN
, 0, NULL
));
8232 if (peer
->status
== Established
)
8233 if (peer
->afc_recv
[afi
][safi
])
8234 vty_out(vty
, " %12ld",
8238 vty_out(vty
, " NoNeg");
8240 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8241 vty_out(vty
, " Idle (Admin)");
8242 else if (CHECK_FLAG(
8244 PEER_STATUS_PREFIX_OVERFLOW
))
8245 vty_out(vty
, " Idle (PfxCt)");
8247 vty_out(vty
, " %12s",
8248 lookup_msg(bgp_status_msg
,
8249 peer
->status
, NULL
));
8256 json_object_object_add(json
, "peers", json_peers
);
8258 json_object_int_add(json
, "totalPeers", count
);
8259 json_object_int_add(json
, "dynamicPeers", dn_count
);
8261 bgp_show_bestpath_json(bgp
, json
);
8263 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8264 json
, JSON_C_TO_STRING_PRETTY
));
8265 json_object_free(json
);
8268 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8270 vty_out(vty
, "No %s neighbor is configured\n",
8271 afi_safi_print(afi
, safi
));
8275 vty_out(vty
, "* - dynamic neighbor\n");
8276 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8277 dn_count
, bgp
->dynamic_neighbors_limit
);
8284 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8285 int safi
, bool use_json
,
8289 int afi_wildcard
= (afi
== AFI_MAX
);
8290 int safi_wildcard
= (safi
== SAFI_MAX
);
8291 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8292 bool nbr_output
= false;
8294 if (use_json
&& is_wildcard
)
8295 vty_out(vty
, "{\n");
8297 afi
= 1; /* AFI_IP */
8298 while (afi
< AFI_MAX
) {
8300 safi
= 1; /* SAFI_UNICAST */
8301 while (safi
< SAFI_MAX
) {
8302 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8306 * So limit output to those afi/safi
8308 * actualy have something interesting in
8312 json
= json_object_new_object();
8315 vty_out(vty
, ",\n");
8319 vty_out(vty
, "\"%s\":",
8323 vty_out(vty
, "\n%s Summary:\n",
8328 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8340 if (use_json
&& is_wildcard
)
8341 vty_out(vty
, "}\n");
8342 else if (!nbr_output
) {
8344 vty_out(vty
, "{}\n");
8346 vty_out(vty
, "%% No BGP neighbors found\n");
8350 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8351 safi_t safi
, bool use_json
)
8353 struct listnode
*node
, *nnode
;
8355 json_object
*json
= NULL
;
8357 bool nbr_output
= false;
8360 vty_out(vty
, "{\n");
8362 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8365 json
= json_object_new_object();
8368 vty_out(vty
, ",\n");
8372 vty_out(vty
, "\"%s\":",
8373 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8377 vty_out(vty
, "\nInstance %s:\n",
8378 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8382 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8386 vty_out(vty
, "}\n");
8387 else if (!nbr_output
)
8388 vty_out(vty
, "%% BGP instance not found\n");
8391 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8392 safi_t safi
, bool use_json
)
8397 if (strmatch(name
, "all")) {
8398 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8402 bgp
= bgp_lookup_by_name(name
);
8406 vty_out(vty
, "{}\n");
8409 "%% BGP instance not found\n");
8413 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8419 bgp
= bgp_get_default();
8422 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8425 vty_out(vty
, "{}\n");
8427 vty_out(vty
, "%% BGP instance not found\n");
8434 /* `show [ip] bgp summary' commands. */
8435 DEFUN (show_ip_bgp_summary
,
8436 show_ip_bgp_summary_cmd
,
8437 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8441 BGP_INSTANCE_HELP_STR
8443 BGP_SAFI_WITH_LABEL_HELP_STR
8444 "Summary of BGP neighbor status\n"
8448 afi_t afi
= AFI_MAX
;
8449 safi_t safi
= SAFI_MAX
;
8454 if (argv_find(argv
, argc
, "ip", &idx
))
8456 /* [<vrf> VIEWVRFNAME] */
8457 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8458 vrf
= argv
[idx
+ 1]->arg
;
8459 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8461 } else if (argv_find(argv
, argc
, "view", &idx
))
8462 /* [<view> VIEWVRFNAME] */
8463 vrf
= argv
[idx
+ 1]->arg
;
8464 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8465 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8466 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8469 bool uj
= use_json(argc
, argv
);
8471 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8474 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8476 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8477 return "IPv4 Unicast";
8478 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8479 return "IPv4 Multicast";
8480 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8481 return "IPv4 Labeled Unicast";
8482 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8484 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8485 return "IPv4 Encap";
8486 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8487 return "IPv4 Flowspec";
8488 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8489 return "IPv6 Unicast";
8490 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8491 return "IPv6 Multicast";
8492 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8493 return "IPv6 Labeled Unicast";
8494 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8496 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8497 return "IPv6 Encap";
8498 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8499 return "IPv6 Flowspec";
8500 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8501 return "L2VPN EVPN";
8507 * Please note that we have intentionally camelCased
8508 * the return strings here. So if you want
8509 * to use this function, please ensure you
8510 * are doing this within json output
8512 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8514 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8515 return "ipv4Unicast";
8516 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8517 return "ipv4Multicast";
8518 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8519 return "ipv4LabeledUnicast";
8520 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8522 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8524 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8525 return "ipv4Flowspec";
8526 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8527 return "ipv6Unicast";
8528 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8529 return "ipv6Multicast";
8530 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8531 return "ipv6LabeledUnicast";
8532 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8534 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8536 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8537 return "ipv6Flowspec";
8538 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8544 /* Show BGP peer's information. */
8545 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8547 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8548 afi_t afi
, safi_t safi
,
8549 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8550 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8551 bool use_json
, json_object
*json_pref
)
8554 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8555 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8557 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8558 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8559 json_object_string_add(json_pref
, "sendMode",
8560 "advertisedAndReceived");
8561 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8562 json_object_string_add(json_pref
, "sendMode",
8564 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8565 json_object_string_add(json_pref
, "sendMode",
8568 vty_out(vty
, " Send-mode: ");
8569 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8570 vty_out(vty
, "advertised");
8571 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8572 vty_out(vty
, "%sreceived",
8573 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8582 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8583 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8585 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8586 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8587 json_object_string_add(json_pref
, "recvMode",
8588 "advertisedAndReceived");
8589 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8590 json_object_string_add(json_pref
, "recvMode",
8592 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8593 json_object_string_add(json_pref
, "recvMode",
8596 vty_out(vty
, " Receive-mode: ");
8597 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8598 vty_out(vty
, "advertised");
8599 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8600 vty_out(vty
, "%sreceived",
8601 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8610 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8611 safi_t safi
, bool use_json
,
8612 json_object
*json_neigh
)
8614 struct bgp_filter
*filter
;
8615 struct peer_af
*paf
;
8616 char orf_pfx_name
[BUFSIZ
];
8618 json_object
*json_af
= NULL
;
8619 json_object
*json_prefA
= NULL
;
8620 json_object
*json_prefB
= NULL
;
8621 json_object
*json_addr
= NULL
;
8624 json_addr
= json_object_new_object();
8625 json_af
= json_object_new_object();
8626 filter
= &p
->filter
[afi
][safi
];
8628 if (peer_group_active(p
))
8629 json_object_string_add(json_addr
, "peerGroupMember",
8632 paf
= peer_af_find(p
, afi
, safi
);
8633 if (paf
&& PAF_SUBGRP(paf
)) {
8634 json_object_int_add(json_addr
, "updateGroupId",
8635 PAF_UPDGRP(paf
)->id
);
8636 json_object_int_add(json_addr
, "subGroupId",
8637 PAF_SUBGRP(paf
)->id
);
8638 json_object_int_add(json_addr
, "packetQueueLength",
8639 bpacket_queue_virtual_length(paf
));
8642 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8643 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8644 PEER_CAP_ORF_PREFIX_SM_RCV
)
8645 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8646 PEER_CAP_ORF_PREFIX_RM_ADV
)
8647 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8648 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8649 json_object_int_add(json_af
, "orfType",
8651 json_prefA
= json_object_new_object();
8652 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8653 PEER_CAP_ORF_PREFIX_SM_ADV
,
8654 PEER_CAP_ORF_PREFIX_RM_ADV
,
8655 PEER_CAP_ORF_PREFIX_SM_RCV
,
8656 PEER_CAP_ORF_PREFIX_RM_RCV
,
8657 use_json
, json_prefA
);
8658 json_object_object_add(json_af
, "orfPrefixList",
8662 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8663 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8664 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8665 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8666 PEER_CAP_ORF_PREFIX_RM_ADV
)
8667 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8668 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8669 json_object_int_add(json_af
, "orfOldType",
8670 ORF_TYPE_PREFIX_OLD
);
8671 json_prefB
= json_object_new_object();
8672 bgp_show_peer_afi_orf_cap(
8673 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8674 PEER_CAP_ORF_PREFIX_RM_ADV
,
8675 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8676 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8678 json_object_object_add(json_af
, "orfOldPrefixList",
8682 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8683 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8684 PEER_CAP_ORF_PREFIX_SM_RCV
)
8685 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8686 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8687 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8688 PEER_CAP_ORF_PREFIX_RM_ADV
)
8689 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8690 PEER_CAP_ORF_PREFIX_RM_RCV
)
8691 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8692 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8693 json_object_object_add(json_addr
, "afDependentCap",
8696 json_object_free(json_af
);
8698 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8699 orf_pfx_count
= prefix_bgp_show_prefix_list(
8700 NULL
, afi
, orf_pfx_name
, use_json
);
8702 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8703 PEER_STATUS_ORF_PREFIX_SEND
)
8705 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8706 PEER_STATUS_ORF_PREFIX_SEND
))
8707 json_object_boolean_true_add(json_neigh
,
8710 json_object_int_add(json_addr
, "orfRecvCounter",
8713 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8714 PEER_STATUS_ORF_WAIT_REFRESH
))
8715 json_object_string_add(
8716 json_addr
, "orfFirstUpdate",
8717 "deferredUntilORFOrRouteRefreshRecvd");
8719 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8720 PEER_FLAG_REFLECTOR_CLIENT
))
8721 json_object_boolean_true_add(json_addr
,
8722 "routeReflectorClient");
8723 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8724 PEER_FLAG_RSERVER_CLIENT
))
8725 json_object_boolean_true_add(json_addr
,
8726 "routeServerClient");
8727 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8728 json_object_boolean_true_add(json_addr
,
8729 "inboundSoftConfigPermit");
8731 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8732 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8733 json_object_boolean_true_add(
8735 "privateAsNumsAllReplacedInUpdatesToNbr");
8736 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8737 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8738 json_object_boolean_true_add(
8740 "privateAsNumsReplacedInUpdatesToNbr");
8741 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8742 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8743 json_object_boolean_true_add(
8745 "privateAsNumsAllRemovedInUpdatesToNbr");
8746 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8747 PEER_FLAG_REMOVE_PRIVATE_AS
))
8748 json_object_boolean_true_add(
8750 "privateAsNumsRemovedInUpdatesToNbr");
8752 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8753 json_object_boolean_true_add(
8755 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8758 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8759 json_object_string_add(json_addr
,
8760 "overrideASNsInOutboundUpdates",
8761 "ifAspathEqualRemoteAs");
8763 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8764 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8765 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8766 json_object_boolean_true_add(json_addr
,
8767 "routerAlwaysNextHop");
8768 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8769 PEER_FLAG_AS_PATH_UNCHANGED
))
8770 json_object_boolean_true_add(
8771 json_addr
, "unchangedAsPathPropogatedToNbr");
8772 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8773 PEER_FLAG_NEXTHOP_UNCHANGED
))
8774 json_object_boolean_true_add(
8775 json_addr
, "unchangedNextHopPropogatedToNbr");
8776 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8777 json_object_boolean_true_add(
8778 json_addr
, "unchangedMedPropogatedToNbr");
8779 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8780 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8781 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8782 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8783 PEER_FLAG_SEND_COMMUNITY
)
8784 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8785 PEER_FLAG_SEND_EXT_COMMUNITY
))
8786 json_object_string_add(json_addr
,
8787 "commAttriSentToNbr",
8788 "extendedAndStandard");
8789 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8790 PEER_FLAG_SEND_EXT_COMMUNITY
))
8791 json_object_string_add(json_addr
,
8792 "commAttriSentToNbr",
8795 json_object_string_add(json_addr
,
8796 "commAttriSentToNbr",
8799 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8800 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8801 if (p
->default_rmap
[afi
][safi
].name
)
8802 json_object_string_add(
8803 json_addr
, "defaultRouteMap",
8804 p
->default_rmap
[afi
][safi
].name
);
8806 if (paf
&& PAF_SUBGRP(paf
)
8807 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8808 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8809 json_object_boolean_true_add(json_addr
,
8812 json_object_boolean_true_add(json_addr
,
8816 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8817 if (is_evpn_enabled())
8818 json_object_boolean_true_add(
8819 json_addr
, "advertiseAllVnis");
8822 if (filter
->plist
[FILTER_IN
].name
8823 || filter
->dlist
[FILTER_IN
].name
8824 || filter
->aslist
[FILTER_IN
].name
8825 || filter
->map
[RMAP_IN
].name
)
8826 json_object_boolean_true_add(json_addr
,
8827 "inboundPathPolicyConfig");
8828 if (filter
->plist
[FILTER_OUT
].name
8829 || filter
->dlist
[FILTER_OUT
].name
8830 || filter
->aslist
[FILTER_OUT
].name
8831 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8832 json_object_boolean_true_add(
8833 json_addr
, "outboundPathPolicyConfig");
8836 if (filter
->plist
[FILTER_IN
].name
)
8837 json_object_string_add(json_addr
,
8838 "incomingUpdatePrefixFilterList",
8839 filter
->plist
[FILTER_IN
].name
);
8840 if (filter
->plist
[FILTER_OUT
].name
)
8841 json_object_string_add(json_addr
,
8842 "outgoingUpdatePrefixFilterList",
8843 filter
->plist
[FILTER_OUT
].name
);
8845 /* distribute-list */
8846 if (filter
->dlist
[FILTER_IN
].name
)
8847 json_object_string_add(
8848 json_addr
, "incomingUpdateNetworkFilterList",
8849 filter
->dlist
[FILTER_IN
].name
);
8850 if (filter
->dlist
[FILTER_OUT
].name
)
8851 json_object_string_add(
8852 json_addr
, "outgoingUpdateNetworkFilterList",
8853 filter
->dlist
[FILTER_OUT
].name
);
8856 if (filter
->aslist
[FILTER_IN
].name
)
8857 json_object_string_add(json_addr
,
8858 "incomingUpdateAsPathFilterList",
8859 filter
->aslist
[FILTER_IN
].name
);
8860 if (filter
->aslist
[FILTER_OUT
].name
)
8861 json_object_string_add(json_addr
,
8862 "outgoingUpdateAsPathFilterList",
8863 filter
->aslist
[FILTER_OUT
].name
);
8866 if (filter
->map
[RMAP_IN
].name
)
8867 json_object_string_add(
8868 json_addr
, "routeMapForIncomingAdvertisements",
8869 filter
->map
[RMAP_IN
].name
);
8870 if (filter
->map
[RMAP_OUT
].name
)
8871 json_object_string_add(
8872 json_addr
, "routeMapForOutgoingAdvertisements",
8873 filter
->map
[RMAP_OUT
].name
);
8875 /* ebgp-requires-policy (inbound) */
8876 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8877 && !bgp_inbound_policy_exists(p
, filter
))
8878 json_object_string_add(
8879 json_addr
, "inboundEbgpRequiresPolicy",
8880 "Inbound updates discarded due to missing policy");
8882 /* ebgp-requires-policy (outbound) */
8883 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8884 && (!bgp_outbound_policy_exists(p
, filter
)))
8885 json_object_string_add(
8886 json_addr
, "outboundEbgpRequiresPolicy",
8887 "Outbound updates discarded due to missing policy");
8889 /* unsuppress-map */
8890 if (filter
->usmap
.name
)
8891 json_object_string_add(json_addr
,
8892 "selectiveUnsuppressRouteMap",
8893 filter
->usmap
.name
);
8895 /* Receive prefix count */
8896 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8897 p
->pcount
[afi
][safi
]);
8898 if (paf
&& PAF_SUBGRP(paf
))
8899 json_object_int_add(json_addr
, "sentPrefixCounter",
8900 (PAF_SUBGRP(paf
))->scount
);
8902 /* Maximum prefix */
8903 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8904 json_object_int_add(json_addr
, "prefixAllowedMax",
8905 p
->pmax
[afi
][safi
]);
8906 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8907 PEER_FLAG_MAX_PREFIX_WARNING
))
8908 json_object_boolean_true_add(
8909 json_addr
, "prefixAllowedMaxWarning");
8910 json_object_int_add(json_addr
,
8911 "prefixAllowedWarningThresh",
8912 p
->pmax_threshold
[afi
][safi
]);
8913 if (p
->pmax_restart
[afi
][safi
])
8914 json_object_int_add(
8916 "prefixAllowedRestartIntervalMsecs",
8917 p
->pmax_restart
[afi
][safi
] * 60000);
8919 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8923 filter
= &p
->filter
[afi
][safi
];
8925 vty_out(vty
, " For address family: %s\n",
8926 afi_safi_print(afi
, safi
));
8928 if (peer_group_active(p
))
8929 vty_out(vty
, " %s peer-group member\n",
8932 paf
= peer_af_find(p
, afi
, safi
);
8933 if (paf
&& PAF_SUBGRP(paf
)) {
8934 vty_out(vty
, " Update group %" PRIu64
8935 ", subgroup %" PRIu64
"\n",
8936 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8937 vty_out(vty
, " Packet Queue length %d\n",
8938 bpacket_queue_virtual_length(paf
));
8940 vty_out(vty
, " Not part of any update group\n");
8942 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8943 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8944 PEER_CAP_ORF_PREFIX_SM_RCV
)
8945 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8946 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8947 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8948 PEER_CAP_ORF_PREFIX_RM_ADV
)
8949 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8950 PEER_CAP_ORF_PREFIX_RM_RCV
)
8951 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8952 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8953 vty_out(vty
, " AF-dependant capabilities:\n");
8955 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8956 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8957 PEER_CAP_ORF_PREFIX_SM_RCV
)
8958 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8959 PEER_CAP_ORF_PREFIX_RM_ADV
)
8960 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8961 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8963 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8965 bgp_show_peer_afi_orf_cap(
8966 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8967 PEER_CAP_ORF_PREFIX_RM_ADV
,
8968 PEER_CAP_ORF_PREFIX_SM_RCV
,
8969 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8971 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8972 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8973 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8974 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8975 PEER_CAP_ORF_PREFIX_RM_ADV
)
8976 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8977 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8979 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8980 ORF_TYPE_PREFIX_OLD
);
8981 bgp_show_peer_afi_orf_cap(
8982 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8983 PEER_CAP_ORF_PREFIX_RM_ADV
,
8984 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8985 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8988 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8989 orf_pfx_count
= prefix_bgp_show_prefix_list(
8990 NULL
, afi
, orf_pfx_name
, use_json
);
8992 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8993 PEER_STATUS_ORF_PREFIX_SEND
)
8995 vty_out(vty
, " Outbound Route Filter (ORF):");
8996 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8997 PEER_STATUS_ORF_PREFIX_SEND
))
8998 vty_out(vty
, " sent;");
9000 vty_out(vty
, " received (%d entries)",
9004 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9005 PEER_STATUS_ORF_WAIT_REFRESH
))
9007 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
9009 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9010 PEER_FLAG_REFLECTOR_CLIENT
))
9011 vty_out(vty
, " Route-Reflector Client\n");
9012 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9013 PEER_FLAG_RSERVER_CLIENT
))
9014 vty_out(vty
, " Route-Server Client\n");
9015 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9017 " Inbound soft reconfiguration allowed\n");
9019 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9020 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9022 " Private AS numbers (all) replaced in updates to this neighbor\n");
9023 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9024 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9026 " Private AS numbers replaced in updates to this neighbor\n");
9027 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9028 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9030 " Private AS numbers (all) removed in updates to this neighbor\n");
9031 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9032 PEER_FLAG_REMOVE_PRIVATE_AS
))
9034 " Private AS numbers removed in updates to this neighbor\n");
9036 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9037 vty_out(vty
, " %s\n",
9038 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9039 ->human_description
);
9041 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9043 " Override ASNs in outbound updates if aspath equals remote-as\n");
9045 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9046 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9047 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9048 vty_out(vty
, " NEXT_HOP is always this router\n");
9049 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9050 PEER_FLAG_AS_PATH_UNCHANGED
))
9052 " AS_PATH is propagated unchanged to this neighbor\n");
9053 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9054 PEER_FLAG_NEXTHOP_UNCHANGED
))
9056 " NEXT_HOP is propagated unchanged to this neighbor\n");
9057 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9059 " MED is propagated unchanged to this neighbor\n");
9060 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9061 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9062 PEER_FLAG_SEND_EXT_COMMUNITY
)
9063 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9064 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9066 " Community attribute sent to this neighbor");
9067 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9068 PEER_FLAG_SEND_COMMUNITY
)
9069 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9070 PEER_FLAG_SEND_EXT_COMMUNITY
)
9071 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9072 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9073 vty_out(vty
, "(all)\n");
9074 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9075 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9076 vty_out(vty
, "(large)\n");
9077 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9078 PEER_FLAG_SEND_EXT_COMMUNITY
))
9079 vty_out(vty
, "(extended)\n");
9081 vty_out(vty
, "(standard)\n");
9083 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9084 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9085 vty_out(vty
, " Default information originate,");
9087 if (p
->default_rmap
[afi
][safi
].name
)
9088 vty_out(vty
, " default route-map %s%s,",
9089 p
->default_rmap
[afi
][safi
].map
? "*"
9091 p
->default_rmap
[afi
][safi
].name
);
9092 if (paf
&& PAF_SUBGRP(paf
)
9093 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9094 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9095 vty_out(vty
, " default sent\n");
9097 vty_out(vty
, " default not sent\n");
9100 /* advertise-vni-all */
9101 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9102 if (is_evpn_enabled())
9103 vty_out(vty
, " advertise-all-vni\n");
9106 if (filter
->plist
[FILTER_IN
].name
9107 || filter
->dlist
[FILTER_IN
].name
9108 || filter
->aslist
[FILTER_IN
].name
9109 || filter
->map
[RMAP_IN
].name
)
9110 vty_out(vty
, " Inbound path policy configured\n");
9111 if (filter
->plist
[FILTER_OUT
].name
9112 || filter
->dlist
[FILTER_OUT
].name
9113 || filter
->aslist
[FILTER_OUT
].name
9114 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9115 vty_out(vty
, " Outbound path policy configured\n");
9118 if (filter
->plist
[FILTER_IN
].name
)
9120 " Incoming update prefix filter list is %s%s\n",
9121 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9122 filter
->plist
[FILTER_IN
].name
);
9123 if (filter
->plist
[FILTER_OUT
].name
)
9125 " Outgoing update prefix filter list is %s%s\n",
9126 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9127 filter
->plist
[FILTER_OUT
].name
);
9129 /* distribute-list */
9130 if (filter
->dlist
[FILTER_IN
].name
)
9132 " Incoming update network filter list is %s%s\n",
9133 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9134 filter
->dlist
[FILTER_IN
].name
);
9135 if (filter
->dlist
[FILTER_OUT
].name
)
9137 " Outgoing update network filter list is %s%s\n",
9138 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9139 filter
->dlist
[FILTER_OUT
].name
);
9142 if (filter
->aslist
[FILTER_IN
].name
)
9144 " Incoming update AS path filter list is %s%s\n",
9145 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9146 filter
->aslist
[FILTER_IN
].name
);
9147 if (filter
->aslist
[FILTER_OUT
].name
)
9149 " Outgoing update AS path filter list is %s%s\n",
9150 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9151 filter
->aslist
[FILTER_OUT
].name
);
9154 if (filter
->map
[RMAP_IN
].name
)
9156 " Route map for incoming advertisements is %s%s\n",
9157 filter
->map
[RMAP_IN
].map
? "*" : "",
9158 filter
->map
[RMAP_IN
].name
);
9159 if (filter
->map
[RMAP_OUT
].name
)
9161 " Route map for outgoing advertisements is %s%s\n",
9162 filter
->map
[RMAP_OUT
].map
? "*" : "",
9163 filter
->map
[RMAP_OUT
].name
);
9165 /* ebgp-requires-policy (inbound) */
9166 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9167 && !bgp_inbound_policy_exists(p
, filter
))
9169 " Inbound updates discarded due to missing policy\n");
9171 /* ebgp-requires-policy (outbound) */
9172 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9173 && !bgp_outbound_policy_exists(p
, filter
))
9175 " Outbound updates discarded due to missing policy\n");
9177 /* unsuppress-map */
9178 if (filter
->usmap
.name
)
9180 " Route map for selective unsuppress is %s%s\n",
9181 filter
->usmap
.map
? "*" : "",
9182 filter
->usmap
.name
);
9184 /* Receive prefix count */
9185 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9187 /* Maximum prefix */
9188 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9189 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9191 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9192 PEER_FLAG_MAX_PREFIX_WARNING
)
9195 vty_out(vty
, " Threshold for warning message %d%%",
9196 p
->pmax_threshold
[afi
][safi
]);
9197 if (p
->pmax_restart
[afi
][safi
])
9198 vty_out(vty
, ", restart interval %d min",
9199 p
->pmax_restart
[afi
][safi
]);
9207 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9211 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9212 char timebuf
[BGP_UPTIME_LEN
];
9214 const char *subcode_str
;
9215 const char *code_str
;
9220 json_object
*json_neigh
= NULL
;
9226 json_neigh
= json_object_new_object();
9228 memset(dn_flag
, '\0', sizeof(dn_flag
));
9229 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9233 if (p
->conf_if
) /* Configured interface name. */
9234 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9235 BGP_PEER_SU_UNSPEC(p
)
9237 : sockunion2str(&p
->su
, buf
,
9239 else /* Configured IP address. */
9240 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9245 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9246 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9248 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9249 json_object_string_add(
9250 json_neigh
, "bgpNeighborAddr",
9251 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9253 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9255 if (p
->change_local_as
)
9256 json_object_int_add(json_neigh
, "localAs",
9257 p
->change_local_as
);
9259 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9261 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9262 json_object_boolean_true_add(json_neigh
,
9263 "localAsNoPrepend");
9265 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9266 json_object_boolean_true_add(json_neigh
,
9267 "localAsReplaceAs");
9269 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9270 || (p
->as_type
== AS_INTERNAL
))
9271 vty_out(vty
, "remote AS %u, ", p
->as
);
9273 vty_out(vty
, "remote AS Unspecified, ");
9274 vty_out(vty
, "local AS %u%s%s, ",
9275 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9276 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9279 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9283 /* peer type internal or confed-internal */
9284 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9286 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9287 json_object_boolean_true_add(
9288 json_neigh
, "nbrConfedInternalLink");
9290 json_object_boolean_true_add(json_neigh
,
9293 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9294 vty_out(vty
, "confed-internal link\n");
9296 vty_out(vty
, "internal link\n");
9298 /* peer type external or confed-external */
9299 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9301 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9302 json_object_boolean_true_add(
9303 json_neigh
, "nbrConfedExternalLink");
9305 json_object_boolean_true_add(json_neigh
,
9308 if (bgp_confederation_peers_check(bgp
, p
->as
))
9309 vty_out(vty
, "confed-external link\n");
9311 vty_out(vty
, "external link\n");
9315 json_object_boolean_true_add(json_neigh
,
9316 "nbrUnspecifiedLink");
9318 vty_out(vty
, "unspecified link\n");
9324 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9326 vty_out(vty
, " Description: %s\n", p
->desc
);
9332 json_object_string_add(json_neigh
, "hostname",
9336 json_object_string_add(json_neigh
, "domainname",
9339 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9340 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9343 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9350 json_object_string_add(json_neigh
, "peerGroup",
9354 struct prefix prefix
, *range
= NULL
;
9356 sockunion2hostprefix(&(p
->su
), &prefix
);
9357 range
= peer_group_lookup_dynamic_neighbor_range(
9361 prefix2str(range
, buf1
, sizeof(buf1
));
9362 json_object_string_add(
9364 "peerSubnetRangeGroup", buf1
);
9369 " Member of peer-group %s for session parameters\n",
9373 struct prefix prefix
, *range
= NULL
;
9375 sockunion2hostprefix(&(p
->su
), &prefix
);
9376 range
= peer_group_lookup_dynamic_neighbor_range(
9380 prefix2str(range
, buf1
, sizeof(buf1
));
9382 " Belongs to the subnet range group: %s\n",
9390 /* Administrative shutdown. */
9391 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9392 json_object_boolean_true_add(json_neigh
,
9396 json_object_int_add(json_neigh
, "bgpVersion", 4);
9397 json_object_string_add(
9398 json_neigh
, "remoteRouterId",
9399 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9400 json_object_string_add(
9401 json_neigh
, "localRouterId",
9402 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9406 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9407 && bgp_confederation_peers_check(bgp
, p
->as
))
9408 json_object_boolean_true_add(json_neigh
,
9412 json_object_string_add(
9413 json_neigh
, "bgpState",
9414 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9416 if (p
->status
== Established
) {
9419 uptime
= bgp_clock();
9420 uptime
-= p
->uptime
;
9421 epoch_tbuf
= time(NULL
) - uptime
;
9423 #if CONFDATE > 20200101
9425 "bgpTimerUp should be deprecated and can be removed now");
9428 * bgpTimerUp was miliseconds that was accurate
9429 * up to 1 day, then the value returned
9430 * became garbage. So in order to provide
9431 * some level of backwards compatability,
9432 * we still provde the data, but now
9433 * we are returning the correct value
9434 * and also adding a new bgpTimerUpMsec
9435 * which will allow us to deprecate
9438 json_object_int_add(json_neigh
, "bgpTimerUp",
9440 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9442 json_object_string_add(json_neigh
, "bgpTimerUpString",
9443 peer_uptime(p
->uptime
, timebuf
,
9446 json_object_int_add(json_neigh
,
9447 "bgpTimerUpEstablishedEpoch",
9451 else if (p
->status
== Active
) {
9452 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9453 json_object_string_add(json_neigh
, "bgpStateIs",
9455 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9456 json_object_string_add(json_neigh
, "bgpStateIs",
9464 uptime
= bgp_clock();
9465 uptime
-= p
->readtime
;
9466 tm
= gmtime(&uptime
);
9467 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9468 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9469 + (tm
->tm_hour
* 3600000));
9471 uptime
= bgp_clock();
9472 uptime
-= p
->last_write
;
9473 tm
= gmtime(&uptime
);
9474 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9475 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9476 + (tm
->tm_hour
* 3600000));
9478 uptime
= bgp_clock();
9479 uptime
-= p
->update_time
;
9480 tm
= gmtime(&uptime
);
9481 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9482 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9483 + (tm
->tm_hour
* 3600000));
9485 /* Configured timer values. */
9486 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9487 p
->v_holdtime
* 1000);
9488 json_object_int_add(json_neigh
,
9489 "bgpTimerKeepAliveIntervalMsecs",
9490 p
->v_keepalive
* 1000);
9491 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9492 json_object_int_add(json_neigh
,
9493 "bgpTimerConfiguredHoldTimeMsecs",
9494 p
->holdtime
* 1000);
9495 json_object_int_add(
9497 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9498 p
->keepalive
* 1000);
9499 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9500 || (bgp
->default_keepalive
9501 != BGP_DEFAULT_KEEPALIVE
)) {
9502 json_object_int_add(json_neigh
,
9503 "bgpTimerConfiguredHoldTimeMsecs",
9504 bgp
->default_holdtime
);
9505 json_object_int_add(
9507 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9508 bgp
->default_keepalive
);
9511 /* Administrative shutdown. */
9512 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9513 vty_out(vty
, " Administratively shut down\n");
9516 vty_out(vty
, " BGP version 4");
9517 vty_out(vty
, ", remote router ID %s",
9518 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9519 vty_out(vty
, ", local router ID %s\n",
9520 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9524 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9525 && bgp_confederation_peers_check(bgp
, p
->as
))
9527 " Neighbor under common administration\n");
9530 vty_out(vty
, " BGP state = %s",
9531 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9533 if (p
->status
== Established
)
9534 vty_out(vty
, ", up for %8s",
9535 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9538 else if (p
->status
== Active
) {
9539 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9540 vty_out(vty
, " (passive)");
9541 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9542 vty_out(vty
, " (NSF passive)");
9547 vty_out(vty
, " Last read %s",
9548 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9550 vty_out(vty
, ", Last write %s\n",
9551 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9554 /* Configured timer values. */
9556 " Hold time is %d, keepalive interval is %d seconds\n",
9557 p
->v_holdtime
, p
->v_keepalive
);
9558 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9559 vty_out(vty
, " Configured hold time is %d",
9561 vty_out(vty
, ", keepalive interval is %d seconds\n",
9563 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9564 || (bgp
->default_keepalive
9565 != BGP_DEFAULT_KEEPALIVE
)) {
9566 vty_out(vty
, " Configured hold time is %d",
9567 bgp
->default_holdtime
);
9568 vty_out(vty
, ", keepalive interval is %d seconds\n",
9569 bgp
->default_keepalive
);
9573 if (p
->status
== Established
) {
9574 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9575 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9576 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9577 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9578 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9579 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9580 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9581 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9582 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9583 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9584 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9585 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9586 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9587 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9588 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9589 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9590 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9591 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9592 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9593 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9595 json_object
*json_cap
= NULL
;
9597 json_cap
= json_object_new_object();
9600 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9601 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9602 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9603 && CHECK_FLAG(p
->cap
,
9605 json_object_string_add(
9606 json_cap
, "4byteAs",
9607 "advertisedAndReceived");
9608 else if (CHECK_FLAG(p
->cap
,
9610 json_object_string_add(
9611 json_cap
, "4byteAs",
9613 else if (CHECK_FLAG(p
->cap
,
9615 json_object_string_add(
9616 json_cap
, "4byteAs",
9621 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9622 || CHECK_FLAG(p
->cap
,
9623 PEER_CAP_ADDPATH_ADV
)) {
9624 json_object
*json_add
= NULL
;
9625 const char *print_store
;
9627 json_add
= json_object_new_object();
9629 FOREACH_AFI_SAFI (afi
, safi
) {
9630 json_object
*json_sub
= NULL
;
9632 json_object_new_object();
9633 print_store
= afi_safi_print(
9639 PEER_CAP_ADDPATH_AF_TX_ADV
)
9643 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9648 PEER_CAP_ADDPATH_AF_TX_ADV
)
9653 PEER_CAP_ADDPATH_AF_TX_RCV
))
9654 json_object_boolean_true_add(
9656 "txAdvertisedAndReceived");
9662 PEER_CAP_ADDPATH_AF_TX_ADV
))
9663 json_object_boolean_true_add(
9671 PEER_CAP_ADDPATH_AF_TX_RCV
))
9672 json_object_boolean_true_add(
9680 PEER_CAP_ADDPATH_AF_RX_ADV
)
9684 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9689 PEER_CAP_ADDPATH_AF_RX_ADV
)
9694 PEER_CAP_ADDPATH_AF_RX_RCV
))
9695 json_object_boolean_true_add(
9697 "rxAdvertisedAndReceived");
9703 PEER_CAP_ADDPATH_AF_RX_ADV
))
9704 json_object_boolean_true_add(
9712 PEER_CAP_ADDPATH_AF_RX_RCV
))
9713 json_object_boolean_true_add(
9721 PEER_CAP_ADDPATH_AF_TX_ADV
)
9725 PEER_CAP_ADDPATH_AF_TX_RCV
)
9729 PEER_CAP_ADDPATH_AF_RX_ADV
)
9733 PEER_CAP_ADDPATH_AF_RX_RCV
))
9734 json_object_object_add(
9743 json_object_object_add(
9744 json_cap
, "addPath", json_add
);
9748 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9749 || CHECK_FLAG(p
->cap
,
9750 PEER_CAP_DYNAMIC_ADV
)) {
9751 if (CHECK_FLAG(p
->cap
,
9752 PEER_CAP_DYNAMIC_ADV
)
9753 && CHECK_FLAG(p
->cap
,
9754 PEER_CAP_DYNAMIC_RCV
))
9755 json_object_string_add(
9756 json_cap
, "dynamic",
9757 "advertisedAndReceived");
9758 else if (CHECK_FLAG(
9760 PEER_CAP_DYNAMIC_ADV
))
9761 json_object_string_add(
9762 json_cap
, "dynamic",
9764 else if (CHECK_FLAG(
9766 PEER_CAP_DYNAMIC_RCV
))
9767 json_object_string_add(
9768 json_cap
, "dynamic",
9772 /* Extended nexthop */
9773 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9774 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9775 json_object
*json_nxt
= NULL
;
9776 const char *print_store
;
9779 if (CHECK_FLAG(p
->cap
,
9781 && CHECK_FLAG(p
->cap
,
9783 json_object_string_add(
9786 "advertisedAndReceived");
9787 else if (CHECK_FLAG(p
->cap
,
9789 json_object_string_add(
9793 else if (CHECK_FLAG(p
->cap
,
9795 json_object_string_add(
9800 if (CHECK_FLAG(p
->cap
,
9801 PEER_CAP_ENHE_RCV
)) {
9803 json_object_new_object();
9805 for (safi
= SAFI_UNICAST
;
9806 safi
< SAFI_MAX
; safi
++) {
9811 PEER_CAP_ENHE_AF_RCV
)) {
9812 print_store
= afi_safi_print(
9815 json_object_string_add(
9818 "recieved"); /* misspelled for compatibility */
9821 json_object_object_add(
9823 "extendedNexthopFamililesByPeer",
9829 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9830 || CHECK_FLAG(p
->cap
,
9831 PEER_CAP_REFRESH_NEW_RCV
)
9832 || CHECK_FLAG(p
->cap
,
9833 PEER_CAP_REFRESH_OLD_RCV
)) {
9834 if (CHECK_FLAG(p
->cap
,
9835 PEER_CAP_REFRESH_ADV
)
9838 PEER_CAP_REFRESH_NEW_RCV
)
9841 PEER_CAP_REFRESH_OLD_RCV
))) {
9844 PEER_CAP_REFRESH_OLD_RCV
)
9847 PEER_CAP_REFRESH_NEW_RCV
))
9848 json_object_string_add(
9851 "advertisedAndReceivedOldNew");
9855 PEER_CAP_REFRESH_OLD_RCV
))
9856 json_object_string_add(
9859 "advertisedAndReceivedOld");
9861 json_object_string_add(
9864 "advertisedAndReceivedNew");
9869 PEER_CAP_REFRESH_ADV
))
9870 json_object_string_add(
9877 PEER_CAP_REFRESH_NEW_RCV
)
9880 PEER_CAP_REFRESH_OLD_RCV
))
9881 json_object_string_add(
9887 /* Multiprotocol Extensions */
9888 json_object
*json_multi
= NULL
;
9889 json_multi
= json_object_new_object();
9891 FOREACH_AFI_SAFI (afi
, safi
) {
9892 if (p
->afc_adv
[afi
][safi
]
9893 || p
->afc_recv
[afi
][safi
]) {
9894 json_object
*json_exten
= NULL
;
9896 json_object_new_object();
9898 if (p
->afc_adv
[afi
][safi
]
9899 && p
->afc_recv
[afi
][safi
])
9900 json_object_boolean_true_add(
9902 "advertisedAndReceived");
9903 else if (p
->afc_adv
[afi
][safi
])
9904 json_object_boolean_true_add(
9907 else if (p
->afc_recv
[afi
][safi
])
9908 json_object_boolean_true_add(
9912 json_object_object_add(
9919 json_object_object_add(
9920 json_cap
, "multiprotocolExtensions",
9923 /* Hostname capabilities */
9924 json_object
*json_hname
= NULL
;
9926 json_hname
= json_object_new_object();
9928 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9929 json_object_string_add(
9930 json_hname
, "advHostName",
9931 bgp
->peer_self
->hostname
9935 json_object_string_add(
9936 json_hname
, "advDomainName",
9937 bgp
->peer_self
->domainname
9944 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9945 json_object_string_add(
9946 json_hname
, "rcvHostName",
9947 p
->hostname
? p
->hostname
9949 json_object_string_add(
9950 json_hname
, "rcvDomainName",
9951 p
->domainname
? p
->domainname
9955 json_object_object_add(json_cap
, "hostName",
9958 /* Gracefull Restart */
9959 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9960 || CHECK_FLAG(p
->cap
,
9961 PEER_CAP_RESTART_ADV
)) {
9962 if (CHECK_FLAG(p
->cap
,
9963 PEER_CAP_RESTART_ADV
)
9964 && CHECK_FLAG(p
->cap
,
9965 PEER_CAP_RESTART_RCV
))
9966 json_object_string_add(
9969 "advertisedAndReceived");
9970 else if (CHECK_FLAG(
9972 PEER_CAP_RESTART_ADV
))
9973 json_object_string_add(
9975 "gracefulRestartCapability",
9977 else if (CHECK_FLAG(
9979 PEER_CAP_RESTART_RCV
))
9980 json_object_string_add(
9982 "gracefulRestartCapability",
9985 if (CHECK_FLAG(p
->cap
,
9986 PEER_CAP_RESTART_RCV
)) {
9987 int restart_af_count
= 0;
9988 json_object
*json_restart
=
9991 json_object_new_object();
9993 json_object_int_add(
9995 "gracefulRestartRemoteTimerMsecs",
9996 p
->v_gr_restart
* 1000);
9998 FOREACH_AFI_SAFI (afi
, safi
) {
10003 PEER_CAP_RESTART_AF_RCV
)) {
10008 json_object_new_object();
10014 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10015 json_object_boolean_true_add(
10018 restart_af_count
++;
10019 json_object_object_add(
10027 if (!restart_af_count
) {
10028 json_object_string_add(
10030 "addressFamiliesByPeer",
10035 json_object_object_add(
10037 "addressFamiliesByPeer",
10041 json_object_object_add(json_neigh
,
10042 "neighborCapabilities",
10045 vty_out(vty
, " Neighbor capabilities:\n");
10048 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10049 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10050 vty_out(vty
, " 4 Byte AS:");
10051 if (CHECK_FLAG(p
->cap
,
10053 vty_out(vty
, " advertised");
10054 if (CHECK_FLAG(p
->cap
,
10056 vty_out(vty
, " %sreceived",
10062 vty_out(vty
, "\n");
10066 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10067 || CHECK_FLAG(p
->cap
,
10068 PEER_CAP_ADDPATH_ADV
)) {
10069 vty_out(vty
, " AddPath:\n");
10071 FOREACH_AFI_SAFI (afi
, safi
) {
10075 PEER_CAP_ADDPATH_AF_TX_ADV
)
10079 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10090 PEER_CAP_ADDPATH_AF_TX_ADV
))
10101 PEER_CAP_ADDPATH_AF_TX_RCV
))
10108 PEER_CAP_ADDPATH_AF_TX_ADV
)
10112 vty_out(vty
, "\n");
10118 PEER_CAP_ADDPATH_AF_RX_ADV
)
10122 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10133 PEER_CAP_ADDPATH_AF_RX_ADV
))
10144 PEER_CAP_ADDPATH_AF_RX_RCV
))
10151 PEER_CAP_ADDPATH_AF_RX_ADV
)
10155 vty_out(vty
, "\n");
10161 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10162 || CHECK_FLAG(p
->cap
,
10163 PEER_CAP_DYNAMIC_ADV
)) {
10164 vty_out(vty
, " Dynamic:");
10165 if (CHECK_FLAG(p
->cap
,
10166 PEER_CAP_DYNAMIC_ADV
))
10167 vty_out(vty
, " advertised");
10168 if (CHECK_FLAG(p
->cap
,
10169 PEER_CAP_DYNAMIC_RCV
))
10170 vty_out(vty
, " %sreceived",
10173 PEER_CAP_DYNAMIC_ADV
)
10176 vty_out(vty
, "\n");
10179 /* Extended nexthop */
10180 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10181 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10182 vty_out(vty
, " Extended nexthop:");
10183 if (CHECK_FLAG(p
->cap
,
10184 PEER_CAP_ENHE_ADV
))
10185 vty_out(vty
, " advertised");
10186 if (CHECK_FLAG(p
->cap
,
10187 PEER_CAP_ENHE_RCV
))
10188 vty_out(vty
, " %sreceived",
10194 vty_out(vty
, "\n");
10196 if (CHECK_FLAG(p
->cap
,
10197 PEER_CAP_ENHE_RCV
)) {
10199 " Address families by peer:\n ");
10200 for (safi
= SAFI_UNICAST
;
10201 safi
< SAFI_MAX
; safi
++)
10206 PEER_CAP_ENHE_AF_RCV
))
10215 /* Route Refresh */
10216 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10217 || CHECK_FLAG(p
->cap
,
10218 PEER_CAP_REFRESH_NEW_RCV
)
10219 || CHECK_FLAG(p
->cap
,
10220 PEER_CAP_REFRESH_OLD_RCV
)) {
10221 vty_out(vty
, " Route refresh:");
10222 if (CHECK_FLAG(p
->cap
,
10223 PEER_CAP_REFRESH_ADV
))
10224 vty_out(vty
, " advertised");
10225 if (CHECK_FLAG(p
->cap
,
10226 PEER_CAP_REFRESH_NEW_RCV
)
10229 PEER_CAP_REFRESH_OLD_RCV
))
10230 vty_out(vty
, " %sreceived(%s)",
10233 PEER_CAP_REFRESH_ADV
)
10238 PEER_CAP_REFRESH_OLD_RCV
)
10241 PEER_CAP_REFRESH_NEW_RCV
))
10245 PEER_CAP_REFRESH_OLD_RCV
)
10249 vty_out(vty
, "\n");
10252 /* Multiprotocol Extensions */
10253 FOREACH_AFI_SAFI (afi
, safi
)
10254 if (p
->afc_adv
[afi
][safi
]
10255 || p
->afc_recv
[afi
][safi
]) {
10257 " Address Family %s:",
10258 afi_safi_print(afi
,
10260 if (p
->afc_adv
[afi
][safi
])
10263 if (p
->afc_recv
[afi
][safi
])
10270 vty_out(vty
, "\n");
10273 /* Hostname capability */
10274 vty_out(vty
, " Hostname Capability:");
10276 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10278 " advertised (name: %s,domain name: %s)",
10279 bgp
->peer_self
->hostname
10283 bgp
->peer_self
->domainname
10288 vty_out(vty
, " not advertised");
10291 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10293 " received (name: %s,domain name: %s)",
10294 p
->hostname
? p
->hostname
10296 p
->domainname
? p
->domainname
10299 vty_out(vty
, " not received");
10302 vty_out(vty
, "\n");
10304 /* Gracefull Restart */
10305 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10306 || CHECK_FLAG(p
->cap
,
10307 PEER_CAP_RESTART_ADV
)) {
10309 " Graceful Restart Capabilty:");
10310 if (CHECK_FLAG(p
->cap
,
10311 PEER_CAP_RESTART_ADV
))
10312 vty_out(vty
, " advertised");
10313 if (CHECK_FLAG(p
->cap
,
10314 PEER_CAP_RESTART_RCV
))
10315 vty_out(vty
, " %sreceived",
10318 PEER_CAP_RESTART_ADV
)
10321 vty_out(vty
, "\n");
10323 if (CHECK_FLAG(p
->cap
,
10324 PEER_CAP_RESTART_RCV
)) {
10325 int restart_af_count
= 0;
10328 " Remote Restart timer is %d seconds\n",
10331 " Address families by peer:\n ");
10333 FOREACH_AFI_SAFI (afi
, safi
)
10338 PEER_CAP_RESTART_AF_RCV
)) {
10351 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10353 : "not preserved");
10354 restart_af_count
++;
10356 if (!restart_af_count
)
10357 vty_out(vty
, "none");
10358 vty_out(vty
, "\n");
10365 /* graceful restart information */
10366 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10367 || p
->t_gr_stale
) {
10368 json_object
*json_grace
= NULL
;
10369 json_object
*json_grace_send
= NULL
;
10370 json_object
*json_grace_recv
= NULL
;
10371 int eor_send_af_count
= 0;
10372 int eor_receive_af_count
= 0;
10375 json_grace
= json_object_new_object();
10376 json_grace_send
= json_object_new_object();
10377 json_grace_recv
= json_object_new_object();
10379 if (p
->status
== Established
) {
10380 FOREACH_AFI_SAFI (afi
, safi
) {
10381 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10382 PEER_STATUS_EOR_SEND
)) {
10383 json_object_boolean_true_add(
10385 afi_safi_print(afi
,
10387 eor_send_af_count
++;
10390 FOREACH_AFI_SAFI (afi
, safi
) {
10392 p
->af_sflags
[afi
][safi
],
10393 PEER_STATUS_EOR_RECEIVED
)) {
10394 json_object_boolean_true_add(
10396 afi_safi_print(afi
,
10398 eor_receive_af_count
++;
10403 json_object_object_add(json_grace
, "endOfRibSend",
10405 json_object_object_add(json_grace
, "endOfRibRecv",
10408 if (p
->t_gr_restart
)
10409 json_object_int_add(json_grace
,
10410 "gracefulRestartTimerMsecs",
10411 thread_timer_remain_second(
10416 json_object_int_add(
10418 "gracefulStalepathTimerMsecs",
10419 thread_timer_remain_second(
10423 json_object_object_add(
10424 json_neigh
, "gracefulRestartInfo", json_grace
);
10426 vty_out(vty
, " Graceful restart information:\n");
10427 if (p
->status
== Established
) {
10428 vty_out(vty
, " End-of-RIB send: ");
10429 FOREACH_AFI_SAFI (afi
, safi
) {
10430 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10431 PEER_STATUS_EOR_SEND
)) {
10432 vty_out(vty
, "%s%s",
10433 eor_send_af_count
? ", "
10435 afi_safi_print(afi
,
10437 eor_send_af_count
++;
10440 vty_out(vty
, "\n");
10441 vty_out(vty
, " End-of-RIB received: ");
10442 FOREACH_AFI_SAFI (afi
, safi
) {
10444 p
->af_sflags
[afi
][safi
],
10445 PEER_STATUS_EOR_RECEIVED
)) {
10446 vty_out(vty
, "%s%s",
10447 eor_receive_af_count
10450 afi_safi_print(afi
,
10452 eor_receive_af_count
++;
10455 vty_out(vty
, "\n");
10458 if (p
->t_gr_restart
)
10460 " The remaining time of restart timer is %ld\n",
10461 thread_timer_remain_second(
10466 " The remaining time of stalepath timer is %ld\n",
10467 thread_timer_remain_second(
10472 json_object
*json_stat
= NULL
;
10473 json_stat
= json_object_new_object();
10474 /* Packet counts. */
10475 json_object_int_add(json_stat
, "depthInq", 0);
10476 json_object_int_add(json_stat
, "depthOutq",
10477 (unsigned long)p
->obuf
->count
);
10478 json_object_int_add(json_stat
, "opensSent",
10479 atomic_load_explicit(&p
->open_out
,
10480 memory_order_relaxed
));
10481 json_object_int_add(json_stat
, "opensRecv",
10482 atomic_load_explicit(&p
->open_in
,
10483 memory_order_relaxed
));
10484 json_object_int_add(json_stat
, "notificationsSent",
10485 atomic_load_explicit(&p
->notify_out
,
10486 memory_order_relaxed
));
10487 json_object_int_add(json_stat
, "notificationsRecv",
10488 atomic_load_explicit(&p
->notify_in
,
10489 memory_order_relaxed
));
10490 json_object_int_add(json_stat
, "updatesSent",
10491 atomic_load_explicit(&p
->update_out
,
10492 memory_order_relaxed
));
10493 json_object_int_add(json_stat
, "updatesRecv",
10494 atomic_load_explicit(&p
->update_in
,
10495 memory_order_relaxed
));
10496 json_object_int_add(json_stat
, "keepalivesSent",
10497 atomic_load_explicit(&p
->keepalive_out
,
10498 memory_order_relaxed
));
10499 json_object_int_add(json_stat
, "keepalivesRecv",
10500 atomic_load_explicit(&p
->keepalive_in
,
10501 memory_order_relaxed
));
10502 json_object_int_add(json_stat
, "routeRefreshSent",
10503 atomic_load_explicit(&p
->refresh_out
,
10504 memory_order_relaxed
));
10505 json_object_int_add(json_stat
, "routeRefreshRecv",
10506 atomic_load_explicit(&p
->refresh_in
,
10507 memory_order_relaxed
));
10508 json_object_int_add(json_stat
, "capabilitySent",
10509 atomic_load_explicit(&p
->dynamic_cap_out
,
10510 memory_order_relaxed
));
10511 json_object_int_add(json_stat
, "capabilityRecv",
10512 atomic_load_explicit(&p
->dynamic_cap_in
,
10513 memory_order_relaxed
));
10514 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10515 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10516 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10518 /* Packet counts. */
10519 vty_out(vty
, " Message statistics:\n");
10520 vty_out(vty
, " Inq depth is 0\n");
10521 vty_out(vty
, " Outq depth is %lu\n",
10522 (unsigned long)p
->obuf
->count
);
10523 vty_out(vty
, " Sent Rcvd\n");
10524 vty_out(vty
, " Opens: %10d %10d\n",
10525 atomic_load_explicit(&p
->open_out
,
10526 memory_order_relaxed
),
10527 atomic_load_explicit(&p
->open_in
,
10528 memory_order_relaxed
));
10529 vty_out(vty
, " Notifications: %10d %10d\n",
10530 atomic_load_explicit(&p
->notify_out
,
10531 memory_order_relaxed
),
10532 atomic_load_explicit(&p
->notify_in
,
10533 memory_order_relaxed
));
10534 vty_out(vty
, " Updates: %10d %10d\n",
10535 atomic_load_explicit(&p
->update_out
,
10536 memory_order_relaxed
),
10537 atomic_load_explicit(&p
->update_in
,
10538 memory_order_relaxed
));
10539 vty_out(vty
, " Keepalives: %10d %10d\n",
10540 atomic_load_explicit(&p
->keepalive_out
,
10541 memory_order_relaxed
),
10542 atomic_load_explicit(&p
->keepalive_in
,
10543 memory_order_relaxed
));
10544 vty_out(vty
, " Route Refresh: %10d %10d\n",
10545 atomic_load_explicit(&p
->refresh_out
,
10546 memory_order_relaxed
),
10547 atomic_load_explicit(&p
->refresh_in
,
10548 memory_order_relaxed
));
10549 vty_out(vty
, " Capability: %10d %10d\n",
10550 atomic_load_explicit(&p
->dynamic_cap_out
,
10551 memory_order_relaxed
),
10552 atomic_load_explicit(&p
->dynamic_cap_in
,
10553 memory_order_relaxed
));
10554 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10559 /* advertisement-interval */
10560 json_object_int_add(json_neigh
,
10561 "minBtwnAdvertisementRunsTimerMsecs",
10562 p
->v_routeadv
* 1000);
10564 /* Update-source. */
10565 if (p
->update_if
|| p
->update_source
) {
10567 json_object_string_add(json_neigh
,
10570 else if (p
->update_source
)
10571 json_object_string_add(
10572 json_neigh
, "updateSource",
10573 sockunion2str(p
->update_source
, buf1
,
10577 /* advertisement-interval */
10579 " Minimum time between advertisement runs is %d seconds\n",
10582 /* Update-source. */
10583 if (p
->update_if
|| p
->update_source
) {
10584 vty_out(vty
, " Update source is ");
10586 vty_out(vty
, "%s", p
->update_if
);
10587 else if (p
->update_source
)
10589 sockunion2str(p
->update_source
, buf1
,
10591 vty_out(vty
, "\n");
10594 vty_out(vty
, "\n");
10597 /* Address Family Information */
10598 json_object
*json_hold
= NULL
;
10601 json_hold
= json_object_new_object();
10603 FOREACH_AFI_SAFI (afi
, safi
)
10604 if (p
->afc
[afi
][safi
])
10605 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10609 json_object_object_add(json_neigh
, "addressFamilyInfo",
10611 json_object_int_add(json_neigh
, "connectionsEstablished",
10613 json_object_int_add(json_neigh
, "connectionsDropped",
10616 vty_out(vty
, " Connections established %d; dropped %d\n",
10617 p
->established
, p
->dropped
);
10619 if (!p
->last_reset
) {
10621 json_object_string_add(json_neigh
, "lastReset",
10624 vty_out(vty
, " Last reset never\n");
10630 uptime
= bgp_clock();
10631 uptime
-= p
->resettime
;
10632 tm
= gmtime(&uptime
);
10633 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10634 (tm
->tm_sec
* 1000)
10635 + (tm
->tm_min
* 60000)
10636 + (tm
->tm_hour
* 3600000));
10637 json_object_string_add(
10638 json_neigh
, "lastResetDueTo",
10639 peer_down_str
[(int)p
->last_reset
]);
10640 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10641 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10642 char errorcodesubcode_hexstr
[5];
10643 char errorcodesubcode_str
[256];
10645 code_str
= bgp_notify_code_str(p
->notify
.code
);
10646 subcode_str
= bgp_notify_subcode_str(
10647 p
->notify
.code
, p
->notify
.subcode
);
10649 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10650 p
->notify
.code
, p
->notify
.subcode
);
10651 json_object_string_add(json_neigh
,
10652 "lastErrorCodeSubcode",
10653 errorcodesubcode_hexstr
);
10654 snprintf(errorcodesubcode_str
, 255, "%s%s",
10655 code_str
, subcode_str
);
10656 json_object_string_add(json_neigh
,
10657 "lastNotificationReason",
10658 errorcodesubcode_str
);
10659 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10660 && p
->notify
.code
== BGP_NOTIFY_CEASE
10661 && (p
->notify
.subcode
10662 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10663 || p
->notify
.subcode
10664 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10665 && p
->notify
.length
) {
10667 const char *msg_str
;
10669 msg_str
= bgp_notify_admin_message(
10670 msgbuf
, sizeof(msgbuf
),
10671 (uint8_t *)p
->notify
.data
,
10674 json_object_string_add(
10676 "lastShutdownDescription",
10681 vty_out(vty
, " Last reset %s, ",
10682 peer_uptime(p
->resettime
, timebuf
,
10683 BGP_UPTIME_LEN
, 0, NULL
));
10685 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10686 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10687 code_str
= bgp_notify_code_str(p
->notify
.code
);
10688 subcode_str
= bgp_notify_subcode_str(
10689 p
->notify
.code
, p
->notify
.subcode
);
10690 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10691 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10694 code_str
, subcode_str
);
10695 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10696 && p
->notify
.code
== BGP_NOTIFY_CEASE
10697 && (p
->notify
.subcode
10698 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10699 || p
->notify
.subcode
10700 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10701 && p
->notify
.length
) {
10703 const char *msg_str
;
10705 msg_str
= bgp_notify_admin_message(
10706 msgbuf
, sizeof(msgbuf
),
10707 (uint8_t *)p
->notify
.data
,
10711 " Message: \"%s\"\n",
10715 vty_out(vty
, "due to %s\n",
10716 peer_down_str
[(int)p
->last_reset
]);
10719 if (p
->last_reset_cause_size
) {
10720 msg
= p
->last_reset_cause
;
10722 " Message received that caused BGP to send a NOTIFICATION:\n ");
10723 for (i
= 1; i
<= p
->last_reset_cause_size
;
10725 vty_out(vty
, "%02X", *msg
++);
10727 if (i
!= p
->last_reset_cause_size
) {
10729 vty_out(vty
, "\n ");
10730 } else if (i
% 4 == 0) {
10735 vty_out(vty
, "\n");
10740 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10742 json_object_boolean_true_add(json_neigh
,
10743 "prefixesConfigExceedMax");
10746 " Peer had exceeded the max. no. of prefixes configured.\n");
10748 if (p
->t_pmax_restart
) {
10750 json_object_boolean_true_add(
10751 json_neigh
, "reducePrefixNumFrom");
10752 json_object_int_add(json_neigh
,
10753 "restartInTimerMsec",
10754 thread_timer_remain_second(
10759 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10760 p
->host
, thread_timer_remain_second(
10761 p
->t_pmax_restart
));
10764 json_object_boolean_true_add(
10766 "reducePrefixNumAndClearIpBgp");
10769 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10774 /* EBGP Multihop and GTSM */
10775 if (p
->sort
!= BGP_PEER_IBGP
) {
10777 if (p
->gtsm_hops
> 0)
10778 json_object_int_add(json_neigh
,
10779 "externalBgpNbrMaxHopsAway",
10781 else if (p
->ttl
> 1)
10782 json_object_int_add(json_neigh
,
10783 "externalBgpNbrMaxHopsAway",
10786 if (p
->gtsm_hops
> 0)
10788 " External BGP neighbor may be up to %d hops away.\n",
10790 else if (p
->ttl
> 1)
10792 " External BGP neighbor may be up to %d hops away.\n",
10796 if (p
->gtsm_hops
> 0) {
10798 json_object_int_add(json_neigh
,
10799 "internalBgpNbrMaxHopsAway",
10803 " Internal BGP neighbor may be up to %d hops away.\n",
10808 /* Local address. */
10811 json_object_string_add(json_neigh
, "hostLocal",
10812 sockunion2str(p
->su_local
, buf1
,
10814 json_object_int_add(json_neigh
, "portLocal",
10815 ntohs(p
->su_local
->sin
.sin_port
));
10817 vty_out(vty
, "Local host: %s, Local port: %d\n",
10818 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10819 ntohs(p
->su_local
->sin
.sin_port
));
10822 /* Remote address. */
10823 if (p
->su_remote
) {
10825 json_object_string_add(json_neigh
, "hostForeign",
10826 sockunion2str(p
->su_remote
, buf1
,
10828 json_object_int_add(json_neigh
, "portForeign",
10829 ntohs(p
->su_remote
->sin
.sin_port
));
10831 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10832 sockunion2str(p
->su_remote
, buf1
,
10834 ntohs(p
->su_remote
->sin
.sin_port
));
10837 /* Nexthop display. */
10840 json_object_string_add(json_neigh
, "nexthop",
10842 &p
->nexthop
.v4
, buf1
,
10844 json_object_string_add(json_neigh
, "nexthopGlobal",
10845 inet_ntop(AF_INET6
,
10846 &p
->nexthop
.v6_global
,
10847 buf1
, sizeof(buf1
)));
10848 json_object_string_add(json_neigh
, "nexthopLocal",
10849 inet_ntop(AF_INET6
,
10850 &p
->nexthop
.v6_local
,
10851 buf1
, sizeof(buf1
)));
10852 if (p
->shared_network
)
10853 json_object_string_add(json_neigh
,
10857 json_object_string_add(json_neigh
,
10859 "nonSharedNetwork");
10861 vty_out(vty
, "Nexthop: %s\n",
10862 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10864 vty_out(vty
, "Nexthop global: %s\n",
10865 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10867 vty_out(vty
, "Nexthop local: %s\n",
10868 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10870 vty_out(vty
, "BGP connection: %s\n",
10871 p
->shared_network
? "shared network"
10872 : "non shared network");
10876 /* Timer information. */
10878 json_object_int_add(json_neigh
, "connectRetryTimer",
10880 if (p
->status
== Established
&& p
->rtt
)
10881 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10884 json_object_int_add(
10885 json_neigh
, "nextStartTimerDueInMsecs",
10886 thread_timer_remain_second(p
->t_start
) * 1000);
10888 json_object_int_add(
10889 json_neigh
, "nextConnectTimerDueInMsecs",
10890 thread_timer_remain_second(p
->t_connect
)
10892 if (p
->t_routeadv
) {
10893 json_object_int_add(json_neigh
, "mraiInterval",
10895 json_object_int_add(
10896 json_neigh
, "mraiTimerExpireInMsecs",
10897 thread_timer_remain_second(p
->t_routeadv
)
10901 json_object_int_add(json_neigh
, "authenticationEnabled",
10905 json_object_string_add(json_neigh
, "readThread", "on");
10907 json_object_string_add(json_neigh
, "readThread", "off");
10909 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10910 json_object_string_add(json_neigh
, "writeThread", "on");
10912 json_object_string_add(json_neigh
, "writeThread",
10915 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10917 if (p
->status
== Established
&& p
->rtt
)
10918 vty_out(vty
, "Estimated round trip time: %d ms\n",
10921 vty_out(vty
, "Next start timer due in %ld seconds\n",
10922 thread_timer_remain_second(p
->t_start
));
10924 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10925 thread_timer_remain_second(p
->t_connect
));
10928 "MRAI (interval %u) timer expires in %ld seconds\n",
10930 thread_timer_remain_second(p
->t_routeadv
));
10932 vty_out(vty
, "Peer Authentication Enabled\n");
10934 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10935 p
->t_read
? "on" : "off",
10936 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10941 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10942 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10943 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10946 vty_out(vty
, "\n");
10948 /* BFD information. */
10949 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10952 if (p
->conf_if
) /* Configured interface name. */
10953 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10954 else /* Configured IP address. */
10955 json_object_object_add(json
, p
->host
, json_neigh
);
10959 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10960 enum show_type type
, union sockunion
*su
,
10961 const char *conf_if
, bool use_json
,
10964 struct listnode
*node
, *nnode
;
10967 bool nbr_output
= false;
10968 afi_t afi
= AFI_MAX
;
10969 safi_t safi
= SAFI_MAX
;
10971 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10973 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10977 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10978 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10983 bgp_show_peer(vty
, peer
, use_json
, json
);
10989 && !strcmp(peer
->conf_if
, conf_if
))
10991 && !strcmp(peer
->hostname
, conf_if
))) {
10993 bgp_show_peer(vty
, peer
, use_json
,
10997 if (sockunion_same(&peer
->su
, su
)) {
10999 bgp_show_peer(vty
, peer
, use_json
,
11004 case show_ipv4_peer
:
11005 case show_ipv6_peer
:
11006 FOREACH_SAFI (safi
) {
11007 if (peer
->afc
[afi
][safi
]) {
11010 && !strcmp(peer
->conf_if
, conf_if
))
11012 && !strcmp(peer
->hostname
, conf_if
))) {
11014 bgp_show_peer(vty
, peer
, use_json
,
11019 if (sockunion_same(&peer
->su
, su
)) {
11021 bgp_show_peer(vty
, peer
, use_json
,
11029 case show_ipv4_all
:
11030 case show_ipv6_all
:
11031 FOREACH_SAFI (safi
) {
11032 if (peer
->afc
[afi
][safi
]) {
11033 bgp_show_peer(vty
, peer
, use_json
, json
);
11042 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11043 type
== show_ipv6_peer
) && !find
) {
11045 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11047 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11050 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11051 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11052 vty_out(vty
, "%% No BGP neighbors found\n");
11055 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11056 json
, JSON_C_TO_STRING_PRETTY
));
11058 vty_out(vty
, "\n");
11061 return CMD_SUCCESS
;
11064 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11065 enum show_type type
,
11066 const char *ip_str
,
11069 struct listnode
*node
, *nnode
;
11071 union sockunion su
;
11072 json_object
*json
= NULL
;
11073 int ret
, is_first
= 1;
11074 bool nbr_output
= false;
11077 vty_out(vty
, "{\n");
11079 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11082 if (!(json
= json_object_new_object())) {
11084 EC_BGP_JSON_MEM_ERROR
,
11085 "Unable to allocate memory for JSON object");
11087 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11091 json_object_int_add(json
, "vrfId",
11092 (bgp
->vrf_id
== VRF_UNKNOWN
)
11094 : (int64_t)bgp
->vrf_id
);
11095 json_object_string_add(
11097 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11102 vty_out(vty
, ",\n");
11106 vty_out(vty
, "\"%s\":",
11107 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11111 vty_out(vty
, "\nInstance %s:\n",
11112 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11117 if (type
== show_peer
|| type
== show_ipv4_peer
||
11118 type
== show_ipv6_peer
) {
11119 ret
= str2sockunion(ip_str
, &su
);
11121 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11124 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11127 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11130 json_object_free(json
);
11134 vty_out(vty
, "}\n");
11135 json_object_free(json
);
11137 else if (!nbr_output
)
11138 vty_out(vty
, "%% BGP instance not found\n");
11141 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11142 enum show_type type
, const char *ip_str
,
11147 union sockunion su
;
11148 json_object
*json
= NULL
;
11151 if (strmatch(name
, "all")) {
11152 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11154 return CMD_SUCCESS
;
11156 bgp
= bgp_lookup_by_name(name
);
11159 json
= json_object_new_object();
11160 vty_out(vty
, "%s\n",
11161 json_object_to_json_string_ext(
11163 JSON_C_TO_STRING_PRETTY
));
11164 json_object_free(json
);
11167 "%% BGP instance not found\n");
11169 return CMD_WARNING
;
11173 bgp
= bgp_get_default();
11177 json
= json_object_new_object();
11179 ret
= str2sockunion(ip_str
, &su
);
11181 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11184 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11187 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11190 json_object_free(json
);
11193 vty_out(vty
, "{}\n");
11195 vty_out(vty
, "%% BGP instance not found\n");
11198 return CMD_SUCCESS
;
11201 /* "show [ip] bgp neighbors" commands. */
11202 DEFUN (show_ip_bgp_neighbors
,
11203 show_ip_bgp_neighbors_cmd
,
11204 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11208 BGP_INSTANCE_HELP_STR
11211 "Detailed information on TCP and BGP neighbor connections\n"
11212 "Neighbor to display information about\n"
11213 "Neighbor to display information about\n"
11214 "Neighbor on BGP configured interface\n"
11218 char *sh_arg
= NULL
;
11219 enum show_type sh_type
;
11220 afi_t afi
= AFI_MAX
;
11222 bool uj
= use_json(argc
, argv
);
11226 /* [<vrf> VIEWVRFNAME] */
11227 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11228 vrf
= argv
[idx
+ 1]->arg
;
11229 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11231 } else if (argv_find(argv
, argc
, "view", &idx
))
11232 /* [<view> VIEWVRFNAME] */
11233 vrf
= argv
[idx
+ 1]->arg
;
11237 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11238 sh_type
= show_ipv4_all
;
11240 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11241 sh_type
= show_ipv6_all
;
11244 sh_type
= show_all
;
11247 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11248 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11249 || argv_find(argv
, argc
, "WORD", &idx
)) {
11250 sh_type
= show_peer
;
11251 sh_arg
= argv
[idx
]->arg
;
11254 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11255 sh_type
= show_ipv4_peer
;
11256 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11257 sh_type
= show_ipv6_peer
;
11260 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11263 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11264 paths' and `show ip mbgp paths'. Those functions results are the
11266 DEFUN (show_ip_bgp_paths
,
11267 show_ip_bgp_paths_cmd
,
11268 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11273 "Path information\n")
11275 vty_out(vty
, "Address Refcnt Path\n");
11276 aspath_print_all_vty(vty
);
11277 return CMD_SUCCESS
;
11282 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11285 struct community
*com
;
11287 com
= (struct community
*)bucket
->data
;
11288 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11289 community_str(com
, false));
11292 /* Show BGP's community internal data. */
11293 DEFUN (show_ip_bgp_community_info
,
11294 show_ip_bgp_community_info_cmd
,
11295 "show [ip] bgp community-info",
11299 "List all bgp community information\n")
11301 vty_out(vty
, "Address Refcnt Community\n");
11303 hash_iterate(community_hash(),
11304 (void (*)(struct hash_bucket
*,
11305 void *))community_show_all_iterator
,
11308 return CMD_SUCCESS
;
11311 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11314 struct lcommunity
*lcom
;
11316 lcom
= (struct lcommunity
*)bucket
->data
;
11317 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11318 lcommunity_str(lcom
, false));
11321 /* Show BGP's community internal data. */
11322 DEFUN (show_ip_bgp_lcommunity_info
,
11323 show_ip_bgp_lcommunity_info_cmd
,
11324 "show ip bgp large-community-info",
11328 "List all bgp large-community information\n")
11330 vty_out(vty
, "Address Refcnt Large-community\n");
11332 hash_iterate(lcommunity_hash(),
11333 (void (*)(struct hash_bucket
*,
11334 void *))lcommunity_show_all_iterator
,
11337 return CMD_SUCCESS
;
11341 DEFUN (show_ip_bgp_attr_info
,
11342 show_ip_bgp_attr_info_cmd
,
11343 "show [ip] bgp attribute-info",
11347 "List all bgp attribute information\n")
11349 attr_show_all(vty
);
11350 return CMD_SUCCESS
;
11353 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11354 afi_t afi
, safi_t safi
,
11355 bool use_json
, json_object
*json
)
11358 struct listnode
*node
;
11360 char buf1
[INET6_ADDRSTRLEN
];
11362 vpn_policy_direction_t dir
;
11365 json_object
*json_import_vrfs
= NULL
;
11366 json_object
*json_export_vrfs
= NULL
;
11368 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11371 vty_out(vty
, "%s\n",
11372 json_object_to_json_string_ext(
11374 JSON_C_TO_STRING_PRETTY
));
11375 json_object_free(json
);
11377 return CMD_WARNING
;
11380 /* Provide context for the block */
11381 json_object_string_add(json
, "vrf", name
? name
: "default");
11382 json_object_string_add(json
, "afiSafi",
11383 afi_safi_print(afi
, safi
));
11385 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11386 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11387 json_object_string_add(json
, "importFromVrfs", "none");
11388 json_object_string_add(json
, "importRts", "none");
11390 json_import_vrfs
= json_object_new_array();
11392 for (ALL_LIST_ELEMENTS_RO(
11393 bgp
->vpn_policy
[afi
].import_vrf
,
11395 json_object_array_add(json_import_vrfs
,
11396 json_object_new_string(vname
));
11398 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11399 ecom_str
= ecommunity_ecom2str(
11400 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11401 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11402 json_object_object_add(json
, "importFromVrfs",
11404 json_object_string_add(json
, "importRts", ecom_str
);
11406 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11409 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11410 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11411 json_object_string_add(json
, "exportToVrfs", "none");
11412 json_object_string_add(json
, "routeDistinguisher",
11414 json_object_string_add(json
, "exportRts", "none");
11416 json_export_vrfs
= json_object_new_array();
11418 for (ALL_LIST_ELEMENTS_RO(
11419 bgp
->vpn_policy
[afi
].export_vrf
,
11421 json_object_array_add(json_export_vrfs
,
11422 json_object_new_string(vname
));
11423 json_object_object_add(json
, "exportToVrfs",
11425 json_object_string_add(json
, "routeDistinguisher",
11426 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11427 buf1
, RD_ADDRSTRLEN
));
11429 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11430 ecom_str
= ecommunity_ecom2str(
11431 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11432 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11433 json_object_string_add(json
, "exportRts", ecom_str
);
11435 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11439 vty_out(vty
, "%s\n",
11440 json_object_to_json_string_ext(json
,
11441 JSON_C_TO_STRING_PRETTY
));
11442 json_object_free(json
);
11445 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11448 vty_out(vty
, "%% No such BGP instance exist\n");
11449 return CMD_WARNING
;
11452 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11453 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11455 "This VRF is not importing %s routes from any other VRF\n",
11456 afi_safi_print(afi
, safi
));
11459 "This VRF is importing %s routes from the following VRFs:\n",
11460 afi_safi_print(afi
, safi
));
11462 for (ALL_LIST_ELEMENTS_RO(
11463 bgp
->vpn_policy
[afi
].import_vrf
,
11465 vty_out(vty
, " %s\n", vname
);
11467 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11468 ecom_str
= ecommunity_ecom2str(
11469 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11470 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11471 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11473 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11476 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11477 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11479 "This VRF is not exporting %s routes to any other VRF\n",
11480 afi_safi_print(afi
, safi
));
11483 "This VRF is exporting %s routes to the following VRFs:\n",
11484 afi_safi_print(afi
, safi
));
11486 for (ALL_LIST_ELEMENTS_RO(
11487 bgp
->vpn_policy
[afi
].export_vrf
,
11489 vty_out(vty
, " %s\n", vname
);
11491 vty_out(vty
, "RD: %s\n",
11492 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11493 buf1
, RD_ADDRSTRLEN
));
11495 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11496 ecom_str
= ecommunity_ecom2str(
11497 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11498 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11499 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11500 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11504 return CMD_SUCCESS
;
11507 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11508 safi_t safi
, bool use_json
)
11510 struct listnode
*node
, *nnode
;
11512 char *vrf_name
= NULL
;
11513 json_object
*json
= NULL
;
11514 json_object
*json_vrf
= NULL
;
11515 json_object
*json_vrfs
= NULL
;
11518 json
= json_object_new_object();
11519 json_vrfs
= json_object_new_object();
11522 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11524 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11525 vrf_name
= bgp
->name
;
11528 json_vrf
= json_object_new_object();
11530 vty_out(vty
, "\nInstance %s:\n",
11531 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11532 ? VRF_DEFAULT_NAME
: bgp
->name
);
11534 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11536 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11537 json_object_object_add(json_vrfs
,
11538 VRF_DEFAULT_NAME
, json_vrf
);
11540 json_object_object_add(json_vrfs
, vrf_name
,
11546 json_object_object_add(json
, "vrfs", json_vrfs
);
11547 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11548 JSON_C_TO_STRING_PRETTY
));
11549 json_object_free(json
);
11552 return CMD_SUCCESS
;
11555 /* "show [ip] bgp route-leak" command. */
11556 DEFUN (show_ip_bgp_route_leak
,
11557 show_ip_bgp_route_leak_cmd
,
11558 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11562 BGP_INSTANCE_HELP_STR
11565 "Route leaking information\n"
11569 afi_t afi
= AFI_MAX
;
11570 safi_t safi
= SAFI_MAX
;
11572 bool uj
= use_json(argc
, argv
);
11574 json_object
*json
= NULL
;
11576 /* show [ip] bgp */
11577 if (argv_find(argv
, argc
, "ip", &idx
)) {
11579 safi
= SAFI_UNICAST
;
11581 /* [vrf VIEWVRFNAME] */
11582 if (argv_find(argv
, argc
, "view", &idx
)) {
11584 "%% This command is not applicable to BGP views\n");
11585 return CMD_WARNING
;
11588 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11589 vrf
= argv
[idx
+ 1]->arg
;
11590 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11593 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11594 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11595 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11598 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11600 "%% This command is applicable only for unicast ipv4|ipv6\n");
11601 return CMD_WARNING
;
11604 if (vrf
&& strmatch(vrf
, "all"))
11605 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11608 json
= json_object_new_object();
11610 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11613 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11616 struct listnode
*node
, *nnode
;
11619 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11620 vty_out(vty
, "\nInstance %s:\n",
11621 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11624 update_group_show(bgp
, afi
, safi
, vty
, 0);
11628 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11629 int safi
, uint64_t subgrp_id
)
11634 if (strmatch(name
, "all")) {
11635 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11636 return CMD_SUCCESS
;
11638 bgp
= bgp_lookup_by_name(name
);
11641 bgp
= bgp_get_default();
11645 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11646 return CMD_SUCCESS
;
11649 DEFUN (show_ip_bgp_updgrps
,
11650 show_ip_bgp_updgrps_cmd
,
11651 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11655 BGP_INSTANCE_HELP_STR
11657 BGP_SAFI_WITH_LABEL_HELP_STR
11658 "Detailed info about dynamic update groups\n"
11659 "Specific subgroup to display detailed info for\n")
11662 afi_t afi
= AFI_IP6
;
11663 safi_t safi
= SAFI_UNICAST
;
11664 uint64_t subgrp_id
= 0;
11668 /* show [ip] bgp */
11669 if (argv_find(argv
, argc
, "ip", &idx
))
11671 /* [<vrf> VIEWVRFNAME] */
11672 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11673 vrf
= argv
[idx
+ 1]->arg
;
11674 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11676 } else if (argv_find(argv
, argc
, "view", &idx
))
11677 /* [<view> VIEWVRFNAME] */
11678 vrf
= argv
[idx
+ 1]->arg
;
11679 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11680 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11681 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11684 /* get subgroup id, if provided */
11686 if (argv
[idx
]->type
== VARIABLE_TKN
)
11687 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11689 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11692 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11693 show_bgp_instance_all_ipv6_updgrps_cmd
,
11694 "show [ip] bgp <view|vrf> all update-groups",
11698 BGP_INSTANCE_ALL_HELP_STR
11699 "Detailed info about dynamic update groups\n")
11701 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11702 return CMD_SUCCESS
;
11705 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11706 show_bgp_l2vpn_evpn_updgrps_cmd
,
11707 "show [ip] bgp l2vpn evpn update-groups",
11711 "l2vpn address family\n"
11712 "evpn sub-address family\n"
11713 "Detailed info about dynamic update groups\n")
11716 uint64_t subgrp_id
= 0;
11718 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11719 return CMD_SUCCESS
;
11722 DEFUN (show_bgp_updgrps_stats
,
11723 show_bgp_updgrps_stats_cmd
,
11724 "show [ip] bgp update-groups statistics",
11728 "Detailed info about dynamic update groups\n"
11733 bgp
= bgp_get_default();
11735 update_group_show_stats(bgp
, vty
);
11737 return CMD_SUCCESS
;
11740 DEFUN (show_bgp_instance_updgrps_stats
,
11741 show_bgp_instance_updgrps_stats_cmd
,
11742 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11746 BGP_INSTANCE_HELP_STR
11747 "Detailed info about dynamic update groups\n"
11753 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11755 update_group_show_stats(bgp
, vty
);
11757 return CMD_SUCCESS
;
11760 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11761 afi_t afi
, safi_t safi
,
11762 const char *what
, uint64_t subgrp_id
)
11767 bgp
= bgp_lookup_by_name(name
);
11769 bgp
= bgp_get_default();
11772 if (!strcmp(what
, "advertise-queue"))
11773 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11775 else if (!strcmp(what
, "advertised-routes"))
11776 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11778 else if (!strcmp(what
, "packet-queue"))
11779 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11784 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11785 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11786 "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",
11787 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11789 "Detailed info about dynamic update groups\n"
11790 "Specific subgroup to display info for\n"
11791 "Advertisement queue\n"
11792 "Announced routes\n"
11795 uint64_t subgrp_id
= 0;
11799 subgrp_id
= strtoull(sgid
, NULL
, 10);
11804 afiz
= bgp_vty_afi_from_str(afi
);
11808 afiz
= bgp_vty_afi_from_str(afi
);
11809 if (afiz
!= AFI_IP
)
11811 "%% Cannot specify both 'ip' and 'ipv6'\n");
11812 return CMD_WARNING
;
11815 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11817 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11818 return CMD_SUCCESS
;
11821 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11823 struct listnode
*node
, *nnode
;
11824 struct prefix
*range
;
11827 char buf
[PREFIX2STR_BUFFER
];
11830 const char *peer_status
;
11831 const char *af_str
;
11836 conf
= group
->conf
;
11838 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11839 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11840 group
->name
, conf
->as
);
11841 } else if (conf
->as_type
== AS_INTERNAL
) {
11842 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11843 group
->name
, group
->bgp
->as
);
11845 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11848 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11849 vty_out(vty
, " Peer-group type is internal\n");
11851 vty_out(vty
, " Peer-group type is external\n");
11853 /* Display AFs configured. */
11854 vty_out(vty
, " Configured address-families:");
11855 FOREACH_AFI_SAFI (afi
, safi
) {
11856 if (conf
->afc
[afi
][safi
]) {
11858 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11862 vty_out(vty
, " none\n");
11864 vty_out(vty
, "\n");
11866 /* Display listen ranges (for dynamic neighbors), if any */
11867 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11870 else if (afi
== AFI_IP6
)
11874 lr_count
= listcount(group
->listen_range
[afi
]);
11876 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11880 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11882 prefix2str(range
, buf
, sizeof(buf
));
11883 vty_out(vty
, " %s\n", buf
);
11888 /* Display group members and their status */
11889 if (listcount(group
->peer
)) {
11890 vty_out(vty
, " Peer-group members:\n");
11891 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11892 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11893 peer_status
= "Idle (Admin)";
11894 else if (CHECK_FLAG(peer
->sflags
,
11895 PEER_STATUS_PREFIX_OVERFLOW
))
11896 peer_status
= "Idle (PfxCt)";
11898 peer_status
= lookup_msg(bgp_status_msg
,
11899 peer
->status
, NULL
);
11901 dynamic
= peer_dynamic_neighbor(peer
);
11902 vty_out(vty
, " %s %s %s \n", peer
->host
,
11903 dynamic
? "(dynamic)" : "", peer_status
);
11907 return CMD_SUCCESS
;
11910 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11911 const char *group_name
)
11914 struct listnode
*node
, *nnode
;
11915 struct peer_group
*group
;
11916 bool found
= false;
11918 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11921 vty_out(vty
, "%% BGP instance not found\n");
11922 return CMD_WARNING
;
11925 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11927 if (strmatch(group
->name
, group_name
)) {
11928 bgp_show_one_peer_group(vty
, group
);
11933 bgp_show_one_peer_group(vty
, group
);
11937 if (group_name
&& !found
)
11938 vty_out(vty
, "%% No such peer-group\n");
11940 return CMD_SUCCESS
;
11943 DEFUN (show_ip_bgp_peer_groups
,
11944 show_ip_bgp_peer_groups_cmd
,
11945 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11949 BGP_INSTANCE_HELP_STR
11950 "Detailed information on BGP peer groups\n"
11951 "Peer group name\n")
11956 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11958 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11960 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11964 /* Redistribute VTY commands. */
11966 DEFUN (bgp_redistribute_ipv4
,
11967 bgp_redistribute_ipv4_cmd
,
11968 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11969 "Redistribute information from another routing protocol\n"
11970 FRR_IP_REDIST_HELP_STR_BGPD
)
11972 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11973 int idx_protocol
= 1;
11976 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11978 vty_out(vty
, "%% Invalid route type\n");
11979 return CMD_WARNING_CONFIG_FAILED
;
11982 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11983 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11987 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11988 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11989 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11991 DEFUN (bgp_redistribute_ipv4_rmap
,
11992 bgp_redistribute_ipv4_rmap_cmd
,
11993 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11994 "Redistribute information from another routing protocol\n"
11995 FRR_IP_REDIST_HELP_STR_BGPD
11996 "Route map reference\n"
11997 "Pointer to route-map entries\n")
11999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12000 int idx_protocol
= 1;
12003 struct bgp_redist
*red
;
12005 struct route_map
*route_map
= route_map_lookup_warn_noexist(
12006 vty
, argv
[idx_word
]->arg
);
12008 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12010 vty_out(vty
, "%% Invalid route type\n");
12011 return CMD_WARNING_CONFIG_FAILED
;
12014 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12016 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12017 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12021 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12022 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12023 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12024 "Route map reference\n"
12025 "Pointer to route-map entries\n")
12027 DEFUN (bgp_redistribute_ipv4_metric
,
12028 bgp_redistribute_ipv4_metric_cmd
,
12029 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12030 "Redistribute information from another routing protocol\n"
12031 FRR_IP_REDIST_HELP_STR_BGPD
12032 "Metric for redistributed routes\n"
12033 "Default metric\n")
12035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12036 int idx_protocol
= 1;
12037 int idx_number
= 3;
12040 struct bgp_redist
*red
;
12043 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12045 vty_out(vty
, "%% Invalid route type\n");
12046 return CMD_WARNING_CONFIG_FAILED
;
12048 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12050 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12051 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12052 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12056 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12057 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12058 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12059 "Metric for redistributed routes\n"
12060 "Default metric\n")
12062 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12063 bgp_redistribute_ipv4_rmap_metric_cmd
,
12064 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12065 "Redistribute information from another routing protocol\n"
12066 FRR_IP_REDIST_HELP_STR_BGPD
12067 "Route map reference\n"
12068 "Pointer to route-map entries\n"
12069 "Metric for redistributed routes\n"
12070 "Default metric\n")
12072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12073 int idx_protocol
= 1;
12075 int idx_number
= 5;
12078 struct bgp_redist
*red
;
12080 struct route_map
*route_map
=
12081 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12083 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12085 vty_out(vty
, "%% Invalid route type\n");
12086 return CMD_WARNING_CONFIG_FAILED
;
12088 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12090 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12092 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12093 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12094 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12098 bgp_redistribute_ipv4_rmap_metric
,
12099 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12100 "redistribute " FRR_IP_REDIST_STR_BGPD
12101 " route-map WORD metric (0-4294967295)",
12102 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12103 "Route map reference\n"
12104 "Pointer to route-map entries\n"
12105 "Metric for redistributed routes\n"
12106 "Default metric\n")
12108 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12109 bgp_redistribute_ipv4_metric_rmap_cmd
,
12110 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12111 "Redistribute information from another routing protocol\n"
12112 FRR_IP_REDIST_HELP_STR_BGPD
12113 "Metric for redistributed routes\n"
12115 "Route map reference\n"
12116 "Pointer to route-map entries\n")
12118 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12119 int idx_protocol
= 1;
12120 int idx_number
= 3;
12124 struct bgp_redist
*red
;
12126 struct route_map
*route_map
=
12127 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12129 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12131 vty_out(vty
, "%% Invalid route type\n");
12132 return CMD_WARNING_CONFIG_FAILED
;
12134 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12136 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12137 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12139 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12140 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12144 bgp_redistribute_ipv4_metric_rmap
,
12145 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12146 "redistribute " FRR_IP_REDIST_STR_BGPD
12147 " metric (0-4294967295) route-map WORD",
12148 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12149 "Metric for redistributed routes\n"
12151 "Route map reference\n"
12152 "Pointer to route-map entries\n")
12154 DEFUN (bgp_redistribute_ipv4_ospf
,
12155 bgp_redistribute_ipv4_ospf_cmd
,
12156 "redistribute <ospf|table> (1-65535)",
12157 "Redistribute information from another routing protocol\n"
12158 "Open Shortest Path First (OSPFv2)\n"
12159 "Non-main Kernel Routing Table\n"
12160 "Instance ID/Table ID\n")
12162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12163 int idx_ospf_table
= 1;
12164 int idx_number
= 2;
12165 unsigned short instance
;
12166 unsigned short protocol
;
12168 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12170 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12171 protocol
= ZEBRA_ROUTE_OSPF
;
12173 protocol
= ZEBRA_ROUTE_TABLE
;
12175 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12176 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12179 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12180 "redistribute <ospf|table> (1-65535)",
12181 "Redistribute information from another routing protocol\n"
12182 "Open Shortest Path First (OSPFv2)\n"
12183 "Non-main Kernel Routing Table\n"
12184 "Instance ID/Table ID\n")
12186 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12187 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12188 "redistribute <ospf|table> (1-65535) route-map WORD",
12189 "Redistribute information from another routing protocol\n"
12190 "Open Shortest Path First (OSPFv2)\n"
12191 "Non-main Kernel Routing Table\n"
12192 "Instance ID/Table ID\n"
12193 "Route map reference\n"
12194 "Pointer to route-map entries\n")
12196 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12197 int idx_ospf_table
= 1;
12198 int idx_number
= 2;
12200 struct bgp_redist
*red
;
12201 unsigned short instance
;
12204 struct route_map
*route_map
=
12205 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12207 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12208 protocol
= ZEBRA_ROUTE_OSPF
;
12210 protocol
= ZEBRA_ROUTE_TABLE
;
12212 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12213 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12215 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12216 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12219 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12220 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12221 "redistribute <ospf|table> (1-65535) route-map WORD",
12222 "Redistribute information from another routing protocol\n"
12223 "Open Shortest Path First (OSPFv2)\n"
12224 "Non-main Kernel Routing Table\n"
12225 "Instance ID/Table ID\n"
12226 "Route map reference\n"
12227 "Pointer to route-map entries\n")
12229 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12230 bgp_redistribute_ipv4_ospf_metric_cmd
,
12231 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12232 "Redistribute information from another routing protocol\n"
12233 "Open Shortest Path First (OSPFv2)\n"
12234 "Non-main Kernel Routing Table\n"
12235 "Instance ID/Table ID\n"
12236 "Metric for redistributed routes\n"
12237 "Default metric\n")
12239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12240 int idx_ospf_table
= 1;
12241 int idx_number
= 2;
12242 int idx_number_2
= 4;
12244 struct bgp_redist
*red
;
12245 unsigned short instance
;
12249 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12250 protocol
= ZEBRA_ROUTE_OSPF
;
12252 protocol
= ZEBRA_ROUTE_TABLE
;
12254 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12255 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12257 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12258 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12260 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12263 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12264 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12265 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12266 "Redistribute information from another routing protocol\n"
12267 "Open Shortest Path First (OSPFv2)\n"
12268 "Non-main Kernel Routing Table\n"
12269 "Instance ID/Table ID\n"
12270 "Metric for redistributed routes\n"
12271 "Default metric\n")
12273 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12274 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12275 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12276 "Redistribute information from another routing protocol\n"
12277 "Open Shortest Path First (OSPFv2)\n"
12278 "Non-main Kernel Routing Table\n"
12279 "Instance ID/Table ID\n"
12280 "Route map reference\n"
12281 "Pointer to route-map entries\n"
12282 "Metric for redistributed routes\n"
12283 "Default metric\n")
12285 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12286 int idx_ospf_table
= 1;
12287 int idx_number
= 2;
12289 int idx_number_2
= 6;
12291 struct bgp_redist
*red
;
12292 unsigned short instance
;
12295 struct route_map
*route_map
=
12296 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12298 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12299 protocol
= ZEBRA_ROUTE_OSPF
;
12301 protocol
= ZEBRA_ROUTE_TABLE
;
12303 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12304 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12306 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12308 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12309 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12311 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12315 bgp_redistribute_ipv4_ospf_rmap_metric
,
12316 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12317 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12318 "Redistribute information from another routing protocol\n"
12319 "Open Shortest Path First (OSPFv2)\n"
12320 "Non-main Kernel Routing Table\n"
12321 "Instance ID/Table ID\n"
12322 "Route map reference\n"
12323 "Pointer to route-map entries\n"
12324 "Metric for redistributed routes\n"
12325 "Default metric\n")
12327 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12328 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12329 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12330 "Redistribute information from another routing protocol\n"
12331 "Open Shortest Path First (OSPFv2)\n"
12332 "Non-main Kernel Routing Table\n"
12333 "Instance ID/Table ID\n"
12334 "Metric for redistributed routes\n"
12336 "Route map reference\n"
12337 "Pointer to route-map entries\n")
12339 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12340 int idx_ospf_table
= 1;
12341 int idx_number
= 2;
12342 int idx_number_2
= 4;
12345 struct bgp_redist
*red
;
12346 unsigned short instance
;
12349 struct route_map
*route_map
=
12350 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12352 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12353 protocol
= ZEBRA_ROUTE_OSPF
;
12355 protocol
= ZEBRA_ROUTE_TABLE
;
12357 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12358 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12360 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12361 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12364 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12365 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12369 bgp_redistribute_ipv4_ospf_metric_rmap
,
12370 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12371 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12372 "Redistribute information from another routing protocol\n"
12373 "Open Shortest Path First (OSPFv2)\n"
12374 "Non-main Kernel Routing Table\n"
12375 "Instance ID/Table ID\n"
12376 "Metric for redistributed routes\n"
12378 "Route map reference\n"
12379 "Pointer to route-map entries\n")
12381 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12382 no_bgp_redistribute_ipv4_ospf_cmd
,
12383 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12385 "Redistribute information from another routing protocol\n"
12386 "Open Shortest Path First (OSPFv2)\n"
12387 "Non-main Kernel Routing Table\n"
12388 "Instance ID/Table ID\n"
12389 "Metric for redistributed routes\n"
12391 "Route map reference\n"
12392 "Pointer to route-map entries\n")
12394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12395 int idx_ospf_table
= 2;
12396 int idx_number
= 3;
12397 unsigned short instance
;
12400 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12401 protocol
= ZEBRA_ROUTE_OSPF
;
12403 protocol
= ZEBRA_ROUTE_TABLE
;
12405 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12406 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12410 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12411 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12413 "Redistribute information from another routing protocol\n"
12414 "Open Shortest Path First (OSPFv2)\n"
12415 "Non-main Kernel Routing Table\n"
12416 "Instance ID/Table ID\n"
12417 "Metric for redistributed routes\n"
12419 "Route map reference\n"
12420 "Pointer to route-map entries\n")
12422 DEFUN (no_bgp_redistribute_ipv4
,
12423 no_bgp_redistribute_ipv4_cmd
,
12424 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12426 "Redistribute information from another routing protocol\n"
12427 FRR_IP_REDIST_HELP_STR_BGPD
12428 "Metric for redistributed routes\n"
12430 "Route map reference\n"
12431 "Pointer to route-map entries\n")
12433 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12434 int idx_protocol
= 2;
12437 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12439 vty_out(vty
, "%% Invalid route type\n");
12440 return CMD_WARNING_CONFIG_FAILED
;
12442 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12446 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12447 "no redistribute " FRR_IP_REDIST_STR_BGPD
12448 " [metric (0-4294967295)] [route-map WORD]",
12450 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12451 "Metric for redistributed routes\n"
12453 "Route map reference\n"
12454 "Pointer to route-map entries\n")
12456 DEFUN (bgp_redistribute_ipv6
,
12457 bgp_redistribute_ipv6_cmd
,
12458 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12459 "Redistribute information from another routing protocol\n"
12460 FRR_IP6_REDIST_HELP_STR_BGPD
)
12462 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12463 int idx_protocol
= 1;
12466 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12468 vty_out(vty
, "%% Invalid route type\n");
12469 return CMD_WARNING_CONFIG_FAILED
;
12472 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12473 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12476 DEFUN (bgp_redistribute_ipv6_rmap
,
12477 bgp_redistribute_ipv6_rmap_cmd
,
12478 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12479 "Redistribute information from another routing protocol\n"
12480 FRR_IP6_REDIST_HELP_STR_BGPD
12481 "Route map reference\n"
12482 "Pointer to route-map entries\n")
12484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12485 int idx_protocol
= 1;
12488 struct bgp_redist
*red
;
12490 struct route_map
*route_map
=
12491 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12493 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12495 vty_out(vty
, "%% Invalid route type\n");
12496 return CMD_WARNING_CONFIG_FAILED
;
12499 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12501 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12502 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12505 DEFUN (bgp_redistribute_ipv6_metric
,
12506 bgp_redistribute_ipv6_metric_cmd
,
12507 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12508 "Redistribute information from another routing protocol\n"
12509 FRR_IP6_REDIST_HELP_STR_BGPD
12510 "Metric for redistributed routes\n"
12511 "Default metric\n")
12513 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12514 int idx_protocol
= 1;
12515 int idx_number
= 3;
12518 struct bgp_redist
*red
;
12521 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12523 vty_out(vty
, "%% Invalid route type\n");
12524 return CMD_WARNING_CONFIG_FAILED
;
12526 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12528 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12529 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12530 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12533 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12534 bgp_redistribute_ipv6_rmap_metric_cmd
,
12535 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12536 "Redistribute information from another routing protocol\n"
12537 FRR_IP6_REDIST_HELP_STR_BGPD
12538 "Route map reference\n"
12539 "Pointer to route-map entries\n"
12540 "Metric for redistributed routes\n"
12541 "Default metric\n")
12543 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12544 int idx_protocol
= 1;
12546 int idx_number
= 5;
12549 struct bgp_redist
*red
;
12551 struct route_map
*route_map
=
12552 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12554 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12556 vty_out(vty
, "%% Invalid route type\n");
12557 return CMD_WARNING_CONFIG_FAILED
;
12559 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12561 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12563 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12564 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12566 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12569 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12570 bgp_redistribute_ipv6_metric_rmap_cmd
,
12571 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12572 "Redistribute information from another routing protocol\n"
12573 FRR_IP6_REDIST_HELP_STR_BGPD
12574 "Metric for redistributed routes\n"
12576 "Route map reference\n"
12577 "Pointer to route-map entries\n")
12579 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12580 int idx_protocol
= 1;
12581 int idx_number
= 3;
12585 struct bgp_redist
*red
;
12587 struct route_map
*route_map
=
12588 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12590 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12592 vty_out(vty
, "%% Invalid route type\n");
12593 return CMD_WARNING_CONFIG_FAILED
;
12595 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12597 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12598 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12601 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12602 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12605 DEFUN (no_bgp_redistribute_ipv6
,
12606 no_bgp_redistribute_ipv6_cmd
,
12607 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12609 "Redistribute information from another routing protocol\n"
12610 FRR_IP6_REDIST_HELP_STR_BGPD
12611 "Metric for redistributed routes\n"
12613 "Route map reference\n"
12614 "Pointer to route-map entries\n")
12616 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12617 int idx_protocol
= 2;
12620 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12622 vty_out(vty
, "%% Invalid route type\n");
12623 return CMD_WARNING_CONFIG_FAILED
;
12626 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12629 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12634 /* Unicast redistribution only. */
12635 if (safi
!= SAFI_UNICAST
)
12638 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12639 /* Redistribute BGP does not make sense. */
12640 if (i
!= ZEBRA_ROUTE_BGP
) {
12641 struct list
*red_list
;
12642 struct listnode
*node
;
12643 struct bgp_redist
*red
;
12645 red_list
= bgp
->redist
[afi
][i
];
12649 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12650 /* "redistribute" configuration. */
12651 vty_out(vty
, " redistribute %s",
12652 zebra_route_string(i
));
12654 vty_out(vty
, " %d", red
->instance
);
12655 if (red
->redist_metric_flag
)
12656 vty_out(vty
, " metric %u",
12657 red
->redist_metric
);
12658 if (red
->rmap
.name
)
12659 vty_out(vty
, " route-map %s",
12661 vty_out(vty
, "\n");
12667 /* This is part of the address-family block (unicast only) */
12668 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12673 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12674 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12675 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12676 bgp
->vpn_policy
[afi
]
12677 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12679 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12680 bgp
->vpn_policy
[afi
]
12681 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12683 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12684 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12685 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12686 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12689 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12690 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12692 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12695 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12696 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12697 bgp
->vpn_policy
[afi
].tovpn_label
);
12700 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12701 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12702 char buf
[RD_ADDRSTRLEN
];
12703 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12704 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12707 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12708 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12710 char buf
[PREFIX_STRLEN
];
12711 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12712 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12715 vty_out(vty
, "%*snexthop vpn export %s\n",
12719 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12720 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12722 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12723 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12725 char *b
= ecommunity_ecom2str(
12726 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12727 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12728 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12729 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12731 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12732 char *b
= ecommunity_ecom2str(
12733 bgp
->vpn_policy
[afi
]
12734 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12735 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12736 ECOMMUNITY_ROUTE_TARGET
);
12737 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12738 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12740 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12741 char *b
= ecommunity_ecom2str(
12742 bgp
->vpn_policy
[afi
]
12743 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12744 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12745 ECOMMUNITY_ROUTE_TARGET
);
12746 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12747 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12751 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12752 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12753 bgp
->vpn_policy
[afi
]
12754 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12756 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12757 char *b
= ecommunity_ecom2str(
12758 bgp
->vpn_policy
[afi
]
12759 .import_redirect_rtlist
,
12760 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12761 ECOMMUNITY_ROUTE_TARGET
);
12763 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12764 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12769 /* BGP node structure. */
12770 static struct cmd_node bgp_node
= {
12771 BGP_NODE
, "%s(config-router)# ", 1,
12774 static struct cmd_node bgp_ipv4_unicast_node
= {
12775 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12778 static struct cmd_node bgp_ipv4_multicast_node
= {
12779 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12782 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12783 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12786 static struct cmd_node bgp_ipv6_unicast_node
= {
12787 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12790 static struct cmd_node bgp_ipv6_multicast_node
= {
12791 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12794 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12795 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12798 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12799 "%s(config-router-af)# ", 1};
12801 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12802 "%s(config-router-af-vpnv6)# ", 1};
12804 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12805 "%s(config-router-evpn)# ", 1};
12807 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12808 "%s(config-router-af-vni)# ", 1};
12810 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12811 "%s(config-router-af)# ", 1};
12813 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12814 "%s(config-router-af-vpnv6)# ", 1};
12816 static void community_list_vty(void);
12818 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12822 struct listnode
*lnbgp
, *lnpeer
;
12824 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12825 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12826 /* only provide suggestions on the appropriate input
12828 * they'll otherwise show up multiple times */
12829 enum cmd_token_type match_type
;
12830 char *name
= peer
->host
;
12832 if (peer
->conf_if
) {
12833 match_type
= VARIABLE_TKN
;
12834 name
= peer
->conf_if
;
12835 } else if (strchr(peer
->host
, ':'))
12836 match_type
= IPV6_TKN
;
12838 match_type
= IPV4_TKN
;
12840 if (token
->type
!= match_type
)
12843 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12848 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12849 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12850 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12851 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12852 {.completions
= NULL
}};
12854 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12857 struct peer_group
*group
;
12858 struct listnode
*lnbgp
, *lnpeer
;
12860 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12861 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12862 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12867 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12868 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12869 {.completions
= NULL
} };
12871 void bgp_vty_init(void)
12873 cmd_variable_handler_register(bgp_var_neighbor
);
12874 cmd_variable_handler_register(bgp_var_peergroup
);
12876 /* Install bgp top node. */
12877 install_node(&bgp_node
, bgp_config_write
);
12878 install_node(&bgp_ipv4_unicast_node
, NULL
);
12879 install_node(&bgp_ipv4_multicast_node
, NULL
);
12880 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12881 install_node(&bgp_ipv6_unicast_node
, NULL
);
12882 install_node(&bgp_ipv6_multicast_node
, NULL
);
12883 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12884 install_node(&bgp_vpnv4_node
, NULL
);
12885 install_node(&bgp_vpnv6_node
, NULL
);
12886 install_node(&bgp_evpn_node
, NULL
);
12887 install_node(&bgp_evpn_vni_node
, NULL
);
12888 install_node(&bgp_flowspecv4_node
, NULL
);
12889 install_node(&bgp_flowspecv6_node
, NULL
);
12891 /* Install default VTY commands to new nodes. */
12892 install_default(BGP_NODE
);
12893 install_default(BGP_IPV4_NODE
);
12894 install_default(BGP_IPV4M_NODE
);
12895 install_default(BGP_IPV4L_NODE
);
12896 install_default(BGP_IPV6_NODE
);
12897 install_default(BGP_IPV6M_NODE
);
12898 install_default(BGP_IPV6L_NODE
);
12899 install_default(BGP_VPNV4_NODE
);
12900 install_default(BGP_VPNV6_NODE
);
12901 install_default(BGP_FLOWSPECV4_NODE
);
12902 install_default(BGP_FLOWSPECV6_NODE
);
12903 install_default(BGP_EVPN_NODE
);
12904 install_default(BGP_EVPN_VNI_NODE
);
12906 /* "bgp multiple-instance" commands. */
12907 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12908 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12910 /* "bgp config-type" commands. */
12911 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12912 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12914 /* "bgp local-mac" hidden commands. */
12915 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12916 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12918 /* bgp route-map delay-timer commands. */
12919 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12920 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12922 /* Dummy commands (Currently not supported) */
12923 install_element(BGP_NODE
, &no_synchronization_cmd
);
12924 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12926 /* "router bgp" commands. */
12927 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12929 /* "no router bgp" commands. */
12930 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12932 /* "bgp router-id" commands. */
12933 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12934 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12936 /* "bgp cluster-id" commands. */
12937 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12938 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12940 /* "bgp confederation" commands. */
12941 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12942 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12944 /* "bgp confederation peers" commands. */
12945 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12946 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12948 /* bgp max-med command */
12949 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12950 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12951 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12952 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12953 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12955 /* bgp disable-ebgp-connected-nh-check */
12956 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12957 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12959 /* bgp update-delay command */
12960 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12961 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12962 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12964 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12965 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12966 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12967 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12969 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12970 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12972 /* "maximum-paths" commands. */
12973 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12974 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12975 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12976 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12977 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12978 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12979 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12980 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12981 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12982 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12983 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12984 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12985 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12986 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12987 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12989 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12990 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12991 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12992 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12993 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12995 /* "timers bgp" commands. */
12996 install_element(BGP_NODE
, &bgp_timers_cmd
);
12997 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12999 /* route-map delay-timer commands - per instance for backwards compat.
13001 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13002 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13004 /* "bgp client-to-client reflection" commands */
13005 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
13006 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
13008 /* "bgp always-compare-med" commands */
13009 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
13010 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
13012 /* bgp ebgp-requires-policy */
13013 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
13014 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
13016 /* "bgp deterministic-med" commands */
13017 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
13018 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
13020 /* "bgp graceful-restart" commands */
13021 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
13022 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
13023 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
13024 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
13025 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
13026 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
13028 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
13029 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
13031 /* "bgp graceful-shutdown" commands */
13032 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
13033 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13035 /* "bgp fast-external-failover" commands */
13036 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13037 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13039 /* "bgp enforce-first-as" commands */
13040 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
13042 /* "bgp bestpath compare-routerid" commands */
13043 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13044 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13046 /* "bgp bestpath as-path ignore" commands */
13047 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13048 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13050 /* "bgp bestpath as-path confed" commands */
13051 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13052 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13054 /* "bgp bestpath as-path multipath-relax" commands */
13055 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13056 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13058 /* "bgp log-neighbor-changes" commands */
13059 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13060 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13062 /* "bgp bestpath med" commands */
13063 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13064 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13066 /* "no bgp default ipv4-unicast" commands. */
13067 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13068 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13070 /* "bgp network import-check" commands. */
13071 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13072 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13073 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13075 /* "bgp default local-preference" commands. */
13076 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13077 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13079 /* bgp default show-hostname */
13080 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13081 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13083 /* "bgp default subgroup-pkt-queue-max" commands. */
13084 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13085 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13087 /* bgp ibgp-allow-policy-mods command */
13088 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13089 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13091 /* "bgp listen limit" commands. */
13092 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13093 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13095 /* "bgp listen range" commands. */
13096 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13097 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13099 /* "bgp default shutdown" command */
13100 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13102 /* "neighbor remote-as" commands. */
13103 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13104 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13105 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13106 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13107 install_element(BGP_NODE
,
13108 &neighbor_interface_v6only_config_remote_as_cmd
);
13109 install_element(BGP_NODE
, &no_neighbor_cmd
);
13110 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13112 /* "neighbor peer-group" commands. */
13113 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13114 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13115 install_element(BGP_NODE
,
13116 &no_neighbor_interface_peer_group_remote_as_cmd
);
13118 /* "neighbor local-as" commands. */
13119 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13120 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13121 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13122 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13124 /* "neighbor solo" commands. */
13125 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13126 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13128 /* "neighbor password" commands. */
13129 install_element(BGP_NODE
, &neighbor_password_cmd
);
13130 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13132 /* "neighbor activate" commands. */
13133 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13134 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13135 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13136 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13137 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13138 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13139 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13140 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13141 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13142 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13143 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13144 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13146 /* "no neighbor activate" commands. */
13147 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13148 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13149 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13150 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13151 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13152 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13153 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13154 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13155 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13156 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13157 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13158 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13160 /* "neighbor peer-group" set commands. */
13161 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13162 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13163 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13164 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13165 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13166 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13167 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13168 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13169 install_element(BGP_FLOWSPECV4_NODE
,
13170 &neighbor_set_peer_group_hidden_cmd
);
13171 install_element(BGP_FLOWSPECV6_NODE
,
13172 &neighbor_set_peer_group_hidden_cmd
);
13174 /* "no neighbor peer-group unset" commands. */
13175 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13176 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13177 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13178 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13179 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13180 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13181 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13182 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13183 install_element(BGP_FLOWSPECV4_NODE
,
13184 &no_neighbor_set_peer_group_hidden_cmd
);
13185 install_element(BGP_FLOWSPECV6_NODE
,
13186 &no_neighbor_set_peer_group_hidden_cmd
);
13188 /* "neighbor softreconfiguration inbound" commands.*/
13189 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13190 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13191 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13192 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13193 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13194 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13195 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13196 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13197 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13198 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13199 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13200 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13201 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13202 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13203 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13204 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13205 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13206 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13207 install_element(BGP_FLOWSPECV4_NODE
,
13208 &neighbor_soft_reconfiguration_cmd
);
13209 install_element(BGP_FLOWSPECV4_NODE
,
13210 &no_neighbor_soft_reconfiguration_cmd
);
13211 install_element(BGP_FLOWSPECV6_NODE
,
13212 &neighbor_soft_reconfiguration_cmd
);
13213 install_element(BGP_FLOWSPECV6_NODE
,
13214 &no_neighbor_soft_reconfiguration_cmd
);
13215 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13216 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13218 /* "neighbor attribute-unchanged" commands. */
13219 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13220 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13221 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13222 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13223 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13224 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13225 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13226 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13227 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13228 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13229 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13230 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13231 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13232 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13233 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13234 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13235 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13236 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13238 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13239 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13241 /* "nexthop-local unchanged" commands */
13242 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13243 install_element(BGP_IPV6_NODE
,
13244 &no_neighbor_nexthop_local_unchanged_cmd
);
13246 /* "neighbor next-hop-self" commands. */
13247 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13248 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13249 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13250 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13251 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13252 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13253 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13254 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13255 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13256 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13257 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13258 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13259 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13260 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13261 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13262 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13263 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13264 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13265 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13266 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13268 /* "neighbor next-hop-self force" commands. */
13269 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13270 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13271 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13272 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13273 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13274 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13275 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13276 install_element(BGP_IPV4_NODE
,
13277 &no_neighbor_nexthop_self_all_hidden_cmd
);
13278 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13279 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13280 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13281 install_element(BGP_IPV4M_NODE
,
13282 &no_neighbor_nexthop_self_all_hidden_cmd
);
13283 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13284 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13285 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13286 install_element(BGP_IPV4L_NODE
,
13287 &no_neighbor_nexthop_self_all_hidden_cmd
);
13288 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13289 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13290 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13291 install_element(BGP_IPV6_NODE
,
13292 &no_neighbor_nexthop_self_all_hidden_cmd
);
13293 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13294 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13295 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13296 install_element(BGP_IPV6M_NODE
,
13297 &no_neighbor_nexthop_self_all_hidden_cmd
);
13298 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13299 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13300 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13301 install_element(BGP_IPV6L_NODE
,
13302 &no_neighbor_nexthop_self_all_hidden_cmd
);
13303 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13304 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13305 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13306 install_element(BGP_VPNV4_NODE
,
13307 &no_neighbor_nexthop_self_all_hidden_cmd
);
13308 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13309 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13310 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13311 install_element(BGP_VPNV6_NODE
,
13312 &no_neighbor_nexthop_self_all_hidden_cmd
);
13314 /* "neighbor as-override" commands. */
13315 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13316 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13317 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13318 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13319 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13320 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13321 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13322 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13323 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13324 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13325 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13326 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13327 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13328 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13329 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13330 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13331 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13332 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13334 /* "neighbor remove-private-AS" commands. */
13335 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13336 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13337 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13338 install_element(BGP_NODE
,
13339 &no_neighbor_remove_private_as_all_hidden_cmd
);
13340 install_element(BGP_NODE
,
13341 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13342 install_element(BGP_NODE
,
13343 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13344 install_element(BGP_NODE
,
13345 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13348 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13349 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13350 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13351 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13352 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13353 install_element(BGP_IPV4_NODE
,
13354 &neighbor_remove_private_as_replace_as_cmd
);
13355 install_element(BGP_IPV4_NODE
,
13356 &no_neighbor_remove_private_as_replace_as_cmd
);
13357 install_element(BGP_IPV4_NODE
,
13358 &neighbor_remove_private_as_all_replace_as_cmd
);
13359 install_element(BGP_IPV4_NODE
,
13360 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13361 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13362 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13363 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13364 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13365 install_element(BGP_IPV4M_NODE
,
13366 &neighbor_remove_private_as_replace_as_cmd
);
13367 install_element(BGP_IPV4M_NODE
,
13368 &no_neighbor_remove_private_as_replace_as_cmd
);
13369 install_element(BGP_IPV4M_NODE
,
13370 &neighbor_remove_private_as_all_replace_as_cmd
);
13371 install_element(BGP_IPV4M_NODE
,
13372 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13373 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13374 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13375 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13376 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13377 install_element(BGP_IPV4L_NODE
,
13378 &neighbor_remove_private_as_replace_as_cmd
);
13379 install_element(BGP_IPV4L_NODE
,
13380 &no_neighbor_remove_private_as_replace_as_cmd
);
13381 install_element(BGP_IPV4L_NODE
,
13382 &neighbor_remove_private_as_all_replace_as_cmd
);
13383 install_element(BGP_IPV4L_NODE
,
13384 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13385 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13386 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13387 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13388 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13389 install_element(BGP_IPV6_NODE
,
13390 &neighbor_remove_private_as_replace_as_cmd
);
13391 install_element(BGP_IPV6_NODE
,
13392 &no_neighbor_remove_private_as_replace_as_cmd
);
13393 install_element(BGP_IPV6_NODE
,
13394 &neighbor_remove_private_as_all_replace_as_cmd
);
13395 install_element(BGP_IPV6_NODE
,
13396 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13397 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13398 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13399 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13400 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13401 install_element(BGP_IPV6M_NODE
,
13402 &neighbor_remove_private_as_replace_as_cmd
);
13403 install_element(BGP_IPV6M_NODE
,
13404 &no_neighbor_remove_private_as_replace_as_cmd
);
13405 install_element(BGP_IPV6M_NODE
,
13406 &neighbor_remove_private_as_all_replace_as_cmd
);
13407 install_element(BGP_IPV6M_NODE
,
13408 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13409 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13410 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13411 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13412 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13413 install_element(BGP_IPV6L_NODE
,
13414 &neighbor_remove_private_as_replace_as_cmd
);
13415 install_element(BGP_IPV6L_NODE
,
13416 &no_neighbor_remove_private_as_replace_as_cmd
);
13417 install_element(BGP_IPV6L_NODE
,
13418 &neighbor_remove_private_as_all_replace_as_cmd
);
13419 install_element(BGP_IPV6L_NODE
,
13420 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13421 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13422 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13423 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13424 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13425 install_element(BGP_VPNV4_NODE
,
13426 &neighbor_remove_private_as_replace_as_cmd
);
13427 install_element(BGP_VPNV4_NODE
,
13428 &no_neighbor_remove_private_as_replace_as_cmd
);
13429 install_element(BGP_VPNV4_NODE
,
13430 &neighbor_remove_private_as_all_replace_as_cmd
);
13431 install_element(BGP_VPNV4_NODE
,
13432 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13433 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13434 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13435 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13436 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13437 install_element(BGP_VPNV6_NODE
,
13438 &neighbor_remove_private_as_replace_as_cmd
);
13439 install_element(BGP_VPNV6_NODE
,
13440 &no_neighbor_remove_private_as_replace_as_cmd
);
13441 install_element(BGP_VPNV6_NODE
,
13442 &neighbor_remove_private_as_all_replace_as_cmd
);
13443 install_element(BGP_VPNV6_NODE
,
13444 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13446 /* "neighbor send-community" commands.*/
13447 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13448 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13449 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13450 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13451 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13452 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13453 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13454 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13455 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13456 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13457 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13458 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13459 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13460 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13461 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13462 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13463 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13464 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13465 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13466 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13467 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13468 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13469 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13470 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13471 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13472 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13473 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13474 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13475 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13476 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13477 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13478 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13479 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13480 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13481 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13482 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13484 /* "neighbor route-reflector" commands.*/
13485 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13486 install_element(BGP_NODE
,
13487 &no_neighbor_route_reflector_client_hidden_cmd
);
13488 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13489 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13490 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13491 install_element(BGP_IPV4M_NODE
,
13492 &no_neighbor_route_reflector_client_cmd
);
13493 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13494 install_element(BGP_IPV4L_NODE
,
13495 &no_neighbor_route_reflector_client_cmd
);
13496 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13497 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13498 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13499 install_element(BGP_IPV6M_NODE
,
13500 &no_neighbor_route_reflector_client_cmd
);
13501 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13502 install_element(BGP_IPV6L_NODE
,
13503 &no_neighbor_route_reflector_client_cmd
);
13504 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13505 install_element(BGP_VPNV4_NODE
,
13506 &no_neighbor_route_reflector_client_cmd
);
13507 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13508 install_element(BGP_VPNV6_NODE
,
13509 &no_neighbor_route_reflector_client_cmd
);
13510 install_element(BGP_FLOWSPECV4_NODE
,
13511 &neighbor_route_reflector_client_cmd
);
13512 install_element(BGP_FLOWSPECV4_NODE
,
13513 &no_neighbor_route_reflector_client_cmd
);
13514 install_element(BGP_FLOWSPECV6_NODE
,
13515 &neighbor_route_reflector_client_cmd
);
13516 install_element(BGP_FLOWSPECV6_NODE
,
13517 &no_neighbor_route_reflector_client_cmd
);
13518 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13519 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13521 /* "neighbor route-server" commands.*/
13522 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13523 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13524 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13525 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13526 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13527 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13528 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13529 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13530 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13531 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13532 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13533 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13534 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13535 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13536 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13537 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13538 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13539 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13540 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13541 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13542 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13543 install_element(BGP_FLOWSPECV4_NODE
,
13544 &no_neighbor_route_server_client_cmd
);
13545 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13546 install_element(BGP_FLOWSPECV6_NODE
,
13547 &no_neighbor_route_server_client_cmd
);
13549 /* "neighbor addpath-tx-all-paths" commands.*/
13550 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13551 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13552 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13553 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13554 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13555 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13556 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13557 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13558 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13559 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13560 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13561 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13562 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13563 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13564 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13565 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13566 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13567 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13569 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13570 install_element(BGP_NODE
,
13571 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13572 install_element(BGP_NODE
,
13573 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13574 install_element(BGP_IPV4_NODE
,
13575 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13576 install_element(BGP_IPV4_NODE
,
13577 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13578 install_element(BGP_IPV4M_NODE
,
13579 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13580 install_element(BGP_IPV4M_NODE
,
13581 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13582 install_element(BGP_IPV4L_NODE
,
13583 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13584 install_element(BGP_IPV4L_NODE
,
13585 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13586 install_element(BGP_IPV6_NODE
,
13587 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13588 install_element(BGP_IPV6_NODE
,
13589 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13590 install_element(BGP_IPV6M_NODE
,
13591 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13592 install_element(BGP_IPV6M_NODE
,
13593 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13594 install_element(BGP_IPV6L_NODE
,
13595 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13596 install_element(BGP_IPV6L_NODE
,
13597 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13598 install_element(BGP_VPNV4_NODE
,
13599 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13600 install_element(BGP_VPNV4_NODE
,
13601 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13602 install_element(BGP_VPNV6_NODE
,
13603 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13604 install_element(BGP_VPNV6_NODE
,
13605 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13607 /* "neighbor passive" commands. */
13608 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13609 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13612 /* "neighbor shutdown" commands. */
13613 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13614 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13615 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13616 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13618 /* "neighbor capability extended-nexthop" commands.*/
13619 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13620 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13622 /* "neighbor capability orf prefix-list" commands.*/
13623 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13624 install_element(BGP_NODE
,
13625 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13626 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13627 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13628 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13629 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13630 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13631 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13632 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13633 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13634 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13635 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13636 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13637 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13639 /* "neighbor capability dynamic" commands.*/
13640 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13641 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13643 /* "neighbor dont-capability-negotiate" commands. */
13644 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13645 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13647 /* "neighbor ebgp-multihop" commands. */
13648 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13649 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13650 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13652 /* "neighbor disable-connected-check" commands. */
13653 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13654 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13656 /* "neighbor enforce-first-as" commands. */
13657 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13658 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13660 /* "neighbor description" commands. */
13661 install_element(BGP_NODE
, &neighbor_description_cmd
);
13662 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13663 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13665 /* "neighbor update-source" commands. "*/
13666 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13667 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13669 /* "neighbor default-originate" commands. */
13670 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13671 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13672 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13673 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13674 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13675 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13676 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13677 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13678 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13679 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13680 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13681 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13682 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13683 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13684 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13685 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13686 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13687 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13688 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13689 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13690 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13692 /* "neighbor port" commands. */
13693 install_element(BGP_NODE
, &neighbor_port_cmd
);
13694 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13696 /* "neighbor weight" commands. */
13697 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13698 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13700 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13701 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13702 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13703 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13704 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13705 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13706 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13707 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13708 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13709 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13710 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13711 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13712 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13713 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13714 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13715 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13717 /* "neighbor override-capability" commands. */
13718 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13719 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13721 /* "neighbor strict-capability-match" commands. */
13722 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13723 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13725 /* "neighbor timers" commands. */
13726 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13727 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13729 /* "neighbor timers connect" commands. */
13730 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13731 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13733 /* "neighbor advertisement-interval" commands. */
13734 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13735 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13737 /* "neighbor interface" commands. */
13738 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13739 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13741 /* "neighbor distribute" commands. */
13742 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13743 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13744 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13745 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13746 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13747 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13748 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13749 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13750 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13751 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13752 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13753 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13754 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13755 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13756 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13757 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13758 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13759 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13761 /* "neighbor prefix-list" commands. */
13762 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13763 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13764 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13765 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13766 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13767 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13768 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13769 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13770 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13771 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13772 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13773 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13774 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13775 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13776 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13777 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13778 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13779 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13780 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13781 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13782 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13783 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13785 /* "neighbor filter-list" commands. */
13786 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13787 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13788 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13789 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13790 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13791 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13792 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13793 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13794 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13795 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13796 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13797 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13798 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13799 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13800 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13801 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13802 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13803 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13804 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13805 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13806 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13807 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13809 /* "neighbor route-map" commands. */
13810 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13811 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13812 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13813 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13814 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13815 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13816 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13817 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13818 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13819 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13820 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13821 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13822 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13823 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13824 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13825 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13826 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13827 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13828 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13829 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13830 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13831 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13832 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13833 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13835 /* "neighbor unsuppress-map" commands. */
13836 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13837 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13838 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13839 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13840 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13841 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13842 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13843 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13844 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13845 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13846 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13847 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13848 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13849 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13850 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13851 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13852 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13853 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13855 /* "neighbor maximum-prefix" commands. */
13856 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13857 install_element(BGP_NODE
,
13858 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13859 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13860 install_element(BGP_NODE
,
13861 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13862 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13863 install_element(BGP_NODE
,
13864 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13865 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13866 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13867 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13868 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13869 install_element(BGP_IPV4_NODE
,
13870 &neighbor_maximum_prefix_threshold_warning_cmd
);
13871 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13872 install_element(BGP_IPV4_NODE
,
13873 &neighbor_maximum_prefix_threshold_restart_cmd
);
13874 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13875 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13876 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13877 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13878 install_element(BGP_IPV4M_NODE
,
13879 &neighbor_maximum_prefix_threshold_warning_cmd
);
13880 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13881 install_element(BGP_IPV4M_NODE
,
13882 &neighbor_maximum_prefix_threshold_restart_cmd
);
13883 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13884 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13885 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13886 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13887 install_element(BGP_IPV4L_NODE
,
13888 &neighbor_maximum_prefix_threshold_warning_cmd
);
13889 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13890 install_element(BGP_IPV4L_NODE
,
13891 &neighbor_maximum_prefix_threshold_restart_cmd
);
13892 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13893 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13894 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13895 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13896 install_element(BGP_IPV6_NODE
,
13897 &neighbor_maximum_prefix_threshold_warning_cmd
);
13898 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13899 install_element(BGP_IPV6_NODE
,
13900 &neighbor_maximum_prefix_threshold_restart_cmd
);
13901 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13902 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13903 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13904 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13905 install_element(BGP_IPV6M_NODE
,
13906 &neighbor_maximum_prefix_threshold_warning_cmd
);
13907 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13908 install_element(BGP_IPV6M_NODE
,
13909 &neighbor_maximum_prefix_threshold_restart_cmd
);
13910 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13911 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13912 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13913 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13914 install_element(BGP_IPV6L_NODE
,
13915 &neighbor_maximum_prefix_threshold_warning_cmd
);
13916 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13917 install_element(BGP_IPV6L_NODE
,
13918 &neighbor_maximum_prefix_threshold_restart_cmd
);
13919 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13920 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13921 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13922 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13923 install_element(BGP_VPNV4_NODE
,
13924 &neighbor_maximum_prefix_threshold_warning_cmd
);
13925 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13926 install_element(BGP_VPNV4_NODE
,
13927 &neighbor_maximum_prefix_threshold_restart_cmd
);
13928 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13929 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13930 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13931 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13932 install_element(BGP_VPNV6_NODE
,
13933 &neighbor_maximum_prefix_threshold_warning_cmd
);
13934 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13935 install_element(BGP_VPNV6_NODE
,
13936 &neighbor_maximum_prefix_threshold_restart_cmd
);
13937 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13939 /* "neighbor allowas-in" */
13940 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13941 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13942 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13943 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13944 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13945 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13946 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13947 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13948 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13949 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13950 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13951 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13952 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13953 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13954 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13955 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13956 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13957 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13958 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13959 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13961 /* address-family commands. */
13962 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13963 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13964 #ifdef KEEP_OLD_VPN_COMMANDS
13965 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13966 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13967 #endif /* KEEP_OLD_VPN_COMMANDS */
13969 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13971 /* "exit-address-family" command. */
13972 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13973 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13974 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13975 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13976 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13977 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13978 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13979 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13980 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13981 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13982 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13984 /* "clear ip bgp commands" */
13985 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13987 /* clear ip bgp prefix */
13988 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13989 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13990 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13992 /* "show [ip] bgp summary" commands. */
13993 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13994 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13995 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13996 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13997 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13998 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13999 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
14001 /* "show [ip] bgp neighbors" commands. */
14002 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
14004 /* "show [ip] bgp peer-group" commands. */
14005 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
14007 /* "show [ip] bgp paths" commands. */
14008 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
14010 /* "show [ip] bgp community" commands. */
14011 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
14013 /* "show ip bgp large-community" commands. */
14014 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
14015 /* "show [ip] bgp attribute-info" commands. */
14016 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
14017 /* "show [ip] bgp route-leak" command */
14018 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
14020 /* "redistribute" commands. */
14021 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
14022 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
14023 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
14024 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
14025 install_element(BGP_NODE
,
14026 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
14027 install_element(BGP_NODE
,
14028 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
14029 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
14030 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
14031 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
14032 install_element(BGP_NODE
,
14033 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
14034 install_element(BGP_NODE
,
14035 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
14036 install_element(BGP_NODE
,
14037 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
14038 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
14039 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
14040 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
14041 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
14042 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
14043 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
14044 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
14045 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
14046 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
14047 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
14048 install_element(BGP_IPV4_NODE
,
14049 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
14050 install_element(BGP_IPV4_NODE
,
14051 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
14052 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
14053 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
14054 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
14055 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
14056 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
14057 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
14059 /* import|export vpn [route-map WORD] */
14060 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14061 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14063 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14064 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14066 /* ttl_security commands */
14067 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14068 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14070 /* "show [ip] bgp memory" commands. */
14071 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14073 /* "show bgp martian next-hop" */
14074 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14076 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14078 /* "show [ip] bgp views" commands. */
14079 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14081 /* "show [ip] bgp vrfs" commands. */
14082 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14084 /* Community-list. */
14085 community_list_vty();
14087 /* vpn-policy commands */
14088 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14089 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14090 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14091 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14092 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14093 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14094 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14095 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14096 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14097 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14098 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14099 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14101 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14102 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14104 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14105 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14106 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14107 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14108 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14109 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14110 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14111 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14112 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14113 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14114 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14115 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14118 #include "memory.h"
14119 #include "bgp_regex.h"
14120 #include "bgp_clist.h"
14121 #include "bgp_ecommunity.h"
14123 /* VTY functions. */
14125 /* Direction value to string conversion. */
14126 static const char *community_direct_str(int direct
)
14129 case COMMUNITY_DENY
:
14131 case COMMUNITY_PERMIT
:
14138 /* Display error string. */
14139 static void community_list_perror(struct vty
*vty
, int ret
)
14142 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14143 vty_out(vty
, "%% Can't find community-list\n");
14145 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14146 vty_out(vty
, "%% Malformed community-list value\n");
14148 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14150 "%% Community name conflict, previously defined as standard community\n");
14152 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14154 "%% Community name conflict, previously defined as expanded community\n");
14159 /* "community-list" keyword help string. */
14160 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14162 /*community-list standard */
14163 DEFUN (community_list_standard
,
14164 bgp_community_list_standard_cmd
,
14165 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14168 "Community list number (standard)\n"
14169 "Add an standard community-list entry\n"
14170 "Community list name\n"
14171 "Specify community to reject\n"
14172 "Specify community to accept\n"
14175 char *cl_name_or_number
= NULL
;
14177 int style
= COMMUNITY_LIST_STANDARD
;
14181 if (argv_find(argv
, argc
, "ip", &idx
)) {
14182 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14183 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14184 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14185 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14188 argv_find(argv
, argc
, "(1-99)", &idx
);
14189 argv_find(argv
, argc
, "WORD", &idx
);
14190 cl_name_or_number
= argv
[idx
]->arg
;
14191 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14193 argv_find(argv
, argc
, "AA:NN", &idx
);
14194 char *str
= argv_concat(argv
, argc
, idx
);
14196 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14199 XFREE(MTYPE_TMP
, str
);
14202 /* Display error string. */
14203 community_list_perror(vty
, ret
);
14204 return CMD_WARNING_CONFIG_FAILED
;
14207 return CMD_SUCCESS
;
14210 #if CONFDATE > 20191005
14211 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14213 ALIAS (community_list_standard
,
14214 ip_community_list_standard_cmd
,
14215 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14218 "Community list number (standard)\n"
14219 "Add an standard community-list entry\n"
14220 "Community list name\n"
14221 "Specify community to reject\n"
14222 "Specify community to accept\n"
14225 DEFUN (no_community_list_standard_all
,
14226 no_bgp_community_list_standard_all_cmd
,
14227 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14231 "Community list number (standard)\n"
14232 "Add an standard community-list entry\n"
14233 "Community list name\n"
14234 "Specify community to reject\n"
14235 "Specify community to accept\n"
14238 char *cl_name_or_number
= NULL
;
14241 int style
= COMMUNITY_LIST_STANDARD
;
14245 if (argv_find(argv
, argc
, "ip", &idx
)) {
14246 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14247 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14248 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14249 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14252 argv_find(argv
, argc
, "permit", &idx
);
14253 argv_find(argv
, argc
, "deny", &idx
);
14256 direct
= argv_find(argv
, argc
, "permit", &idx
)
14261 argv_find(argv
, argc
, "AA:NN", &idx
);
14262 str
= argv_concat(argv
, argc
, idx
);
14266 argv_find(argv
, argc
, "(1-99)", &idx
);
14267 argv_find(argv
, argc
, "WORD", &idx
);
14268 cl_name_or_number
= argv
[idx
]->arg
;
14270 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14273 XFREE(MTYPE_TMP
, str
);
14276 community_list_perror(vty
, ret
);
14277 return CMD_WARNING_CONFIG_FAILED
;
14280 return CMD_SUCCESS
;
14282 ALIAS (no_community_list_standard_all
,
14283 no_ip_community_list_standard_all_cmd
,
14284 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14288 "Community list number (standard)\n"
14289 "Add an standard community-list entry\n"
14290 "Community list name\n"
14291 "Specify community to reject\n"
14292 "Specify community to accept\n"
14295 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14296 "no bgp community-list <(1-99)|standard WORD>",
14297 NO_STR BGP_STR COMMUNITY_LIST_STR
14298 "Community list number (standard)\n"
14299 "Add an standard community-list entry\n"
14300 "Community list name\n")
14302 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14303 "no ip community-list <(1-99)|standard WORD>",
14304 NO_STR BGP_STR COMMUNITY_LIST_STR
14305 "Community list number (standard)\n"
14306 "Add an standard community-list entry\n"
14307 "Community list name\n")
14309 /*community-list expanded */
14310 DEFUN (community_list_expanded_all
,
14311 bgp_community_list_expanded_all_cmd
,
14312 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14315 "Community list number (expanded)\n"
14316 "Add an expanded community-list entry\n"
14317 "Community list name\n"
14318 "Specify community to reject\n"
14319 "Specify community to accept\n"
14322 char *cl_name_or_number
= NULL
;
14324 int style
= COMMUNITY_LIST_EXPANDED
;
14327 if (argv_find(argv
, argc
, "ip", &idx
)) {
14328 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14329 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14330 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14331 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14333 argv_find(argv
, argc
, "(100-500)", &idx
);
14334 argv_find(argv
, argc
, "WORD", &idx
);
14335 cl_name_or_number
= argv
[idx
]->arg
;
14336 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14338 argv_find(argv
, argc
, "AA:NN", &idx
);
14339 char *str
= argv_concat(argv
, argc
, idx
);
14341 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14344 XFREE(MTYPE_TMP
, str
);
14347 /* Display error string. */
14348 community_list_perror(vty
, ret
);
14349 return CMD_WARNING_CONFIG_FAILED
;
14352 return CMD_SUCCESS
;
14355 ALIAS (community_list_expanded_all
,
14356 ip_community_list_expanded_all_cmd
,
14357 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14360 "Community list number (expanded)\n"
14361 "Add an expanded community-list entry\n"
14362 "Community list name\n"
14363 "Specify community to reject\n"
14364 "Specify community to accept\n"
14367 DEFUN (no_community_list_expanded_all
,
14368 no_bgp_community_list_expanded_all_cmd
,
14369 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14373 "Community list number (expanded)\n"
14374 "Add an expanded community-list entry\n"
14375 "Community list name\n"
14376 "Specify community to reject\n"
14377 "Specify community to accept\n"
14380 char *cl_name_or_number
= NULL
;
14383 int style
= COMMUNITY_LIST_EXPANDED
;
14386 if (argv_find(argv
, argc
, "ip", &idx
)) {
14387 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14388 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14389 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14390 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14394 argv_find(argv
, argc
, "permit", &idx
);
14395 argv_find(argv
, argc
, "deny", &idx
);
14398 direct
= argv_find(argv
, argc
, "permit", &idx
)
14403 argv_find(argv
, argc
, "AA:NN", &idx
);
14404 str
= argv_concat(argv
, argc
, idx
);
14408 argv_find(argv
, argc
, "(100-500)", &idx
);
14409 argv_find(argv
, argc
, "WORD", &idx
);
14410 cl_name_or_number
= argv
[idx
]->arg
;
14412 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14415 XFREE(MTYPE_TMP
, str
);
14418 community_list_perror(vty
, ret
);
14419 return CMD_WARNING_CONFIG_FAILED
;
14422 return CMD_SUCCESS
;
14425 ALIAS (no_community_list_expanded_all
,
14426 no_ip_community_list_expanded_all_cmd
,
14427 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14431 "Community list number (expanded)\n"
14432 "Add an expanded community-list entry\n"
14433 "Community list name\n"
14434 "Specify community to reject\n"
14435 "Specify community to accept\n"
14438 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14439 "no bgp community-list <(100-500)|expanded WORD>",
14440 NO_STR IP_STR COMMUNITY_LIST_STR
14441 "Community list number (expanded)\n"
14442 "Add an expanded community-list entry\n"
14443 "Community list name\n")
14445 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14446 "no ip community-list <(100-500)|expanded WORD>",
14447 NO_STR IP_STR COMMUNITY_LIST_STR
14448 "Community list number (expanded)\n"
14449 "Add an expanded community-list entry\n"
14450 "Community list name\n")
14452 /* Return configuration string of community-list entry. */
14453 static const char *community_list_config_str(struct community_entry
*entry
)
14460 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14461 str
= community_str(entry
->u
.com
, false);
14462 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14463 str
= lcommunity_str(entry
->u
.lcom
, false);
14465 str
= entry
->config
;
14470 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14472 struct community_entry
*entry
;
14474 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14475 if (entry
== list
->head
) {
14476 if (all_digit(list
->name
))
14477 vty_out(vty
, "Community %s list %s\n",
14478 entry
->style
== COMMUNITY_LIST_STANDARD
14480 : "(expanded) access",
14483 vty_out(vty
, "Named Community %s list %s\n",
14484 entry
->style
== COMMUNITY_LIST_STANDARD
14490 vty_out(vty
, " %s\n",
14491 community_direct_str(entry
->direct
));
14493 vty_out(vty
, " %s %s\n",
14494 community_direct_str(entry
->direct
),
14495 community_list_config_str(entry
));
14499 DEFUN (show_community_list
,
14500 show_bgp_community_list_cmd
,
14501 "show bgp community-list",
14504 "List community-list\n")
14506 struct community_list
*list
;
14507 struct community_list_master
*cm
;
14510 if (argv_find(argv
, argc
, "ip", &idx
)) {
14511 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14512 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14513 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14514 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14516 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14518 return CMD_SUCCESS
;
14520 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14521 community_list_show(vty
, list
);
14523 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14524 community_list_show(vty
, list
);
14526 return CMD_SUCCESS
;
14529 ALIAS (show_community_list
,
14530 show_ip_community_list_cmd
,
14531 "show ip community-list",
14534 "List community-list\n")
14536 DEFUN (show_community_list_arg
,
14537 show_bgp_community_list_arg_cmd
,
14538 "show bgp community-list <(1-500)|WORD>",
14541 "List community-list\n"
14542 "Community-list number\n"
14543 "Community-list name\n")
14545 int idx_comm_list
= 3;
14546 struct community_list
*list
;
14549 if (argv_find(argv
, argc
, "ip", &idx
)) {
14550 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14551 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14552 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14553 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14555 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14556 COMMUNITY_LIST_MASTER
);
14558 vty_out(vty
, "%% Can't find community-list\n");
14559 return CMD_WARNING
;
14562 community_list_show(vty
, list
);
14564 return CMD_SUCCESS
;
14567 ALIAS (show_community_list_arg
,
14568 show_ip_community_list_arg_cmd
,
14569 "show ip community-list <(1-500)|WORD>",
14572 "List community-list\n"
14573 "Community-list number\n"
14574 "Community-list name\n")
14577 * Large Community code.
14579 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14580 struct cmd_token
**argv
, int style
,
14581 int reject_all_digit_name
)
14589 if (argv_find(argv
, argc
, "ip", &idx
)) {
14590 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14591 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14592 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14593 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14595 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14598 /* All digit name check. */
14600 argv_find(argv
, argc
, "WORD", &idx
);
14601 argv_find(argv
, argc
, "(1-99)", &idx
);
14602 argv_find(argv
, argc
, "(100-500)", &idx
);
14603 cl_name
= argv
[idx
]->arg
;
14604 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14605 vty_out(vty
, "%% Community name cannot have all digits\n");
14606 return CMD_WARNING_CONFIG_FAILED
;
14610 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14611 argv_find(argv
, argc
, "LINE", &idx
);
14612 /* Concat community string argument. */
14614 str
= argv_concat(argv
, argc
, idx
);
14618 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14620 /* Free temporary community list string allocated by
14622 XFREE(MTYPE_TMP
, str
);
14625 community_list_perror(vty
, ret
);
14626 return CMD_WARNING_CONFIG_FAILED
;
14628 return CMD_SUCCESS
;
14631 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14632 struct cmd_token
**argv
, int style
)
14639 if (argv_find(argv
, argc
, "ip", &idx
)) {
14640 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14641 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14642 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14643 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14645 argv_find(argv
, argc
, "permit", &idx
);
14646 argv_find(argv
, argc
, "deny", &idx
);
14649 /* Check the list direct. */
14650 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14651 direct
= COMMUNITY_PERMIT
;
14653 direct
= COMMUNITY_DENY
;
14656 argv_find(argv
, argc
, "LINE", &idx
);
14657 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14658 /* Concat community string argument. */
14659 str
= argv_concat(argv
, argc
, idx
);
14663 argv_find(argv
, argc
, "(1-99)", &idx
);
14664 argv_find(argv
, argc
, "(100-500)", &idx
);
14665 argv_find(argv
, argc
, "WORD", &idx
);
14667 /* Unset community list. */
14668 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14671 /* Free temporary community list string allocated by
14673 XFREE(MTYPE_TMP
, str
);
14676 community_list_perror(vty
, ret
);
14677 return CMD_WARNING_CONFIG_FAILED
;
14680 return CMD_SUCCESS
;
14683 /* "large-community-list" keyword help string. */
14684 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14685 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14687 #if CONFDATE > 20191005
14688 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14690 DEFUN (lcommunity_list_standard
,
14691 bgp_lcommunity_list_standard_cmd
,
14692 "bgp large-community-list (1-99) <deny|permit>",
14694 LCOMMUNITY_LIST_STR
14695 "Large Community list number (standard)\n"
14696 "Specify large community to reject\n"
14697 "Specify large community to accept\n")
14699 return lcommunity_list_set_vty(vty
, argc
, argv
,
14700 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14703 ALIAS (lcommunity_list_standard
,
14704 ip_lcommunity_list_standard_cmd
,
14705 "ip large-community-list (1-99) <deny|permit>",
14707 LCOMMUNITY_LIST_STR
14708 "Large Community list number (standard)\n"
14709 "Specify large community to reject\n"
14710 "Specify large community to accept\n")
14712 DEFUN (lcommunity_list_standard1
,
14713 bgp_lcommunity_list_standard1_cmd
,
14714 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14716 LCOMMUNITY_LIST_STR
14717 "Large Community list number (standard)\n"
14718 "Specify large community to reject\n"
14719 "Specify large community to accept\n"
14720 LCOMMUNITY_VAL_STR
)
14722 return lcommunity_list_set_vty(vty
, argc
, argv
,
14723 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14726 ALIAS (lcommunity_list_standard1
,
14727 ip_lcommunity_list_standard1_cmd
,
14728 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14730 LCOMMUNITY_LIST_STR
14731 "Large Community list number (standard)\n"
14732 "Specify large community to reject\n"
14733 "Specify large community to accept\n"
14734 LCOMMUNITY_VAL_STR
)
14736 DEFUN (lcommunity_list_expanded
,
14737 bgp_lcommunity_list_expanded_cmd
,
14738 "bgp large-community-list (100-500) <deny|permit> LINE...",
14740 LCOMMUNITY_LIST_STR
14741 "Large Community list number (expanded)\n"
14742 "Specify large community to reject\n"
14743 "Specify large community to accept\n"
14744 "An ordered list as a regular-expression\n")
14746 return lcommunity_list_set_vty(vty
, argc
, argv
,
14747 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14750 ALIAS (lcommunity_list_expanded
,
14751 ip_lcommunity_list_expanded_cmd
,
14752 "ip large-community-list (100-500) <deny|permit> LINE...",
14754 LCOMMUNITY_LIST_STR
14755 "Large Community list number (expanded)\n"
14756 "Specify large community to reject\n"
14757 "Specify large community to accept\n"
14758 "An ordered list as a regular-expression\n")
14760 DEFUN (lcommunity_list_name_standard
,
14761 bgp_lcommunity_list_name_standard_cmd
,
14762 "bgp large-community-list standard WORD <deny|permit>",
14764 LCOMMUNITY_LIST_STR
14765 "Specify standard large-community-list\n"
14766 "Large Community list name\n"
14767 "Specify large community to reject\n"
14768 "Specify large community to accept\n")
14770 return lcommunity_list_set_vty(vty
, argc
, argv
,
14771 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14774 ALIAS (lcommunity_list_name_standard
,
14775 ip_lcommunity_list_name_standard_cmd
,
14776 "ip large-community-list standard WORD <deny|permit>",
14778 LCOMMUNITY_LIST_STR
14779 "Specify standard large-community-list\n"
14780 "Large Community list name\n"
14781 "Specify large community to reject\n"
14782 "Specify large community to accept\n")
14784 DEFUN (lcommunity_list_name_standard1
,
14785 bgp_lcommunity_list_name_standard1_cmd
,
14786 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14788 LCOMMUNITY_LIST_STR
14789 "Specify standard large-community-list\n"
14790 "Large Community list name\n"
14791 "Specify large community to reject\n"
14792 "Specify large community to accept\n"
14793 LCOMMUNITY_VAL_STR
)
14795 return lcommunity_list_set_vty(vty
, argc
, argv
,
14796 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14799 ALIAS (lcommunity_list_name_standard1
,
14800 ip_lcommunity_list_name_standard1_cmd
,
14801 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14803 LCOMMUNITY_LIST_STR
14804 "Specify standard large-community-list\n"
14805 "Large Community list name\n"
14806 "Specify large community to reject\n"
14807 "Specify large community to accept\n"
14808 LCOMMUNITY_VAL_STR
)
14810 DEFUN (lcommunity_list_name_expanded
,
14811 bgp_lcommunity_list_name_expanded_cmd
,
14812 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14814 LCOMMUNITY_LIST_STR
14815 "Specify expanded large-community-list\n"
14816 "Large Community list name\n"
14817 "Specify large community to reject\n"
14818 "Specify large community to accept\n"
14819 "An ordered list as a regular-expression\n")
14821 return lcommunity_list_set_vty(vty
, argc
, argv
,
14822 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14825 ALIAS (lcommunity_list_name_expanded
,
14826 ip_lcommunity_list_name_expanded_cmd
,
14827 "ip large-community-list expanded WORD <deny|permit> LINE...",
14829 LCOMMUNITY_LIST_STR
14830 "Specify expanded large-community-list\n"
14831 "Large Community list name\n"
14832 "Specify large community to reject\n"
14833 "Specify large community to accept\n"
14834 "An ordered list as a regular-expression\n")
14836 DEFUN (no_lcommunity_list_standard_all
,
14837 no_bgp_lcommunity_list_standard_all_cmd
,
14838 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14841 LCOMMUNITY_LIST_STR
14842 "Large Community list number (standard)\n"
14843 "Large Community list number (expanded)\n"
14844 "Large Community list name\n")
14846 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14847 LARGE_COMMUNITY_LIST_STANDARD
);
14850 ALIAS (no_lcommunity_list_standard_all
,
14851 no_ip_lcommunity_list_standard_all_cmd
,
14852 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14855 LCOMMUNITY_LIST_STR
14856 "Large Community list number (standard)\n"
14857 "Large Community list number (expanded)\n"
14858 "Large Community list name\n")
14860 DEFUN (no_lcommunity_list_name_expanded_all
,
14861 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14862 "no bgp large-community-list expanded WORD",
14865 LCOMMUNITY_LIST_STR
14866 "Specify expanded large-community-list\n"
14867 "Large Community list name\n")
14869 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14870 LARGE_COMMUNITY_LIST_EXPANDED
);
14873 ALIAS (no_lcommunity_list_name_expanded_all
,
14874 no_ip_lcommunity_list_name_expanded_all_cmd
,
14875 "no ip large-community-list expanded WORD",
14878 LCOMMUNITY_LIST_STR
14879 "Specify expanded large-community-list\n"
14880 "Large Community list name\n")
14882 DEFUN (no_lcommunity_list_standard
,
14883 no_bgp_lcommunity_list_standard_cmd
,
14884 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14887 LCOMMUNITY_LIST_STR
14888 "Large Community list number (standard)\n"
14889 "Specify large community to reject\n"
14890 "Specify large community to accept\n"
14891 LCOMMUNITY_VAL_STR
)
14893 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14894 LARGE_COMMUNITY_LIST_STANDARD
);
14897 ALIAS (no_lcommunity_list_standard
,
14898 no_ip_lcommunity_list_standard_cmd
,
14899 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14902 LCOMMUNITY_LIST_STR
14903 "Large Community list number (standard)\n"
14904 "Specify large community to reject\n"
14905 "Specify large community to accept\n"
14906 LCOMMUNITY_VAL_STR
)
14908 DEFUN (no_lcommunity_list_expanded
,
14909 no_bgp_lcommunity_list_expanded_cmd
,
14910 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14913 LCOMMUNITY_LIST_STR
14914 "Large Community list number (expanded)\n"
14915 "Specify large community to reject\n"
14916 "Specify large community to accept\n"
14917 "An ordered list as a regular-expression\n")
14919 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14920 LARGE_COMMUNITY_LIST_EXPANDED
);
14923 ALIAS (no_lcommunity_list_expanded
,
14924 no_ip_lcommunity_list_expanded_cmd
,
14925 "no ip large-community-list (100-500) <deny|permit> LINE...",
14928 LCOMMUNITY_LIST_STR
14929 "Large Community list number (expanded)\n"
14930 "Specify large community to reject\n"
14931 "Specify large community to accept\n"
14932 "An ordered list as a regular-expression\n")
14934 DEFUN (no_lcommunity_list_name_standard
,
14935 no_bgp_lcommunity_list_name_standard_cmd
,
14936 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14939 LCOMMUNITY_LIST_STR
14940 "Specify standard large-community-list\n"
14941 "Large Community list name\n"
14942 "Specify large community to reject\n"
14943 "Specify large community to accept\n"
14944 LCOMMUNITY_VAL_STR
)
14946 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14947 LARGE_COMMUNITY_LIST_STANDARD
);
14950 ALIAS (no_lcommunity_list_name_standard
,
14951 no_ip_lcommunity_list_name_standard_cmd
,
14952 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14955 LCOMMUNITY_LIST_STR
14956 "Specify standard large-community-list\n"
14957 "Large Community list name\n"
14958 "Specify large community to reject\n"
14959 "Specify large community to accept\n"
14960 LCOMMUNITY_VAL_STR
)
14962 DEFUN (no_lcommunity_list_name_expanded
,
14963 no_bgp_lcommunity_list_name_expanded_cmd
,
14964 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14967 LCOMMUNITY_LIST_STR
14968 "Specify expanded large-community-list\n"
14969 "Large community list name\n"
14970 "Specify large community to reject\n"
14971 "Specify large community to accept\n"
14972 "An ordered list as a regular-expression\n")
14974 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14975 LARGE_COMMUNITY_LIST_EXPANDED
);
14978 ALIAS (no_lcommunity_list_name_expanded
,
14979 no_ip_lcommunity_list_name_expanded_cmd
,
14980 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14983 LCOMMUNITY_LIST_STR
14984 "Specify expanded large-community-list\n"
14985 "Large community list name\n"
14986 "Specify large community to reject\n"
14987 "Specify large community to accept\n"
14988 "An ordered list as a regular-expression\n")
14990 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14992 struct community_entry
*entry
;
14994 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14995 if (entry
== list
->head
) {
14996 if (all_digit(list
->name
))
14997 vty_out(vty
, "Large community %s list %s\n",
14999 LARGE_COMMUNITY_LIST_STANDARD
15001 : "(expanded) access",
15005 "Named large community %s list %s\n",
15007 LARGE_COMMUNITY_LIST_STANDARD
15013 vty_out(vty
, " %s\n",
15014 community_direct_str(entry
->direct
));
15016 vty_out(vty
, " %s %s\n",
15017 community_direct_str(entry
->direct
),
15018 community_list_config_str(entry
));
15022 DEFUN (show_lcommunity_list
,
15023 show_bgp_lcommunity_list_cmd
,
15024 "show bgp large-community-list",
15027 "List large-community list\n")
15029 struct community_list
*list
;
15030 struct community_list_master
*cm
;
15033 if (argv_find(argv
, argc
, "ip", &idx
)) {
15034 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15035 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15036 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15037 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15040 cm
= community_list_master_lookup(bgp_clist
,
15041 LARGE_COMMUNITY_LIST_MASTER
);
15043 return CMD_SUCCESS
;
15045 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15046 lcommunity_list_show(vty
, list
);
15048 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15049 lcommunity_list_show(vty
, list
);
15051 return CMD_SUCCESS
;
15054 ALIAS (show_lcommunity_list
,
15055 show_ip_lcommunity_list_cmd
,
15056 "show ip large-community-list",
15059 "List large-community list\n")
15061 DEFUN (show_lcommunity_list_arg
,
15062 show_bgp_lcommunity_list_arg_cmd
,
15063 "show bgp large-community-list <(1-500)|WORD>",
15066 "List large-community list\n"
15067 "large-community-list number\n"
15068 "large-community-list name\n")
15070 struct community_list
*list
;
15073 if (argv_find(argv
, argc
, "ip", &idx
)) {
15074 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15075 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15076 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15077 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15080 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
15081 LARGE_COMMUNITY_LIST_MASTER
);
15083 vty_out(vty
, "%% Can't find extcommunity-list\n");
15084 return CMD_WARNING
;
15087 lcommunity_list_show(vty
, list
);
15089 return CMD_SUCCESS
;
15092 ALIAS (show_lcommunity_list_arg
,
15093 show_ip_lcommunity_list_arg_cmd
,
15094 "show ip large-community-list <(1-500)|WORD>",
15097 "List large-community list\n"
15098 "large-community-list number\n"
15099 "large-community-list name\n")
15101 /* "extcommunity-list" keyword help string. */
15102 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15103 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15105 DEFUN (extcommunity_list_standard
,
15106 bgp_extcommunity_list_standard_cmd
,
15107 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15109 EXTCOMMUNITY_LIST_STR
15110 "Extended Community list number (standard)\n"
15111 "Specify standard extcommunity-list\n"
15112 "Community list name\n"
15113 "Specify community to reject\n"
15114 "Specify community to accept\n"
15115 EXTCOMMUNITY_VAL_STR
)
15117 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15119 char *cl_number_or_name
= NULL
;
15122 if (argv_find(argv
, argc
, "ip", &idx
)) {
15123 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15124 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15125 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15126 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15128 argv_find(argv
, argc
, "(1-99)", &idx
);
15129 argv_find(argv
, argc
, "WORD", &idx
);
15130 cl_number_or_name
= argv
[idx
]->arg
;
15131 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15133 argv_find(argv
, argc
, "AA:NN", &idx
);
15134 char *str
= argv_concat(argv
, argc
, idx
);
15136 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15139 XFREE(MTYPE_TMP
, str
);
15142 community_list_perror(vty
, ret
);
15143 return CMD_WARNING_CONFIG_FAILED
;
15146 return CMD_SUCCESS
;
15149 #if CONFDATE > 20191005
15150 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15152 ALIAS (extcommunity_list_standard
,
15153 ip_extcommunity_list_standard_cmd
,
15154 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15156 EXTCOMMUNITY_LIST_STR
15157 "Extended Community list number (standard)\n"
15158 "Specify standard extcommunity-list\n"
15159 "Community list name\n"
15160 "Specify community to reject\n"
15161 "Specify community to accept\n"
15162 EXTCOMMUNITY_VAL_STR
)
15164 DEFUN (extcommunity_list_name_expanded
,
15165 bgp_extcommunity_list_name_expanded_cmd
,
15166 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15168 EXTCOMMUNITY_LIST_STR
15169 "Extended Community list number (expanded)\n"
15170 "Specify expanded extcommunity-list\n"
15171 "Extended Community list name\n"
15172 "Specify community to reject\n"
15173 "Specify community to accept\n"
15174 "An ordered list as a regular-expression\n")
15176 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15178 char *cl_number_or_name
= NULL
;
15181 if (argv_find(argv
, argc
, "ip", &idx
)) {
15182 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15183 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15184 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15185 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15188 argv_find(argv
, argc
, "(100-500)", &idx
);
15189 argv_find(argv
, argc
, "WORD", &idx
);
15190 cl_number_or_name
= argv
[idx
]->arg
;
15191 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15193 argv_find(argv
, argc
, "LINE", &idx
);
15194 char *str
= argv_concat(argv
, argc
, idx
);
15196 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15199 XFREE(MTYPE_TMP
, str
);
15202 community_list_perror(vty
, ret
);
15203 return CMD_WARNING_CONFIG_FAILED
;
15206 return CMD_SUCCESS
;
15209 ALIAS (extcommunity_list_name_expanded
,
15210 ip_extcommunity_list_name_expanded_cmd
,
15211 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15213 EXTCOMMUNITY_LIST_STR
15214 "Extended Community list number (expanded)\n"
15215 "Specify expanded extcommunity-list\n"
15216 "Extended Community list name\n"
15217 "Specify community to reject\n"
15218 "Specify community to accept\n"
15219 "An ordered list as a regular-expression\n")
15221 DEFUN (no_extcommunity_list_standard_all
,
15222 no_bgp_extcommunity_list_standard_all_cmd
,
15223 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15226 EXTCOMMUNITY_LIST_STR
15227 "Extended Community list number (standard)\n"
15228 "Specify standard extcommunity-list\n"
15229 "Community list name\n"
15230 "Specify community to reject\n"
15231 "Specify community to accept\n"
15232 EXTCOMMUNITY_VAL_STR
)
15234 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15236 char *cl_number_or_name
= NULL
;
15240 if (argv_find(argv
, argc
, "ip", &idx
)) {
15241 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15242 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15243 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15244 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15248 argv_find(argv
, argc
, "permit", &idx
);
15249 argv_find(argv
, argc
, "deny", &idx
);
15252 direct
= argv_find(argv
, argc
, "permit", &idx
)
15257 argv_find(argv
, argc
, "AA:NN", &idx
);
15258 str
= argv_concat(argv
, argc
, idx
);
15262 argv_find(argv
, argc
, "(1-99)", &idx
);
15263 argv_find(argv
, argc
, "WORD", &idx
);
15264 cl_number_or_name
= argv
[idx
]->arg
;
15266 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15269 XFREE(MTYPE_TMP
, str
);
15272 community_list_perror(vty
, ret
);
15273 return CMD_WARNING_CONFIG_FAILED
;
15276 return CMD_SUCCESS
;
15279 ALIAS (no_extcommunity_list_standard_all
,
15280 no_ip_extcommunity_list_standard_all_cmd
,
15281 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15284 EXTCOMMUNITY_LIST_STR
15285 "Extended Community list number (standard)\n"
15286 "Specify standard extcommunity-list\n"
15287 "Community list name\n"
15288 "Specify community to reject\n"
15289 "Specify community to accept\n"
15290 EXTCOMMUNITY_VAL_STR
)
15292 ALIAS(no_extcommunity_list_standard_all
,
15293 no_bgp_extcommunity_list_standard_all_list_cmd
,
15294 "no bgp extcommunity-list <(1-99)|standard WORD>",
15295 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15296 "Extended Community list number (standard)\n"
15297 "Specify standard extcommunity-list\n"
15298 "Community list name\n")
15300 ALIAS(no_extcommunity_list_standard_all
,
15301 no_ip_extcommunity_list_standard_all_list_cmd
,
15302 "no ip extcommunity-list <(1-99)|standard WORD>",
15303 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15304 "Extended Community list number (standard)\n"
15305 "Specify standard extcommunity-list\n"
15306 "Community list name\n")
15308 DEFUN (no_extcommunity_list_expanded_all
,
15309 no_bgp_extcommunity_list_expanded_all_cmd
,
15310 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15313 EXTCOMMUNITY_LIST_STR
15314 "Extended Community list number (expanded)\n"
15315 "Specify expanded extcommunity-list\n"
15316 "Extended Community list name\n"
15317 "Specify community to reject\n"
15318 "Specify community to accept\n"
15319 "An ordered list as a regular-expression\n")
15321 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15323 char *cl_number_or_name
= NULL
;
15327 if (argv_find(argv
, argc
, "ip", &idx
)) {
15328 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15329 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15330 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15331 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15335 argv_find(argv
, argc
, "permit", &idx
);
15336 argv_find(argv
, argc
, "deny", &idx
);
15339 direct
= argv_find(argv
, argc
, "permit", &idx
)
15344 argv_find(argv
, argc
, "LINE", &idx
);
15345 str
= argv_concat(argv
, argc
, idx
);
15349 argv_find(argv
, argc
, "(100-500)", &idx
);
15350 argv_find(argv
, argc
, "WORD", &idx
);
15351 cl_number_or_name
= argv
[idx
]->arg
;
15353 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15356 XFREE(MTYPE_TMP
, str
);
15359 community_list_perror(vty
, ret
);
15360 return CMD_WARNING_CONFIG_FAILED
;
15363 return CMD_SUCCESS
;
15366 ALIAS (no_extcommunity_list_expanded_all
,
15367 no_ip_extcommunity_list_expanded_all_cmd
,
15368 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15371 EXTCOMMUNITY_LIST_STR
15372 "Extended Community list number (expanded)\n"
15373 "Specify expanded extcommunity-list\n"
15374 "Extended Community list name\n"
15375 "Specify community to reject\n"
15376 "Specify community to accept\n"
15377 "An ordered list as a regular-expression\n")
15379 ALIAS(no_extcommunity_list_expanded_all
,
15380 no_ip_extcommunity_list_expanded_all_list_cmd
,
15381 "no ip extcommunity-list <(100-500)|expanded WORD>",
15382 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15383 "Extended Community list number (expanded)\n"
15384 "Specify expanded extcommunity-list\n"
15385 "Extended Community list name\n")
15387 ALIAS(no_extcommunity_list_expanded_all
,
15388 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15389 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15390 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15391 "Extended Community list number (expanded)\n"
15392 "Specify expanded extcommunity-list\n"
15393 "Extended Community list name\n")
15395 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15397 struct community_entry
*entry
;
15399 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15400 if (entry
== list
->head
) {
15401 if (all_digit(list
->name
))
15402 vty_out(vty
, "Extended community %s list %s\n",
15403 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15405 : "(expanded) access",
15409 "Named extended community %s list %s\n",
15410 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15416 vty_out(vty
, " %s\n",
15417 community_direct_str(entry
->direct
));
15419 vty_out(vty
, " %s %s\n",
15420 community_direct_str(entry
->direct
),
15421 community_list_config_str(entry
));
15425 DEFUN (show_extcommunity_list
,
15426 show_bgp_extcommunity_list_cmd
,
15427 "show bgp extcommunity-list",
15430 "List extended-community list\n")
15432 struct community_list
*list
;
15433 struct community_list_master
*cm
;
15436 if (argv_find(argv
, argc
, "ip", &idx
)) {
15437 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15438 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15439 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15440 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15442 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15444 return CMD_SUCCESS
;
15446 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15447 extcommunity_list_show(vty
, list
);
15449 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15450 extcommunity_list_show(vty
, list
);
15452 return CMD_SUCCESS
;
15455 ALIAS (show_extcommunity_list
,
15456 show_ip_extcommunity_list_cmd
,
15457 "show ip extcommunity-list",
15460 "List extended-community list\n")
15462 DEFUN (show_extcommunity_list_arg
,
15463 show_bgp_extcommunity_list_arg_cmd
,
15464 "show bgp extcommunity-list <(1-500)|WORD>",
15467 "List extended-community list\n"
15468 "Extcommunity-list number\n"
15469 "Extcommunity-list name\n")
15471 int idx_comm_list
= 3;
15472 struct community_list
*list
;
15475 if (argv_find(argv
, argc
, "ip", &idx
)) {
15476 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15477 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15478 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15479 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15481 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15482 EXTCOMMUNITY_LIST_MASTER
);
15484 vty_out(vty
, "%% Can't find extcommunity-list\n");
15485 return CMD_WARNING
;
15488 extcommunity_list_show(vty
, list
);
15490 return CMD_SUCCESS
;
15493 ALIAS (show_extcommunity_list_arg
,
15494 show_ip_extcommunity_list_arg_cmd
,
15495 "show ip extcommunity-list <(1-500)|WORD>",
15498 "List extended-community list\n"
15499 "Extcommunity-list number\n"
15500 "Extcommunity-list name\n")
15502 /* Display community-list and extcommunity-list configuration. */
15503 static int community_list_config_write(struct vty
*vty
)
15505 struct community_list
*list
;
15506 struct community_entry
*entry
;
15507 struct community_list_master
*cm
;
15510 /* Community-list. */
15511 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15513 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15514 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15515 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15516 community_direct_str(entry
->direct
),
15517 community_list_config_str(entry
));
15520 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15521 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15522 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15523 entry
->style
== COMMUNITY_LIST_STANDARD
15526 list
->name
, community_direct_str(entry
->direct
),
15527 community_list_config_str(entry
));
15531 /* Extcommunity-list. */
15532 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15534 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15535 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15536 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15537 list
->name
, community_direct_str(entry
->direct
),
15538 community_list_config_str(entry
));
15541 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15542 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15543 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15544 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15547 list
->name
, community_direct_str(entry
->direct
),
15548 community_list_config_str(entry
));
15553 /* lcommunity-list. */
15554 cm
= community_list_master_lookup(bgp_clist
,
15555 LARGE_COMMUNITY_LIST_MASTER
);
15557 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15558 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15559 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15560 list
->name
, community_direct_str(entry
->direct
),
15561 community_list_config_str(entry
));
15564 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15565 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15566 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15567 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15570 list
->name
, community_direct_str(entry
->direct
),
15571 community_list_config_str(entry
));
15578 static struct cmd_node community_list_node
= {
15579 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15582 static void community_list_vty(void)
15584 install_node(&community_list_node
, community_list_config_write
);
15586 /* Community-list. */
15587 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15588 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15589 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15590 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15591 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15592 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15593 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15594 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15595 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15596 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15597 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15598 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15599 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15600 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15601 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15602 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15604 /* Extcommunity-list. */
15605 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15606 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15607 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15608 install_element(CONFIG_NODE
,
15609 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15610 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15611 install_element(CONFIG_NODE
,
15612 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15613 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15614 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15615 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15616 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15617 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15618 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15619 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15620 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15621 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15622 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15624 /* Large Community List */
15625 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15626 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15627 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15628 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15629 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15630 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15631 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15632 install_element(CONFIG_NODE
,
15633 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15634 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15635 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15636 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15637 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15638 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15639 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15640 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15641 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15642 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15643 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15644 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15645 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15646 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15647 install_element(CONFIG_NODE
,
15648 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15649 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15650 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15651 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15652 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15653 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15654 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);