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 WORD",
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
, "WORD", &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 WORD",
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 WORD]",
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 WORD]",
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 WORD] [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 WORD",
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 WORD",
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 WORD",
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 WORD",
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
;
4901 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4903 return CMD_WARNING_CONFIG_FAILED
;
4906 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4907 ret
= peer_default_originate_set(peer
, afi
, safi
,
4910 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4912 return bgp_vty_return(vty
, ret
);
4915 /* neighbor default-originate. */
4916 DEFUN (neighbor_default_originate
,
4917 neighbor_default_originate_cmd
,
4918 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4921 "Originate default route to this neighbor\n")
4924 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4926 bgp_node_safi(vty
), NULL
, 1);
4929 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4930 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4931 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4932 "Originate default route to this neighbor\n")
4934 DEFUN (neighbor_default_originate_rmap
,
4935 neighbor_default_originate_rmap_cmd
,
4936 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4939 "Originate default route to this neighbor\n"
4940 "Route-map to specify criteria to originate default\n"
4945 return peer_default_originate_set_vty(
4946 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4947 argv
[idx_word
]->arg
, 1);
4951 neighbor_default_originate_rmap
,
4952 neighbor_default_originate_rmap_hidden_cmd
,
4953 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4954 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4955 "Originate default route to this neighbor\n"
4956 "Route-map to specify criteria to originate default\n"
4959 DEFUN (no_neighbor_default_originate
,
4960 no_neighbor_default_originate_cmd
,
4961 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4965 "Originate default route to this neighbor\n"
4966 "Route-map to specify criteria to originate default\n"
4970 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4972 bgp_node_safi(vty
), NULL
, 0);
4976 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4977 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4978 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4979 "Originate default route to this neighbor\n"
4980 "Route-map to specify criteria to originate default\n"
4984 /* Set neighbor's BGP port. */
4985 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4986 const char *port_str
)
4992 peer
= peer_lookup_vty(vty
, ip_str
);
4994 return CMD_WARNING_CONFIG_FAILED
;
4997 sp
= getservbyname("bgp", "tcp");
4998 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5000 port
= strtoul(port_str
, NULL
, 10);
5003 peer_port_set(peer
, port
);
5008 /* Set specified peer's BGP port. */
5009 DEFUN (neighbor_port
,
5011 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5014 "Neighbor's BGP port\n"
5015 "TCP port number\n")
5019 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5020 argv
[idx_number
]->arg
);
5023 DEFUN (no_neighbor_port
,
5024 no_neighbor_port_cmd
,
5025 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5029 "Neighbor's BGP port\n"
5030 "TCP port number\n")
5033 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5037 /* neighbor weight. */
5038 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5039 safi_t safi
, const char *weight_str
)
5043 unsigned long weight
;
5045 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5047 return CMD_WARNING_CONFIG_FAILED
;
5049 weight
= strtoul(weight_str
, NULL
, 10);
5051 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5052 return bgp_vty_return(vty
, ret
);
5055 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5061 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5063 return CMD_WARNING_CONFIG_FAILED
;
5065 ret
= peer_weight_unset(peer
, afi
, safi
);
5066 return bgp_vty_return(vty
, ret
);
5069 DEFUN (neighbor_weight
,
5070 neighbor_weight_cmd
,
5071 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5074 "Set default weight for routes from this neighbor\n"
5079 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5080 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5083 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5084 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5085 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5086 "Set default weight for routes from this neighbor\n"
5089 DEFUN (no_neighbor_weight
,
5090 no_neighbor_weight_cmd
,
5091 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5095 "Set default weight for routes from this neighbor\n"
5099 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5100 bgp_node_afi(vty
), bgp_node_safi(vty
));
5103 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5104 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5105 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5106 "Set default weight for routes from this neighbor\n"
5110 /* Override capability negotiation. */
5111 DEFUN (neighbor_override_capability
,
5112 neighbor_override_capability_cmd
,
5113 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5116 "Override capability negotiation result\n")
5119 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5120 PEER_FLAG_OVERRIDE_CAPABILITY
);
5123 DEFUN (no_neighbor_override_capability
,
5124 no_neighbor_override_capability_cmd
,
5125 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5129 "Override capability negotiation result\n")
5132 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5133 PEER_FLAG_OVERRIDE_CAPABILITY
);
5136 DEFUN (neighbor_strict_capability
,
5137 neighbor_strict_capability_cmd
,
5138 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5141 "Strict capability negotiation match\n")
5145 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5146 PEER_FLAG_STRICT_CAP_MATCH
);
5149 DEFUN (no_neighbor_strict_capability
,
5150 no_neighbor_strict_capability_cmd
,
5151 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5155 "Strict capability negotiation match\n")
5159 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5160 PEER_FLAG_STRICT_CAP_MATCH
);
5163 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5164 const char *keep_str
, const char *hold_str
)
5171 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5173 return CMD_WARNING_CONFIG_FAILED
;
5175 keepalive
= strtoul(keep_str
, NULL
, 10);
5176 holdtime
= strtoul(hold_str
, NULL
, 10);
5178 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5180 return bgp_vty_return(vty
, ret
);
5183 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5188 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5190 return CMD_WARNING_CONFIG_FAILED
;
5192 ret
= peer_timers_unset(peer
);
5194 return bgp_vty_return(vty
, ret
);
5197 DEFUN (neighbor_timers
,
5198 neighbor_timers_cmd
,
5199 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5202 "BGP per neighbor timers\n"
5203 "Keepalive interval\n"
5208 int idx_number_2
= 4;
5209 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5210 argv
[idx_number
]->arg
,
5211 argv
[idx_number_2
]->arg
);
5214 DEFUN (no_neighbor_timers
,
5215 no_neighbor_timers_cmd
,
5216 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5220 "BGP per neighbor timers\n"
5221 "Keepalive interval\n"
5225 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5229 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5230 const char *time_str
)
5236 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5238 return CMD_WARNING_CONFIG_FAILED
;
5240 connect
= strtoul(time_str
, NULL
, 10);
5242 ret
= peer_timers_connect_set(peer
, connect
);
5244 return bgp_vty_return(vty
, ret
);
5247 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5252 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5254 return CMD_WARNING_CONFIG_FAILED
;
5256 ret
= peer_timers_connect_unset(peer
);
5258 return bgp_vty_return(vty
, ret
);
5261 DEFUN (neighbor_timers_connect
,
5262 neighbor_timers_connect_cmd
,
5263 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5266 "BGP per neighbor timers\n"
5267 "BGP connect timer\n"
5272 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5273 argv
[idx_number
]->arg
);
5276 DEFUN (no_neighbor_timers_connect
,
5277 no_neighbor_timers_connect_cmd
,
5278 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5282 "BGP per neighbor timers\n"
5283 "BGP connect timer\n"
5287 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5291 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5292 const char *time_str
, int set
)
5296 uint32_t routeadv
= 0;
5298 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5300 return CMD_WARNING_CONFIG_FAILED
;
5303 routeadv
= strtoul(time_str
, NULL
, 10);
5306 ret
= peer_advertise_interval_set(peer
, routeadv
);
5308 ret
= peer_advertise_interval_unset(peer
);
5310 return bgp_vty_return(vty
, ret
);
5313 DEFUN (neighbor_advertise_interval
,
5314 neighbor_advertise_interval_cmd
,
5315 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5318 "Minimum interval between sending BGP routing updates\n"
5319 "time in seconds\n")
5323 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5324 argv
[idx_number
]->arg
, 1);
5327 DEFUN (no_neighbor_advertise_interval
,
5328 no_neighbor_advertise_interval_cmd
,
5329 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5333 "Minimum interval between sending BGP routing updates\n"
5334 "time in seconds\n")
5337 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5341 /* Time to wait before processing route-map updates */
5342 DEFUN (bgp_set_route_map_delay_timer
,
5343 bgp_set_route_map_delay_timer_cmd
,
5344 "bgp route-map delay-timer (0-600)",
5346 "BGP route-map delay timer\n"
5347 "Time in secs to wait before processing route-map changes\n"
5348 "0 disables the timer, no route updates happen when route-maps change\n")
5351 uint32_t rmap_delay_timer
;
5353 if (argv
[idx_number
]->arg
) {
5354 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5355 bm
->rmap_update_timer
= rmap_delay_timer
;
5357 /* if the dynamic update handling is being disabled, and a timer
5359 * running, stop the timer and act as if the timer has already
5362 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5363 BGP_TIMER_OFF(bm
->t_rmap_update
);
5364 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5369 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5370 return CMD_WARNING_CONFIG_FAILED
;
5374 DEFUN (no_bgp_set_route_map_delay_timer
,
5375 no_bgp_set_route_map_delay_timer_cmd
,
5376 "no bgp route-map delay-timer [(0-600)]",
5379 "Default BGP route-map delay timer\n"
5380 "Reset to default time to wait for processing route-map changes\n"
5381 "0 disables the timer, no route updates happen when route-maps change\n")
5384 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5390 /* neighbor interface */
5391 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5396 peer
= peer_lookup_vty(vty
, ip_str
);
5397 if (!peer
|| peer
->conf_if
) {
5398 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5399 return CMD_WARNING_CONFIG_FAILED
;
5403 peer_interface_set(peer
, str
);
5405 peer_interface_unset(peer
);
5410 DEFUN (neighbor_interface
,
5411 neighbor_interface_cmd
,
5412 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5420 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5423 DEFUN (no_neighbor_interface
,
5424 no_neighbor_interface_cmd
,
5425 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5433 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5436 DEFUN (neighbor_distribute_list
,
5437 neighbor_distribute_list_cmd
,
5438 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5441 "Filter updates to/from this neighbor\n"
5442 "IP access-list number\n"
5443 "IP access-list number (expanded range)\n"
5444 "IP Access-list name\n"
5445 "Filter incoming updates\n"
5446 "Filter outgoing updates\n")
5453 const char *pstr
= argv
[idx_peer
]->arg
;
5454 const char *acl
= argv
[idx_acl
]->arg
;
5455 const char *inout
= argv
[argc
- 1]->text
;
5457 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5459 return CMD_WARNING_CONFIG_FAILED
;
5461 /* Check filter direction. */
5462 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5463 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5466 return bgp_vty_return(vty
, ret
);
5470 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5471 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5472 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5473 "Filter updates to/from this neighbor\n"
5474 "IP access-list number\n"
5475 "IP access-list number (expanded range)\n"
5476 "IP Access-list name\n"
5477 "Filter incoming updates\n"
5478 "Filter outgoing updates\n")
5480 DEFUN (no_neighbor_distribute_list
,
5481 no_neighbor_distribute_list_cmd
,
5482 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5486 "Filter updates to/from this neighbor\n"
5487 "IP access-list number\n"
5488 "IP access-list number (expanded range)\n"
5489 "IP Access-list name\n"
5490 "Filter incoming updates\n"
5491 "Filter outgoing updates\n")
5497 const char *pstr
= argv
[idx_peer
]->arg
;
5498 const char *inout
= argv
[argc
- 1]->text
;
5500 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5502 return CMD_WARNING_CONFIG_FAILED
;
5504 /* Check filter direction. */
5505 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5506 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5509 return bgp_vty_return(vty
, ret
);
5513 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5514 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5515 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5516 "Filter updates to/from this neighbor\n"
5517 "IP access-list number\n"
5518 "IP access-list number (expanded range)\n"
5519 "IP Access-list name\n"
5520 "Filter incoming updates\n"
5521 "Filter outgoing updates\n")
5523 /* Set prefix list to the peer. */
5524 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5525 afi_t afi
, safi_t safi
,
5526 const char *name_str
,
5527 const char *direct_str
)
5530 int direct
= FILTER_IN
;
5533 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5535 return CMD_WARNING_CONFIG_FAILED
;
5537 /* Check filter direction. */
5538 if (strncmp(direct_str
, "i", 1) == 0)
5540 else if (strncmp(direct_str
, "o", 1) == 0)
5541 direct
= FILTER_OUT
;
5543 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5545 return bgp_vty_return(vty
, ret
);
5548 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5549 afi_t afi
, safi_t safi
,
5550 const char *direct_str
)
5554 int direct
= FILTER_IN
;
5556 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5558 return CMD_WARNING_CONFIG_FAILED
;
5560 /* Check filter direction. */
5561 if (strncmp(direct_str
, "i", 1) == 0)
5563 else if (strncmp(direct_str
, "o", 1) == 0)
5564 direct
= FILTER_OUT
;
5566 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5568 return bgp_vty_return(vty
, ret
);
5571 DEFUN (neighbor_prefix_list
,
5572 neighbor_prefix_list_cmd
,
5573 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5576 "Filter updates to/from this neighbor\n"
5577 "Name of a prefix list\n"
5578 "Filter incoming updates\n"
5579 "Filter outgoing updates\n")
5584 return peer_prefix_list_set_vty(
5585 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5586 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5589 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5590 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5591 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5592 "Filter updates to/from this neighbor\n"
5593 "Name of a prefix list\n"
5594 "Filter incoming updates\n"
5595 "Filter outgoing updates\n")
5597 DEFUN (no_neighbor_prefix_list
,
5598 no_neighbor_prefix_list_cmd
,
5599 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5603 "Filter updates to/from this neighbor\n"
5604 "Name of a prefix list\n"
5605 "Filter incoming updates\n"
5606 "Filter outgoing updates\n")
5610 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5611 bgp_node_afi(vty
), bgp_node_safi(vty
),
5612 argv
[idx_in_out
]->arg
);
5615 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5616 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5617 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5618 "Filter updates to/from this neighbor\n"
5619 "Name of a prefix list\n"
5620 "Filter incoming updates\n"
5621 "Filter outgoing updates\n")
5623 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5624 safi_t safi
, const char *name_str
,
5625 const char *direct_str
)
5629 int direct
= FILTER_IN
;
5631 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5633 return CMD_WARNING_CONFIG_FAILED
;
5635 /* Check filter direction. */
5636 if (strncmp(direct_str
, "i", 1) == 0)
5638 else if (strncmp(direct_str
, "o", 1) == 0)
5639 direct
= FILTER_OUT
;
5641 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5643 return bgp_vty_return(vty
, ret
);
5646 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5647 safi_t safi
, const char *direct_str
)
5651 int direct
= FILTER_IN
;
5653 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5655 return CMD_WARNING_CONFIG_FAILED
;
5657 /* Check filter direction. */
5658 if (strncmp(direct_str
, "i", 1) == 0)
5660 else if (strncmp(direct_str
, "o", 1) == 0)
5661 direct
= FILTER_OUT
;
5663 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5665 return bgp_vty_return(vty
, ret
);
5668 DEFUN (neighbor_filter_list
,
5669 neighbor_filter_list_cmd
,
5670 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5673 "Establish BGP filters\n"
5674 "AS path access-list name\n"
5675 "Filter incoming routes\n"
5676 "Filter outgoing routes\n")
5681 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5682 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5683 argv
[idx_in_out
]->arg
);
5686 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5687 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5688 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5689 "Establish BGP filters\n"
5690 "AS path access-list name\n"
5691 "Filter incoming routes\n"
5692 "Filter outgoing routes\n")
5694 DEFUN (no_neighbor_filter_list
,
5695 no_neighbor_filter_list_cmd
,
5696 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5700 "Establish BGP filters\n"
5701 "AS path access-list name\n"
5702 "Filter incoming routes\n"
5703 "Filter outgoing routes\n")
5707 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5708 bgp_node_afi(vty
), bgp_node_safi(vty
),
5709 argv
[idx_in_out
]->arg
);
5712 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5713 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5714 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5715 "Establish BGP filters\n"
5716 "AS path access-list name\n"
5717 "Filter incoming routes\n"
5718 "Filter outgoing routes\n")
5720 /* Set route-map to the peer. */
5721 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5722 afi_t afi
, safi_t safi
, const char *name_str
,
5723 const char *direct_str
)
5727 int direct
= RMAP_IN
;
5728 struct route_map
*route_map
;
5730 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5732 return CMD_WARNING_CONFIG_FAILED
;
5734 /* Check filter direction. */
5735 if (strncmp(direct_str
, "in", 2) == 0)
5737 else if (strncmp(direct_str
, "o", 1) == 0)
5740 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5741 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5743 return bgp_vty_return(vty
, ret
);
5746 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5747 afi_t afi
, safi_t safi
,
5748 const char *direct_str
)
5752 int direct
= RMAP_IN
;
5754 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5756 return CMD_WARNING_CONFIG_FAILED
;
5758 /* Check filter direction. */
5759 if (strncmp(direct_str
, "in", 2) == 0)
5761 else if (strncmp(direct_str
, "o", 1) == 0)
5764 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5766 return bgp_vty_return(vty
, ret
);
5769 DEFUN (neighbor_route_map
,
5770 neighbor_route_map_cmd
,
5771 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5774 "Apply route map to neighbor\n"
5775 "Name of route map\n"
5776 "Apply map to incoming routes\n"
5777 "Apply map to outbound routes\n")
5782 return peer_route_map_set_vty(
5783 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5784 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5787 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5788 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5789 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5790 "Apply route map to neighbor\n"
5791 "Name of route map\n"
5792 "Apply map to incoming routes\n"
5793 "Apply map to outbound routes\n")
5795 DEFUN (no_neighbor_route_map
,
5796 no_neighbor_route_map_cmd
,
5797 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5801 "Apply route map to neighbor\n"
5802 "Name of route map\n"
5803 "Apply map to incoming routes\n"
5804 "Apply map to outbound routes\n")
5808 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5809 bgp_node_afi(vty
), bgp_node_safi(vty
),
5810 argv
[idx_in_out
]->arg
);
5813 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5814 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5815 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5816 "Apply route map to neighbor\n"
5817 "Name of route map\n"
5818 "Apply map to incoming routes\n"
5819 "Apply map to outbound routes\n")
5821 /* Set unsuppress-map to the peer. */
5822 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5823 afi_t afi
, safi_t safi
,
5824 const char *name_str
)
5828 struct route_map
*route_map
;
5830 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5832 return CMD_WARNING_CONFIG_FAILED
;
5834 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5835 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5837 return bgp_vty_return(vty
, ret
);
5840 /* Unset route-map from the peer. */
5841 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5842 afi_t afi
, safi_t safi
)
5847 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5849 return CMD_WARNING_CONFIG_FAILED
;
5851 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5853 return bgp_vty_return(vty
, ret
);
5856 DEFUN (neighbor_unsuppress_map
,
5857 neighbor_unsuppress_map_cmd
,
5858 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5861 "Route-map to selectively unsuppress suppressed routes\n"
5862 "Name of route map\n")
5866 return peer_unsuppress_map_set_vty(
5867 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5868 argv
[idx_word
]->arg
);
5871 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5872 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5873 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5874 "Route-map to selectively unsuppress suppressed routes\n"
5875 "Name of route map\n")
5877 DEFUN (no_neighbor_unsuppress_map
,
5878 no_neighbor_unsuppress_map_cmd
,
5879 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5883 "Route-map to selectively unsuppress suppressed routes\n"
5884 "Name of route map\n")
5887 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5889 bgp_node_safi(vty
));
5892 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5893 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5894 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5895 "Route-map to selectively unsuppress suppressed routes\n"
5896 "Name of route map\n")
5898 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5899 afi_t afi
, safi_t safi
,
5900 const char *num_str
,
5901 const char *threshold_str
, int warning
,
5902 const char *restart_str
)
5910 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5912 return CMD_WARNING_CONFIG_FAILED
;
5914 max
= strtoul(num_str
, NULL
, 10);
5916 threshold
= atoi(threshold_str
);
5918 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5921 restart
= atoi(restart_str
);
5925 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5928 return bgp_vty_return(vty
, ret
);
5931 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5932 afi_t afi
, safi_t safi
)
5937 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5939 return CMD_WARNING_CONFIG_FAILED
;
5941 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5943 return bgp_vty_return(vty
, ret
);
5946 /* Maximum number of prefix configuration. prefix count is different
5947 for each peer configuration. So this configuration can be set for
5948 each peer configuration. */
5949 DEFUN (neighbor_maximum_prefix
,
5950 neighbor_maximum_prefix_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5954 "Maximum number of prefix accept from this peer\n"
5955 "maximum no. of prefix limit\n")
5959 return peer_maximum_prefix_set_vty(
5960 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5961 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5964 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5965 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5966 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5967 "Maximum number of prefix accept from this peer\n"
5968 "maximum no. of prefix limit\n")
5970 DEFUN (neighbor_maximum_prefix_threshold
,
5971 neighbor_maximum_prefix_threshold_cmd
,
5972 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5975 "Maximum number of prefix accept from this peer\n"
5976 "maximum no. of prefix limit\n"
5977 "Threshold value (%) at which to generate a warning msg\n")
5981 int idx_number_2
= 4;
5982 return peer_maximum_prefix_set_vty(
5983 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5984 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5988 neighbor_maximum_prefix_threshold
,
5989 neighbor_maximum_prefix_threshold_hidden_cmd
,
5990 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5991 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5992 "Maximum number of prefix accept from this peer\n"
5993 "maximum no. of prefix limit\n"
5994 "Threshold value (%) at which to generate a warning msg\n")
5996 DEFUN (neighbor_maximum_prefix_warning
,
5997 neighbor_maximum_prefix_warning_cmd
,
5998 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6001 "Maximum number of prefix accept from this peer\n"
6002 "maximum no. of prefix limit\n"
6003 "Only give warning message when limit is exceeded\n")
6007 return peer_maximum_prefix_set_vty(
6008 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6009 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6013 neighbor_maximum_prefix_warning
,
6014 neighbor_maximum_prefix_warning_hidden_cmd
,
6015 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6017 "Maximum number of prefix accept from this peer\n"
6018 "maximum no. of prefix limit\n"
6019 "Only give warning message when limit is exceeded\n")
6021 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6022 neighbor_maximum_prefix_threshold_warning_cmd
,
6023 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6026 "Maximum number of prefix accept from this peer\n"
6027 "maximum no. of prefix limit\n"
6028 "Threshold value (%) at which to generate a warning msg\n"
6029 "Only give warning message when limit is exceeded\n")
6033 int idx_number_2
= 4;
6034 return peer_maximum_prefix_set_vty(
6035 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6036 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6040 neighbor_maximum_prefix_threshold_warning
,
6041 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6042 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6043 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6044 "Maximum number of prefix accept from this peer\n"
6045 "maximum no. of prefix limit\n"
6046 "Threshold value (%) at which to generate a warning msg\n"
6047 "Only give warning message when limit is exceeded\n")
6049 DEFUN (neighbor_maximum_prefix_restart
,
6050 neighbor_maximum_prefix_restart_cmd
,
6051 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6054 "Maximum number of prefix accept from this peer\n"
6055 "maximum no. of prefix limit\n"
6056 "Restart bgp connection after limit is exceeded\n"
6057 "Restart interval in minutes\n")
6061 int idx_number_2
= 5;
6062 return peer_maximum_prefix_set_vty(
6063 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6064 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6068 neighbor_maximum_prefix_restart
,
6069 neighbor_maximum_prefix_restart_hidden_cmd
,
6070 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6071 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6072 "Maximum number of prefix accept from this peer\n"
6073 "maximum no. of prefix limit\n"
6074 "Restart bgp connection after limit is exceeded\n"
6075 "Restart interval in minutes\n")
6077 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6078 neighbor_maximum_prefix_threshold_restart_cmd
,
6079 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6082 "Maximum number of prefixes to accept from this peer\n"
6083 "maximum no. of prefix limit\n"
6084 "Threshold value (%) at which to generate a warning msg\n"
6085 "Restart bgp connection after limit is exceeded\n"
6086 "Restart interval in minutes\n")
6090 int idx_number_2
= 4;
6091 int idx_number_3
= 6;
6092 return peer_maximum_prefix_set_vty(
6093 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6094 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6095 argv
[idx_number_3
]->arg
);
6099 neighbor_maximum_prefix_threshold_restart
,
6100 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6101 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6102 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6103 "Maximum number of prefixes to accept from this peer\n"
6104 "maximum no. of prefix limit\n"
6105 "Threshold value (%) at which to generate a warning msg\n"
6106 "Restart bgp connection after limit is exceeded\n"
6107 "Restart interval in minutes\n")
6109 DEFUN (no_neighbor_maximum_prefix
,
6110 no_neighbor_maximum_prefix_cmd
,
6111 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6115 "Maximum number of prefixes to accept from this peer\n"
6116 "maximum no. of prefix limit\n"
6117 "Threshold value (%) at which to generate a warning msg\n"
6118 "Restart bgp connection after limit is exceeded\n"
6119 "Restart interval in minutes\n"
6120 "Only give warning message when limit is exceeded\n")
6123 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6125 bgp_node_safi(vty
));
6129 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6130 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6131 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6132 "Maximum number of prefixes to accept from this peer\n"
6133 "maximum no. of prefix limit\n"
6134 "Threshold value (%) at which to generate a warning msg\n"
6135 "Restart bgp connection after limit is exceeded\n"
6136 "Restart interval in minutes\n"
6137 "Only give warning message when limit is exceeded\n")
6140 /* "neighbor allowas-in" */
6141 DEFUN (neighbor_allowas_in
,
6142 neighbor_allowas_in_cmd
,
6143 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6146 "Accept as-path with my AS present in it\n"
6147 "Number of occurences of AS number\n"
6148 "Only accept my AS in the as-path if the route was originated in my AS\n")
6151 int idx_number_origin
= 3;
6157 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6159 return CMD_WARNING_CONFIG_FAILED
;
6161 if (argc
<= idx_number_origin
)
6164 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6167 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6170 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6173 return bgp_vty_return(vty
, ret
);
6177 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6178 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6179 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6180 "Accept as-path with my AS present in it\n"
6181 "Number of occurences of AS number\n"
6182 "Only accept my AS in the as-path if the route was originated in my AS\n")
6184 DEFUN (no_neighbor_allowas_in
,
6185 no_neighbor_allowas_in_cmd
,
6186 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6190 "allow local ASN appears in aspath attribute\n"
6191 "Number of occurences of AS number\n"
6192 "Only accept my AS in the as-path if the route was originated in my AS\n")
6198 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6200 return CMD_WARNING_CONFIG_FAILED
;
6202 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6203 bgp_node_safi(vty
));
6205 return bgp_vty_return(vty
, ret
);
6209 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6210 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6211 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6212 "allow local ASN appears in aspath attribute\n"
6213 "Number of occurences of AS number\n"
6214 "Only accept my AS in the as-path if the route was originated in my AS\n")
6216 DEFUN (neighbor_ttl_security
,
6217 neighbor_ttl_security_cmd
,
6218 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6221 "BGP ttl-security parameters\n"
6222 "Specify the maximum number of hops to the BGP peer\n"
6223 "Number of hops to BGP peer\n")
6230 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6232 return CMD_WARNING_CONFIG_FAILED
;
6234 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6237 * If 'neighbor swpX', then this is for directly connected peers,
6238 * we should not accept a ttl-security hops value greater than 1.
6240 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6242 "%s is directly connected peer, hops cannot exceed 1\n",
6243 argv
[idx_peer
]->arg
);
6244 return CMD_WARNING_CONFIG_FAILED
;
6247 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6250 DEFUN (no_neighbor_ttl_security
,
6251 no_neighbor_ttl_security_cmd
,
6252 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6256 "BGP ttl-security parameters\n"
6257 "Specify the maximum number of hops to the BGP peer\n"
6258 "Number of hops to BGP peer\n")
6263 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6265 return CMD_WARNING_CONFIG_FAILED
;
6267 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6270 DEFUN (neighbor_addpath_tx_all_paths
,
6271 neighbor_addpath_tx_all_paths_cmd
,
6272 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6275 "Use addpath to advertise all paths to a neighbor\n")
6280 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6282 return CMD_WARNING_CONFIG_FAILED
;
6284 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6289 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6290 neighbor_addpath_tx_all_paths_hidden_cmd
,
6291 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6292 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6293 "Use addpath to advertise all paths to a neighbor\n")
6295 DEFUN (no_neighbor_addpath_tx_all_paths
,
6296 no_neighbor_addpath_tx_all_paths_cmd
,
6297 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6301 "Use addpath to advertise all paths to a neighbor\n")
6306 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6308 return CMD_WARNING_CONFIG_FAILED
;
6310 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6311 != BGP_ADDPATH_ALL
) {
6313 "%% Peer not currently configured to transmit all paths.");
6314 return CMD_WARNING_CONFIG_FAILED
;
6317 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6323 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6324 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6325 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6326 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6327 "Use addpath to advertise all paths to a neighbor\n")
6329 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6330 neighbor_addpath_tx_bestpath_per_as_cmd
,
6331 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6334 "Use addpath to advertise the bestpath per each neighboring AS\n")
6339 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6341 return CMD_WARNING_CONFIG_FAILED
;
6343 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6344 BGP_ADDPATH_BEST_PER_AS
);
6349 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6350 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6351 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6352 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6353 "Use addpath to advertise the bestpath per each neighboring AS\n")
6355 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6356 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6357 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6361 "Use addpath to advertise the bestpath per each neighboring AS\n")
6366 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6368 return CMD_WARNING_CONFIG_FAILED
;
6370 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6371 != BGP_ADDPATH_BEST_PER_AS
) {
6373 "%% Peer not currently configured to transmit all best path per as.");
6374 return CMD_WARNING_CONFIG_FAILED
;
6377 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6383 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6384 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6385 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6386 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6387 "Use addpath to advertise the bestpath per each neighboring AS\n")
6389 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6390 struct ecommunity
**list
)
6392 struct ecommunity
*ecom
= NULL
;
6393 struct ecommunity
*ecomadd
;
6395 for (; argc
; --argc
, ++argv
) {
6397 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6398 ECOMMUNITY_ROUTE_TARGET
, 0);
6400 vty_out(vty
, "Malformed community-list value\n");
6402 ecommunity_free(&ecom
);
6403 return CMD_WARNING_CONFIG_FAILED
;
6407 ecommunity_merge(ecom
, ecomadd
);
6408 ecommunity_free(&ecomadd
);
6415 ecommunity_free(&*list
);
6423 * v2vimport is true if we are handling a `import vrf ...` command
6425 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6429 switch (vty
->node
) {
6438 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6443 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6444 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6445 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6446 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6448 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6452 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6453 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6454 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6455 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6457 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6464 DEFPY (af_rd_vpn_export
,
6465 af_rd_vpn_export_cmd
,
6466 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6468 "Specify route distinguisher\n"
6469 "Between current address-family and vpn\n"
6470 "For routes leaked from current address-family to vpn\n"
6471 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6473 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6474 struct prefix_rd prd
;
6480 if (argv_find(argv
, argc
, "no", &idx
))
6484 ret
= str2prefix_rd(rd_str
, &prd
);
6486 vty_out(vty
, "%% Malformed rd\n");
6487 return CMD_WARNING_CONFIG_FAILED
;
6491 afi
= vpn_policy_getafi(vty
, bgp
, false);
6493 return CMD_WARNING_CONFIG_FAILED
;
6496 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6498 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6499 bgp_get_default(), bgp
);
6502 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6503 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6504 BGP_VPN_POLICY_TOVPN_RD_SET
);
6506 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6507 BGP_VPN_POLICY_TOVPN_RD_SET
);
6510 /* post-change: re-export vpn routes */
6511 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6512 bgp_get_default(), bgp
);
6517 ALIAS (af_rd_vpn_export
,
6518 af_no_rd_vpn_export_cmd
,
6521 "Specify route distinguisher\n"
6522 "Between current address-family and vpn\n"
6523 "For routes leaked from current address-family to vpn\n")
6525 DEFPY (af_label_vpn_export
,
6526 af_label_vpn_export_cmd
,
6527 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6529 "label value for VRF\n"
6530 "Between current address-family and vpn\n"
6531 "For routes leaked from current address-family to vpn\n"
6532 "Label Value <0-1048575>\n"
6533 "Automatically assign a label\n")
6535 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6536 mpls_label_t label
= MPLS_LABEL_NONE
;
6541 if (argv_find(argv
, argc
, "no", &idx
))
6544 /* If "no ...", squash trailing parameter */
6550 label
= label_val
; /* parser should force unsigned */
6553 afi
= vpn_policy_getafi(vty
, bgp
, false);
6555 return CMD_WARNING_CONFIG_FAILED
;
6558 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6559 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6564 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6566 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6567 bgp_get_default(), bgp
);
6569 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6570 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6572 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6575 * label has previously been automatically
6576 * assigned by labelpool: release it
6578 * NB if tovpn_label == MPLS_LABEL_NONE it
6579 * means the automatic assignment is in flight
6580 * and therefore the labelpool callback must
6581 * detect that the auto label is not needed.
6584 bgp_lp_release(LP_TYPE_VRF
,
6585 &bgp
->vpn_policy
[afi
],
6586 bgp
->vpn_policy
[afi
].tovpn_label
);
6588 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6589 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6592 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6594 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6595 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6596 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6597 vpn_leak_label_callback
);
6600 /* post-change: re-export vpn routes */
6601 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6602 bgp_get_default(), bgp
);
6607 ALIAS (af_label_vpn_export
,
6608 af_no_label_vpn_export_cmd
,
6609 "no label vpn export",
6611 "label value for VRF\n"
6612 "Between current address-family and vpn\n"
6613 "For routes leaked from current address-family to vpn\n")
6615 DEFPY (af_nexthop_vpn_export
,
6616 af_nexthop_vpn_export_cmd
,
6617 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6619 "Specify next hop to use for VRF advertised prefixes\n"
6620 "Between current address-family and vpn\n"
6621 "For routes leaked from current address-family to vpn\n"
6625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6631 if (argv_find(argv
, argc
, "no", &idx
))
6635 if (!sockunion2hostprefix(nexthop_str
, &p
))
6636 return CMD_WARNING_CONFIG_FAILED
;
6639 afi
= vpn_policy_getafi(vty
, bgp
, false);
6641 return CMD_WARNING_CONFIG_FAILED
;
6644 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6646 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6647 bgp_get_default(), bgp
);
6650 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6651 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6652 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6654 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6655 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6658 /* post-change: re-export vpn routes */
6659 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6660 bgp_get_default(), bgp
);
6665 ALIAS (af_nexthop_vpn_export
,
6666 af_no_nexthop_vpn_export_cmd
,
6667 "no nexthop vpn export",
6669 "Specify next hop to use for VRF advertised prefixes\n"
6670 "Between current address-family and vpn\n"
6671 "For routes leaked from current address-family to vpn\n")
6673 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6675 if (!strcmp(dstr
, "import")) {
6676 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6677 } else if (!strcmp(dstr
, "export")) {
6678 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6679 } else if (!strcmp(dstr
, "both")) {
6680 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6681 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6683 vty_out(vty
, "%% direction parse error\n");
6684 return CMD_WARNING_CONFIG_FAILED
;
6689 DEFPY (af_rt_vpn_imexport
,
6690 af_rt_vpn_imexport_cmd
,
6691 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6693 "Specify route target list\n"
6694 "Specify route target list\n"
6695 "Between current address-family and vpn\n"
6696 "For routes leaked from vpn to current address-family: match any\n"
6697 "For routes leaked from current address-family to vpn: set\n"
6698 "both import: match any and export: set\n"
6699 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6701 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6703 struct ecommunity
*ecom
= NULL
;
6704 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6705 vpn_policy_direction_t dir
;
6710 if (argv_find(argv
, argc
, "no", &idx
))
6713 afi
= vpn_policy_getafi(vty
, bgp
, false);
6715 return CMD_WARNING_CONFIG_FAILED
;
6717 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6718 if (ret
!= CMD_SUCCESS
)
6722 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6723 vty_out(vty
, "%% Missing RTLIST\n");
6724 return CMD_WARNING_CONFIG_FAILED
;
6726 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6727 if (ret
!= CMD_SUCCESS
) {
6732 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6736 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6739 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6741 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6742 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6743 ecommunity_dup(ecom
);
6745 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6747 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6748 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6751 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6755 ecommunity_free(&ecom
);
6760 ALIAS (af_rt_vpn_imexport
,
6761 af_no_rt_vpn_imexport_cmd
,
6762 "no <rt|route-target> vpn <import|export|both>$direction_str",
6764 "Specify route target list\n"
6765 "Specify route target list\n"
6766 "Between current address-family and vpn\n"
6767 "For routes leaked from vpn to current address-family\n"
6768 "For routes leaked from current address-family to vpn\n"
6769 "both import and export\n")
6771 DEFPY (af_route_map_vpn_imexport
,
6772 af_route_map_vpn_imexport_cmd
,
6773 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6774 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6776 "Specify route map\n"
6777 "Between current address-family and vpn\n"
6778 "For routes leaked from vpn to current address-family\n"
6779 "For routes leaked from current address-family to vpn\n"
6780 "name of route-map\n")
6782 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6784 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6785 vpn_policy_direction_t dir
;
6790 if (argv_find(argv
, argc
, "no", &idx
))
6793 afi
= vpn_policy_getafi(vty
, bgp
, false);
6795 return CMD_WARNING_CONFIG_FAILED
;
6797 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6798 if (ret
!= CMD_SUCCESS
)
6801 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6805 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6808 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6809 XFREE(MTYPE_ROUTE_MAP_NAME
,
6810 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6811 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6812 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6813 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6814 route_map_lookup_warn_noexist(vty
, rmap_str
);
6815 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6818 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6819 XFREE(MTYPE_ROUTE_MAP_NAME
,
6820 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6821 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6822 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6825 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6831 ALIAS (af_route_map_vpn_imexport
,
6832 af_no_route_map_vpn_imexport_cmd
,
6833 "no route-map vpn <import|export>$direction_str",
6835 "Specify route map\n"
6836 "Between current address-family and vpn\n"
6837 "For routes leaked from vpn to current address-family\n"
6838 "For routes leaked from current address-family to vpn\n")
6840 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6841 "[no] import vrf route-map RMAP$rmap_str",
6843 "Import routes from another VRF\n"
6844 "Vrf routes being filtered\n"
6845 "Specify route map\n"
6846 "name of route-map\n")
6848 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6849 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6853 struct bgp
*bgp_default
;
6855 if (argv_find(argv
, argc
, "no", &idx
))
6858 afi
= vpn_policy_getafi(vty
, bgp
, true);
6860 return CMD_WARNING_CONFIG_FAILED
;
6862 bgp_default
= bgp_get_default();
6867 /* Auto-create assuming the same AS */
6868 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6869 BGP_INSTANCE_TYPE_DEFAULT
);
6873 "VRF default is not configured as a bgp instance\n");
6878 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6881 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6882 XFREE(MTYPE_ROUTE_MAP_NAME
,
6883 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6884 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6885 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6886 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6887 route_map_lookup_warn_noexist(vty
, rmap_str
);
6888 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6891 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6892 XFREE(MTYPE_ROUTE_MAP_NAME
,
6893 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6894 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6895 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6898 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6903 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6904 "no import vrf route-map",
6906 "Import routes from another VRF\n"
6907 "Vrf routes being filtered\n"
6908 "Specify route map\n")
6910 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6911 "[no] import vrf VIEWVRFNAME$import_name",
6913 "Import routes from another VRF\n"
6914 "VRF to import from\n"
6915 "The name of the VRF\n")
6917 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6918 struct listnode
*node
;
6919 struct bgp
*vrf_bgp
, *bgp_default
;
6922 bool remove
= false;
6925 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6929 if (import_name
== NULL
) {
6930 vty_out(vty
, "%% Missing import name\n");
6934 if (argv_find(argv
, argc
, "no", &idx
))
6937 afi
= vpn_policy_getafi(vty
, bgp
, true);
6939 return CMD_WARNING_CONFIG_FAILED
;
6941 safi
= bgp_node_safi(vty
);
6943 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6944 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6945 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6946 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6947 remove
? "unimport" : "import", import_name
);
6951 bgp_default
= bgp_get_default();
6953 /* Auto-create assuming the same AS */
6954 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6955 BGP_INSTANCE_TYPE_DEFAULT
);
6959 "VRF default is not configured as a bgp instance\n");
6964 vrf_bgp
= bgp_lookup_by_name(import_name
);
6966 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6967 vrf_bgp
= bgp_default
;
6969 /* Auto-create assuming the same AS */
6970 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6974 "VRF %s is not configured as a bgp instance\n",
6981 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6983 /* Already importing from "import_vrf"? */
6984 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6986 if (strcmp(vname
, import_name
) == 0)
6990 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6996 /* This command is valid only in a bgp vrf instance or the default instance */
6997 DEFPY (bgp_imexport_vpn
,
6998 bgp_imexport_vpn_cmd
,
6999 "[no] <import|export>$direction_str vpn",
7001 "Import routes to this address-family\n"
7002 "Export routes from this address-family\n"
7003 "to/from default instance VPN RIB\n")
7005 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7012 vpn_policy_direction_t dir
;
7014 if (argv_find(argv
, argc
, "no", &idx
))
7017 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7018 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7020 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7021 return CMD_WARNING_CONFIG_FAILED
;
7024 afi
= bgp_node_afi(vty
);
7025 safi
= bgp_node_safi(vty
);
7026 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7027 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7028 return CMD_WARNING_CONFIG_FAILED
;
7031 if (!strcmp(direction_str
, "import")) {
7032 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7033 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7034 } else if (!strcmp(direction_str
, "export")) {
7035 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7036 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7038 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7039 return CMD_WARNING_CONFIG_FAILED
;
7042 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7045 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7046 if (!previous_state
) {
7047 /* trigger export current vrf */
7048 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7051 if (previous_state
) {
7052 /* trigger un-export current vrf */
7053 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7055 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7061 DEFPY (af_routetarget_import
,
7062 af_routetarget_import_cmd
,
7063 "[no] <rt|route-target> redirect import RTLIST...",
7065 "Specify route target list\n"
7066 "Specify route target list\n"
7067 "Flow-spec redirect type route target\n"
7068 "Import routes to this address-family\n"
7069 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7071 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7073 struct ecommunity
*ecom
= NULL
;
7078 if (argv_find(argv
, argc
, "no", &idx
))
7081 afi
= vpn_policy_getafi(vty
, bgp
, false);
7083 return CMD_WARNING_CONFIG_FAILED
;
7086 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7087 vty_out(vty
, "%% Missing RTLIST\n");
7088 return CMD_WARNING_CONFIG_FAILED
;
7090 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7091 if (ret
!= CMD_SUCCESS
)
7096 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7097 ecommunity_free(&bgp
->vpn_policy
[afi
]
7098 .import_redirect_rtlist
);
7099 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7100 ecommunity_dup(ecom
);
7102 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7103 ecommunity_free(&bgp
->vpn_policy
[afi
]
7104 .import_redirect_rtlist
);
7105 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7109 ecommunity_free(&ecom
);
7114 DEFUN_NOSH (address_family_ipv4_safi
,
7115 address_family_ipv4_safi_cmd
,
7116 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7117 "Enter Address Family command mode\n"
7119 BGP_SAFI_WITH_LABEL_HELP_STR
)
7123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7124 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7125 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7126 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7127 && safi
!= SAFI_EVPN
) {
7129 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7130 return CMD_WARNING_CONFIG_FAILED
;
7132 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7134 vty
->node
= BGP_IPV4_NODE
;
7139 DEFUN_NOSH (address_family_ipv6_safi
,
7140 address_family_ipv6_safi_cmd
,
7141 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7142 "Enter Address Family command mode\n"
7144 BGP_SAFI_WITH_LABEL_HELP_STR
)
7147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7148 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7149 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7150 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7151 && safi
!= SAFI_EVPN
) {
7153 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7154 return CMD_WARNING_CONFIG_FAILED
;
7156 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7158 vty
->node
= BGP_IPV6_NODE
;
7163 #ifdef KEEP_OLD_VPN_COMMANDS
7164 DEFUN_NOSH (address_family_vpnv4
,
7165 address_family_vpnv4_cmd
,
7166 "address-family vpnv4 [unicast]",
7167 "Enter Address Family command mode\n"
7169 "Address Family modifier\n")
7171 vty
->node
= BGP_VPNV4_NODE
;
7175 DEFUN_NOSH (address_family_vpnv6
,
7176 address_family_vpnv6_cmd
,
7177 "address-family vpnv6 [unicast]",
7178 "Enter Address Family command mode\n"
7180 "Address Family modifier\n")
7182 vty
->node
= BGP_VPNV6_NODE
;
7185 #endif /* KEEP_OLD_VPN_COMMANDS */
7187 DEFUN_NOSH (address_family_evpn
,
7188 address_family_evpn_cmd
,
7189 "address-family l2vpn evpn",
7190 "Enter Address Family command mode\n"
7192 "Address Family modifier\n")
7194 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7195 vty
->node
= BGP_EVPN_NODE
;
7199 DEFUN_NOSH (exit_address_family
,
7200 exit_address_family_cmd
,
7201 "exit-address-family",
7202 "Exit from Address Family configuration mode\n")
7204 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7205 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7206 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7207 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7208 || vty
->node
== BGP_EVPN_NODE
7209 || vty
->node
== BGP_FLOWSPECV4_NODE
7210 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7211 vty
->node
= BGP_NODE
;
7215 /* Recalculate bestpath and re-advertise a prefix */
7216 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7217 const char *ip_str
, afi_t afi
, safi_t safi
,
7218 struct prefix_rd
*prd
)
7221 struct prefix match
;
7222 struct bgp_node
*rn
;
7223 struct bgp_node
*rm
;
7225 struct bgp_table
*table
;
7226 struct bgp_table
*rib
;
7228 /* BGP structure lookup. */
7230 bgp
= bgp_lookup_by_name(view_name
);
7232 vty_out(vty
, "%% Can't find BGP instance %s\n",
7237 bgp
= bgp_get_default();
7239 vty_out(vty
, "%% No BGP process is configured\n");
7244 /* Check IP address argument. */
7245 ret
= str2prefix(ip_str
, &match
);
7247 vty_out(vty
, "%% address is malformed\n");
7251 match
.family
= afi2family(afi
);
7252 rib
= bgp
->rib
[afi
][safi
];
7254 if (safi
== SAFI_MPLS_VPN
) {
7255 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7256 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7259 table
= bgp_node_get_bgp_table_info(rn
);
7260 if (table
!= NULL
) {
7262 if ((rm
= bgp_node_match(table
, &match
))
7265 == match
.prefixlen
) {
7267 BGP_NODE_USER_CLEAR
);
7268 bgp_process(bgp
, rm
, afi
, safi
);
7270 bgp_unlock_node(rm
);
7275 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7276 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7277 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7278 bgp_process(bgp
, rn
, afi
, safi
);
7280 bgp_unlock_node(rn
);
7287 /* one clear bgp command to rule them all */
7288 DEFUN (clear_ip_bgp_all
,
7289 clear_ip_bgp_all_cmd
,
7290 "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 WORD> [<soft [<in|out>]|in [prefix-filter]|out>]",
7294 BGP_INSTANCE_HELP_STR
7297 BGP_SAFI_WITH_LABEL_HELP_STR
7298 "Address Family modifier\n"
7300 "BGP neighbor address to clear\n"
7301 "BGP IPv6 neighbor to clear\n"
7302 "BGP neighbor on interface to clear\n"
7303 "Clear peers with the AS number\n"
7304 "Clear all external peers\n"
7305 "Clear all members of peer-group\n"
7306 "BGP peer-group name\n"
7311 "Push out prefix-list ORF and do inbound soft reconfig\n"
7316 afi_t afi
= AFI_IP6
;
7317 safi_t safi
= SAFI_UNICAST
;
7318 enum clear_sort clr_sort
= clear_peer
;
7319 enum bgp_clear_type clr_type
;
7320 char *clr_arg
= NULL
;
7324 /* clear [ip] bgp */
7325 if (argv_find(argv
, argc
, "ip", &idx
))
7328 /* [<vrf> VIEWVRFNAME] */
7329 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7330 vrf
= argv
[idx
+ 1]->arg
;
7332 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7334 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7335 /* [<view> VIEWVRFNAME] */
7336 vrf
= argv
[idx
+ 1]->arg
;
7339 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7340 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7341 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7343 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7344 if (argv_find(argv
, argc
, "*", &idx
)) {
7345 clr_sort
= clear_all
;
7346 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7347 clr_sort
= clear_peer
;
7348 clr_arg
= argv
[idx
]->arg
;
7349 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7350 clr_sort
= clear_peer
;
7351 clr_arg
= argv
[idx
]->arg
;
7352 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7353 clr_sort
= clear_group
;
7355 clr_arg
= argv
[idx
]->arg
;
7356 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7357 clr_sort
= clear_peer
;
7358 clr_arg
= argv
[idx
]->arg
;
7359 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7360 clr_sort
= clear_as
;
7361 clr_arg
= argv
[idx
]->arg
;
7362 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7363 clr_sort
= clear_external
;
7366 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7367 if (argv_find(argv
, argc
, "soft", &idx
)) {
7368 if (argv_find(argv
, argc
, "in", &idx
)
7369 || argv_find(argv
, argc
, "out", &idx
))
7370 clr_type
= strmatch(argv
[idx
]->text
, "in")
7372 : BGP_CLEAR_SOFT_OUT
;
7374 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7375 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7376 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7377 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7378 : BGP_CLEAR_SOFT_IN
;
7379 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7380 clr_type
= BGP_CLEAR_SOFT_OUT
;
7382 clr_type
= BGP_CLEAR_SOFT_NONE
;
7384 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7387 DEFUN (clear_ip_bgp_prefix
,
7388 clear_ip_bgp_prefix_cmd
,
7389 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7393 BGP_INSTANCE_HELP_STR
7394 "Clear bestpath and re-advertise\n"
7398 char *prefix
= NULL
;
7402 /* [<view|vrf> VIEWVRFNAME] */
7403 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7404 vrf
= argv
[idx
+ 1]->arg
;
7406 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7408 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7409 /* [<view> VIEWVRFNAME] */
7410 vrf
= argv
[idx
+ 1]->arg
;
7414 prefix
= argv
[argc
- 1]->arg
;
7416 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7419 DEFUN (clear_bgp_ipv6_safi_prefix
,
7420 clear_bgp_ipv6_safi_prefix_cmd
,
7421 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7427 "Clear bestpath and re-advertise\n"
7431 int idx_ipv6_prefix
= 0;
7432 safi_t safi
= SAFI_UNICAST
;
7433 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7434 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7436 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7437 return bgp_clear_prefix(
7438 vty
, NULL
, prefix
, AFI_IP6
,
7442 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7443 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7444 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7448 BGP_INSTANCE_HELP_STR
7451 "Clear bestpath and re-advertise\n"
7455 int idx_vrfview
= 0;
7456 int idx_ipv6_prefix
= 0;
7457 safi_t safi
= SAFI_UNICAST
;
7458 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7459 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7460 char *vrfview
= NULL
;
7462 /* [<view|vrf> VIEWVRFNAME] */
7463 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7464 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7465 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7467 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7468 /* [<view> VIEWVRFNAME] */
7469 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7471 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7473 return bgp_clear_prefix(
7474 vty
, vrfview
, prefix
,
7475 AFI_IP6
, safi
, NULL
);
7478 DEFUN (show_bgp_views
,
7480 "show [ip] bgp views",
7484 "Show the defined BGP views\n")
7486 struct list
*inst
= bm
->bgp
;
7487 struct listnode
*node
;
7490 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7491 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7495 vty_out(vty
, "Defined BGP views:\n");
7496 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7498 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7500 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7507 DEFUN (show_bgp_vrfs
,
7509 "show [ip] bgp vrfs [json]",
7516 char buf
[ETHER_ADDR_STRLEN
];
7517 struct list
*inst
= bm
->bgp
;
7518 struct listnode
*node
;
7520 bool uj
= use_json(argc
, argv
);
7521 json_object
*json
= NULL
;
7522 json_object
*json_vrfs
= NULL
;
7525 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7526 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7531 json
= json_object_new_object();
7532 json_vrfs
= json_object_new_object();
7535 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7536 const char *name
, *type
;
7538 struct listnode
*node2
, *nnode2
;
7539 int peers_cfg
, peers_estb
;
7540 json_object
*json_vrf
= NULL
;
7543 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7547 if (!uj
&& count
== 1)
7549 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7550 "Type", "Id", "routerId", "#PeersVfg",
7551 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7553 peers_cfg
= peers_estb
= 0;
7555 json_vrf
= json_object_new_object();
7558 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7559 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7562 if (peer
->status
== Established
)
7566 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7567 name
= VRF_DEFAULT_NAME
;
7576 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7578 : (int64_t)bgp
->vrf_id
;
7579 json_object_string_add(json_vrf
, "type", type
);
7580 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7581 json_object_string_add(json_vrf
, "routerId",
7582 inet_ntoa(bgp
->router_id
));
7583 json_object_int_add(json_vrf
, "numConfiguredPeers",
7585 json_object_int_add(json_vrf
, "numEstablishedPeers",
7588 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7589 json_object_string_add(
7591 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7592 json_object_object_add(json_vrfs
, name
, json_vrf
);
7595 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7597 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7599 inet_ntoa(bgp
->router_id
), peers_cfg
,
7600 peers_estb
, name
, bgp
->l3vni
,
7601 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7605 json_object_object_add(json
, "vrfs", json_vrfs
);
7607 json_object_int_add(json
, "totalVrfs", count
);
7609 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7610 json
, JSON_C_TO_STRING_PRETTY
));
7611 json_object_free(json
);
7615 "\nTotal number of VRFs (including default): %d\n",
7622 DEFUN (show_bgp_mac_hash
,
7623 show_bgp_mac_hash_cmd
,
7624 "show bgp mac hash",
7628 "Mac Address database\n")
7630 bgp_mac_dump_table(vty
);
7635 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7637 struct vty
*vty
= (struct vty
*)args
;
7638 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7640 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7644 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7646 vty_out(vty
, "self nexthop database:\n");
7647 bgp_nexthop_show_address_hash(vty
, bgp
);
7649 vty_out(vty
, "Tunnel-ip database:\n");
7650 hash_iterate(bgp
->tip_hash
,
7651 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7655 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7656 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7657 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7658 "martian next-hops\n"
7659 "martian next-hop database\n")
7661 struct bgp
*bgp
= NULL
;
7665 /* [<vrf> VIEWVRFNAME] */
7666 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7667 name
= argv
[idx
+ 1]->arg
;
7668 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7670 } else if (argv_find(argv
, argc
, "view", &idx
))
7671 /* [<view> VIEWVRFNAME] */
7672 name
= argv
[idx
+ 1]->arg
;
7674 bgp
= bgp_lookup_by_name(name
);
7676 bgp
= bgp_get_default();
7679 vty_out(vty
, "%% No BGP process is configured\n");
7682 bgp_show_martian_nexthops(vty
, bgp
);
7687 DEFUN (show_bgp_memory
,
7688 show_bgp_memory_cmd
,
7689 "show [ip] bgp memory",
7693 "Global BGP memory statistics\n")
7695 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7696 unsigned long count
;
7698 /* RIB related usage stats */
7699 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7700 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7701 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7702 count
* sizeof(struct bgp_node
)));
7704 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7705 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7706 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7707 count
* sizeof(struct bgp_path_info
)));
7708 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7709 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7712 memstrbuf
, sizeof(memstrbuf
),
7713 count
* sizeof(struct bgp_path_info_extra
)));
7715 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7716 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7717 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7718 count
* sizeof(struct bgp_static
)));
7720 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7721 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7722 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7723 count
* sizeof(struct bpacket
)));
7726 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7727 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7728 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7729 count
* sizeof(struct bgp_adj_in
)));
7730 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7731 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7732 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7733 count
* sizeof(struct bgp_adj_out
)));
7735 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7736 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7738 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7739 count
* sizeof(struct bgp_nexthop_cache
)));
7741 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7742 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7744 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7745 count
* sizeof(struct bgp_damp_info
)));
7748 count
= attr_count();
7749 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7750 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7751 count
* sizeof(struct attr
)));
7753 if ((count
= attr_unknown_count()))
7754 vty_out(vty
, "%ld unknown attributes\n", count
);
7756 /* AS_PATH attributes */
7757 count
= aspath_count();
7758 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7759 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7760 count
* sizeof(struct aspath
)));
7762 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7763 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7764 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7765 count
* sizeof(struct assegment
)));
7767 /* Other attributes */
7768 if ((count
= community_count()))
7769 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7770 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7771 count
* sizeof(struct community
)));
7772 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7773 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7774 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7775 count
* sizeof(struct ecommunity
)));
7776 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7778 "%ld BGP large-community entries, using %s of memory\n",
7779 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7780 count
* sizeof(struct lcommunity
)));
7782 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7783 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7784 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7785 count
* sizeof(struct cluster_list
)));
7787 /* Peer related usage */
7788 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7789 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7790 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7791 count
* sizeof(struct peer
)));
7793 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7794 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7795 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7796 count
* sizeof(struct peer_group
)));
7799 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7800 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7801 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7802 count
* sizeof(struct hash
)));
7803 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7804 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7805 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7806 count
* sizeof(struct hash_bucket
)));
7807 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7808 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7809 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7810 count
* sizeof(regex_t
)));
7814 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7816 json_object
*bestpath
= json_object_new_object();
7818 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7819 json_object_string_add(bestpath
, "asPath", "ignore");
7821 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7822 json_object_string_add(bestpath
, "asPath", "confed");
7824 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7825 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7826 json_object_string_add(bestpath
, "multiPathRelax",
7829 json_object_string_add(bestpath
, "multiPathRelax",
7832 json_object_string_add(bestpath
, "multiPathRelax", "false");
7834 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7835 json_object_string_add(bestpath
, "compareRouterId", "true");
7836 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7837 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7838 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7839 json_object_string_add(bestpath
, "med", "confed");
7840 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7841 json_object_string_add(bestpath
, "med",
7842 "missing-as-worst");
7844 json_object_string_add(bestpath
, "med", "true");
7847 json_object_object_add(json
, "bestPath", bestpath
);
7850 /* Show BGP peer's summary information. */
7851 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7852 bool use_json
, json_object
*json
)
7855 struct listnode
*node
, *nnode
;
7856 unsigned int count
= 0, dn_count
= 0;
7857 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7858 char neighbor_buf
[VTY_BUFSIZ
];
7859 int neighbor_col_default_width
= 16;
7861 int max_neighbor_width
= 0;
7863 json_object
*json_peer
= NULL
;
7864 json_object
*json_peers
= NULL
;
7865 struct peer_af
*paf
;
7867 /* labeled-unicast routes are installed in the unicast table so in order
7869 * display the correct PfxRcd value we must look at SAFI_UNICAST
7871 if (safi
== SAFI_LABELED_UNICAST
)
7872 pfx_rcd_safi
= SAFI_UNICAST
;
7874 pfx_rcd_safi
= safi
;
7878 json
= json_object_new_object();
7880 json_peers
= json_object_new_object();
7882 /* Loop over all neighbors that will be displayed to determine
7884 * characters are needed for the Neighbor column
7886 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7887 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7890 if (peer
->afc
[afi
][safi
]) {
7891 memset(dn_flag
, '\0', sizeof(dn_flag
));
7892 if (peer_dynamic_neighbor(peer
))
7896 && bgp_flag_check(bgp
,
7897 BGP_FLAG_SHOW_HOSTNAME
))
7898 sprintf(neighbor_buf
, "%s%s(%s) ",
7899 dn_flag
, peer
->hostname
,
7902 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7905 len
= strlen(neighbor_buf
);
7907 if (len
> max_neighbor_width
)
7908 max_neighbor_width
= len
;
7912 /* Originally we displayed the Neighbor column as 16
7913 * characters wide so make that the default
7915 if (max_neighbor_width
< neighbor_col_default_width
)
7916 max_neighbor_width
= neighbor_col_default_width
;
7919 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7920 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7923 if (!peer
->afc
[afi
][safi
])
7928 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7931 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7933 : (int64_t)bgp
->vrf_id
;
7935 /* Usage summary and header */
7937 json_object_string_add(
7939 inet_ntoa(bgp
->router_id
));
7940 json_object_int_add(json
, "as", bgp
->as
);
7941 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7942 json_object_string_add(
7945 == BGP_INSTANCE_TYPE_DEFAULT
)
7950 "BGP router identifier %s, local AS number %u vrf-id %d",
7951 inet_ntoa(bgp
->router_id
), bgp
->as
,
7952 bgp
->vrf_id
== VRF_UNKNOWN
7954 : (int)bgp
->vrf_id
);
7958 if (bgp_update_delay_configured(bgp
)) {
7960 json_object_int_add(
7961 json
, "updateDelayLimit",
7962 bgp
->v_update_delay
);
7964 if (bgp
->v_update_delay
7965 != bgp
->v_establish_wait
)
7966 json_object_int_add(
7968 "updateDelayEstablishWait",
7969 bgp
->v_establish_wait
);
7971 if (bgp_update_delay_active(bgp
)) {
7972 json_object_string_add(
7974 "updateDelayFirstNeighbor",
7975 bgp
->update_delay_begin_time
);
7976 json_object_boolean_true_add(
7978 "updateDelayInProgress");
7980 if (bgp
->update_delay_over
) {
7981 json_object_string_add(
7983 "updateDelayFirstNeighbor",
7984 bgp
->update_delay_begin_time
);
7985 json_object_string_add(
7987 "updateDelayBestpathResumed",
7988 bgp
->update_delay_end_time
);
7989 json_object_string_add(
7991 "updateDelayZebraUpdateResume",
7992 bgp
->update_delay_zebra_resume_time
);
7993 json_object_string_add(
7995 "updateDelayPeerUpdateResume",
7996 bgp
->update_delay_peers_resume_time
);
8001 "Read-only mode update-delay limit: %d seconds\n",
8002 bgp
->v_update_delay
);
8003 if (bgp
->v_update_delay
8004 != bgp
->v_establish_wait
)
8006 " Establish wait: %d seconds\n",
8007 bgp
->v_establish_wait
);
8009 if (bgp_update_delay_active(bgp
)) {
8011 " First neighbor established: %s\n",
8012 bgp
->update_delay_begin_time
);
8014 " Delay in progress\n");
8016 if (bgp
->update_delay_over
) {
8018 " First neighbor established: %s\n",
8019 bgp
->update_delay_begin_time
);
8021 " Best-paths resumed: %s\n",
8022 bgp
->update_delay_end_time
);
8024 " zebra update resumed: %s\n",
8025 bgp
->update_delay_zebra_resume_time
);
8027 " peers update resumed: %s\n",
8028 bgp
->update_delay_peers_resume_time
);
8035 if (bgp_maxmed_onstartup_configured(bgp
)
8036 && bgp
->maxmed_active
)
8037 json_object_boolean_true_add(
8038 json
, "maxMedOnStartup");
8039 if (bgp
->v_maxmed_admin
)
8040 json_object_boolean_true_add(
8041 json
, "maxMedAdministrative");
8043 json_object_int_add(
8044 json
, "tableVersion",
8045 bgp_table_version(bgp
->rib
[afi
][safi
]));
8047 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8048 json_object_int_add(json
, "ribCount", ents
);
8049 json_object_int_add(
8051 ents
* sizeof(struct bgp_node
));
8053 ents
= bgp
->af_peer_count
[afi
][safi
];
8054 json_object_int_add(json
, "peerCount", ents
);
8055 json_object_int_add(json
, "peerMemory",
8056 ents
* sizeof(struct peer
));
8058 if ((ents
= listcount(bgp
->group
))) {
8059 json_object_int_add(
8060 json
, "peerGroupCount", ents
);
8061 json_object_int_add(
8062 json
, "peerGroupMemory",
8063 ents
* sizeof(struct
8067 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8068 BGP_CONFIG_DAMPENING
))
8069 json_object_boolean_true_add(
8070 json
, "dampeningEnabled");
8072 if (bgp_maxmed_onstartup_configured(bgp
)
8073 && bgp
->maxmed_active
)
8075 "Max-med on-startup active\n");
8076 if (bgp
->v_maxmed_admin
)
8078 "Max-med administrative active\n");
8080 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8081 bgp_table_version(bgp
->rib
[afi
][safi
]));
8083 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8085 "RIB entries %ld, using %s of memory\n",
8087 mtype_memstr(memstrbuf
,
8089 ents
* sizeof(struct
8092 /* Peer related usage */
8093 ents
= bgp
->af_peer_count
[afi
][safi
];
8094 vty_out(vty
, "Peers %ld, using %s of memory\n",
8097 memstrbuf
, sizeof(memstrbuf
),
8098 ents
* sizeof(struct peer
)));
8100 if ((ents
= listcount(bgp
->group
)))
8102 "Peer groups %ld, using %s of memory\n",
8107 ents
* sizeof(struct
8110 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8111 BGP_CONFIG_DAMPENING
))
8112 vty_out(vty
, "Dampening enabled.\n");
8115 /* Subtract 8 here because 'Neighbor' is
8117 vty_out(vty
, "Neighbor");
8118 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8121 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8128 json_peer
= json_object_new_object();
8130 if (peer_dynamic_neighbor(peer
)) {
8132 json_object_boolean_true_add(json_peer
,
8137 json_object_string_add(json_peer
, "hostname",
8140 if (peer
->domainname
)
8141 json_object_string_add(json_peer
, "domainname",
8144 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8145 json_object_int_add(json_peer
, "version", 4);
8146 json_object_int_add(json_peer
, "msgRcvd",
8147 PEER_TOTAL_RX(peer
));
8148 json_object_int_add(json_peer
, "msgSent",
8149 PEER_TOTAL_TX(peer
));
8151 json_object_int_add(json_peer
, "tableVersion",
8152 peer
->version
[afi
][safi
]);
8153 json_object_int_add(json_peer
, "outq",
8155 json_object_int_add(json_peer
, "inq", 0);
8156 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8157 use_json
, json_peer
);
8160 * Adding "pfxRcd" field to match with the corresponding
8161 * CLI. "prefixReceivedCount" will be deprecated in
8164 json_object_int_add(json_peer
, "prefixReceivedCount",
8165 peer
->pcount
[afi
][pfx_rcd_safi
]);
8166 json_object_int_add(json_peer
, "pfxRcd",
8167 peer
->pcount
[afi
][pfx_rcd_safi
]);
8169 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8170 if (paf
&& PAF_SUBGRP(paf
))
8171 json_object_int_add(json_peer
,
8173 (PAF_SUBGRP(paf
))->scount
);
8175 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8176 json_object_string_add(json_peer
, "state",
8178 else if (peer
->afc_recv
[afi
][safi
])
8179 json_object_string_add(
8181 lookup_msg(bgp_status_msg
, peer
->status
,
8183 else if (CHECK_FLAG(peer
->sflags
,
8184 PEER_STATUS_PREFIX_OVERFLOW
))
8185 json_object_string_add(json_peer
, "state",
8188 json_object_string_add(
8190 lookup_msg(bgp_status_msg
, peer
->status
,
8194 json_object_string_add(json_peer
, "idType",
8196 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8197 json_object_string_add(json_peer
, "idType",
8199 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8200 json_object_string_add(json_peer
, "idType",
8203 json_object_object_add(json_peers
, peer
->host
,
8206 memset(dn_flag
, '\0', sizeof(dn_flag
));
8207 if (peer_dynamic_neighbor(peer
)) {
8213 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8214 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8215 peer
->hostname
, peer
->host
);
8217 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8219 /* pad the neighbor column with spaces */
8220 if (len
< max_neighbor_width
)
8221 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8224 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8225 peer
->as
, PEER_TOTAL_RX(peer
),
8226 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8227 0, peer
->obuf
->count
,
8228 peer_uptime(peer
->uptime
, timebuf
,
8229 BGP_UPTIME_LEN
, 0, NULL
));
8231 if (peer
->status
== Established
)
8232 if (peer
->afc_recv
[afi
][safi
])
8233 vty_out(vty
, " %12ld",
8237 vty_out(vty
, " NoNeg");
8239 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8240 vty_out(vty
, " Idle (Admin)");
8241 else if (CHECK_FLAG(
8243 PEER_STATUS_PREFIX_OVERFLOW
))
8244 vty_out(vty
, " Idle (PfxCt)");
8246 vty_out(vty
, " %12s",
8247 lookup_msg(bgp_status_msg
,
8248 peer
->status
, NULL
));
8255 json_object_object_add(json
, "peers", json_peers
);
8257 json_object_int_add(json
, "totalPeers", count
);
8258 json_object_int_add(json
, "dynamicPeers", dn_count
);
8260 bgp_show_bestpath_json(bgp
, json
);
8262 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8263 json
, JSON_C_TO_STRING_PRETTY
));
8264 json_object_free(json
);
8267 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8269 vty_out(vty
, "No %s neighbor is configured\n",
8270 afi_safi_print(afi
, safi
));
8274 vty_out(vty
, "* - dynamic neighbor\n");
8275 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8276 dn_count
, bgp
->dynamic_neighbors_limit
);
8283 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8284 int safi
, bool use_json
,
8288 int afi_wildcard
= (afi
== AFI_MAX
);
8289 int safi_wildcard
= (safi
== SAFI_MAX
);
8290 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8291 bool nbr_output
= false;
8293 if (use_json
&& is_wildcard
)
8294 vty_out(vty
, "{\n");
8296 afi
= 1; /* AFI_IP */
8297 while (afi
< AFI_MAX
) {
8299 safi
= 1; /* SAFI_UNICAST */
8300 while (safi
< SAFI_MAX
) {
8301 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8305 * So limit output to those afi/safi
8307 * actualy have something interesting in
8311 json
= json_object_new_object();
8314 vty_out(vty
, ",\n");
8318 vty_out(vty
, "\"%s\":",
8322 vty_out(vty
, "\n%s Summary:\n",
8327 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8339 if (use_json
&& is_wildcard
)
8340 vty_out(vty
, "}\n");
8341 else if (!nbr_output
) {
8343 vty_out(vty
, "{}\n");
8345 vty_out(vty
, "%% No BGP neighbors found\n");
8349 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8350 safi_t safi
, bool use_json
)
8352 struct listnode
*node
, *nnode
;
8354 json_object
*json
= NULL
;
8356 bool nbr_output
= false;
8359 vty_out(vty
, "{\n");
8361 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8364 json
= json_object_new_object();
8367 vty_out(vty
, ",\n");
8371 vty_out(vty
, "\"%s\":",
8372 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8376 vty_out(vty
, "\nInstance %s:\n",
8377 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8381 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8385 vty_out(vty
, "}\n");
8386 else if (!nbr_output
)
8387 vty_out(vty
, "%% BGP instance not found\n");
8390 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8391 safi_t safi
, bool use_json
)
8396 if (strmatch(name
, "all")) {
8397 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8401 bgp
= bgp_lookup_by_name(name
);
8405 vty_out(vty
, "{}\n");
8408 "%% BGP instance not found\n");
8412 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8418 bgp
= bgp_get_default();
8421 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8424 vty_out(vty
, "{}\n");
8426 vty_out(vty
, "%% BGP instance not found\n");
8433 /* `show [ip] bgp summary' commands. */
8434 DEFUN (show_ip_bgp_summary
,
8435 show_ip_bgp_summary_cmd
,
8436 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8440 BGP_INSTANCE_HELP_STR
8442 BGP_SAFI_WITH_LABEL_HELP_STR
8443 "Summary of BGP neighbor status\n"
8447 afi_t afi
= AFI_MAX
;
8448 safi_t safi
= SAFI_MAX
;
8453 if (argv_find(argv
, argc
, "ip", &idx
))
8455 /* [<vrf> VIEWVRFNAME] */
8456 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8457 vrf
= argv
[idx
+ 1]->arg
;
8458 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8460 } else if (argv_find(argv
, argc
, "view", &idx
))
8461 /* [<view> VIEWVRFNAME] */
8462 vrf
= argv
[idx
+ 1]->arg
;
8463 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8464 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8465 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8468 bool uj
= use_json(argc
, argv
);
8470 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8473 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8475 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8476 return "IPv4 Unicast";
8477 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8478 return "IPv4 Multicast";
8479 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8480 return "IPv4 Labeled Unicast";
8481 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8483 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8484 return "IPv4 Encap";
8485 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8486 return "IPv4 Flowspec";
8487 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8488 return "IPv6 Unicast";
8489 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8490 return "IPv6 Multicast";
8491 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8492 return "IPv6 Labeled Unicast";
8493 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8495 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8496 return "IPv6 Encap";
8497 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8498 return "IPv6 Flowspec";
8499 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8500 return "L2VPN EVPN";
8506 * Please note that we have intentionally camelCased
8507 * the return strings here. So if you want
8508 * to use this function, please ensure you
8509 * are doing this within json output
8511 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8513 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8514 return "ipv4Unicast";
8515 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8516 return "ipv4Multicast";
8517 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8518 return "ipv4LabeledUnicast";
8519 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8521 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8523 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8524 return "ipv4Flowspec";
8525 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8526 return "ipv6Unicast";
8527 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8528 return "ipv6Multicast";
8529 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8530 return "ipv6LabeledUnicast";
8531 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8533 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8535 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8536 return "ipv6Flowspec";
8537 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8543 /* Show BGP peer's information. */
8544 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8546 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8547 afi_t afi
, safi_t safi
,
8548 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8549 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8550 bool use_json
, json_object
*json_pref
)
8553 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8554 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8556 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8557 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8558 json_object_string_add(json_pref
, "sendMode",
8559 "advertisedAndReceived");
8560 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8561 json_object_string_add(json_pref
, "sendMode",
8563 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8564 json_object_string_add(json_pref
, "sendMode",
8567 vty_out(vty
, " Send-mode: ");
8568 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8569 vty_out(vty
, "advertised");
8570 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8571 vty_out(vty
, "%sreceived",
8572 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8581 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8582 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8584 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8585 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8586 json_object_string_add(json_pref
, "recvMode",
8587 "advertisedAndReceived");
8588 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8589 json_object_string_add(json_pref
, "recvMode",
8591 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8592 json_object_string_add(json_pref
, "recvMode",
8595 vty_out(vty
, " Receive-mode: ");
8596 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8597 vty_out(vty
, "advertised");
8598 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8599 vty_out(vty
, "%sreceived",
8600 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8609 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8610 safi_t safi
, bool use_json
,
8611 json_object
*json_neigh
)
8613 struct bgp_filter
*filter
;
8614 struct peer_af
*paf
;
8615 char orf_pfx_name
[BUFSIZ
];
8617 json_object
*json_af
= NULL
;
8618 json_object
*json_prefA
= NULL
;
8619 json_object
*json_prefB
= NULL
;
8620 json_object
*json_addr
= NULL
;
8623 json_addr
= json_object_new_object();
8624 json_af
= json_object_new_object();
8625 filter
= &p
->filter
[afi
][safi
];
8627 if (peer_group_active(p
))
8628 json_object_string_add(json_addr
, "peerGroupMember",
8631 paf
= peer_af_find(p
, afi
, safi
);
8632 if (paf
&& PAF_SUBGRP(paf
)) {
8633 json_object_int_add(json_addr
, "updateGroupId",
8634 PAF_UPDGRP(paf
)->id
);
8635 json_object_int_add(json_addr
, "subGroupId",
8636 PAF_SUBGRP(paf
)->id
);
8637 json_object_int_add(json_addr
, "packetQueueLength",
8638 bpacket_queue_virtual_length(paf
));
8641 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8642 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8643 PEER_CAP_ORF_PREFIX_SM_RCV
)
8644 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8645 PEER_CAP_ORF_PREFIX_RM_ADV
)
8646 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8647 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8648 json_object_int_add(json_af
, "orfType",
8650 json_prefA
= json_object_new_object();
8651 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8652 PEER_CAP_ORF_PREFIX_SM_ADV
,
8653 PEER_CAP_ORF_PREFIX_RM_ADV
,
8654 PEER_CAP_ORF_PREFIX_SM_RCV
,
8655 PEER_CAP_ORF_PREFIX_RM_RCV
,
8656 use_json
, json_prefA
);
8657 json_object_object_add(json_af
, "orfPrefixList",
8661 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8662 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8663 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8664 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8665 PEER_CAP_ORF_PREFIX_RM_ADV
)
8666 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8667 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8668 json_object_int_add(json_af
, "orfOldType",
8669 ORF_TYPE_PREFIX_OLD
);
8670 json_prefB
= json_object_new_object();
8671 bgp_show_peer_afi_orf_cap(
8672 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8673 PEER_CAP_ORF_PREFIX_RM_ADV
,
8674 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8675 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8677 json_object_object_add(json_af
, "orfOldPrefixList",
8681 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8682 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8683 PEER_CAP_ORF_PREFIX_SM_RCV
)
8684 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8685 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8686 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8687 PEER_CAP_ORF_PREFIX_RM_ADV
)
8688 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8689 PEER_CAP_ORF_PREFIX_RM_RCV
)
8690 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8691 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8692 json_object_object_add(json_addr
, "afDependentCap",
8695 json_object_free(json_af
);
8697 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8698 orf_pfx_count
= prefix_bgp_show_prefix_list(
8699 NULL
, afi
, orf_pfx_name
, use_json
);
8701 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8702 PEER_STATUS_ORF_PREFIX_SEND
)
8704 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8705 PEER_STATUS_ORF_PREFIX_SEND
))
8706 json_object_boolean_true_add(json_neigh
,
8709 json_object_int_add(json_addr
, "orfRecvCounter",
8712 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8713 PEER_STATUS_ORF_WAIT_REFRESH
))
8714 json_object_string_add(
8715 json_addr
, "orfFirstUpdate",
8716 "deferredUntilORFOrRouteRefreshRecvd");
8718 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8719 PEER_FLAG_REFLECTOR_CLIENT
))
8720 json_object_boolean_true_add(json_addr
,
8721 "routeReflectorClient");
8722 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8723 PEER_FLAG_RSERVER_CLIENT
))
8724 json_object_boolean_true_add(json_addr
,
8725 "routeServerClient");
8726 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8727 json_object_boolean_true_add(json_addr
,
8728 "inboundSoftConfigPermit");
8730 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8731 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8732 json_object_boolean_true_add(
8734 "privateAsNumsAllReplacedInUpdatesToNbr");
8735 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8736 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8737 json_object_boolean_true_add(
8739 "privateAsNumsReplacedInUpdatesToNbr");
8740 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8741 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8742 json_object_boolean_true_add(
8744 "privateAsNumsAllRemovedInUpdatesToNbr");
8745 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8746 PEER_FLAG_REMOVE_PRIVATE_AS
))
8747 json_object_boolean_true_add(
8749 "privateAsNumsRemovedInUpdatesToNbr");
8751 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8752 json_object_boolean_true_add(
8754 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8757 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8758 json_object_string_add(json_addr
,
8759 "overrideASNsInOutboundUpdates",
8760 "ifAspathEqualRemoteAs");
8762 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8763 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8764 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8765 json_object_boolean_true_add(json_addr
,
8766 "routerAlwaysNextHop");
8767 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8768 PEER_FLAG_AS_PATH_UNCHANGED
))
8769 json_object_boolean_true_add(
8770 json_addr
, "unchangedAsPathPropogatedToNbr");
8771 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8772 PEER_FLAG_NEXTHOP_UNCHANGED
))
8773 json_object_boolean_true_add(
8774 json_addr
, "unchangedNextHopPropogatedToNbr");
8775 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8776 json_object_boolean_true_add(
8777 json_addr
, "unchangedMedPropogatedToNbr");
8778 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8779 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8780 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8781 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8782 PEER_FLAG_SEND_COMMUNITY
)
8783 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8784 PEER_FLAG_SEND_EXT_COMMUNITY
))
8785 json_object_string_add(json_addr
,
8786 "commAttriSentToNbr",
8787 "extendedAndStandard");
8788 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8789 PEER_FLAG_SEND_EXT_COMMUNITY
))
8790 json_object_string_add(json_addr
,
8791 "commAttriSentToNbr",
8794 json_object_string_add(json_addr
,
8795 "commAttriSentToNbr",
8798 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8799 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8800 if (p
->default_rmap
[afi
][safi
].name
)
8801 json_object_string_add(
8802 json_addr
, "defaultRouteMap",
8803 p
->default_rmap
[afi
][safi
].name
);
8805 if (paf
&& PAF_SUBGRP(paf
)
8806 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8807 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8808 json_object_boolean_true_add(json_addr
,
8811 json_object_boolean_true_add(json_addr
,
8815 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8816 if (is_evpn_enabled())
8817 json_object_boolean_true_add(
8818 json_addr
, "advertiseAllVnis");
8821 if (filter
->plist
[FILTER_IN
].name
8822 || filter
->dlist
[FILTER_IN
].name
8823 || filter
->aslist
[FILTER_IN
].name
8824 || filter
->map
[RMAP_IN
].name
)
8825 json_object_boolean_true_add(json_addr
,
8826 "inboundPathPolicyConfig");
8827 if (filter
->plist
[FILTER_OUT
].name
8828 || filter
->dlist
[FILTER_OUT
].name
8829 || filter
->aslist
[FILTER_OUT
].name
8830 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8831 json_object_boolean_true_add(
8832 json_addr
, "outboundPathPolicyConfig");
8835 if (filter
->plist
[FILTER_IN
].name
)
8836 json_object_string_add(json_addr
,
8837 "incomingUpdatePrefixFilterList",
8838 filter
->plist
[FILTER_IN
].name
);
8839 if (filter
->plist
[FILTER_OUT
].name
)
8840 json_object_string_add(json_addr
,
8841 "outgoingUpdatePrefixFilterList",
8842 filter
->plist
[FILTER_OUT
].name
);
8844 /* distribute-list */
8845 if (filter
->dlist
[FILTER_IN
].name
)
8846 json_object_string_add(
8847 json_addr
, "incomingUpdateNetworkFilterList",
8848 filter
->dlist
[FILTER_IN
].name
);
8849 if (filter
->dlist
[FILTER_OUT
].name
)
8850 json_object_string_add(
8851 json_addr
, "outgoingUpdateNetworkFilterList",
8852 filter
->dlist
[FILTER_OUT
].name
);
8855 if (filter
->aslist
[FILTER_IN
].name
)
8856 json_object_string_add(json_addr
,
8857 "incomingUpdateAsPathFilterList",
8858 filter
->aslist
[FILTER_IN
].name
);
8859 if (filter
->aslist
[FILTER_OUT
].name
)
8860 json_object_string_add(json_addr
,
8861 "outgoingUpdateAsPathFilterList",
8862 filter
->aslist
[FILTER_OUT
].name
);
8865 if (filter
->map
[RMAP_IN
].name
)
8866 json_object_string_add(
8867 json_addr
, "routeMapForIncomingAdvertisements",
8868 filter
->map
[RMAP_IN
].name
);
8869 if (filter
->map
[RMAP_OUT
].name
)
8870 json_object_string_add(
8871 json_addr
, "routeMapForOutgoingAdvertisements",
8872 filter
->map
[RMAP_OUT
].name
);
8874 /* ebgp-requires-policy (inbound) */
8875 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8876 && !bgp_inbound_policy_exists(p
, filter
))
8877 json_object_string_add(
8878 json_addr
, "inboundEbgpRequiresPolicy",
8879 "Inbound updates discarded due to missing policy");
8881 /* ebgp-requires-policy (outbound) */
8882 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8883 && (!bgp_outbound_policy_exists(p
, filter
)))
8884 json_object_string_add(
8885 json_addr
, "outboundEbgpRequiresPolicy",
8886 "Outbound updates discarded due to missing policy");
8888 /* unsuppress-map */
8889 if (filter
->usmap
.name
)
8890 json_object_string_add(json_addr
,
8891 "selectiveUnsuppressRouteMap",
8892 filter
->usmap
.name
);
8894 /* Receive prefix count */
8895 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8896 p
->pcount
[afi
][safi
]);
8897 if (paf
&& PAF_SUBGRP(paf
))
8898 json_object_int_add(json_addr
, "sentPrefixCounter",
8899 (PAF_SUBGRP(paf
))->scount
);
8901 /* Maximum prefix */
8902 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8903 json_object_int_add(json_addr
, "prefixAllowedMax",
8904 p
->pmax
[afi
][safi
]);
8905 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8906 PEER_FLAG_MAX_PREFIX_WARNING
))
8907 json_object_boolean_true_add(
8908 json_addr
, "prefixAllowedMaxWarning");
8909 json_object_int_add(json_addr
,
8910 "prefixAllowedWarningThresh",
8911 p
->pmax_threshold
[afi
][safi
]);
8912 if (p
->pmax_restart
[afi
][safi
])
8913 json_object_int_add(
8915 "prefixAllowedRestartIntervalMsecs",
8916 p
->pmax_restart
[afi
][safi
] * 60000);
8918 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8922 filter
= &p
->filter
[afi
][safi
];
8924 vty_out(vty
, " For address family: %s\n",
8925 afi_safi_print(afi
, safi
));
8927 if (peer_group_active(p
))
8928 vty_out(vty
, " %s peer-group member\n",
8931 paf
= peer_af_find(p
, afi
, safi
);
8932 if (paf
&& PAF_SUBGRP(paf
)) {
8933 vty_out(vty
, " Update group %" PRIu64
8934 ", subgroup %" PRIu64
"\n",
8935 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8936 vty_out(vty
, " Packet Queue length %d\n",
8937 bpacket_queue_virtual_length(paf
));
8939 vty_out(vty
, " Not part of any update group\n");
8941 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8942 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8943 PEER_CAP_ORF_PREFIX_SM_RCV
)
8944 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8945 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8946 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8947 PEER_CAP_ORF_PREFIX_RM_ADV
)
8948 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8949 PEER_CAP_ORF_PREFIX_RM_RCV
)
8950 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8951 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8952 vty_out(vty
, " AF-dependant capabilities:\n");
8954 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8955 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8956 PEER_CAP_ORF_PREFIX_SM_RCV
)
8957 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8958 PEER_CAP_ORF_PREFIX_RM_ADV
)
8959 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8960 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8962 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8964 bgp_show_peer_afi_orf_cap(
8965 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8966 PEER_CAP_ORF_PREFIX_RM_ADV
,
8967 PEER_CAP_ORF_PREFIX_SM_RCV
,
8968 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8970 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8971 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8972 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8973 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8974 PEER_CAP_ORF_PREFIX_RM_ADV
)
8975 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8976 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8978 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8979 ORF_TYPE_PREFIX_OLD
);
8980 bgp_show_peer_afi_orf_cap(
8981 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8982 PEER_CAP_ORF_PREFIX_RM_ADV
,
8983 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8984 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8987 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8988 orf_pfx_count
= prefix_bgp_show_prefix_list(
8989 NULL
, afi
, orf_pfx_name
, use_json
);
8991 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8992 PEER_STATUS_ORF_PREFIX_SEND
)
8994 vty_out(vty
, " Outbound Route Filter (ORF):");
8995 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8996 PEER_STATUS_ORF_PREFIX_SEND
))
8997 vty_out(vty
, " sent;");
8999 vty_out(vty
, " received (%d entries)",
9003 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9004 PEER_STATUS_ORF_WAIT_REFRESH
))
9006 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
9008 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9009 PEER_FLAG_REFLECTOR_CLIENT
))
9010 vty_out(vty
, " Route-Reflector Client\n");
9011 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9012 PEER_FLAG_RSERVER_CLIENT
))
9013 vty_out(vty
, " Route-Server Client\n");
9014 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9016 " Inbound soft reconfiguration allowed\n");
9018 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9019 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9021 " Private AS numbers (all) replaced in updates to this neighbor\n");
9022 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9023 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9025 " Private AS numbers replaced in updates to this neighbor\n");
9026 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9027 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9029 " Private AS numbers (all) removed in updates to this neighbor\n");
9030 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9031 PEER_FLAG_REMOVE_PRIVATE_AS
))
9033 " Private AS numbers removed in updates to this neighbor\n");
9035 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9036 vty_out(vty
, " %s\n",
9037 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9038 ->human_description
);
9040 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9042 " Override ASNs in outbound updates if aspath equals remote-as\n");
9044 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9045 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9046 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9047 vty_out(vty
, " NEXT_HOP is always this router\n");
9048 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9049 PEER_FLAG_AS_PATH_UNCHANGED
))
9051 " AS_PATH is propagated unchanged to this neighbor\n");
9052 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9053 PEER_FLAG_NEXTHOP_UNCHANGED
))
9055 " NEXT_HOP is propagated unchanged to this neighbor\n");
9056 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9058 " MED is propagated unchanged to this neighbor\n");
9059 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9060 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9061 PEER_FLAG_SEND_EXT_COMMUNITY
)
9062 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9063 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9065 " Community attribute sent to this neighbor");
9066 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9067 PEER_FLAG_SEND_COMMUNITY
)
9068 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9069 PEER_FLAG_SEND_EXT_COMMUNITY
)
9070 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9071 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9072 vty_out(vty
, "(all)\n");
9073 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9074 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9075 vty_out(vty
, "(large)\n");
9076 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9077 PEER_FLAG_SEND_EXT_COMMUNITY
))
9078 vty_out(vty
, "(extended)\n");
9080 vty_out(vty
, "(standard)\n");
9082 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9083 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9084 vty_out(vty
, " Default information originate,");
9086 if (p
->default_rmap
[afi
][safi
].name
)
9087 vty_out(vty
, " default route-map %s%s,",
9088 p
->default_rmap
[afi
][safi
].map
? "*"
9090 p
->default_rmap
[afi
][safi
].name
);
9091 if (paf
&& PAF_SUBGRP(paf
)
9092 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9093 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9094 vty_out(vty
, " default sent\n");
9096 vty_out(vty
, " default not sent\n");
9099 /* advertise-vni-all */
9100 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9101 if (is_evpn_enabled())
9102 vty_out(vty
, " advertise-all-vni\n");
9105 if (filter
->plist
[FILTER_IN
].name
9106 || filter
->dlist
[FILTER_IN
].name
9107 || filter
->aslist
[FILTER_IN
].name
9108 || filter
->map
[RMAP_IN
].name
)
9109 vty_out(vty
, " Inbound path policy configured\n");
9110 if (filter
->plist
[FILTER_OUT
].name
9111 || filter
->dlist
[FILTER_OUT
].name
9112 || filter
->aslist
[FILTER_OUT
].name
9113 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9114 vty_out(vty
, " Outbound path policy configured\n");
9117 if (filter
->plist
[FILTER_IN
].name
)
9119 " Incoming update prefix filter list is %s%s\n",
9120 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9121 filter
->plist
[FILTER_IN
].name
);
9122 if (filter
->plist
[FILTER_OUT
].name
)
9124 " Outgoing update prefix filter list is %s%s\n",
9125 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9126 filter
->plist
[FILTER_OUT
].name
);
9128 /* distribute-list */
9129 if (filter
->dlist
[FILTER_IN
].name
)
9131 " Incoming update network filter list is %s%s\n",
9132 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9133 filter
->dlist
[FILTER_IN
].name
);
9134 if (filter
->dlist
[FILTER_OUT
].name
)
9136 " Outgoing update network filter list is %s%s\n",
9137 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9138 filter
->dlist
[FILTER_OUT
].name
);
9141 if (filter
->aslist
[FILTER_IN
].name
)
9143 " Incoming update AS path filter list is %s%s\n",
9144 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9145 filter
->aslist
[FILTER_IN
].name
);
9146 if (filter
->aslist
[FILTER_OUT
].name
)
9148 " Outgoing update AS path filter list is %s%s\n",
9149 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9150 filter
->aslist
[FILTER_OUT
].name
);
9153 if (filter
->map
[RMAP_IN
].name
)
9155 " Route map for incoming advertisements is %s%s\n",
9156 filter
->map
[RMAP_IN
].map
? "*" : "",
9157 filter
->map
[RMAP_IN
].name
);
9158 if (filter
->map
[RMAP_OUT
].name
)
9160 " Route map for outgoing advertisements is %s%s\n",
9161 filter
->map
[RMAP_OUT
].map
? "*" : "",
9162 filter
->map
[RMAP_OUT
].name
);
9164 /* ebgp-requires-policy (inbound) */
9165 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9166 && !bgp_inbound_policy_exists(p
, filter
))
9168 " Inbound updates discarded due to missing policy\n");
9170 /* ebgp-requires-policy (outbound) */
9171 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9172 && !bgp_outbound_policy_exists(p
, filter
))
9174 " Outbound updates discarded due to missing policy\n");
9176 /* unsuppress-map */
9177 if (filter
->usmap
.name
)
9179 " Route map for selective unsuppress is %s%s\n",
9180 filter
->usmap
.map
? "*" : "",
9181 filter
->usmap
.name
);
9183 /* Receive prefix count */
9184 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9186 /* Maximum prefix */
9187 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9188 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9190 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9191 PEER_FLAG_MAX_PREFIX_WARNING
)
9194 vty_out(vty
, " Threshold for warning message %d%%",
9195 p
->pmax_threshold
[afi
][safi
]);
9196 if (p
->pmax_restart
[afi
][safi
])
9197 vty_out(vty
, ", restart interval %d min",
9198 p
->pmax_restart
[afi
][safi
]);
9206 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9210 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9211 char timebuf
[BGP_UPTIME_LEN
];
9213 const char *subcode_str
;
9214 const char *code_str
;
9219 json_object
*json_neigh
= NULL
;
9225 json_neigh
= json_object_new_object();
9227 memset(dn_flag
, '\0', sizeof(dn_flag
));
9228 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9232 if (p
->conf_if
) /* Configured interface name. */
9233 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9234 BGP_PEER_SU_UNSPEC(p
)
9236 : sockunion2str(&p
->su
, buf
,
9238 else /* Configured IP address. */
9239 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9244 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9245 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9247 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9248 json_object_string_add(
9249 json_neigh
, "bgpNeighborAddr",
9250 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9252 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9254 if (p
->change_local_as
)
9255 json_object_int_add(json_neigh
, "localAs",
9256 p
->change_local_as
);
9258 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9260 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9261 json_object_boolean_true_add(json_neigh
,
9262 "localAsNoPrepend");
9264 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9265 json_object_boolean_true_add(json_neigh
,
9266 "localAsReplaceAs");
9268 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9269 || (p
->as_type
== AS_INTERNAL
))
9270 vty_out(vty
, "remote AS %u, ", p
->as
);
9272 vty_out(vty
, "remote AS Unspecified, ");
9273 vty_out(vty
, "local AS %u%s%s, ",
9274 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9275 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9278 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9282 /* peer type internal or confed-internal */
9283 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9285 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9286 json_object_boolean_true_add(
9287 json_neigh
, "nbrConfedInternalLink");
9289 json_object_boolean_true_add(json_neigh
,
9292 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9293 vty_out(vty
, "confed-internal link\n");
9295 vty_out(vty
, "internal link\n");
9297 /* peer type external or confed-external */
9298 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9300 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9301 json_object_boolean_true_add(
9302 json_neigh
, "nbrConfedExternalLink");
9304 json_object_boolean_true_add(json_neigh
,
9307 if (bgp_confederation_peers_check(bgp
, p
->as
))
9308 vty_out(vty
, "confed-external link\n");
9310 vty_out(vty
, "external link\n");
9314 json_object_boolean_true_add(json_neigh
,
9315 "nbrUnspecifiedLink");
9317 vty_out(vty
, "unspecified link\n");
9323 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9325 vty_out(vty
, " Description: %s\n", p
->desc
);
9331 json_object_string_add(json_neigh
, "hostname",
9335 json_object_string_add(json_neigh
, "domainname",
9338 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9339 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9342 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9349 json_object_string_add(json_neigh
, "peerGroup",
9353 struct prefix prefix
, *range
= NULL
;
9355 sockunion2hostprefix(&(p
->su
), &prefix
);
9356 range
= peer_group_lookup_dynamic_neighbor_range(
9360 prefix2str(range
, buf1
, sizeof(buf1
));
9361 json_object_string_add(
9363 "peerSubnetRangeGroup", buf1
);
9368 " Member of peer-group %s for session parameters\n",
9372 struct prefix prefix
, *range
= NULL
;
9374 sockunion2hostprefix(&(p
->su
), &prefix
);
9375 range
= peer_group_lookup_dynamic_neighbor_range(
9379 prefix2str(range
, buf1
, sizeof(buf1
));
9381 " Belongs to the subnet range group: %s\n",
9389 /* Administrative shutdown. */
9390 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9391 json_object_boolean_true_add(json_neigh
,
9395 json_object_int_add(json_neigh
, "bgpVersion", 4);
9396 json_object_string_add(
9397 json_neigh
, "remoteRouterId",
9398 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9399 json_object_string_add(
9400 json_neigh
, "localRouterId",
9401 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9405 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9406 && bgp_confederation_peers_check(bgp
, p
->as
))
9407 json_object_boolean_true_add(json_neigh
,
9411 json_object_string_add(
9412 json_neigh
, "bgpState",
9413 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9415 if (p
->status
== Established
) {
9418 uptime
= bgp_clock();
9419 uptime
-= p
->uptime
;
9420 epoch_tbuf
= time(NULL
) - uptime
;
9422 #if CONFDATE > 20200101
9424 "bgpTimerUp should be deprecated and can be removed now");
9427 * bgpTimerUp was miliseconds that was accurate
9428 * up to 1 day, then the value returned
9429 * became garbage. So in order to provide
9430 * some level of backwards compatability,
9431 * we still provde the data, but now
9432 * we are returning the correct value
9433 * and also adding a new bgpTimerUpMsec
9434 * which will allow us to deprecate
9437 json_object_int_add(json_neigh
, "bgpTimerUp",
9439 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9441 json_object_string_add(json_neigh
, "bgpTimerUpString",
9442 peer_uptime(p
->uptime
, timebuf
,
9445 json_object_int_add(json_neigh
,
9446 "bgpTimerUpEstablishedEpoch",
9450 else if (p
->status
== Active
) {
9451 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9452 json_object_string_add(json_neigh
, "bgpStateIs",
9454 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9455 json_object_string_add(json_neigh
, "bgpStateIs",
9463 uptime
= bgp_clock();
9464 uptime
-= p
->readtime
;
9465 tm
= gmtime(&uptime
);
9466 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9467 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9468 + (tm
->tm_hour
* 3600000));
9470 uptime
= bgp_clock();
9471 uptime
-= p
->last_write
;
9472 tm
= gmtime(&uptime
);
9473 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9474 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9475 + (tm
->tm_hour
* 3600000));
9477 uptime
= bgp_clock();
9478 uptime
-= p
->update_time
;
9479 tm
= gmtime(&uptime
);
9480 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9481 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9482 + (tm
->tm_hour
* 3600000));
9484 /* Configured timer values. */
9485 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9486 p
->v_holdtime
* 1000);
9487 json_object_int_add(json_neigh
,
9488 "bgpTimerKeepAliveIntervalMsecs",
9489 p
->v_keepalive
* 1000);
9490 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9491 json_object_int_add(json_neigh
,
9492 "bgpTimerConfiguredHoldTimeMsecs",
9493 p
->holdtime
* 1000);
9494 json_object_int_add(
9496 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9497 p
->keepalive
* 1000);
9498 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9499 || (bgp
->default_keepalive
9500 != BGP_DEFAULT_KEEPALIVE
)) {
9501 json_object_int_add(json_neigh
,
9502 "bgpTimerConfiguredHoldTimeMsecs",
9503 bgp
->default_holdtime
);
9504 json_object_int_add(
9506 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9507 bgp
->default_keepalive
);
9510 /* Administrative shutdown. */
9511 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9512 vty_out(vty
, " Administratively shut down\n");
9515 vty_out(vty
, " BGP version 4");
9516 vty_out(vty
, ", remote router ID %s",
9517 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9518 vty_out(vty
, ", local router ID %s\n",
9519 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9523 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9524 && bgp_confederation_peers_check(bgp
, p
->as
))
9526 " Neighbor under common administration\n");
9529 vty_out(vty
, " BGP state = %s",
9530 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9532 if (p
->status
== Established
)
9533 vty_out(vty
, ", up for %8s",
9534 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9537 else if (p
->status
== Active
) {
9538 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9539 vty_out(vty
, " (passive)");
9540 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9541 vty_out(vty
, " (NSF passive)");
9546 vty_out(vty
, " Last read %s",
9547 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9549 vty_out(vty
, ", Last write %s\n",
9550 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9553 /* Configured timer values. */
9555 " Hold time is %d, keepalive interval is %d seconds\n",
9556 p
->v_holdtime
, p
->v_keepalive
);
9557 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9558 vty_out(vty
, " Configured hold time is %d",
9560 vty_out(vty
, ", keepalive interval is %d seconds\n",
9562 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9563 || (bgp
->default_keepalive
9564 != BGP_DEFAULT_KEEPALIVE
)) {
9565 vty_out(vty
, " Configured hold time is %d",
9566 bgp
->default_holdtime
);
9567 vty_out(vty
, ", keepalive interval is %d seconds\n",
9568 bgp
->default_keepalive
);
9572 if (p
->status
== Established
) {
9573 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9574 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9575 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9576 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9577 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9578 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9579 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9580 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9581 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9582 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9583 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9584 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9585 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9586 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9587 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9588 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9589 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9590 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9591 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9592 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9594 json_object
*json_cap
= NULL
;
9596 json_cap
= json_object_new_object();
9599 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9600 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9601 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9602 && CHECK_FLAG(p
->cap
,
9604 json_object_string_add(
9605 json_cap
, "4byteAs",
9606 "advertisedAndReceived");
9607 else if (CHECK_FLAG(p
->cap
,
9609 json_object_string_add(
9610 json_cap
, "4byteAs",
9612 else if (CHECK_FLAG(p
->cap
,
9614 json_object_string_add(
9615 json_cap
, "4byteAs",
9620 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9621 || CHECK_FLAG(p
->cap
,
9622 PEER_CAP_ADDPATH_ADV
)) {
9623 json_object
*json_add
= NULL
;
9624 const char *print_store
;
9626 json_add
= json_object_new_object();
9628 FOREACH_AFI_SAFI (afi
, safi
) {
9629 json_object
*json_sub
= NULL
;
9631 json_object_new_object();
9632 print_store
= afi_safi_print(
9638 PEER_CAP_ADDPATH_AF_TX_ADV
)
9642 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9647 PEER_CAP_ADDPATH_AF_TX_ADV
)
9652 PEER_CAP_ADDPATH_AF_TX_RCV
))
9653 json_object_boolean_true_add(
9655 "txAdvertisedAndReceived");
9661 PEER_CAP_ADDPATH_AF_TX_ADV
))
9662 json_object_boolean_true_add(
9670 PEER_CAP_ADDPATH_AF_TX_RCV
))
9671 json_object_boolean_true_add(
9679 PEER_CAP_ADDPATH_AF_RX_ADV
)
9683 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9688 PEER_CAP_ADDPATH_AF_RX_ADV
)
9693 PEER_CAP_ADDPATH_AF_RX_RCV
))
9694 json_object_boolean_true_add(
9696 "rxAdvertisedAndReceived");
9702 PEER_CAP_ADDPATH_AF_RX_ADV
))
9703 json_object_boolean_true_add(
9711 PEER_CAP_ADDPATH_AF_RX_RCV
))
9712 json_object_boolean_true_add(
9720 PEER_CAP_ADDPATH_AF_TX_ADV
)
9724 PEER_CAP_ADDPATH_AF_TX_RCV
)
9728 PEER_CAP_ADDPATH_AF_RX_ADV
)
9732 PEER_CAP_ADDPATH_AF_RX_RCV
))
9733 json_object_object_add(
9742 json_object_object_add(
9743 json_cap
, "addPath", json_add
);
9747 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9748 || CHECK_FLAG(p
->cap
,
9749 PEER_CAP_DYNAMIC_ADV
)) {
9750 if (CHECK_FLAG(p
->cap
,
9751 PEER_CAP_DYNAMIC_ADV
)
9752 && CHECK_FLAG(p
->cap
,
9753 PEER_CAP_DYNAMIC_RCV
))
9754 json_object_string_add(
9755 json_cap
, "dynamic",
9756 "advertisedAndReceived");
9757 else if (CHECK_FLAG(
9759 PEER_CAP_DYNAMIC_ADV
))
9760 json_object_string_add(
9761 json_cap
, "dynamic",
9763 else if (CHECK_FLAG(
9765 PEER_CAP_DYNAMIC_RCV
))
9766 json_object_string_add(
9767 json_cap
, "dynamic",
9771 /* Extended nexthop */
9772 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9773 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9774 json_object
*json_nxt
= NULL
;
9775 const char *print_store
;
9778 if (CHECK_FLAG(p
->cap
,
9780 && CHECK_FLAG(p
->cap
,
9782 json_object_string_add(
9785 "advertisedAndReceived");
9786 else if (CHECK_FLAG(p
->cap
,
9788 json_object_string_add(
9792 else if (CHECK_FLAG(p
->cap
,
9794 json_object_string_add(
9799 if (CHECK_FLAG(p
->cap
,
9800 PEER_CAP_ENHE_RCV
)) {
9802 json_object_new_object();
9804 for (safi
= SAFI_UNICAST
;
9805 safi
< SAFI_MAX
; safi
++) {
9810 PEER_CAP_ENHE_AF_RCV
)) {
9811 print_store
= afi_safi_print(
9814 json_object_string_add(
9817 "recieved"); /* misspelled for compatibility */
9820 json_object_object_add(
9822 "extendedNexthopFamililesByPeer",
9828 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9829 || CHECK_FLAG(p
->cap
,
9830 PEER_CAP_REFRESH_NEW_RCV
)
9831 || CHECK_FLAG(p
->cap
,
9832 PEER_CAP_REFRESH_OLD_RCV
)) {
9833 if (CHECK_FLAG(p
->cap
,
9834 PEER_CAP_REFRESH_ADV
)
9837 PEER_CAP_REFRESH_NEW_RCV
)
9840 PEER_CAP_REFRESH_OLD_RCV
))) {
9843 PEER_CAP_REFRESH_OLD_RCV
)
9846 PEER_CAP_REFRESH_NEW_RCV
))
9847 json_object_string_add(
9850 "advertisedAndReceivedOldNew");
9854 PEER_CAP_REFRESH_OLD_RCV
))
9855 json_object_string_add(
9858 "advertisedAndReceivedOld");
9860 json_object_string_add(
9863 "advertisedAndReceivedNew");
9868 PEER_CAP_REFRESH_ADV
))
9869 json_object_string_add(
9876 PEER_CAP_REFRESH_NEW_RCV
)
9879 PEER_CAP_REFRESH_OLD_RCV
))
9880 json_object_string_add(
9886 /* Multiprotocol Extensions */
9887 json_object
*json_multi
= NULL
;
9888 json_multi
= json_object_new_object();
9890 FOREACH_AFI_SAFI (afi
, safi
) {
9891 if (p
->afc_adv
[afi
][safi
]
9892 || p
->afc_recv
[afi
][safi
]) {
9893 json_object
*json_exten
= NULL
;
9895 json_object_new_object();
9897 if (p
->afc_adv
[afi
][safi
]
9898 && p
->afc_recv
[afi
][safi
])
9899 json_object_boolean_true_add(
9901 "advertisedAndReceived");
9902 else if (p
->afc_adv
[afi
][safi
])
9903 json_object_boolean_true_add(
9906 else if (p
->afc_recv
[afi
][safi
])
9907 json_object_boolean_true_add(
9911 json_object_object_add(
9918 json_object_object_add(
9919 json_cap
, "multiprotocolExtensions",
9922 /* Hostname capabilities */
9923 json_object
*json_hname
= NULL
;
9925 json_hname
= json_object_new_object();
9927 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9928 json_object_string_add(
9929 json_hname
, "advHostName",
9930 bgp
->peer_self
->hostname
9934 json_object_string_add(
9935 json_hname
, "advDomainName",
9936 bgp
->peer_self
->domainname
9943 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9944 json_object_string_add(
9945 json_hname
, "rcvHostName",
9946 p
->hostname
? p
->hostname
9948 json_object_string_add(
9949 json_hname
, "rcvDomainName",
9950 p
->domainname
? p
->domainname
9954 json_object_object_add(json_cap
, "hostName",
9957 /* Gracefull Restart */
9958 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9959 || CHECK_FLAG(p
->cap
,
9960 PEER_CAP_RESTART_ADV
)) {
9961 if (CHECK_FLAG(p
->cap
,
9962 PEER_CAP_RESTART_ADV
)
9963 && CHECK_FLAG(p
->cap
,
9964 PEER_CAP_RESTART_RCV
))
9965 json_object_string_add(
9968 "advertisedAndReceived");
9969 else if (CHECK_FLAG(
9971 PEER_CAP_RESTART_ADV
))
9972 json_object_string_add(
9974 "gracefulRestartCapability",
9976 else if (CHECK_FLAG(
9978 PEER_CAP_RESTART_RCV
))
9979 json_object_string_add(
9981 "gracefulRestartCapability",
9984 if (CHECK_FLAG(p
->cap
,
9985 PEER_CAP_RESTART_RCV
)) {
9986 int restart_af_count
= 0;
9987 json_object
*json_restart
=
9990 json_object_new_object();
9992 json_object_int_add(
9994 "gracefulRestartRemoteTimerMsecs",
9995 p
->v_gr_restart
* 1000);
9997 FOREACH_AFI_SAFI (afi
, safi
) {
10002 PEER_CAP_RESTART_AF_RCV
)) {
10007 json_object_new_object();
10013 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10014 json_object_boolean_true_add(
10017 restart_af_count
++;
10018 json_object_object_add(
10026 if (!restart_af_count
) {
10027 json_object_string_add(
10029 "addressFamiliesByPeer",
10034 json_object_object_add(
10036 "addressFamiliesByPeer",
10040 json_object_object_add(json_neigh
,
10041 "neighborCapabilities",
10044 vty_out(vty
, " Neighbor capabilities:\n");
10047 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10048 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10049 vty_out(vty
, " 4 Byte AS:");
10050 if (CHECK_FLAG(p
->cap
,
10052 vty_out(vty
, " advertised");
10053 if (CHECK_FLAG(p
->cap
,
10055 vty_out(vty
, " %sreceived",
10061 vty_out(vty
, "\n");
10065 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10066 || CHECK_FLAG(p
->cap
,
10067 PEER_CAP_ADDPATH_ADV
)) {
10068 vty_out(vty
, " AddPath:\n");
10070 FOREACH_AFI_SAFI (afi
, safi
) {
10074 PEER_CAP_ADDPATH_AF_TX_ADV
)
10078 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10089 PEER_CAP_ADDPATH_AF_TX_ADV
))
10100 PEER_CAP_ADDPATH_AF_TX_RCV
))
10107 PEER_CAP_ADDPATH_AF_TX_ADV
)
10111 vty_out(vty
, "\n");
10117 PEER_CAP_ADDPATH_AF_RX_ADV
)
10121 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10132 PEER_CAP_ADDPATH_AF_RX_ADV
))
10143 PEER_CAP_ADDPATH_AF_RX_RCV
))
10150 PEER_CAP_ADDPATH_AF_RX_ADV
)
10154 vty_out(vty
, "\n");
10160 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10161 || CHECK_FLAG(p
->cap
,
10162 PEER_CAP_DYNAMIC_ADV
)) {
10163 vty_out(vty
, " Dynamic:");
10164 if (CHECK_FLAG(p
->cap
,
10165 PEER_CAP_DYNAMIC_ADV
))
10166 vty_out(vty
, " advertised");
10167 if (CHECK_FLAG(p
->cap
,
10168 PEER_CAP_DYNAMIC_RCV
))
10169 vty_out(vty
, " %sreceived",
10172 PEER_CAP_DYNAMIC_ADV
)
10175 vty_out(vty
, "\n");
10178 /* Extended nexthop */
10179 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10180 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10181 vty_out(vty
, " Extended nexthop:");
10182 if (CHECK_FLAG(p
->cap
,
10183 PEER_CAP_ENHE_ADV
))
10184 vty_out(vty
, " advertised");
10185 if (CHECK_FLAG(p
->cap
,
10186 PEER_CAP_ENHE_RCV
))
10187 vty_out(vty
, " %sreceived",
10193 vty_out(vty
, "\n");
10195 if (CHECK_FLAG(p
->cap
,
10196 PEER_CAP_ENHE_RCV
)) {
10198 " Address families by peer:\n ");
10199 for (safi
= SAFI_UNICAST
;
10200 safi
< SAFI_MAX
; safi
++)
10205 PEER_CAP_ENHE_AF_RCV
))
10214 /* Route Refresh */
10215 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10216 || CHECK_FLAG(p
->cap
,
10217 PEER_CAP_REFRESH_NEW_RCV
)
10218 || CHECK_FLAG(p
->cap
,
10219 PEER_CAP_REFRESH_OLD_RCV
)) {
10220 vty_out(vty
, " Route refresh:");
10221 if (CHECK_FLAG(p
->cap
,
10222 PEER_CAP_REFRESH_ADV
))
10223 vty_out(vty
, " advertised");
10224 if (CHECK_FLAG(p
->cap
,
10225 PEER_CAP_REFRESH_NEW_RCV
)
10228 PEER_CAP_REFRESH_OLD_RCV
))
10229 vty_out(vty
, " %sreceived(%s)",
10232 PEER_CAP_REFRESH_ADV
)
10237 PEER_CAP_REFRESH_OLD_RCV
)
10240 PEER_CAP_REFRESH_NEW_RCV
))
10244 PEER_CAP_REFRESH_OLD_RCV
)
10248 vty_out(vty
, "\n");
10251 /* Multiprotocol Extensions */
10252 FOREACH_AFI_SAFI (afi
, safi
)
10253 if (p
->afc_adv
[afi
][safi
]
10254 || p
->afc_recv
[afi
][safi
]) {
10256 " Address Family %s:",
10257 afi_safi_print(afi
,
10259 if (p
->afc_adv
[afi
][safi
])
10262 if (p
->afc_recv
[afi
][safi
])
10269 vty_out(vty
, "\n");
10272 /* Hostname capability */
10273 vty_out(vty
, " Hostname Capability:");
10275 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10277 " advertised (name: %s,domain name: %s)",
10278 bgp
->peer_self
->hostname
10282 bgp
->peer_self
->domainname
10287 vty_out(vty
, " not advertised");
10290 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10292 " received (name: %s,domain name: %s)",
10293 p
->hostname
? p
->hostname
10295 p
->domainname
? p
->domainname
10298 vty_out(vty
, " not received");
10301 vty_out(vty
, "\n");
10303 /* Gracefull Restart */
10304 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10305 || CHECK_FLAG(p
->cap
,
10306 PEER_CAP_RESTART_ADV
)) {
10308 " Graceful Restart Capabilty:");
10309 if (CHECK_FLAG(p
->cap
,
10310 PEER_CAP_RESTART_ADV
))
10311 vty_out(vty
, " advertised");
10312 if (CHECK_FLAG(p
->cap
,
10313 PEER_CAP_RESTART_RCV
))
10314 vty_out(vty
, " %sreceived",
10317 PEER_CAP_RESTART_ADV
)
10320 vty_out(vty
, "\n");
10322 if (CHECK_FLAG(p
->cap
,
10323 PEER_CAP_RESTART_RCV
)) {
10324 int restart_af_count
= 0;
10327 " Remote Restart timer is %d seconds\n",
10330 " Address families by peer:\n ");
10332 FOREACH_AFI_SAFI (afi
, safi
)
10337 PEER_CAP_RESTART_AF_RCV
)) {
10350 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10352 : "not preserved");
10353 restart_af_count
++;
10355 if (!restart_af_count
)
10356 vty_out(vty
, "none");
10357 vty_out(vty
, "\n");
10364 /* graceful restart information */
10365 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10366 || p
->t_gr_stale
) {
10367 json_object
*json_grace
= NULL
;
10368 json_object
*json_grace_send
= NULL
;
10369 json_object
*json_grace_recv
= NULL
;
10370 int eor_send_af_count
= 0;
10371 int eor_receive_af_count
= 0;
10374 json_grace
= json_object_new_object();
10375 json_grace_send
= json_object_new_object();
10376 json_grace_recv
= json_object_new_object();
10378 if (p
->status
== Established
) {
10379 FOREACH_AFI_SAFI (afi
, safi
) {
10380 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10381 PEER_STATUS_EOR_SEND
)) {
10382 json_object_boolean_true_add(
10384 afi_safi_print(afi
,
10386 eor_send_af_count
++;
10389 FOREACH_AFI_SAFI (afi
, safi
) {
10391 p
->af_sflags
[afi
][safi
],
10392 PEER_STATUS_EOR_RECEIVED
)) {
10393 json_object_boolean_true_add(
10395 afi_safi_print(afi
,
10397 eor_receive_af_count
++;
10402 json_object_object_add(json_grace
, "endOfRibSend",
10404 json_object_object_add(json_grace
, "endOfRibRecv",
10407 if (p
->t_gr_restart
)
10408 json_object_int_add(json_grace
,
10409 "gracefulRestartTimerMsecs",
10410 thread_timer_remain_second(
10415 json_object_int_add(
10417 "gracefulStalepathTimerMsecs",
10418 thread_timer_remain_second(
10422 json_object_object_add(
10423 json_neigh
, "gracefulRestartInfo", json_grace
);
10425 vty_out(vty
, " Graceful restart information:\n");
10426 if (p
->status
== Established
) {
10427 vty_out(vty
, " End-of-RIB send: ");
10428 FOREACH_AFI_SAFI (afi
, safi
) {
10429 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10430 PEER_STATUS_EOR_SEND
)) {
10431 vty_out(vty
, "%s%s",
10432 eor_send_af_count
? ", "
10434 afi_safi_print(afi
,
10436 eor_send_af_count
++;
10439 vty_out(vty
, "\n");
10440 vty_out(vty
, " End-of-RIB received: ");
10441 FOREACH_AFI_SAFI (afi
, safi
) {
10443 p
->af_sflags
[afi
][safi
],
10444 PEER_STATUS_EOR_RECEIVED
)) {
10445 vty_out(vty
, "%s%s",
10446 eor_receive_af_count
10449 afi_safi_print(afi
,
10451 eor_receive_af_count
++;
10454 vty_out(vty
, "\n");
10457 if (p
->t_gr_restart
)
10459 " The remaining time of restart timer is %ld\n",
10460 thread_timer_remain_second(
10465 " The remaining time of stalepath timer is %ld\n",
10466 thread_timer_remain_second(
10471 json_object
*json_stat
= NULL
;
10472 json_stat
= json_object_new_object();
10473 /* Packet counts. */
10474 json_object_int_add(json_stat
, "depthInq", 0);
10475 json_object_int_add(json_stat
, "depthOutq",
10476 (unsigned long)p
->obuf
->count
);
10477 json_object_int_add(json_stat
, "opensSent",
10478 atomic_load_explicit(&p
->open_out
,
10479 memory_order_relaxed
));
10480 json_object_int_add(json_stat
, "opensRecv",
10481 atomic_load_explicit(&p
->open_in
,
10482 memory_order_relaxed
));
10483 json_object_int_add(json_stat
, "notificationsSent",
10484 atomic_load_explicit(&p
->notify_out
,
10485 memory_order_relaxed
));
10486 json_object_int_add(json_stat
, "notificationsRecv",
10487 atomic_load_explicit(&p
->notify_in
,
10488 memory_order_relaxed
));
10489 json_object_int_add(json_stat
, "updatesSent",
10490 atomic_load_explicit(&p
->update_out
,
10491 memory_order_relaxed
));
10492 json_object_int_add(json_stat
, "updatesRecv",
10493 atomic_load_explicit(&p
->update_in
,
10494 memory_order_relaxed
));
10495 json_object_int_add(json_stat
, "keepalivesSent",
10496 atomic_load_explicit(&p
->keepalive_out
,
10497 memory_order_relaxed
));
10498 json_object_int_add(json_stat
, "keepalivesRecv",
10499 atomic_load_explicit(&p
->keepalive_in
,
10500 memory_order_relaxed
));
10501 json_object_int_add(json_stat
, "routeRefreshSent",
10502 atomic_load_explicit(&p
->refresh_out
,
10503 memory_order_relaxed
));
10504 json_object_int_add(json_stat
, "routeRefreshRecv",
10505 atomic_load_explicit(&p
->refresh_in
,
10506 memory_order_relaxed
));
10507 json_object_int_add(json_stat
, "capabilitySent",
10508 atomic_load_explicit(&p
->dynamic_cap_out
,
10509 memory_order_relaxed
));
10510 json_object_int_add(json_stat
, "capabilityRecv",
10511 atomic_load_explicit(&p
->dynamic_cap_in
,
10512 memory_order_relaxed
));
10513 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10514 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10515 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10517 /* Packet counts. */
10518 vty_out(vty
, " Message statistics:\n");
10519 vty_out(vty
, " Inq depth is 0\n");
10520 vty_out(vty
, " Outq depth is %lu\n",
10521 (unsigned long)p
->obuf
->count
);
10522 vty_out(vty
, " Sent Rcvd\n");
10523 vty_out(vty
, " Opens: %10d %10d\n",
10524 atomic_load_explicit(&p
->open_out
,
10525 memory_order_relaxed
),
10526 atomic_load_explicit(&p
->open_in
,
10527 memory_order_relaxed
));
10528 vty_out(vty
, " Notifications: %10d %10d\n",
10529 atomic_load_explicit(&p
->notify_out
,
10530 memory_order_relaxed
),
10531 atomic_load_explicit(&p
->notify_in
,
10532 memory_order_relaxed
));
10533 vty_out(vty
, " Updates: %10d %10d\n",
10534 atomic_load_explicit(&p
->update_out
,
10535 memory_order_relaxed
),
10536 atomic_load_explicit(&p
->update_in
,
10537 memory_order_relaxed
));
10538 vty_out(vty
, " Keepalives: %10d %10d\n",
10539 atomic_load_explicit(&p
->keepalive_out
,
10540 memory_order_relaxed
),
10541 atomic_load_explicit(&p
->keepalive_in
,
10542 memory_order_relaxed
));
10543 vty_out(vty
, " Route Refresh: %10d %10d\n",
10544 atomic_load_explicit(&p
->refresh_out
,
10545 memory_order_relaxed
),
10546 atomic_load_explicit(&p
->refresh_in
,
10547 memory_order_relaxed
));
10548 vty_out(vty
, " Capability: %10d %10d\n",
10549 atomic_load_explicit(&p
->dynamic_cap_out
,
10550 memory_order_relaxed
),
10551 atomic_load_explicit(&p
->dynamic_cap_in
,
10552 memory_order_relaxed
));
10553 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10558 /* advertisement-interval */
10559 json_object_int_add(json_neigh
,
10560 "minBtwnAdvertisementRunsTimerMsecs",
10561 p
->v_routeadv
* 1000);
10563 /* Update-source. */
10564 if (p
->update_if
|| p
->update_source
) {
10566 json_object_string_add(json_neigh
,
10569 else if (p
->update_source
)
10570 json_object_string_add(
10571 json_neigh
, "updateSource",
10572 sockunion2str(p
->update_source
, buf1
,
10576 /* advertisement-interval */
10578 " Minimum time between advertisement runs is %d seconds\n",
10581 /* Update-source. */
10582 if (p
->update_if
|| p
->update_source
) {
10583 vty_out(vty
, " Update source is ");
10585 vty_out(vty
, "%s", p
->update_if
);
10586 else if (p
->update_source
)
10588 sockunion2str(p
->update_source
, buf1
,
10590 vty_out(vty
, "\n");
10593 vty_out(vty
, "\n");
10596 /* Address Family Information */
10597 json_object
*json_hold
= NULL
;
10600 json_hold
= json_object_new_object();
10602 FOREACH_AFI_SAFI (afi
, safi
)
10603 if (p
->afc
[afi
][safi
])
10604 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10608 json_object_object_add(json_neigh
, "addressFamilyInfo",
10610 json_object_int_add(json_neigh
, "connectionsEstablished",
10612 json_object_int_add(json_neigh
, "connectionsDropped",
10615 vty_out(vty
, " Connections established %d; dropped %d\n",
10616 p
->established
, p
->dropped
);
10618 if (!p
->last_reset
) {
10620 json_object_string_add(json_neigh
, "lastReset",
10623 vty_out(vty
, " Last reset never\n");
10629 uptime
= bgp_clock();
10630 uptime
-= p
->resettime
;
10631 tm
= gmtime(&uptime
);
10632 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10633 (tm
->tm_sec
* 1000)
10634 + (tm
->tm_min
* 60000)
10635 + (tm
->tm_hour
* 3600000));
10636 json_object_string_add(
10637 json_neigh
, "lastResetDueTo",
10638 peer_down_str
[(int)p
->last_reset
]);
10639 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10640 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10641 char errorcodesubcode_hexstr
[5];
10642 char errorcodesubcode_str
[256];
10644 code_str
= bgp_notify_code_str(p
->notify
.code
);
10645 subcode_str
= bgp_notify_subcode_str(
10646 p
->notify
.code
, p
->notify
.subcode
);
10648 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10649 p
->notify
.code
, p
->notify
.subcode
);
10650 json_object_string_add(json_neigh
,
10651 "lastErrorCodeSubcode",
10652 errorcodesubcode_hexstr
);
10653 snprintf(errorcodesubcode_str
, 255, "%s%s",
10654 code_str
, subcode_str
);
10655 json_object_string_add(json_neigh
,
10656 "lastNotificationReason",
10657 errorcodesubcode_str
);
10658 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10659 && p
->notify
.code
== BGP_NOTIFY_CEASE
10660 && (p
->notify
.subcode
10661 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10662 || p
->notify
.subcode
10663 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10664 && p
->notify
.length
) {
10666 const char *msg_str
;
10668 msg_str
= bgp_notify_admin_message(
10669 msgbuf
, sizeof(msgbuf
),
10670 (uint8_t *)p
->notify
.data
,
10673 json_object_string_add(
10675 "lastShutdownDescription",
10680 vty_out(vty
, " Last reset %s, ",
10681 peer_uptime(p
->resettime
, timebuf
,
10682 BGP_UPTIME_LEN
, 0, NULL
));
10684 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10685 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10686 code_str
= bgp_notify_code_str(p
->notify
.code
);
10687 subcode_str
= bgp_notify_subcode_str(
10688 p
->notify
.code
, p
->notify
.subcode
);
10689 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10690 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10693 code_str
, subcode_str
);
10694 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10695 && p
->notify
.code
== BGP_NOTIFY_CEASE
10696 && (p
->notify
.subcode
10697 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10698 || p
->notify
.subcode
10699 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10700 && p
->notify
.length
) {
10702 const char *msg_str
;
10704 msg_str
= bgp_notify_admin_message(
10705 msgbuf
, sizeof(msgbuf
),
10706 (uint8_t *)p
->notify
.data
,
10710 " Message: \"%s\"\n",
10714 vty_out(vty
, "due to %s\n",
10715 peer_down_str
[(int)p
->last_reset
]);
10718 if (p
->last_reset_cause_size
) {
10719 msg
= p
->last_reset_cause
;
10721 " Message received that caused BGP to send a NOTIFICATION:\n ");
10722 for (i
= 1; i
<= p
->last_reset_cause_size
;
10724 vty_out(vty
, "%02X", *msg
++);
10726 if (i
!= p
->last_reset_cause_size
) {
10728 vty_out(vty
, "\n ");
10729 } else if (i
% 4 == 0) {
10734 vty_out(vty
, "\n");
10739 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10741 json_object_boolean_true_add(json_neigh
,
10742 "prefixesConfigExceedMax");
10745 " Peer had exceeded the max. no. of prefixes configured.\n");
10747 if (p
->t_pmax_restart
) {
10749 json_object_boolean_true_add(
10750 json_neigh
, "reducePrefixNumFrom");
10751 json_object_int_add(json_neigh
,
10752 "restartInTimerMsec",
10753 thread_timer_remain_second(
10758 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10759 p
->host
, thread_timer_remain_second(
10760 p
->t_pmax_restart
));
10763 json_object_boolean_true_add(
10765 "reducePrefixNumAndClearIpBgp");
10768 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10773 /* EBGP Multihop and GTSM */
10774 if (p
->sort
!= BGP_PEER_IBGP
) {
10776 if (p
->gtsm_hops
> 0)
10777 json_object_int_add(json_neigh
,
10778 "externalBgpNbrMaxHopsAway",
10780 else if (p
->ttl
> 1)
10781 json_object_int_add(json_neigh
,
10782 "externalBgpNbrMaxHopsAway",
10785 if (p
->gtsm_hops
> 0)
10787 " External BGP neighbor may be up to %d hops away.\n",
10789 else if (p
->ttl
> 1)
10791 " External BGP neighbor may be up to %d hops away.\n",
10795 if (p
->gtsm_hops
> 0) {
10797 json_object_int_add(json_neigh
,
10798 "internalBgpNbrMaxHopsAway",
10802 " Internal BGP neighbor may be up to %d hops away.\n",
10807 /* Local address. */
10810 json_object_string_add(json_neigh
, "hostLocal",
10811 sockunion2str(p
->su_local
, buf1
,
10813 json_object_int_add(json_neigh
, "portLocal",
10814 ntohs(p
->su_local
->sin
.sin_port
));
10816 vty_out(vty
, "Local host: %s, Local port: %d\n",
10817 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10818 ntohs(p
->su_local
->sin
.sin_port
));
10821 /* Remote address. */
10822 if (p
->su_remote
) {
10824 json_object_string_add(json_neigh
, "hostForeign",
10825 sockunion2str(p
->su_remote
, buf1
,
10827 json_object_int_add(json_neigh
, "portForeign",
10828 ntohs(p
->su_remote
->sin
.sin_port
));
10830 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10831 sockunion2str(p
->su_remote
, buf1
,
10833 ntohs(p
->su_remote
->sin
.sin_port
));
10836 /* Nexthop display. */
10839 json_object_string_add(json_neigh
, "nexthop",
10841 &p
->nexthop
.v4
, buf1
,
10843 json_object_string_add(json_neigh
, "nexthopGlobal",
10844 inet_ntop(AF_INET6
,
10845 &p
->nexthop
.v6_global
,
10846 buf1
, sizeof(buf1
)));
10847 json_object_string_add(json_neigh
, "nexthopLocal",
10848 inet_ntop(AF_INET6
,
10849 &p
->nexthop
.v6_local
,
10850 buf1
, sizeof(buf1
)));
10851 if (p
->shared_network
)
10852 json_object_string_add(json_neigh
,
10856 json_object_string_add(json_neigh
,
10858 "nonSharedNetwork");
10860 vty_out(vty
, "Nexthop: %s\n",
10861 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10863 vty_out(vty
, "Nexthop global: %s\n",
10864 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10866 vty_out(vty
, "Nexthop local: %s\n",
10867 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10869 vty_out(vty
, "BGP connection: %s\n",
10870 p
->shared_network
? "shared network"
10871 : "non shared network");
10875 /* Timer information. */
10877 json_object_int_add(json_neigh
, "connectRetryTimer",
10879 if (p
->status
== Established
&& p
->rtt
)
10880 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10883 json_object_int_add(
10884 json_neigh
, "nextStartTimerDueInMsecs",
10885 thread_timer_remain_second(p
->t_start
) * 1000);
10887 json_object_int_add(
10888 json_neigh
, "nextConnectTimerDueInMsecs",
10889 thread_timer_remain_second(p
->t_connect
)
10891 if (p
->t_routeadv
) {
10892 json_object_int_add(json_neigh
, "mraiInterval",
10894 json_object_int_add(
10895 json_neigh
, "mraiTimerExpireInMsecs",
10896 thread_timer_remain_second(p
->t_routeadv
)
10900 json_object_int_add(json_neigh
, "authenticationEnabled",
10904 json_object_string_add(json_neigh
, "readThread", "on");
10906 json_object_string_add(json_neigh
, "readThread", "off");
10908 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10909 json_object_string_add(json_neigh
, "writeThread", "on");
10911 json_object_string_add(json_neigh
, "writeThread",
10914 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10916 if (p
->status
== Established
&& p
->rtt
)
10917 vty_out(vty
, "Estimated round trip time: %d ms\n",
10920 vty_out(vty
, "Next start timer due in %ld seconds\n",
10921 thread_timer_remain_second(p
->t_start
));
10923 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10924 thread_timer_remain_second(p
->t_connect
));
10927 "MRAI (interval %u) timer expires in %ld seconds\n",
10929 thread_timer_remain_second(p
->t_routeadv
));
10931 vty_out(vty
, "Peer Authentication Enabled\n");
10933 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10934 p
->t_read
? "on" : "off",
10935 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10940 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10941 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10942 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10945 vty_out(vty
, "\n");
10947 /* BFD information. */
10948 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10951 if (p
->conf_if
) /* Configured interface name. */
10952 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10953 else /* Configured IP address. */
10954 json_object_object_add(json
, p
->host
, json_neigh
);
10958 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10959 enum show_type type
, union sockunion
*su
,
10960 const char *conf_if
, bool use_json
,
10963 struct listnode
*node
, *nnode
;
10966 bool nbr_output
= false;
10967 afi_t afi
= AFI_MAX
;
10968 safi_t safi
= SAFI_MAX
;
10970 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10972 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10976 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10977 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10982 bgp_show_peer(vty
, peer
, use_json
, json
);
10988 && !strcmp(peer
->conf_if
, conf_if
))
10990 && !strcmp(peer
->hostname
, conf_if
))) {
10992 bgp_show_peer(vty
, peer
, use_json
,
10996 if (sockunion_same(&peer
->su
, su
)) {
10998 bgp_show_peer(vty
, peer
, use_json
,
11003 case show_ipv4_peer
:
11004 case show_ipv6_peer
:
11005 FOREACH_SAFI (safi
) {
11006 if (peer
->afc
[afi
][safi
]) {
11009 && !strcmp(peer
->conf_if
, conf_if
))
11011 && !strcmp(peer
->hostname
, conf_if
))) {
11013 bgp_show_peer(vty
, peer
, use_json
,
11018 if (sockunion_same(&peer
->su
, su
)) {
11020 bgp_show_peer(vty
, peer
, use_json
,
11028 case show_ipv4_all
:
11029 case show_ipv6_all
:
11030 FOREACH_SAFI (safi
) {
11031 if (peer
->afc
[afi
][safi
]) {
11032 bgp_show_peer(vty
, peer
, use_json
, json
);
11041 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11042 type
== show_ipv6_peer
) && !find
) {
11044 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11046 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11049 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11050 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11051 vty_out(vty
, "%% No BGP neighbors found\n");
11054 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11055 json
, JSON_C_TO_STRING_PRETTY
));
11057 vty_out(vty
, "\n");
11060 return CMD_SUCCESS
;
11063 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11064 enum show_type type
,
11065 const char *ip_str
,
11068 struct listnode
*node
, *nnode
;
11070 union sockunion su
;
11071 json_object
*json
= NULL
;
11072 int ret
, is_first
= 1;
11073 bool nbr_output
= false;
11076 vty_out(vty
, "{\n");
11078 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11081 if (!(json
= json_object_new_object())) {
11083 EC_BGP_JSON_MEM_ERROR
,
11084 "Unable to allocate memory for JSON object");
11086 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11090 json_object_int_add(json
, "vrfId",
11091 (bgp
->vrf_id
== VRF_UNKNOWN
)
11093 : (int64_t)bgp
->vrf_id
);
11094 json_object_string_add(
11096 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11101 vty_out(vty
, ",\n");
11105 vty_out(vty
, "\"%s\":",
11106 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11110 vty_out(vty
, "\nInstance %s:\n",
11111 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11116 if (type
== show_peer
|| type
== show_ipv4_peer
||
11117 type
== show_ipv6_peer
) {
11118 ret
= str2sockunion(ip_str
, &su
);
11120 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11123 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11126 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11129 json_object_free(json
);
11133 vty_out(vty
, "}\n");
11134 json_object_free(json
);
11136 else if (!nbr_output
)
11137 vty_out(vty
, "%% BGP instance not found\n");
11140 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11141 enum show_type type
, const char *ip_str
,
11146 union sockunion su
;
11147 json_object
*json
= NULL
;
11150 if (strmatch(name
, "all")) {
11151 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11153 return CMD_SUCCESS
;
11155 bgp
= bgp_lookup_by_name(name
);
11158 json
= json_object_new_object();
11159 vty_out(vty
, "%s\n",
11160 json_object_to_json_string_ext(
11162 JSON_C_TO_STRING_PRETTY
));
11163 json_object_free(json
);
11166 "%% BGP instance not found\n");
11168 return CMD_WARNING
;
11172 bgp
= bgp_get_default();
11176 json
= json_object_new_object();
11178 ret
= str2sockunion(ip_str
, &su
);
11180 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11183 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11186 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11189 json_object_free(json
);
11192 vty_out(vty
, "{}\n");
11194 vty_out(vty
, "%% BGP instance not found\n");
11197 return CMD_SUCCESS
;
11200 /* "show [ip] bgp neighbors" commands. */
11201 DEFUN (show_ip_bgp_neighbors
,
11202 show_ip_bgp_neighbors_cmd
,
11203 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11207 BGP_INSTANCE_HELP_STR
11210 "Detailed information on TCP and BGP neighbor connections\n"
11211 "Neighbor to display information about\n"
11212 "Neighbor to display information about\n"
11213 "Neighbor on BGP configured interface\n"
11217 char *sh_arg
= NULL
;
11218 enum show_type sh_type
;
11219 afi_t afi
= AFI_MAX
;
11221 bool uj
= use_json(argc
, argv
);
11225 /* [<vrf> VIEWVRFNAME] */
11226 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11227 vrf
= argv
[idx
+ 1]->arg
;
11228 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11230 } else if (argv_find(argv
, argc
, "view", &idx
))
11231 /* [<view> VIEWVRFNAME] */
11232 vrf
= argv
[idx
+ 1]->arg
;
11236 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11237 sh_type
= show_ipv4_all
;
11239 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11240 sh_type
= show_ipv6_all
;
11243 sh_type
= show_all
;
11246 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11247 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11248 || argv_find(argv
, argc
, "WORD", &idx
)) {
11249 sh_type
= show_peer
;
11250 sh_arg
= argv
[idx
]->arg
;
11253 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11254 sh_type
= show_ipv4_peer
;
11255 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11256 sh_type
= show_ipv6_peer
;
11259 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11262 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11263 paths' and `show ip mbgp paths'. Those functions results are the
11265 DEFUN (show_ip_bgp_paths
,
11266 show_ip_bgp_paths_cmd
,
11267 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11272 "Path information\n")
11274 vty_out(vty
, "Address Refcnt Path\n");
11275 aspath_print_all_vty(vty
);
11276 return CMD_SUCCESS
;
11281 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11284 struct community
*com
;
11286 com
= (struct community
*)bucket
->data
;
11287 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11288 community_str(com
, false));
11291 /* Show BGP's community internal data. */
11292 DEFUN (show_ip_bgp_community_info
,
11293 show_ip_bgp_community_info_cmd
,
11294 "show [ip] bgp community-info",
11298 "List all bgp community information\n")
11300 vty_out(vty
, "Address Refcnt Community\n");
11302 hash_iterate(community_hash(),
11303 (void (*)(struct hash_bucket
*,
11304 void *))community_show_all_iterator
,
11307 return CMD_SUCCESS
;
11310 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11313 struct lcommunity
*lcom
;
11315 lcom
= (struct lcommunity
*)bucket
->data
;
11316 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11317 lcommunity_str(lcom
, false));
11320 /* Show BGP's community internal data. */
11321 DEFUN (show_ip_bgp_lcommunity_info
,
11322 show_ip_bgp_lcommunity_info_cmd
,
11323 "show ip bgp large-community-info",
11327 "List all bgp large-community information\n")
11329 vty_out(vty
, "Address Refcnt Large-community\n");
11331 hash_iterate(lcommunity_hash(),
11332 (void (*)(struct hash_bucket
*,
11333 void *))lcommunity_show_all_iterator
,
11336 return CMD_SUCCESS
;
11340 DEFUN (show_ip_bgp_attr_info
,
11341 show_ip_bgp_attr_info_cmd
,
11342 "show [ip] bgp attribute-info",
11346 "List all bgp attribute information\n")
11348 attr_show_all(vty
);
11349 return CMD_SUCCESS
;
11352 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11353 afi_t afi
, safi_t safi
,
11354 bool use_json
, json_object
*json
)
11357 struct listnode
*node
;
11359 char buf1
[INET6_ADDRSTRLEN
];
11361 vpn_policy_direction_t dir
;
11364 json_object
*json_import_vrfs
= NULL
;
11365 json_object
*json_export_vrfs
= NULL
;
11367 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11370 vty_out(vty
, "%s\n",
11371 json_object_to_json_string_ext(
11373 JSON_C_TO_STRING_PRETTY
));
11374 json_object_free(json
);
11376 return CMD_WARNING
;
11379 /* Provide context for the block */
11380 json_object_string_add(json
, "vrf", name
? name
: "default");
11381 json_object_string_add(json
, "afiSafi",
11382 afi_safi_print(afi
, safi
));
11384 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11385 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11386 json_object_string_add(json
, "importFromVrfs", "none");
11387 json_object_string_add(json
, "importRts", "none");
11389 json_import_vrfs
= json_object_new_array();
11391 for (ALL_LIST_ELEMENTS_RO(
11392 bgp
->vpn_policy
[afi
].import_vrf
,
11394 json_object_array_add(json_import_vrfs
,
11395 json_object_new_string(vname
));
11397 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11398 ecom_str
= ecommunity_ecom2str(
11399 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11400 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11401 json_object_object_add(json
, "importFromVrfs",
11403 json_object_string_add(json
, "importRts", ecom_str
);
11405 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11408 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11409 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11410 json_object_string_add(json
, "exportToVrfs", "none");
11411 json_object_string_add(json
, "routeDistinguisher",
11413 json_object_string_add(json
, "exportRts", "none");
11415 json_export_vrfs
= json_object_new_array();
11417 for (ALL_LIST_ELEMENTS_RO(
11418 bgp
->vpn_policy
[afi
].export_vrf
,
11420 json_object_array_add(json_export_vrfs
,
11421 json_object_new_string(vname
));
11422 json_object_object_add(json
, "exportToVrfs",
11424 json_object_string_add(json
, "routeDistinguisher",
11425 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11426 buf1
, RD_ADDRSTRLEN
));
11428 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11429 ecom_str
= ecommunity_ecom2str(
11430 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11431 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11432 json_object_string_add(json
, "exportRts", ecom_str
);
11434 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11438 vty_out(vty
, "%s\n",
11439 json_object_to_json_string_ext(json
,
11440 JSON_C_TO_STRING_PRETTY
));
11441 json_object_free(json
);
11444 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11447 vty_out(vty
, "%% No such BGP instance exist\n");
11448 return CMD_WARNING
;
11451 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11452 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11454 "This VRF is not importing %s routes from any other VRF\n",
11455 afi_safi_print(afi
, safi
));
11458 "This VRF is importing %s routes from the following VRFs:\n",
11459 afi_safi_print(afi
, safi
));
11461 for (ALL_LIST_ELEMENTS_RO(
11462 bgp
->vpn_policy
[afi
].import_vrf
,
11464 vty_out(vty
, " %s\n", vname
);
11466 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11467 ecom_str
= ecommunity_ecom2str(
11468 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11469 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11470 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11472 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11475 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11476 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11478 "This VRF is not exporting %s routes to any other VRF\n",
11479 afi_safi_print(afi
, safi
));
11482 "This VRF is exporting %s routes to the following VRFs:\n",
11483 afi_safi_print(afi
, safi
));
11485 for (ALL_LIST_ELEMENTS_RO(
11486 bgp
->vpn_policy
[afi
].export_vrf
,
11488 vty_out(vty
, " %s\n", vname
);
11490 vty_out(vty
, "RD: %s\n",
11491 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11492 buf1
, RD_ADDRSTRLEN
));
11494 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11495 ecom_str
= ecommunity_ecom2str(
11496 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11497 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11498 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11499 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11503 return CMD_SUCCESS
;
11506 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11507 safi_t safi
, bool use_json
)
11509 struct listnode
*node
, *nnode
;
11511 char *vrf_name
= NULL
;
11512 json_object
*json
= NULL
;
11513 json_object
*json_vrf
= NULL
;
11514 json_object
*json_vrfs
= NULL
;
11517 json
= json_object_new_object();
11518 json_vrfs
= json_object_new_object();
11521 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11523 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11524 vrf_name
= bgp
->name
;
11527 json_vrf
= json_object_new_object();
11529 vty_out(vty
, "\nInstance %s:\n",
11530 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11531 ? VRF_DEFAULT_NAME
: bgp
->name
);
11533 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11535 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11536 json_object_object_add(json_vrfs
,
11537 VRF_DEFAULT_NAME
, json_vrf
);
11539 json_object_object_add(json_vrfs
, vrf_name
,
11545 json_object_object_add(json
, "vrfs", json_vrfs
);
11546 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11547 JSON_C_TO_STRING_PRETTY
));
11548 json_object_free(json
);
11551 return CMD_SUCCESS
;
11554 /* "show [ip] bgp route-leak" command. */
11555 DEFUN (show_ip_bgp_route_leak
,
11556 show_ip_bgp_route_leak_cmd
,
11557 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11561 BGP_INSTANCE_HELP_STR
11564 "Route leaking information\n"
11568 afi_t afi
= AFI_MAX
;
11569 safi_t safi
= SAFI_MAX
;
11571 bool uj
= use_json(argc
, argv
);
11573 json_object
*json
= NULL
;
11575 /* show [ip] bgp */
11576 if (argv_find(argv
, argc
, "ip", &idx
)) {
11578 safi
= SAFI_UNICAST
;
11580 /* [vrf VIEWVRFNAME] */
11581 if (argv_find(argv
, argc
, "view", &idx
)) {
11583 "%% This command is not applicable to BGP views\n");
11584 return CMD_WARNING
;
11587 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11588 vrf
= argv
[idx
+ 1]->arg
;
11589 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11592 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11593 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11594 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11597 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11599 "%% This command is applicable only for unicast ipv4|ipv6\n");
11600 return CMD_WARNING
;
11603 if (vrf
&& strmatch(vrf
, "all"))
11604 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11607 json
= json_object_new_object();
11609 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11612 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11615 struct listnode
*node
, *nnode
;
11618 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11619 vty_out(vty
, "\nInstance %s:\n",
11620 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11623 update_group_show(bgp
, afi
, safi
, vty
, 0);
11627 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11628 int safi
, uint64_t subgrp_id
)
11633 if (strmatch(name
, "all")) {
11634 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11635 return CMD_SUCCESS
;
11637 bgp
= bgp_lookup_by_name(name
);
11640 bgp
= bgp_get_default();
11644 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11645 return CMD_SUCCESS
;
11648 DEFUN (show_ip_bgp_updgrps
,
11649 show_ip_bgp_updgrps_cmd
,
11650 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11654 BGP_INSTANCE_HELP_STR
11656 BGP_SAFI_WITH_LABEL_HELP_STR
11657 "Detailed info about dynamic update groups\n"
11658 "Specific subgroup to display detailed info for\n")
11661 afi_t afi
= AFI_IP6
;
11662 safi_t safi
= SAFI_UNICAST
;
11663 uint64_t subgrp_id
= 0;
11667 /* show [ip] bgp */
11668 if (argv_find(argv
, argc
, "ip", &idx
))
11670 /* [<vrf> VIEWVRFNAME] */
11671 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11672 vrf
= argv
[idx
+ 1]->arg
;
11673 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11675 } else if (argv_find(argv
, argc
, "view", &idx
))
11676 /* [<view> VIEWVRFNAME] */
11677 vrf
= argv
[idx
+ 1]->arg
;
11678 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11679 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11680 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11683 /* get subgroup id, if provided */
11685 if (argv
[idx
]->type
== VARIABLE_TKN
)
11686 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11688 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11691 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11692 show_bgp_instance_all_ipv6_updgrps_cmd
,
11693 "show [ip] bgp <view|vrf> all update-groups",
11697 BGP_INSTANCE_ALL_HELP_STR
11698 "Detailed info about dynamic update groups\n")
11700 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11701 return CMD_SUCCESS
;
11704 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11705 show_bgp_l2vpn_evpn_updgrps_cmd
,
11706 "show [ip] bgp l2vpn evpn update-groups",
11710 "l2vpn address family\n"
11711 "evpn sub-address family\n"
11712 "Detailed info about dynamic update groups\n")
11715 uint64_t subgrp_id
= 0;
11717 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11718 return CMD_SUCCESS
;
11721 DEFUN (show_bgp_updgrps_stats
,
11722 show_bgp_updgrps_stats_cmd
,
11723 "show [ip] bgp update-groups statistics",
11727 "Detailed info about dynamic update groups\n"
11732 bgp
= bgp_get_default();
11734 update_group_show_stats(bgp
, vty
);
11736 return CMD_SUCCESS
;
11739 DEFUN (show_bgp_instance_updgrps_stats
,
11740 show_bgp_instance_updgrps_stats_cmd
,
11741 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11745 BGP_INSTANCE_HELP_STR
11746 "Detailed info about dynamic update groups\n"
11752 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11754 update_group_show_stats(bgp
, vty
);
11756 return CMD_SUCCESS
;
11759 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11760 afi_t afi
, safi_t safi
,
11761 const char *what
, uint64_t subgrp_id
)
11766 bgp
= bgp_lookup_by_name(name
);
11768 bgp
= bgp_get_default();
11771 if (!strcmp(what
, "advertise-queue"))
11772 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11774 else if (!strcmp(what
, "advertised-routes"))
11775 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11777 else if (!strcmp(what
, "packet-queue"))
11778 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11783 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11784 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11785 "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",
11786 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11788 "Detailed info about dynamic update groups\n"
11789 "Specific subgroup to display info for\n"
11790 "Advertisement queue\n"
11791 "Announced routes\n"
11794 uint64_t subgrp_id
= 0;
11798 subgrp_id
= strtoull(sgid
, NULL
, 10);
11803 afiz
= bgp_vty_afi_from_str(afi
);
11807 afiz
= bgp_vty_afi_from_str(afi
);
11808 if (afiz
!= AFI_IP
)
11810 "%% Cannot specify both 'ip' and 'ipv6'\n");
11811 return CMD_WARNING
;
11814 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11816 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11817 return CMD_SUCCESS
;
11820 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11822 struct listnode
*node
, *nnode
;
11823 struct prefix
*range
;
11826 char buf
[PREFIX2STR_BUFFER
];
11829 const char *peer_status
;
11830 const char *af_str
;
11835 conf
= group
->conf
;
11837 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11838 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11839 group
->name
, conf
->as
);
11840 } else if (conf
->as_type
== AS_INTERNAL
) {
11841 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11842 group
->name
, group
->bgp
->as
);
11844 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11847 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11848 vty_out(vty
, " Peer-group type is internal\n");
11850 vty_out(vty
, " Peer-group type is external\n");
11852 /* Display AFs configured. */
11853 vty_out(vty
, " Configured address-families:");
11854 FOREACH_AFI_SAFI (afi
, safi
) {
11855 if (conf
->afc
[afi
][safi
]) {
11857 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11861 vty_out(vty
, " none\n");
11863 vty_out(vty
, "\n");
11865 /* Display listen ranges (for dynamic neighbors), if any */
11866 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11869 else if (afi
== AFI_IP6
)
11873 lr_count
= listcount(group
->listen_range
[afi
]);
11875 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11879 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11881 prefix2str(range
, buf
, sizeof(buf
));
11882 vty_out(vty
, " %s\n", buf
);
11887 /* Display group members and their status */
11888 if (listcount(group
->peer
)) {
11889 vty_out(vty
, " Peer-group members:\n");
11890 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11891 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11892 peer_status
= "Idle (Admin)";
11893 else if (CHECK_FLAG(peer
->sflags
,
11894 PEER_STATUS_PREFIX_OVERFLOW
))
11895 peer_status
= "Idle (PfxCt)";
11897 peer_status
= lookup_msg(bgp_status_msg
,
11898 peer
->status
, NULL
);
11900 dynamic
= peer_dynamic_neighbor(peer
);
11901 vty_out(vty
, " %s %s %s \n", peer
->host
,
11902 dynamic
? "(dynamic)" : "", peer_status
);
11906 return CMD_SUCCESS
;
11909 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11910 const char *group_name
)
11913 struct listnode
*node
, *nnode
;
11914 struct peer_group
*group
;
11915 bool found
= false;
11917 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11920 vty_out(vty
, "%% BGP instance not found\n");
11921 return CMD_WARNING
;
11924 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11926 if (strmatch(group
->name
, group_name
)) {
11927 bgp_show_one_peer_group(vty
, group
);
11932 bgp_show_one_peer_group(vty
, group
);
11936 if (group_name
&& !found
)
11937 vty_out(vty
, "%% No such peer-group\n");
11939 return CMD_SUCCESS
;
11942 DEFUN (show_ip_bgp_peer_groups
,
11943 show_ip_bgp_peer_groups_cmd
,
11944 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11948 BGP_INSTANCE_HELP_STR
11949 "Detailed information on BGP peer groups\n"
11950 "Peer group name\n")
11955 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11957 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11959 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11963 /* Redistribute VTY commands. */
11965 DEFUN (bgp_redistribute_ipv4
,
11966 bgp_redistribute_ipv4_cmd
,
11967 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11968 "Redistribute information from another routing protocol\n"
11969 FRR_IP_REDIST_HELP_STR_BGPD
)
11971 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11972 int idx_protocol
= 1;
11975 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11977 vty_out(vty
, "%% Invalid route type\n");
11978 return CMD_WARNING_CONFIG_FAILED
;
11981 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11982 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11986 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11987 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11988 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11990 DEFUN (bgp_redistribute_ipv4_rmap
,
11991 bgp_redistribute_ipv4_rmap_cmd
,
11992 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11993 "Redistribute information from another routing protocol\n"
11994 FRR_IP_REDIST_HELP_STR_BGPD
11995 "Route map reference\n"
11996 "Pointer to route-map entries\n")
11998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11999 int idx_protocol
= 1;
12002 struct bgp_redist
*red
;
12004 struct route_map
*route_map
= route_map_lookup_warn_noexist(
12005 vty
, argv
[idx_word
]->arg
);
12007 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12009 vty_out(vty
, "%% Invalid route type\n");
12010 return CMD_WARNING_CONFIG_FAILED
;
12013 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12015 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12016 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12020 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12021 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12022 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12023 "Route map reference\n"
12024 "Pointer to route-map entries\n")
12026 DEFUN (bgp_redistribute_ipv4_metric
,
12027 bgp_redistribute_ipv4_metric_cmd
,
12028 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12029 "Redistribute information from another routing protocol\n"
12030 FRR_IP_REDIST_HELP_STR_BGPD
12031 "Metric for redistributed routes\n"
12032 "Default metric\n")
12034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12035 int idx_protocol
= 1;
12036 int idx_number
= 3;
12039 struct bgp_redist
*red
;
12042 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12044 vty_out(vty
, "%% Invalid route type\n");
12045 return CMD_WARNING_CONFIG_FAILED
;
12047 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12049 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12050 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12051 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12055 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12056 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12057 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12058 "Metric for redistributed routes\n"
12059 "Default metric\n")
12061 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12062 bgp_redistribute_ipv4_rmap_metric_cmd
,
12063 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12064 "Redistribute information from another routing protocol\n"
12065 FRR_IP_REDIST_HELP_STR_BGPD
12066 "Route map reference\n"
12067 "Pointer to route-map entries\n"
12068 "Metric for redistributed routes\n"
12069 "Default metric\n")
12071 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12072 int idx_protocol
= 1;
12074 int idx_number
= 5;
12077 struct bgp_redist
*red
;
12079 struct route_map
*route_map
=
12080 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12082 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12084 vty_out(vty
, "%% Invalid route type\n");
12085 return CMD_WARNING_CONFIG_FAILED
;
12087 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12089 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12091 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12092 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12093 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12097 bgp_redistribute_ipv4_rmap_metric
,
12098 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12099 "redistribute " FRR_IP_REDIST_STR_BGPD
12100 " route-map WORD metric (0-4294967295)",
12101 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12102 "Route map reference\n"
12103 "Pointer to route-map entries\n"
12104 "Metric for redistributed routes\n"
12105 "Default metric\n")
12107 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12108 bgp_redistribute_ipv4_metric_rmap_cmd
,
12109 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12110 "Redistribute information from another routing protocol\n"
12111 FRR_IP_REDIST_HELP_STR_BGPD
12112 "Metric for redistributed routes\n"
12114 "Route map reference\n"
12115 "Pointer to route-map entries\n")
12117 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12118 int idx_protocol
= 1;
12119 int idx_number
= 3;
12123 struct bgp_redist
*red
;
12125 struct route_map
*route_map
=
12126 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12128 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12130 vty_out(vty
, "%% Invalid route type\n");
12131 return CMD_WARNING_CONFIG_FAILED
;
12133 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12135 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12136 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12138 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12139 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12143 bgp_redistribute_ipv4_metric_rmap
,
12144 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12145 "redistribute " FRR_IP_REDIST_STR_BGPD
12146 " metric (0-4294967295) route-map WORD",
12147 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12148 "Metric for redistributed routes\n"
12150 "Route map reference\n"
12151 "Pointer to route-map entries\n")
12153 DEFUN (bgp_redistribute_ipv4_ospf
,
12154 bgp_redistribute_ipv4_ospf_cmd
,
12155 "redistribute <ospf|table> (1-65535)",
12156 "Redistribute information from another routing protocol\n"
12157 "Open Shortest Path First (OSPFv2)\n"
12158 "Non-main Kernel Routing Table\n"
12159 "Instance ID/Table ID\n")
12161 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12162 int idx_ospf_table
= 1;
12163 int idx_number
= 2;
12164 unsigned short instance
;
12165 unsigned short protocol
;
12167 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12169 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12170 protocol
= ZEBRA_ROUTE_OSPF
;
12172 protocol
= ZEBRA_ROUTE_TABLE
;
12174 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12175 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12178 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12179 "redistribute <ospf|table> (1-65535)",
12180 "Redistribute information from another routing protocol\n"
12181 "Open Shortest Path First (OSPFv2)\n"
12182 "Non-main Kernel Routing Table\n"
12183 "Instance ID/Table ID\n")
12185 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12186 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12187 "redistribute <ospf|table> (1-65535) route-map WORD",
12188 "Redistribute information from another routing protocol\n"
12189 "Open Shortest Path First (OSPFv2)\n"
12190 "Non-main Kernel Routing Table\n"
12191 "Instance ID/Table ID\n"
12192 "Route map reference\n"
12193 "Pointer to route-map entries\n")
12195 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12196 int idx_ospf_table
= 1;
12197 int idx_number
= 2;
12199 struct bgp_redist
*red
;
12200 unsigned short instance
;
12203 struct route_map
*route_map
=
12204 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12206 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12207 protocol
= ZEBRA_ROUTE_OSPF
;
12209 protocol
= ZEBRA_ROUTE_TABLE
;
12211 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12212 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12214 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12215 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12218 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12219 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12220 "redistribute <ospf|table> (1-65535) route-map WORD",
12221 "Redistribute information from another routing protocol\n"
12222 "Open Shortest Path First (OSPFv2)\n"
12223 "Non-main Kernel Routing Table\n"
12224 "Instance ID/Table ID\n"
12225 "Route map reference\n"
12226 "Pointer to route-map entries\n")
12228 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12229 bgp_redistribute_ipv4_ospf_metric_cmd
,
12230 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12231 "Redistribute information from another routing protocol\n"
12232 "Open Shortest Path First (OSPFv2)\n"
12233 "Non-main Kernel Routing Table\n"
12234 "Instance ID/Table ID\n"
12235 "Metric for redistributed routes\n"
12236 "Default metric\n")
12238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12239 int idx_ospf_table
= 1;
12240 int idx_number
= 2;
12241 int idx_number_2
= 4;
12243 struct bgp_redist
*red
;
12244 unsigned short instance
;
12248 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12249 protocol
= ZEBRA_ROUTE_OSPF
;
12251 protocol
= ZEBRA_ROUTE_TABLE
;
12253 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12254 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12256 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12257 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12259 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12262 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12263 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12264 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12265 "Redistribute information from another routing protocol\n"
12266 "Open Shortest Path First (OSPFv2)\n"
12267 "Non-main Kernel Routing Table\n"
12268 "Instance ID/Table ID\n"
12269 "Metric for redistributed routes\n"
12270 "Default metric\n")
12272 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12273 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12274 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12275 "Redistribute information from another routing protocol\n"
12276 "Open Shortest Path First (OSPFv2)\n"
12277 "Non-main Kernel Routing Table\n"
12278 "Instance ID/Table ID\n"
12279 "Route map reference\n"
12280 "Pointer to route-map entries\n"
12281 "Metric for redistributed routes\n"
12282 "Default metric\n")
12284 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12285 int idx_ospf_table
= 1;
12286 int idx_number
= 2;
12288 int idx_number_2
= 6;
12290 struct bgp_redist
*red
;
12291 unsigned short instance
;
12294 struct route_map
*route_map
=
12295 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12297 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12298 protocol
= ZEBRA_ROUTE_OSPF
;
12300 protocol
= ZEBRA_ROUTE_TABLE
;
12302 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12303 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12305 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12307 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12308 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12310 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12314 bgp_redistribute_ipv4_ospf_rmap_metric
,
12315 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12316 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12317 "Redistribute information from another routing protocol\n"
12318 "Open Shortest Path First (OSPFv2)\n"
12319 "Non-main Kernel Routing Table\n"
12320 "Instance ID/Table ID\n"
12321 "Route map reference\n"
12322 "Pointer to route-map entries\n"
12323 "Metric for redistributed routes\n"
12324 "Default metric\n")
12326 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12327 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12328 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12329 "Redistribute information from another routing protocol\n"
12330 "Open Shortest Path First (OSPFv2)\n"
12331 "Non-main Kernel Routing Table\n"
12332 "Instance ID/Table ID\n"
12333 "Metric for redistributed routes\n"
12335 "Route map reference\n"
12336 "Pointer to route-map entries\n")
12338 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12339 int idx_ospf_table
= 1;
12340 int idx_number
= 2;
12341 int idx_number_2
= 4;
12344 struct bgp_redist
*red
;
12345 unsigned short instance
;
12348 struct route_map
*route_map
=
12349 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12351 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12352 protocol
= ZEBRA_ROUTE_OSPF
;
12354 protocol
= ZEBRA_ROUTE_TABLE
;
12356 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12357 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12359 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12360 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12363 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12364 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12368 bgp_redistribute_ipv4_ospf_metric_rmap
,
12369 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12370 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12371 "Redistribute information from another routing protocol\n"
12372 "Open Shortest Path First (OSPFv2)\n"
12373 "Non-main Kernel Routing Table\n"
12374 "Instance ID/Table ID\n"
12375 "Metric for redistributed routes\n"
12377 "Route map reference\n"
12378 "Pointer to route-map entries\n")
12380 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12381 no_bgp_redistribute_ipv4_ospf_cmd
,
12382 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12384 "Redistribute information from another routing protocol\n"
12385 "Open Shortest Path First (OSPFv2)\n"
12386 "Non-main Kernel Routing Table\n"
12387 "Instance ID/Table ID\n"
12388 "Metric for redistributed routes\n"
12390 "Route map reference\n"
12391 "Pointer to route-map entries\n")
12393 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12394 int idx_ospf_table
= 2;
12395 int idx_number
= 3;
12396 unsigned short instance
;
12399 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12400 protocol
= ZEBRA_ROUTE_OSPF
;
12402 protocol
= ZEBRA_ROUTE_TABLE
;
12404 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12405 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12409 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12410 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12412 "Redistribute information from another routing protocol\n"
12413 "Open Shortest Path First (OSPFv2)\n"
12414 "Non-main Kernel Routing Table\n"
12415 "Instance ID/Table ID\n"
12416 "Metric for redistributed routes\n"
12418 "Route map reference\n"
12419 "Pointer to route-map entries\n")
12421 DEFUN (no_bgp_redistribute_ipv4
,
12422 no_bgp_redistribute_ipv4_cmd
,
12423 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12425 "Redistribute information from another routing protocol\n"
12426 FRR_IP_REDIST_HELP_STR_BGPD
12427 "Metric for redistributed routes\n"
12429 "Route map reference\n"
12430 "Pointer to route-map entries\n")
12432 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12433 int idx_protocol
= 2;
12436 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12438 vty_out(vty
, "%% Invalid route type\n");
12439 return CMD_WARNING_CONFIG_FAILED
;
12441 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12445 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12446 "no redistribute " FRR_IP_REDIST_STR_BGPD
12447 " [metric (0-4294967295)] [route-map WORD]",
12449 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12450 "Metric for redistributed routes\n"
12452 "Route map reference\n"
12453 "Pointer to route-map entries\n")
12455 DEFUN (bgp_redistribute_ipv6
,
12456 bgp_redistribute_ipv6_cmd
,
12457 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12458 "Redistribute information from another routing protocol\n"
12459 FRR_IP6_REDIST_HELP_STR_BGPD
)
12461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12462 int idx_protocol
= 1;
12465 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12467 vty_out(vty
, "%% Invalid route type\n");
12468 return CMD_WARNING_CONFIG_FAILED
;
12471 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12472 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12475 DEFUN (bgp_redistribute_ipv6_rmap
,
12476 bgp_redistribute_ipv6_rmap_cmd
,
12477 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12478 "Redistribute information from another routing protocol\n"
12479 FRR_IP6_REDIST_HELP_STR_BGPD
12480 "Route map reference\n"
12481 "Pointer to route-map entries\n")
12483 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12484 int idx_protocol
= 1;
12487 struct bgp_redist
*red
;
12489 struct route_map
*route_map
=
12490 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12492 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12494 vty_out(vty
, "%% Invalid route type\n");
12495 return CMD_WARNING_CONFIG_FAILED
;
12498 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12500 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12501 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12504 DEFUN (bgp_redistribute_ipv6_metric
,
12505 bgp_redistribute_ipv6_metric_cmd
,
12506 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12507 "Redistribute information from another routing protocol\n"
12508 FRR_IP6_REDIST_HELP_STR_BGPD
12509 "Metric for redistributed routes\n"
12510 "Default metric\n")
12512 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12513 int idx_protocol
= 1;
12514 int idx_number
= 3;
12517 struct bgp_redist
*red
;
12520 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12522 vty_out(vty
, "%% Invalid route type\n");
12523 return CMD_WARNING_CONFIG_FAILED
;
12525 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12527 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12528 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12529 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12532 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12533 bgp_redistribute_ipv6_rmap_metric_cmd
,
12534 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12535 "Redistribute information from another routing protocol\n"
12536 FRR_IP6_REDIST_HELP_STR_BGPD
12537 "Route map reference\n"
12538 "Pointer to route-map entries\n"
12539 "Metric for redistributed routes\n"
12540 "Default metric\n")
12542 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12543 int idx_protocol
= 1;
12545 int idx_number
= 5;
12548 struct bgp_redist
*red
;
12550 struct route_map
*route_map
=
12551 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12553 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12555 vty_out(vty
, "%% Invalid route type\n");
12556 return CMD_WARNING_CONFIG_FAILED
;
12558 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12560 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12562 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12563 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12565 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12568 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12569 bgp_redistribute_ipv6_metric_rmap_cmd
,
12570 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12571 "Redistribute information from another routing protocol\n"
12572 FRR_IP6_REDIST_HELP_STR_BGPD
12573 "Metric for redistributed routes\n"
12575 "Route map reference\n"
12576 "Pointer to route-map entries\n")
12578 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12579 int idx_protocol
= 1;
12580 int idx_number
= 3;
12584 struct bgp_redist
*red
;
12586 struct route_map
*route_map
=
12587 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12589 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12591 vty_out(vty
, "%% Invalid route type\n");
12592 return CMD_WARNING_CONFIG_FAILED
;
12594 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12596 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12597 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12600 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12601 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12604 DEFUN (no_bgp_redistribute_ipv6
,
12605 no_bgp_redistribute_ipv6_cmd
,
12606 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12608 "Redistribute information from another routing protocol\n"
12609 FRR_IP6_REDIST_HELP_STR_BGPD
12610 "Metric for redistributed routes\n"
12612 "Route map reference\n"
12613 "Pointer to route-map entries\n")
12615 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12616 int idx_protocol
= 2;
12619 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12621 vty_out(vty
, "%% Invalid route type\n");
12622 return CMD_WARNING_CONFIG_FAILED
;
12625 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12628 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12633 /* Unicast redistribution only. */
12634 if (safi
!= SAFI_UNICAST
)
12637 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12638 /* Redistribute BGP does not make sense. */
12639 if (i
!= ZEBRA_ROUTE_BGP
) {
12640 struct list
*red_list
;
12641 struct listnode
*node
;
12642 struct bgp_redist
*red
;
12644 red_list
= bgp
->redist
[afi
][i
];
12648 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12649 /* "redistribute" configuration. */
12650 vty_out(vty
, " redistribute %s",
12651 zebra_route_string(i
));
12653 vty_out(vty
, " %d", red
->instance
);
12654 if (red
->redist_metric_flag
)
12655 vty_out(vty
, " metric %u",
12656 red
->redist_metric
);
12657 if (red
->rmap
.name
)
12658 vty_out(vty
, " route-map %s",
12660 vty_out(vty
, "\n");
12666 /* This is part of the address-family block (unicast only) */
12667 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12672 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12673 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12674 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12675 bgp
->vpn_policy
[afi
]
12676 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12678 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12679 bgp
->vpn_policy
[afi
]
12680 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12682 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12683 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12684 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12685 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12688 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12689 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12691 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12694 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12695 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12696 bgp
->vpn_policy
[afi
].tovpn_label
);
12699 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12700 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12701 char buf
[RD_ADDRSTRLEN
];
12702 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12703 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12706 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12707 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12709 char buf
[PREFIX_STRLEN
];
12710 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12711 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12714 vty_out(vty
, "%*snexthop vpn export %s\n",
12718 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12719 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12721 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12722 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12724 char *b
= ecommunity_ecom2str(
12725 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12726 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12727 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12728 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12730 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12731 char *b
= ecommunity_ecom2str(
12732 bgp
->vpn_policy
[afi
]
12733 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12734 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12735 ECOMMUNITY_ROUTE_TARGET
);
12736 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12737 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12739 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12740 char *b
= ecommunity_ecom2str(
12741 bgp
->vpn_policy
[afi
]
12742 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12743 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12744 ECOMMUNITY_ROUTE_TARGET
);
12745 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12746 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12750 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12751 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12752 bgp
->vpn_policy
[afi
]
12753 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12755 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12756 char *b
= ecommunity_ecom2str(
12757 bgp
->vpn_policy
[afi
]
12758 .import_redirect_rtlist
,
12759 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12760 ECOMMUNITY_ROUTE_TARGET
);
12762 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12763 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12768 /* BGP node structure. */
12769 static struct cmd_node bgp_node
= {
12770 BGP_NODE
, "%s(config-router)# ", 1,
12773 static struct cmd_node bgp_ipv4_unicast_node
= {
12774 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12777 static struct cmd_node bgp_ipv4_multicast_node
= {
12778 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12781 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12782 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12785 static struct cmd_node bgp_ipv6_unicast_node
= {
12786 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12789 static struct cmd_node bgp_ipv6_multicast_node
= {
12790 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12793 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12794 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12797 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12798 "%s(config-router-af)# ", 1};
12800 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12801 "%s(config-router-af-vpnv6)# ", 1};
12803 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12804 "%s(config-router-evpn)# ", 1};
12806 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12807 "%s(config-router-af-vni)# ", 1};
12809 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12810 "%s(config-router-af)# ", 1};
12812 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12813 "%s(config-router-af-vpnv6)# ", 1};
12815 static void community_list_vty(void);
12817 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12821 struct listnode
*lnbgp
, *lnpeer
;
12823 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12824 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12825 /* only provide suggestions on the appropriate input
12827 * they'll otherwise show up multiple times */
12828 enum cmd_token_type match_type
;
12829 char *name
= peer
->host
;
12831 if (peer
->conf_if
) {
12832 match_type
= VARIABLE_TKN
;
12833 name
= peer
->conf_if
;
12834 } else if (strchr(peer
->host
, ':'))
12835 match_type
= IPV6_TKN
;
12837 match_type
= IPV4_TKN
;
12839 if (token
->type
!= match_type
)
12842 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12847 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12848 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12849 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12850 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12851 {.completions
= NULL
}};
12853 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12856 struct peer_group
*group
;
12857 struct listnode
*lnbgp
, *lnpeer
;
12859 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12860 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12861 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12866 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12867 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12868 {.completions
= NULL
} };
12870 void bgp_vty_init(void)
12872 cmd_variable_handler_register(bgp_var_neighbor
);
12873 cmd_variable_handler_register(bgp_var_peergroup
);
12875 /* Install bgp top node. */
12876 install_node(&bgp_node
, bgp_config_write
);
12877 install_node(&bgp_ipv4_unicast_node
, NULL
);
12878 install_node(&bgp_ipv4_multicast_node
, NULL
);
12879 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12880 install_node(&bgp_ipv6_unicast_node
, NULL
);
12881 install_node(&bgp_ipv6_multicast_node
, NULL
);
12882 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12883 install_node(&bgp_vpnv4_node
, NULL
);
12884 install_node(&bgp_vpnv6_node
, NULL
);
12885 install_node(&bgp_evpn_node
, NULL
);
12886 install_node(&bgp_evpn_vni_node
, NULL
);
12887 install_node(&bgp_flowspecv4_node
, NULL
);
12888 install_node(&bgp_flowspecv6_node
, NULL
);
12890 /* Install default VTY commands to new nodes. */
12891 install_default(BGP_NODE
);
12892 install_default(BGP_IPV4_NODE
);
12893 install_default(BGP_IPV4M_NODE
);
12894 install_default(BGP_IPV4L_NODE
);
12895 install_default(BGP_IPV6_NODE
);
12896 install_default(BGP_IPV6M_NODE
);
12897 install_default(BGP_IPV6L_NODE
);
12898 install_default(BGP_VPNV4_NODE
);
12899 install_default(BGP_VPNV6_NODE
);
12900 install_default(BGP_FLOWSPECV4_NODE
);
12901 install_default(BGP_FLOWSPECV6_NODE
);
12902 install_default(BGP_EVPN_NODE
);
12903 install_default(BGP_EVPN_VNI_NODE
);
12905 /* "bgp multiple-instance" commands. */
12906 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12907 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12909 /* "bgp config-type" commands. */
12910 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12911 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12913 /* "bgp local-mac" hidden commands. */
12914 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12915 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12917 /* bgp route-map delay-timer commands. */
12918 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12919 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12921 /* Dummy commands (Currently not supported) */
12922 install_element(BGP_NODE
, &no_synchronization_cmd
);
12923 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12925 /* "router bgp" commands. */
12926 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12928 /* "no router bgp" commands. */
12929 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12931 /* "bgp router-id" commands. */
12932 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12933 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12935 /* "bgp cluster-id" commands. */
12936 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12937 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12939 /* "bgp confederation" commands. */
12940 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12941 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12943 /* "bgp confederation peers" commands. */
12944 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12945 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12947 /* bgp max-med command */
12948 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12949 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12950 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12951 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12952 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12954 /* bgp disable-ebgp-connected-nh-check */
12955 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12956 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12958 /* bgp update-delay command */
12959 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12960 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12961 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12963 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12964 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12965 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12966 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12968 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12969 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12971 /* "maximum-paths" commands. */
12972 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12973 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12974 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12975 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12976 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12977 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12978 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12979 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12980 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12981 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12982 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12983 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12984 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12985 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12986 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12988 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12989 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12990 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12991 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12992 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12994 /* "timers bgp" commands. */
12995 install_element(BGP_NODE
, &bgp_timers_cmd
);
12996 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12998 /* route-map delay-timer commands - per instance for backwards compat.
13000 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13001 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13003 /* "bgp client-to-client reflection" commands */
13004 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
13005 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
13007 /* "bgp always-compare-med" commands */
13008 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
13009 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
13011 /* bgp ebgp-requires-policy */
13012 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
13013 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
13015 /* "bgp deterministic-med" commands */
13016 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
13017 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
13019 /* "bgp graceful-restart" commands */
13020 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
13021 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
13022 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
13023 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
13024 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
13025 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
13027 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
13028 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
13030 /* "bgp graceful-shutdown" commands */
13031 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
13032 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13034 /* "bgp fast-external-failover" commands */
13035 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13036 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13038 /* "bgp enforce-first-as" commands */
13039 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
13041 /* "bgp bestpath compare-routerid" commands */
13042 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13043 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13045 /* "bgp bestpath as-path ignore" commands */
13046 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13047 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13049 /* "bgp bestpath as-path confed" commands */
13050 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13051 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13053 /* "bgp bestpath as-path multipath-relax" commands */
13054 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13055 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13057 /* "bgp log-neighbor-changes" commands */
13058 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13059 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13061 /* "bgp bestpath med" commands */
13062 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13063 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13065 /* "no bgp default ipv4-unicast" commands. */
13066 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13067 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13069 /* "bgp network import-check" commands. */
13070 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13071 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13072 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13074 /* "bgp default local-preference" commands. */
13075 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13076 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13078 /* bgp default show-hostname */
13079 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13080 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13082 /* "bgp default subgroup-pkt-queue-max" commands. */
13083 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13084 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13086 /* bgp ibgp-allow-policy-mods command */
13087 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13088 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13090 /* "bgp listen limit" commands. */
13091 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13092 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13094 /* "bgp listen range" commands. */
13095 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13096 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13098 /* "bgp default shutdown" command */
13099 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13101 /* "neighbor remote-as" commands. */
13102 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13103 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13104 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13105 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13106 install_element(BGP_NODE
,
13107 &neighbor_interface_v6only_config_remote_as_cmd
);
13108 install_element(BGP_NODE
, &no_neighbor_cmd
);
13109 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13111 /* "neighbor peer-group" commands. */
13112 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13113 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13114 install_element(BGP_NODE
,
13115 &no_neighbor_interface_peer_group_remote_as_cmd
);
13117 /* "neighbor local-as" commands. */
13118 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13119 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13120 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13121 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13123 /* "neighbor solo" commands. */
13124 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13125 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13127 /* "neighbor password" commands. */
13128 install_element(BGP_NODE
, &neighbor_password_cmd
);
13129 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13131 /* "neighbor activate" commands. */
13132 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13133 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13134 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13135 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13136 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13137 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13138 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13139 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13140 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13141 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13142 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13143 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13145 /* "no neighbor activate" commands. */
13146 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13147 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13148 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13149 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13150 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13151 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13152 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13153 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13154 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13155 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13156 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13157 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13159 /* "neighbor peer-group" set commands. */
13160 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13161 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13162 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13163 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13164 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13165 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13166 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13167 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13168 install_element(BGP_FLOWSPECV4_NODE
,
13169 &neighbor_set_peer_group_hidden_cmd
);
13170 install_element(BGP_FLOWSPECV6_NODE
,
13171 &neighbor_set_peer_group_hidden_cmd
);
13173 /* "no neighbor peer-group unset" commands. */
13174 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13175 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13176 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13177 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13178 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13179 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13180 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13181 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13182 install_element(BGP_FLOWSPECV4_NODE
,
13183 &no_neighbor_set_peer_group_hidden_cmd
);
13184 install_element(BGP_FLOWSPECV6_NODE
,
13185 &no_neighbor_set_peer_group_hidden_cmd
);
13187 /* "neighbor softreconfiguration inbound" commands.*/
13188 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13189 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13190 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13191 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13192 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13193 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13194 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13195 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13196 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13197 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13198 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13199 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13200 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13201 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13202 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13203 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13204 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13205 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13206 install_element(BGP_FLOWSPECV4_NODE
,
13207 &neighbor_soft_reconfiguration_cmd
);
13208 install_element(BGP_FLOWSPECV4_NODE
,
13209 &no_neighbor_soft_reconfiguration_cmd
);
13210 install_element(BGP_FLOWSPECV6_NODE
,
13211 &neighbor_soft_reconfiguration_cmd
);
13212 install_element(BGP_FLOWSPECV6_NODE
,
13213 &no_neighbor_soft_reconfiguration_cmd
);
13214 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13215 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13217 /* "neighbor attribute-unchanged" commands. */
13218 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13219 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13220 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13221 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13222 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13223 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13224 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13225 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13226 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13227 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13228 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13229 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13230 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13231 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13232 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13233 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13234 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13235 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13237 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13238 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13240 /* "nexthop-local unchanged" commands */
13241 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13242 install_element(BGP_IPV6_NODE
,
13243 &no_neighbor_nexthop_local_unchanged_cmd
);
13245 /* "neighbor next-hop-self" commands. */
13246 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13247 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13248 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13249 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13250 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13251 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13252 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13253 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13254 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13255 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13256 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13257 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13258 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13259 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13260 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13261 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13262 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13263 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13264 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13265 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13267 /* "neighbor next-hop-self force" commands. */
13268 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13269 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13270 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13271 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13272 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13273 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13274 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13275 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13276 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13277 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13278 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13279 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13280 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13281 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13282 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13283 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13284 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13285 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13286 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13287 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13289 /* "neighbor as-override" commands. */
13290 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13291 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13292 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13293 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13294 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13295 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13296 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13297 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13298 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13299 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13300 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13301 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13302 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13303 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13304 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13305 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13306 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13307 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13309 /* "neighbor remove-private-AS" commands. */
13310 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13311 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13312 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13313 install_element(BGP_NODE
,
13314 &no_neighbor_remove_private_as_all_hidden_cmd
);
13315 install_element(BGP_NODE
,
13316 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13317 install_element(BGP_NODE
,
13318 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13319 install_element(BGP_NODE
,
13320 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13323 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13324 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13325 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13326 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13327 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13328 install_element(BGP_IPV4_NODE
,
13329 &neighbor_remove_private_as_replace_as_cmd
);
13330 install_element(BGP_IPV4_NODE
,
13331 &no_neighbor_remove_private_as_replace_as_cmd
);
13332 install_element(BGP_IPV4_NODE
,
13333 &neighbor_remove_private_as_all_replace_as_cmd
);
13334 install_element(BGP_IPV4_NODE
,
13335 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13336 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13337 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13338 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13339 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13340 install_element(BGP_IPV4M_NODE
,
13341 &neighbor_remove_private_as_replace_as_cmd
);
13342 install_element(BGP_IPV4M_NODE
,
13343 &no_neighbor_remove_private_as_replace_as_cmd
);
13344 install_element(BGP_IPV4M_NODE
,
13345 &neighbor_remove_private_as_all_replace_as_cmd
);
13346 install_element(BGP_IPV4M_NODE
,
13347 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13348 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13349 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13350 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13351 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13352 install_element(BGP_IPV4L_NODE
,
13353 &neighbor_remove_private_as_replace_as_cmd
);
13354 install_element(BGP_IPV4L_NODE
,
13355 &no_neighbor_remove_private_as_replace_as_cmd
);
13356 install_element(BGP_IPV4L_NODE
,
13357 &neighbor_remove_private_as_all_replace_as_cmd
);
13358 install_element(BGP_IPV4L_NODE
,
13359 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13360 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13361 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13362 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13363 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13364 install_element(BGP_IPV6_NODE
,
13365 &neighbor_remove_private_as_replace_as_cmd
);
13366 install_element(BGP_IPV6_NODE
,
13367 &no_neighbor_remove_private_as_replace_as_cmd
);
13368 install_element(BGP_IPV6_NODE
,
13369 &neighbor_remove_private_as_all_replace_as_cmd
);
13370 install_element(BGP_IPV6_NODE
,
13371 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13372 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13373 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13374 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13375 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13376 install_element(BGP_IPV6M_NODE
,
13377 &neighbor_remove_private_as_replace_as_cmd
);
13378 install_element(BGP_IPV6M_NODE
,
13379 &no_neighbor_remove_private_as_replace_as_cmd
);
13380 install_element(BGP_IPV6M_NODE
,
13381 &neighbor_remove_private_as_all_replace_as_cmd
);
13382 install_element(BGP_IPV6M_NODE
,
13383 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13384 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13385 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13386 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13387 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13388 install_element(BGP_IPV6L_NODE
,
13389 &neighbor_remove_private_as_replace_as_cmd
);
13390 install_element(BGP_IPV6L_NODE
,
13391 &no_neighbor_remove_private_as_replace_as_cmd
);
13392 install_element(BGP_IPV6L_NODE
,
13393 &neighbor_remove_private_as_all_replace_as_cmd
);
13394 install_element(BGP_IPV6L_NODE
,
13395 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13396 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13397 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13398 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13399 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13400 install_element(BGP_VPNV4_NODE
,
13401 &neighbor_remove_private_as_replace_as_cmd
);
13402 install_element(BGP_VPNV4_NODE
,
13403 &no_neighbor_remove_private_as_replace_as_cmd
);
13404 install_element(BGP_VPNV4_NODE
,
13405 &neighbor_remove_private_as_all_replace_as_cmd
);
13406 install_element(BGP_VPNV4_NODE
,
13407 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13408 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13409 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13410 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13411 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13412 install_element(BGP_VPNV6_NODE
,
13413 &neighbor_remove_private_as_replace_as_cmd
);
13414 install_element(BGP_VPNV6_NODE
,
13415 &no_neighbor_remove_private_as_replace_as_cmd
);
13416 install_element(BGP_VPNV6_NODE
,
13417 &neighbor_remove_private_as_all_replace_as_cmd
);
13418 install_element(BGP_VPNV6_NODE
,
13419 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13421 /* "neighbor send-community" commands.*/
13422 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13423 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13424 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13425 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13426 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13427 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13428 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13429 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13430 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13431 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13432 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13433 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13434 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13435 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13436 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13437 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13438 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13439 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13440 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13441 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13442 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13443 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13444 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13445 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13446 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13447 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13448 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13449 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13450 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13451 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13452 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13453 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13454 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13455 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13456 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13457 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13459 /* "neighbor route-reflector" commands.*/
13460 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13461 install_element(BGP_NODE
,
13462 &no_neighbor_route_reflector_client_hidden_cmd
);
13463 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13464 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13465 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13466 install_element(BGP_IPV4M_NODE
,
13467 &no_neighbor_route_reflector_client_cmd
);
13468 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13469 install_element(BGP_IPV4L_NODE
,
13470 &no_neighbor_route_reflector_client_cmd
);
13471 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13472 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13473 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13474 install_element(BGP_IPV6M_NODE
,
13475 &no_neighbor_route_reflector_client_cmd
);
13476 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13477 install_element(BGP_IPV6L_NODE
,
13478 &no_neighbor_route_reflector_client_cmd
);
13479 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13480 install_element(BGP_VPNV4_NODE
,
13481 &no_neighbor_route_reflector_client_cmd
);
13482 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13483 install_element(BGP_VPNV6_NODE
,
13484 &no_neighbor_route_reflector_client_cmd
);
13485 install_element(BGP_FLOWSPECV4_NODE
,
13486 &neighbor_route_reflector_client_cmd
);
13487 install_element(BGP_FLOWSPECV4_NODE
,
13488 &no_neighbor_route_reflector_client_cmd
);
13489 install_element(BGP_FLOWSPECV6_NODE
,
13490 &neighbor_route_reflector_client_cmd
);
13491 install_element(BGP_FLOWSPECV6_NODE
,
13492 &no_neighbor_route_reflector_client_cmd
);
13493 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13494 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13496 /* "neighbor route-server" commands.*/
13497 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13498 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13499 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13500 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13501 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13502 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13503 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13504 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13505 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13506 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13507 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13508 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13509 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13510 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13511 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13512 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13513 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13514 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13515 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13516 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13517 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13518 install_element(BGP_FLOWSPECV4_NODE
,
13519 &no_neighbor_route_server_client_cmd
);
13520 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13521 install_element(BGP_FLOWSPECV6_NODE
,
13522 &no_neighbor_route_server_client_cmd
);
13524 /* "neighbor addpath-tx-all-paths" commands.*/
13525 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13526 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13527 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13528 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13529 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13530 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13531 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13532 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13533 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13534 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13535 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13536 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13537 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13538 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13539 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13540 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13541 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13542 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13544 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13545 install_element(BGP_NODE
,
13546 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13547 install_element(BGP_NODE
,
13548 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13549 install_element(BGP_IPV4_NODE
,
13550 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13551 install_element(BGP_IPV4_NODE
,
13552 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13553 install_element(BGP_IPV4M_NODE
,
13554 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13555 install_element(BGP_IPV4M_NODE
,
13556 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13557 install_element(BGP_IPV4L_NODE
,
13558 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13559 install_element(BGP_IPV4L_NODE
,
13560 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13561 install_element(BGP_IPV6_NODE
,
13562 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13563 install_element(BGP_IPV6_NODE
,
13564 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13565 install_element(BGP_IPV6M_NODE
,
13566 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13567 install_element(BGP_IPV6M_NODE
,
13568 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13569 install_element(BGP_IPV6L_NODE
,
13570 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13571 install_element(BGP_IPV6L_NODE
,
13572 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13573 install_element(BGP_VPNV4_NODE
,
13574 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13575 install_element(BGP_VPNV4_NODE
,
13576 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13577 install_element(BGP_VPNV6_NODE
,
13578 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13579 install_element(BGP_VPNV6_NODE
,
13580 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13582 /* "neighbor passive" commands. */
13583 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13584 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13587 /* "neighbor shutdown" commands. */
13588 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13589 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13590 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13591 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13593 /* "neighbor capability extended-nexthop" commands.*/
13594 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13595 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13597 /* "neighbor capability orf prefix-list" commands.*/
13598 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13599 install_element(BGP_NODE
,
13600 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13601 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13602 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13603 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13604 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13605 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13606 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13607 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13608 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13609 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13610 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13611 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13612 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13614 /* "neighbor capability dynamic" commands.*/
13615 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13616 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13618 /* "neighbor dont-capability-negotiate" commands. */
13619 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13620 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13622 /* "neighbor ebgp-multihop" commands. */
13623 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13624 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13625 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13627 /* "neighbor disable-connected-check" commands. */
13628 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13629 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13631 /* "neighbor enforce-first-as" commands. */
13632 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13633 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13635 /* "neighbor description" commands. */
13636 install_element(BGP_NODE
, &neighbor_description_cmd
);
13637 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13638 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13640 /* "neighbor update-source" commands. "*/
13641 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13642 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13644 /* "neighbor default-originate" commands. */
13645 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13646 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13647 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13648 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13649 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13650 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13651 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13652 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13653 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13654 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13655 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13656 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13657 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13658 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13659 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13660 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13661 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13662 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13663 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13664 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13665 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13667 /* "neighbor port" commands. */
13668 install_element(BGP_NODE
, &neighbor_port_cmd
);
13669 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13671 /* "neighbor weight" commands. */
13672 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13673 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13675 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13676 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13677 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13678 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13679 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13680 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13681 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13682 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13683 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13684 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13685 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13686 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13687 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13688 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13689 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13690 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13692 /* "neighbor override-capability" commands. */
13693 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13694 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13696 /* "neighbor strict-capability-match" commands. */
13697 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13698 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13700 /* "neighbor timers" commands. */
13701 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13702 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13704 /* "neighbor timers connect" commands. */
13705 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13706 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13708 /* "neighbor advertisement-interval" commands. */
13709 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13710 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13712 /* "neighbor interface" commands. */
13713 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13714 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13716 /* "neighbor distribute" commands. */
13717 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13718 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13719 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13720 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13721 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13722 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13723 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13724 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13725 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13726 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13727 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13728 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13729 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13730 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13731 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13732 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13733 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13734 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13736 /* "neighbor prefix-list" commands. */
13737 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13738 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13739 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13740 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13741 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13742 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13743 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13744 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13745 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13746 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13747 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13748 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13749 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13750 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13751 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13752 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13753 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13754 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13755 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13756 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13757 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13758 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13760 /* "neighbor filter-list" commands. */
13761 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13762 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13763 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13764 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13765 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13766 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13767 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13768 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13769 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13770 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13771 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13772 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13773 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13774 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13775 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13776 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13777 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13778 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13779 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13780 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13781 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13782 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13784 /* "neighbor route-map" commands. */
13785 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13786 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13787 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13788 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13789 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13790 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13791 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13792 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13793 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13794 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13795 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13796 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13797 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13798 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13799 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13800 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13801 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13802 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13803 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13804 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13805 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13806 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13807 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13808 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13810 /* "neighbor unsuppress-map" commands. */
13811 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13812 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13813 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13814 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13815 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13816 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13817 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13818 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13819 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13820 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13821 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13822 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13823 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13824 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13825 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13826 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13827 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13828 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13830 /* "neighbor maximum-prefix" commands. */
13831 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13832 install_element(BGP_NODE
,
13833 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13834 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13835 install_element(BGP_NODE
,
13836 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13837 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13838 install_element(BGP_NODE
,
13839 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13840 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13841 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13842 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13843 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13844 install_element(BGP_IPV4_NODE
,
13845 &neighbor_maximum_prefix_threshold_warning_cmd
);
13846 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13847 install_element(BGP_IPV4_NODE
,
13848 &neighbor_maximum_prefix_threshold_restart_cmd
);
13849 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13850 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13851 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13852 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13853 install_element(BGP_IPV4M_NODE
,
13854 &neighbor_maximum_prefix_threshold_warning_cmd
);
13855 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13856 install_element(BGP_IPV4M_NODE
,
13857 &neighbor_maximum_prefix_threshold_restart_cmd
);
13858 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13859 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13860 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13861 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13862 install_element(BGP_IPV4L_NODE
,
13863 &neighbor_maximum_prefix_threshold_warning_cmd
);
13864 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13865 install_element(BGP_IPV4L_NODE
,
13866 &neighbor_maximum_prefix_threshold_restart_cmd
);
13867 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13868 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13869 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13870 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13871 install_element(BGP_IPV6_NODE
,
13872 &neighbor_maximum_prefix_threshold_warning_cmd
);
13873 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13874 install_element(BGP_IPV6_NODE
,
13875 &neighbor_maximum_prefix_threshold_restart_cmd
);
13876 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13877 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13878 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13879 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13880 install_element(BGP_IPV6M_NODE
,
13881 &neighbor_maximum_prefix_threshold_warning_cmd
);
13882 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13883 install_element(BGP_IPV6M_NODE
,
13884 &neighbor_maximum_prefix_threshold_restart_cmd
);
13885 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13886 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13887 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13888 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13889 install_element(BGP_IPV6L_NODE
,
13890 &neighbor_maximum_prefix_threshold_warning_cmd
);
13891 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13892 install_element(BGP_IPV6L_NODE
,
13893 &neighbor_maximum_prefix_threshold_restart_cmd
);
13894 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13895 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13896 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13897 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13898 install_element(BGP_VPNV4_NODE
,
13899 &neighbor_maximum_prefix_threshold_warning_cmd
);
13900 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13901 install_element(BGP_VPNV4_NODE
,
13902 &neighbor_maximum_prefix_threshold_restart_cmd
);
13903 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13904 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13905 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13906 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13907 install_element(BGP_VPNV6_NODE
,
13908 &neighbor_maximum_prefix_threshold_warning_cmd
);
13909 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13910 install_element(BGP_VPNV6_NODE
,
13911 &neighbor_maximum_prefix_threshold_restart_cmd
);
13912 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13914 /* "neighbor allowas-in" */
13915 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13916 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13917 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13918 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13919 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13920 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13921 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13922 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13923 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13924 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13925 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13926 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13927 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13928 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13929 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13930 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13931 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13932 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13933 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13934 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13936 /* address-family commands. */
13937 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13938 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13939 #ifdef KEEP_OLD_VPN_COMMANDS
13940 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13941 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13942 #endif /* KEEP_OLD_VPN_COMMANDS */
13944 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13946 /* "exit-address-family" command. */
13947 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13948 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13949 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13950 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13951 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13952 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13953 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13954 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13955 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13956 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13957 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13959 /* "clear ip bgp commands" */
13960 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13962 /* clear ip bgp prefix */
13963 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13964 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13965 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13967 /* "show [ip] bgp summary" commands. */
13968 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13969 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13970 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13971 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13972 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13973 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13974 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13976 /* "show [ip] bgp neighbors" commands. */
13977 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13979 /* "show [ip] bgp peer-group" commands. */
13980 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13982 /* "show [ip] bgp paths" commands. */
13983 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13985 /* "show [ip] bgp community" commands. */
13986 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13988 /* "show ip bgp large-community" commands. */
13989 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13990 /* "show [ip] bgp attribute-info" commands. */
13991 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13992 /* "show [ip] bgp route-leak" command */
13993 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13995 /* "redistribute" commands. */
13996 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13997 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13998 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13999 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
14000 install_element(BGP_NODE
,
14001 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
14002 install_element(BGP_NODE
,
14003 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
14004 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
14005 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
14006 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
14007 install_element(BGP_NODE
,
14008 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
14009 install_element(BGP_NODE
,
14010 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
14011 install_element(BGP_NODE
,
14012 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
14013 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
14014 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
14015 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
14016 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
14017 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
14018 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
14019 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
14020 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
14021 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
14022 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
14023 install_element(BGP_IPV4_NODE
,
14024 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
14025 install_element(BGP_IPV4_NODE
,
14026 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
14027 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
14028 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
14029 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
14030 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
14031 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
14032 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
14034 /* import|export vpn [route-map WORD] */
14035 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14036 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14038 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14039 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14041 /* ttl_security commands */
14042 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14043 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14045 /* "show [ip] bgp memory" commands. */
14046 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14048 /* "show bgp martian next-hop" */
14049 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14051 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14053 /* "show [ip] bgp views" commands. */
14054 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14056 /* "show [ip] bgp vrfs" commands. */
14057 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14059 /* Community-list. */
14060 community_list_vty();
14062 /* vpn-policy commands */
14063 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14064 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14065 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14066 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14067 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14068 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14069 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14070 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14071 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14072 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14073 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14074 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14076 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14077 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14079 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14080 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14081 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14082 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14083 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14084 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14085 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14086 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14087 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14088 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14089 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14090 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14093 #include "memory.h"
14094 #include "bgp_regex.h"
14095 #include "bgp_clist.h"
14096 #include "bgp_ecommunity.h"
14098 /* VTY functions. */
14100 /* Direction value to string conversion. */
14101 static const char *community_direct_str(int direct
)
14104 case COMMUNITY_DENY
:
14106 case COMMUNITY_PERMIT
:
14113 /* Display error string. */
14114 static void community_list_perror(struct vty
*vty
, int ret
)
14117 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14118 vty_out(vty
, "%% Can't find community-list\n");
14120 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14121 vty_out(vty
, "%% Malformed community-list value\n");
14123 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14125 "%% Community name conflict, previously defined as standard community\n");
14127 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14129 "%% Community name conflict, previously defined as expanded community\n");
14134 /* "community-list" keyword help string. */
14135 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14137 /*community-list standard */
14138 DEFUN (community_list_standard
,
14139 bgp_community_list_standard_cmd
,
14140 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14143 "Community list number (standard)\n"
14144 "Add an standard community-list entry\n"
14145 "Community list name\n"
14146 "Specify community to reject\n"
14147 "Specify community to accept\n"
14150 char *cl_name_or_number
= NULL
;
14152 int style
= COMMUNITY_LIST_STANDARD
;
14156 if (argv_find(argv
, argc
, "ip", &idx
)) {
14157 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14158 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14159 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14160 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14163 argv_find(argv
, argc
, "(1-99)", &idx
);
14164 argv_find(argv
, argc
, "WORD", &idx
);
14165 cl_name_or_number
= argv
[idx
]->arg
;
14166 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14168 argv_find(argv
, argc
, "AA:NN", &idx
);
14169 char *str
= argv_concat(argv
, argc
, idx
);
14171 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14174 XFREE(MTYPE_TMP
, str
);
14177 /* Display error string. */
14178 community_list_perror(vty
, ret
);
14179 return CMD_WARNING_CONFIG_FAILED
;
14182 return CMD_SUCCESS
;
14185 #if CONFDATE > 20191005
14186 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14188 ALIAS (community_list_standard
,
14189 ip_community_list_standard_cmd
,
14190 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14193 "Community list number (standard)\n"
14194 "Add an standard community-list entry\n"
14195 "Community list name\n"
14196 "Specify community to reject\n"
14197 "Specify community to accept\n"
14200 DEFUN (no_community_list_standard_all
,
14201 no_bgp_community_list_standard_all_cmd
,
14202 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14206 "Community list number (standard)\n"
14207 "Add an standard community-list entry\n"
14208 "Community list name\n"
14209 "Specify community to reject\n"
14210 "Specify community to accept\n"
14213 char *cl_name_or_number
= NULL
;
14216 int style
= COMMUNITY_LIST_STANDARD
;
14220 if (argv_find(argv
, argc
, "ip", &idx
)) {
14221 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14222 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14223 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14224 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14227 argv_find(argv
, argc
, "permit", &idx
);
14228 argv_find(argv
, argc
, "deny", &idx
);
14231 direct
= argv_find(argv
, argc
, "permit", &idx
)
14236 argv_find(argv
, argc
, "AA:NN", &idx
);
14237 str
= argv_concat(argv
, argc
, idx
);
14241 argv_find(argv
, argc
, "(1-99)", &idx
);
14242 argv_find(argv
, argc
, "WORD", &idx
);
14243 cl_name_or_number
= argv
[idx
]->arg
;
14245 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14248 XFREE(MTYPE_TMP
, str
);
14251 community_list_perror(vty
, ret
);
14252 return CMD_WARNING_CONFIG_FAILED
;
14255 return CMD_SUCCESS
;
14257 ALIAS (no_community_list_standard_all
,
14258 no_ip_community_list_standard_all_cmd
,
14259 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14263 "Community list number (standard)\n"
14264 "Add an standard community-list entry\n"
14265 "Community list name\n"
14266 "Specify community to reject\n"
14267 "Specify community to accept\n"
14270 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14271 "no bgp community-list <(1-99)|standard WORD>",
14272 NO_STR BGP_STR COMMUNITY_LIST_STR
14273 "Community list number (standard)\n"
14274 "Add an standard community-list entry\n"
14275 "Community list name\n")
14277 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14278 "no ip community-list <(1-99)|standard WORD>",
14279 NO_STR BGP_STR COMMUNITY_LIST_STR
14280 "Community list number (standard)\n"
14281 "Add an standard community-list entry\n"
14282 "Community list name\n")
14284 /*community-list expanded */
14285 DEFUN (community_list_expanded_all
,
14286 bgp_community_list_expanded_all_cmd
,
14287 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14290 "Community list number (expanded)\n"
14291 "Add an expanded community-list entry\n"
14292 "Community list name\n"
14293 "Specify community to reject\n"
14294 "Specify community to accept\n"
14297 char *cl_name_or_number
= NULL
;
14299 int style
= COMMUNITY_LIST_EXPANDED
;
14302 if (argv_find(argv
, argc
, "ip", &idx
)) {
14303 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14304 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14305 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14306 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14308 argv_find(argv
, argc
, "(100-500)", &idx
);
14309 argv_find(argv
, argc
, "WORD", &idx
);
14310 cl_name_or_number
= argv
[idx
]->arg
;
14311 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14313 argv_find(argv
, argc
, "AA:NN", &idx
);
14314 char *str
= argv_concat(argv
, argc
, idx
);
14316 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14319 XFREE(MTYPE_TMP
, str
);
14322 /* Display error string. */
14323 community_list_perror(vty
, ret
);
14324 return CMD_WARNING_CONFIG_FAILED
;
14327 return CMD_SUCCESS
;
14330 ALIAS (community_list_expanded_all
,
14331 ip_community_list_expanded_all_cmd
,
14332 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14335 "Community list number (expanded)\n"
14336 "Add an expanded community-list entry\n"
14337 "Community list name\n"
14338 "Specify community to reject\n"
14339 "Specify community to accept\n"
14342 DEFUN (no_community_list_expanded_all
,
14343 no_bgp_community_list_expanded_all_cmd
,
14344 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14348 "Community list number (expanded)\n"
14349 "Add an expanded community-list entry\n"
14350 "Community list name\n"
14351 "Specify community to reject\n"
14352 "Specify community to accept\n"
14355 char *cl_name_or_number
= NULL
;
14358 int style
= COMMUNITY_LIST_EXPANDED
;
14361 if (argv_find(argv
, argc
, "ip", &idx
)) {
14362 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14363 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14364 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14365 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14369 argv_find(argv
, argc
, "permit", &idx
);
14370 argv_find(argv
, argc
, "deny", &idx
);
14373 direct
= argv_find(argv
, argc
, "permit", &idx
)
14378 argv_find(argv
, argc
, "AA:NN", &idx
);
14379 str
= argv_concat(argv
, argc
, idx
);
14383 argv_find(argv
, argc
, "(100-500)", &idx
);
14384 argv_find(argv
, argc
, "WORD", &idx
);
14385 cl_name_or_number
= argv
[idx
]->arg
;
14387 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14390 XFREE(MTYPE_TMP
, str
);
14393 community_list_perror(vty
, ret
);
14394 return CMD_WARNING_CONFIG_FAILED
;
14397 return CMD_SUCCESS
;
14400 ALIAS (no_community_list_expanded_all
,
14401 no_ip_community_list_expanded_all_cmd
,
14402 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14406 "Community list number (expanded)\n"
14407 "Add an expanded community-list entry\n"
14408 "Community list name\n"
14409 "Specify community to reject\n"
14410 "Specify community to accept\n"
14413 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14414 "no bgp community-list <(100-500)|expanded WORD>",
14415 NO_STR IP_STR COMMUNITY_LIST_STR
14416 "Community list number (expanded)\n"
14417 "Add an expanded community-list entry\n"
14418 "Community list name\n")
14420 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14421 "no ip community-list <(100-500)|expanded WORD>",
14422 NO_STR IP_STR COMMUNITY_LIST_STR
14423 "Community list number (expanded)\n"
14424 "Add an expanded community-list entry\n"
14425 "Community list name\n")
14427 /* Return configuration string of community-list entry. */
14428 static const char *community_list_config_str(struct community_entry
*entry
)
14435 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14436 str
= community_str(entry
->u
.com
, false);
14437 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14438 str
= lcommunity_str(entry
->u
.lcom
, false);
14440 str
= entry
->config
;
14445 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14447 struct community_entry
*entry
;
14449 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14450 if (entry
== list
->head
) {
14451 if (all_digit(list
->name
))
14452 vty_out(vty
, "Community %s list %s\n",
14453 entry
->style
== COMMUNITY_LIST_STANDARD
14455 : "(expanded) access",
14458 vty_out(vty
, "Named Community %s list %s\n",
14459 entry
->style
== COMMUNITY_LIST_STANDARD
14465 vty_out(vty
, " %s\n",
14466 community_direct_str(entry
->direct
));
14468 vty_out(vty
, " %s %s\n",
14469 community_direct_str(entry
->direct
),
14470 community_list_config_str(entry
));
14474 DEFUN (show_community_list
,
14475 show_bgp_community_list_cmd
,
14476 "show bgp community-list",
14479 "List community-list\n")
14481 struct community_list
*list
;
14482 struct community_list_master
*cm
;
14485 if (argv_find(argv
, argc
, "ip", &idx
)) {
14486 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14487 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14488 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14489 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14491 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14493 return CMD_SUCCESS
;
14495 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14496 community_list_show(vty
, list
);
14498 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14499 community_list_show(vty
, list
);
14501 return CMD_SUCCESS
;
14504 ALIAS (show_community_list
,
14505 show_ip_community_list_cmd
,
14506 "show ip community-list",
14509 "List community-list\n")
14511 DEFUN (show_community_list_arg
,
14512 show_bgp_community_list_arg_cmd
,
14513 "show bgp community-list <(1-500)|WORD>",
14516 "List community-list\n"
14517 "Community-list number\n"
14518 "Community-list name\n")
14520 int idx_comm_list
= 3;
14521 struct community_list
*list
;
14524 if (argv_find(argv
, argc
, "ip", &idx
)) {
14525 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14526 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14527 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14528 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14530 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14531 COMMUNITY_LIST_MASTER
);
14533 vty_out(vty
, "%% Can't find community-list\n");
14534 return CMD_WARNING
;
14537 community_list_show(vty
, list
);
14539 return CMD_SUCCESS
;
14542 ALIAS (show_community_list_arg
,
14543 show_ip_community_list_arg_cmd
,
14544 "show ip community-list <(1-500)|WORD>",
14547 "List community-list\n"
14548 "Community-list number\n"
14549 "Community-list name\n")
14552 * Large Community code.
14554 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14555 struct cmd_token
**argv
, int style
,
14556 int reject_all_digit_name
)
14564 if (argv_find(argv
, argc
, "ip", &idx
)) {
14565 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14566 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14567 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14568 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14570 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14573 /* All digit name check. */
14575 argv_find(argv
, argc
, "WORD", &idx
);
14576 argv_find(argv
, argc
, "(1-99)", &idx
);
14577 argv_find(argv
, argc
, "(100-500)", &idx
);
14578 cl_name
= argv
[idx
]->arg
;
14579 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14580 vty_out(vty
, "%% Community name cannot have all digits\n");
14581 return CMD_WARNING_CONFIG_FAILED
;
14585 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14586 argv_find(argv
, argc
, "LINE", &idx
);
14587 /* Concat community string argument. */
14589 str
= argv_concat(argv
, argc
, idx
);
14593 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14595 /* Free temporary community list string allocated by
14597 XFREE(MTYPE_TMP
, str
);
14600 community_list_perror(vty
, ret
);
14601 return CMD_WARNING_CONFIG_FAILED
;
14603 return CMD_SUCCESS
;
14606 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14607 struct cmd_token
**argv
, int style
)
14614 if (argv_find(argv
, argc
, "ip", &idx
)) {
14615 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14616 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14617 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14618 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14620 argv_find(argv
, argc
, "permit", &idx
);
14621 argv_find(argv
, argc
, "deny", &idx
);
14624 /* Check the list direct. */
14625 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14626 direct
= COMMUNITY_PERMIT
;
14628 direct
= COMMUNITY_DENY
;
14631 argv_find(argv
, argc
, "LINE", &idx
);
14632 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14633 /* Concat community string argument. */
14634 str
= argv_concat(argv
, argc
, idx
);
14638 argv_find(argv
, argc
, "(1-99)", &idx
);
14639 argv_find(argv
, argc
, "(100-500)", &idx
);
14640 argv_find(argv
, argc
, "WORD", &idx
);
14642 /* Unset community list. */
14643 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14646 /* Free temporary community list string allocated by
14648 XFREE(MTYPE_TMP
, str
);
14651 community_list_perror(vty
, ret
);
14652 return CMD_WARNING_CONFIG_FAILED
;
14655 return CMD_SUCCESS
;
14658 /* "large-community-list" keyword help string. */
14659 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14660 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14662 #if CONFDATE > 20191005
14663 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14665 DEFUN (lcommunity_list_standard
,
14666 bgp_lcommunity_list_standard_cmd
,
14667 "bgp large-community-list (1-99) <deny|permit>",
14669 LCOMMUNITY_LIST_STR
14670 "Large Community list number (standard)\n"
14671 "Specify large community to reject\n"
14672 "Specify large community to accept\n")
14674 return lcommunity_list_set_vty(vty
, argc
, argv
,
14675 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14678 ALIAS (lcommunity_list_standard
,
14679 ip_lcommunity_list_standard_cmd
,
14680 "ip large-community-list (1-99) <deny|permit>",
14682 LCOMMUNITY_LIST_STR
14683 "Large Community list number (standard)\n"
14684 "Specify large community to reject\n"
14685 "Specify large community to accept\n")
14687 DEFUN (lcommunity_list_standard1
,
14688 bgp_lcommunity_list_standard1_cmd
,
14689 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14691 LCOMMUNITY_LIST_STR
14692 "Large Community list number (standard)\n"
14693 "Specify large community to reject\n"
14694 "Specify large community to accept\n"
14695 LCOMMUNITY_VAL_STR
)
14697 return lcommunity_list_set_vty(vty
, argc
, argv
,
14698 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14701 ALIAS (lcommunity_list_standard1
,
14702 ip_lcommunity_list_standard1_cmd
,
14703 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14705 LCOMMUNITY_LIST_STR
14706 "Large Community list number (standard)\n"
14707 "Specify large community to reject\n"
14708 "Specify large community to accept\n"
14709 LCOMMUNITY_VAL_STR
)
14711 DEFUN (lcommunity_list_expanded
,
14712 bgp_lcommunity_list_expanded_cmd
,
14713 "bgp large-community-list (100-500) <deny|permit> LINE...",
14715 LCOMMUNITY_LIST_STR
14716 "Large Community list number (expanded)\n"
14717 "Specify large community to reject\n"
14718 "Specify large community to accept\n"
14719 "An ordered list as a regular-expression\n")
14721 return lcommunity_list_set_vty(vty
, argc
, argv
,
14722 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14725 ALIAS (lcommunity_list_expanded
,
14726 ip_lcommunity_list_expanded_cmd
,
14727 "ip large-community-list (100-500) <deny|permit> LINE...",
14729 LCOMMUNITY_LIST_STR
14730 "Large Community list number (expanded)\n"
14731 "Specify large community to reject\n"
14732 "Specify large community to accept\n"
14733 "An ordered list as a regular-expression\n")
14735 DEFUN (lcommunity_list_name_standard
,
14736 bgp_lcommunity_list_name_standard_cmd
,
14737 "bgp large-community-list standard WORD <deny|permit>",
14739 LCOMMUNITY_LIST_STR
14740 "Specify standard large-community-list\n"
14741 "Large Community list name\n"
14742 "Specify large community to reject\n"
14743 "Specify large community to accept\n")
14745 return lcommunity_list_set_vty(vty
, argc
, argv
,
14746 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14749 ALIAS (lcommunity_list_name_standard
,
14750 ip_lcommunity_list_name_standard_cmd
,
14751 "ip large-community-list standard WORD <deny|permit>",
14753 LCOMMUNITY_LIST_STR
14754 "Specify standard large-community-list\n"
14755 "Large Community list name\n"
14756 "Specify large community to reject\n"
14757 "Specify large community to accept\n")
14759 DEFUN (lcommunity_list_name_standard1
,
14760 bgp_lcommunity_list_name_standard1_cmd
,
14761 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14763 LCOMMUNITY_LIST_STR
14764 "Specify standard large-community-list\n"
14765 "Large Community list name\n"
14766 "Specify large community to reject\n"
14767 "Specify large community to accept\n"
14768 LCOMMUNITY_VAL_STR
)
14770 return lcommunity_list_set_vty(vty
, argc
, argv
,
14771 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14774 ALIAS (lcommunity_list_name_standard1
,
14775 ip_lcommunity_list_name_standard1_cmd
,
14776 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
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"
14783 LCOMMUNITY_VAL_STR
)
14785 DEFUN (lcommunity_list_name_expanded
,
14786 bgp_lcommunity_list_name_expanded_cmd
,
14787 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14789 LCOMMUNITY_LIST_STR
14790 "Specify expanded large-community-list\n"
14791 "Large Community list name\n"
14792 "Specify large community to reject\n"
14793 "Specify large community to accept\n"
14794 "An ordered list as a regular-expression\n")
14796 return lcommunity_list_set_vty(vty
, argc
, argv
,
14797 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14800 ALIAS (lcommunity_list_name_expanded
,
14801 ip_lcommunity_list_name_expanded_cmd
,
14802 "ip large-community-list expanded WORD <deny|permit> LINE...",
14804 LCOMMUNITY_LIST_STR
14805 "Specify expanded large-community-list\n"
14806 "Large Community list name\n"
14807 "Specify large community to reject\n"
14808 "Specify large community to accept\n"
14809 "An ordered list as a regular-expression\n")
14811 DEFUN (no_lcommunity_list_standard_all
,
14812 no_bgp_lcommunity_list_standard_all_cmd
,
14813 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14816 LCOMMUNITY_LIST_STR
14817 "Large Community list number (standard)\n"
14818 "Large Community list number (expanded)\n"
14819 "Large Community list name\n")
14821 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14822 LARGE_COMMUNITY_LIST_STANDARD
);
14825 ALIAS (no_lcommunity_list_standard_all
,
14826 no_ip_lcommunity_list_standard_all_cmd
,
14827 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14830 LCOMMUNITY_LIST_STR
14831 "Large Community list number (standard)\n"
14832 "Large Community list number (expanded)\n"
14833 "Large Community list name\n")
14835 DEFUN (no_lcommunity_list_name_expanded_all
,
14836 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14837 "no bgp large-community-list expanded WORD",
14840 LCOMMUNITY_LIST_STR
14841 "Specify expanded large-community-list\n"
14842 "Large Community list name\n")
14844 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14845 LARGE_COMMUNITY_LIST_EXPANDED
);
14848 ALIAS (no_lcommunity_list_name_expanded_all
,
14849 no_ip_lcommunity_list_name_expanded_all_cmd
,
14850 "no ip large-community-list expanded WORD",
14853 LCOMMUNITY_LIST_STR
14854 "Specify expanded large-community-list\n"
14855 "Large Community list name\n")
14857 DEFUN (no_lcommunity_list_standard
,
14858 no_bgp_lcommunity_list_standard_cmd
,
14859 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14862 LCOMMUNITY_LIST_STR
14863 "Large Community list number (standard)\n"
14864 "Specify large community to reject\n"
14865 "Specify large community to accept\n"
14866 LCOMMUNITY_VAL_STR
)
14868 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14869 LARGE_COMMUNITY_LIST_STANDARD
);
14872 ALIAS (no_lcommunity_list_standard
,
14873 no_ip_lcommunity_list_standard_cmd
,
14874 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14877 LCOMMUNITY_LIST_STR
14878 "Large Community list number (standard)\n"
14879 "Specify large community to reject\n"
14880 "Specify large community to accept\n"
14881 LCOMMUNITY_VAL_STR
)
14883 DEFUN (no_lcommunity_list_expanded
,
14884 no_bgp_lcommunity_list_expanded_cmd
,
14885 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14888 LCOMMUNITY_LIST_STR
14889 "Large Community list number (expanded)\n"
14890 "Specify large community to reject\n"
14891 "Specify large community to accept\n"
14892 "An ordered list as a regular-expression\n")
14894 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14895 LARGE_COMMUNITY_LIST_EXPANDED
);
14898 ALIAS (no_lcommunity_list_expanded
,
14899 no_ip_lcommunity_list_expanded_cmd
,
14900 "no ip large-community-list (100-500) <deny|permit> LINE...",
14903 LCOMMUNITY_LIST_STR
14904 "Large Community list number (expanded)\n"
14905 "Specify large community to reject\n"
14906 "Specify large community to accept\n"
14907 "An ordered list as a regular-expression\n")
14909 DEFUN (no_lcommunity_list_name_standard
,
14910 no_bgp_lcommunity_list_name_standard_cmd
,
14911 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14914 LCOMMUNITY_LIST_STR
14915 "Specify standard large-community-list\n"
14916 "Large Community list name\n"
14917 "Specify large community to reject\n"
14918 "Specify large community to accept\n"
14919 LCOMMUNITY_VAL_STR
)
14921 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14922 LARGE_COMMUNITY_LIST_STANDARD
);
14925 ALIAS (no_lcommunity_list_name_standard
,
14926 no_ip_lcommunity_list_name_standard_cmd
,
14927 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14930 LCOMMUNITY_LIST_STR
14931 "Specify standard large-community-list\n"
14932 "Large Community list name\n"
14933 "Specify large community to reject\n"
14934 "Specify large community to accept\n"
14935 LCOMMUNITY_VAL_STR
)
14937 DEFUN (no_lcommunity_list_name_expanded
,
14938 no_bgp_lcommunity_list_name_expanded_cmd
,
14939 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14942 LCOMMUNITY_LIST_STR
14943 "Specify expanded large-community-list\n"
14944 "Large community list name\n"
14945 "Specify large community to reject\n"
14946 "Specify large community to accept\n"
14947 "An ordered list as a regular-expression\n")
14949 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14950 LARGE_COMMUNITY_LIST_EXPANDED
);
14953 ALIAS (no_lcommunity_list_name_expanded
,
14954 no_ip_lcommunity_list_name_expanded_cmd
,
14955 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14958 LCOMMUNITY_LIST_STR
14959 "Specify expanded large-community-list\n"
14960 "Large community list name\n"
14961 "Specify large community to reject\n"
14962 "Specify large community to accept\n"
14963 "An ordered list as a regular-expression\n")
14965 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14967 struct community_entry
*entry
;
14969 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14970 if (entry
== list
->head
) {
14971 if (all_digit(list
->name
))
14972 vty_out(vty
, "Large community %s list %s\n",
14974 LARGE_COMMUNITY_LIST_STANDARD
14976 : "(expanded) access",
14980 "Named large community %s list %s\n",
14982 LARGE_COMMUNITY_LIST_STANDARD
14988 vty_out(vty
, " %s\n",
14989 community_direct_str(entry
->direct
));
14991 vty_out(vty
, " %s %s\n",
14992 community_direct_str(entry
->direct
),
14993 community_list_config_str(entry
));
14997 DEFUN (show_lcommunity_list
,
14998 show_bgp_lcommunity_list_cmd
,
14999 "show bgp large-community-list",
15002 "List large-community list\n")
15004 struct community_list
*list
;
15005 struct community_list_master
*cm
;
15008 if (argv_find(argv
, argc
, "ip", &idx
)) {
15009 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15010 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15011 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15012 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15015 cm
= community_list_master_lookup(bgp_clist
,
15016 LARGE_COMMUNITY_LIST_MASTER
);
15018 return CMD_SUCCESS
;
15020 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15021 lcommunity_list_show(vty
, list
);
15023 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15024 lcommunity_list_show(vty
, list
);
15026 return CMD_SUCCESS
;
15029 ALIAS (show_lcommunity_list
,
15030 show_ip_lcommunity_list_cmd
,
15031 "show ip large-community-list",
15034 "List large-community list\n")
15036 DEFUN (show_lcommunity_list_arg
,
15037 show_bgp_lcommunity_list_arg_cmd
,
15038 "show bgp large-community-list <(1-500)|WORD>",
15041 "List large-community list\n"
15042 "large-community-list number\n"
15043 "large-community-list name\n")
15045 struct community_list
*list
;
15048 if (argv_find(argv
, argc
, "ip", &idx
)) {
15049 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15050 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15051 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15052 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15055 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
15056 LARGE_COMMUNITY_LIST_MASTER
);
15058 vty_out(vty
, "%% Can't find extcommunity-list\n");
15059 return CMD_WARNING
;
15062 lcommunity_list_show(vty
, list
);
15064 return CMD_SUCCESS
;
15067 ALIAS (show_lcommunity_list_arg
,
15068 show_ip_lcommunity_list_arg_cmd
,
15069 "show ip large-community-list <(1-500)|WORD>",
15072 "List large-community list\n"
15073 "large-community-list number\n"
15074 "large-community-list name\n")
15076 /* "extcommunity-list" keyword help string. */
15077 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15078 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15080 DEFUN (extcommunity_list_standard
,
15081 bgp_extcommunity_list_standard_cmd
,
15082 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15084 EXTCOMMUNITY_LIST_STR
15085 "Extended Community list number (standard)\n"
15086 "Specify standard extcommunity-list\n"
15087 "Community list name\n"
15088 "Specify community to reject\n"
15089 "Specify community to accept\n"
15090 EXTCOMMUNITY_VAL_STR
)
15092 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15094 char *cl_number_or_name
= NULL
;
15097 if (argv_find(argv
, argc
, "ip", &idx
)) {
15098 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15099 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15100 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15101 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15103 argv_find(argv
, argc
, "(1-99)", &idx
);
15104 argv_find(argv
, argc
, "WORD", &idx
);
15105 cl_number_or_name
= argv
[idx
]->arg
;
15106 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15108 argv_find(argv
, argc
, "AA:NN", &idx
);
15109 char *str
= argv_concat(argv
, argc
, idx
);
15111 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15114 XFREE(MTYPE_TMP
, str
);
15117 community_list_perror(vty
, ret
);
15118 return CMD_WARNING_CONFIG_FAILED
;
15121 return CMD_SUCCESS
;
15124 #if CONFDATE > 20191005
15125 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15127 ALIAS (extcommunity_list_standard
,
15128 ip_extcommunity_list_standard_cmd
,
15129 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15131 EXTCOMMUNITY_LIST_STR
15132 "Extended Community list number (standard)\n"
15133 "Specify standard extcommunity-list\n"
15134 "Community list name\n"
15135 "Specify community to reject\n"
15136 "Specify community to accept\n"
15137 EXTCOMMUNITY_VAL_STR
)
15139 DEFUN (extcommunity_list_name_expanded
,
15140 bgp_extcommunity_list_name_expanded_cmd
,
15141 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15143 EXTCOMMUNITY_LIST_STR
15144 "Extended Community list number (expanded)\n"
15145 "Specify expanded extcommunity-list\n"
15146 "Extended Community list name\n"
15147 "Specify community to reject\n"
15148 "Specify community to accept\n"
15149 "An ordered list as a regular-expression\n")
15151 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15153 char *cl_number_or_name
= NULL
;
15156 if (argv_find(argv
, argc
, "ip", &idx
)) {
15157 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15158 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15159 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15160 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15163 argv_find(argv
, argc
, "(100-500)", &idx
);
15164 argv_find(argv
, argc
, "WORD", &idx
);
15165 cl_number_or_name
= argv
[idx
]->arg
;
15166 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15168 argv_find(argv
, argc
, "LINE", &idx
);
15169 char *str
= argv_concat(argv
, argc
, idx
);
15171 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15174 XFREE(MTYPE_TMP
, str
);
15177 community_list_perror(vty
, ret
);
15178 return CMD_WARNING_CONFIG_FAILED
;
15181 return CMD_SUCCESS
;
15184 ALIAS (extcommunity_list_name_expanded
,
15185 ip_extcommunity_list_name_expanded_cmd
,
15186 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15188 EXTCOMMUNITY_LIST_STR
15189 "Extended Community list number (expanded)\n"
15190 "Specify expanded extcommunity-list\n"
15191 "Extended Community list name\n"
15192 "Specify community to reject\n"
15193 "Specify community to accept\n"
15194 "An ordered list as a regular-expression\n")
15196 DEFUN (no_extcommunity_list_standard_all
,
15197 no_bgp_extcommunity_list_standard_all_cmd
,
15198 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15201 EXTCOMMUNITY_LIST_STR
15202 "Extended Community list number (standard)\n"
15203 "Specify standard extcommunity-list\n"
15204 "Community list name\n"
15205 "Specify community to reject\n"
15206 "Specify community to accept\n"
15207 EXTCOMMUNITY_VAL_STR
)
15209 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15211 char *cl_number_or_name
= NULL
;
15215 if (argv_find(argv
, argc
, "ip", &idx
)) {
15216 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15217 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15218 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15219 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15223 argv_find(argv
, argc
, "permit", &idx
);
15224 argv_find(argv
, argc
, "deny", &idx
);
15227 direct
= argv_find(argv
, argc
, "permit", &idx
)
15232 argv_find(argv
, argc
, "AA:NN", &idx
);
15233 str
= argv_concat(argv
, argc
, idx
);
15237 argv_find(argv
, argc
, "(1-99)", &idx
);
15238 argv_find(argv
, argc
, "WORD", &idx
);
15239 cl_number_or_name
= argv
[idx
]->arg
;
15241 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15244 XFREE(MTYPE_TMP
, str
);
15247 community_list_perror(vty
, ret
);
15248 return CMD_WARNING_CONFIG_FAILED
;
15251 return CMD_SUCCESS
;
15254 ALIAS (no_extcommunity_list_standard_all
,
15255 no_ip_extcommunity_list_standard_all_cmd
,
15256 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15259 EXTCOMMUNITY_LIST_STR
15260 "Extended Community list number (standard)\n"
15261 "Specify standard extcommunity-list\n"
15262 "Community list name\n"
15263 "Specify community to reject\n"
15264 "Specify community to accept\n"
15265 EXTCOMMUNITY_VAL_STR
)
15267 ALIAS(no_extcommunity_list_standard_all
,
15268 no_bgp_extcommunity_list_standard_all_list_cmd
,
15269 "no bgp extcommunity-list <(1-99)|standard WORD>",
15270 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15271 "Extended Community list number (standard)\n"
15272 "Specify standard extcommunity-list\n"
15273 "Community list name\n")
15275 ALIAS(no_extcommunity_list_standard_all
,
15276 no_ip_extcommunity_list_standard_all_list_cmd
,
15277 "no ip extcommunity-list <(1-99)|standard WORD>",
15278 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15279 "Extended Community list number (standard)\n"
15280 "Specify standard extcommunity-list\n"
15281 "Community list name\n")
15283 DEFUN (no_extcommunity_list_expanded_all
,
15284 no_bgp_extcommunity_list_expanded_all_cmd
,
15285 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15288 EXTCOMMUNITY_LIST_STR
15289 "Extended Community list number (expanded)\n"
15290 "Specify expanded extcommunity-list\n"
15291 "Extended Community list name\n"
15292 "Specify community to reject\n"
15293 "Specify community to accept\n"
15294 "An ordered list as a regular-expression\n")
15296 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15298 char *cl_number_or_name
= NULL
;
15302 if (argv_find(argv
, argc
, "ip", &idx
)) {
15303 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15304 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15305 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15306 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15310 argv_find(argv
, argc
, "permit", &idx
);
15311 argv_find(argv
, argc
, "deny", &idx
);
15314 direct
= argv_find(argv
, argc
, "permit", &idx
)
15319 argv_find(argv
, argc
, "LINE", &idx
);
15320 str
= argv_concat(argv
, argc
, idx
);
15324 argv_find(argv
, argc
, "(100-500)", &idx
);
15325 argv_find(argv
, argc
, "WORD", &idx
);
15326 cl_number_or_name
= argv
[idx
]->arg
;
15328 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15331 XFREE(MTYPE_TMP
, str
);
15334 community_list_perror(vty
, ret
);
15335 return CMD_WARNING_CONFIG_FAILED
;
15338 return CMD_SUCCESS
;
15341 ALIAS (no_extcommunity_list_expanded_all
,
15342 no_ip_extcommunity_list_expanded_all_cmd
,
15343 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15346 EXTCOMMUNITY_LIST_STR
15347 "Extended Community list number (expanded)\n"
15348 "Specify expanded extcommunity-list\n"
15349 "Extended Community list name\n"
15350 "Specify community to reject\n"
15351 "Specify community to accept\n"
15352 "An ordered list as a regular-expression\n")
15354 ALIAS(no_extcommunity_list_expanded_all
,
15355 no_ip_extcommunity_list_expanded_all_list_cmd
,
15356 "no ip extcommunity-list <(100-500)|expanded WORD>",
15357 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15358 "Extended Community list number (expanded)\n"
15359 "Specify expanded extcommunity-list\n"
15360 "Extended Community list name\n")
15362 ALIAS(no_extcommunity_list_expanded_all
,
15363 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15364 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15365 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15366 "Extended Community list number (expanded)\n"
15367 "Specify expanded extcommunity-list\n"
15368 "Extended Community list name\n")
15370 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15372 struct community_entry
*entry
;
15374 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15375 if (entry
== list
->head
) {
15376 if (all_digit(list
->name
))
15377 vty_out(vty
, "Extended community %s list %s\n",
15378 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15380 : "(expanded) access",
15384 "Named extended community %s list %s\n",
15385 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15391 vty_out(vty
, " %s\n",
15392 community_direct_str(entry
->direct
));
15394 vty_out(vty
, " %s %s\n",
15395 community_direct_str(entry
->direct
),
15396 community_list_config_str(entry
));
15400 DEFUN (show_extcommunity_list
,
15401 show_bgp_extcommunity_list_cmd
,
15402 "show bgp extcommunity-list",
15405 "List extended-community list\n")
15407 struct community_list
*list
;
15408 struct community_list_master
*cm
;
15411 if (argv_find(argv
, argc
, "ip", &idx
)) {
15412 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15413 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15414 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15415 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15417 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15419 return CMD_SUCCESS
;
15421 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15422 extcommunity_list_show(vty
, list
);
15424 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15425 extcommunity_list_show(vty
, list
);
15427 return CMD_SUCCESS
;
15430 ALIAS (show_extcommunity_list
,
15431 show_ip_extcommunity_list_cmd
,
15432 "show ip extcommunity-list",
15435 "List extended-community list\n")
15437 DEFUN (show_extcommunity_list_arg
,
15438 show_bgp_extcommunity_list_arg_cmd
,
15439 "show bgp extcommunity-list <(1-500)|WORD>",
15442 "List extended-community list\n"
15443 "Extcommunity-list number\n"
15444 "Extcommunity-list name\n")
15446 int idx_comm_list
= 3;
15447 struct community_list
*list
;
15450 if (argv_find(argv
, argc
, "ip", &idx
)) {
15451 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15452 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15453 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15454 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15456 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15457 EXTCOMMUNITY_LIST_MASTER
);
15459 vty_out(vty
, "%% Can't find extcommunity-list\n");
15460 return CMD_WARNING
;
15463 extcommunity_list_show(vty
, list
);
15465 return CMD_SUCCESS
;
15468 ALIAS (show_extcommunity_list_arg
,
15469 show_ip_extcommunity_list_arg_cmd
,
15470 "show ip extcommunity-list <(1-500)|WORD>",
15473 "List extended-community list\n"
15474 "Extcommunity-list number\n"
15475 "Extcommunity-list name\n")
15477 /* Display community-list and extcommunity-list configuration. */
15478 static int community_list_config_write(struct vty
*vty
)
15480 struct community_list
*list
;
15481 struct community_entry
*entry
;
15482 struct community_list_master
*cm
;
15485 /* Community-list. */
15486 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15488 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15489 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15490 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15491 community_direct_str(entry
->direct
),
15492 community_list_config_str(entry
));
15495 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15496 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15497 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15498 entry
->style
== COMMUNITY_LIST_STANDARD
15501 list
->name
, community_direct_str(entry
->direct
),
15502 community_list_config_str(entry
));
15506 /* Extcommunity-list. */
15507 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15509 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15510 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15511 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15512 list
->name
, community_direct_str(entry
->direct
),
15513 community_list_config_str(entry
));
15516 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15517 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15518 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15519 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15522 list
->name
, community_direct_str(entry
->direct
),
15523 community_list_config_str(entry
));
15528 /* lcommunity-list. */
15529 cm
= community_list_master_lookup(bgp_clist
,
15530 LARGE_COMMUNITY_LIST_MASTER
);
15532 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15533 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15534 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15535 list
->name
, community_direct_str(entry
->direct
),
15536 community_list_config_str(entry
));
15539 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15540 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15541 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15542 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15545 list
->name
, community_direct_str(entry
->direct
),
15546 community_list_config_str(entry
));
15553 static struct cmd_node community_list_node
= {
15554 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15557 static void community_list_vty(void)
15559 install_node(&community_list_node
, community_list_config_write
);
15561 /* Community-list. */
15562 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15563 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15564 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15565 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15566 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15567 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15568 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15569 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15570 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15571 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15572 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15573 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15574 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15575 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15576 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15577 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15579 /* Extcommunity-list. */
15580 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15581 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15582 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15583 install_element(CONFIG_NODE
,
15584 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15585 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15586 install_element(CONFIG_NODE
,
15587 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15588 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15589 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15590 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15591 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15592 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15593 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15594 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15595 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15596 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15597 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15599 /* Large Community List */
15600 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15601 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15602 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15603 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15604 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15605 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15606 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15607 install_element(CONFIG_NODE
,
15608 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15609 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15610 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15611 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15612 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15613 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15614 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15615 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15616 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15617 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15618 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15619 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15620 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15621 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15622 install_element(CONFIG_NODE
,
15623 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15624 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15625 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15626 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15627 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15628 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15629 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);