2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/zclient.h"
34 #include "memory_vty.h"
40 #include "bgpd/bgpd.h"
41 #include "bgpd/bgp_attr_evpn.h"
42 #include "bgpd/bgp_advertise.h"
43 #include "bgpd/bgp_attr.h"
44 #include "bgpd/bgp_aspath.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_lcommunity.h"
48 #include "bgpd/bgp_damp.h"
49 #include "bgpd/bgp_debug.h"
50 #include "bgpd/bgp_errors.h"
51 #include "bgpd/bgp_fsm.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_open.h"
54 #include "bgpd/bgp_regex.h"
55 #include "bgpd/bgp_route.h"
56 #include "bgpd/bgp_mplsvpn.h"
57 #include "bgpd/bgp_zebra.h"
58 #include "bgpd/bgp_table.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_packet.h"
62 #include "bgpd/bgp_updgrp.h"
63 #include "bgpd/bgp_bfd.h"
64 #include "bgpd/bgp_io.h"
65 #include "bgpd/bgp_evpn.h"
66 #include "bgpd/bgp_addpath.h"
67 #include "bgpd/bgp_mac.h"
69 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
70 struct prefix
*range
, int exact
);
72 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
81 return BGP_IPV4M_NODE
;
83 case SAFI_LABELED_UNICAST
:
84 return BGP_IPV4L_NODE
;
87 return BGP_VPNV4_NODE
;
90 return BGP_FLOWSPECV4_NODE
;
100 return BGP_IPV6_NODE
;
103 return BGP_IPV6M_NODE
;
105 case SAFI_LABELED_UNICAST
:
106 return BGP_IPV6L_NODE
;
109 return BGP_VPNV6_NODE
;
112 return BGP_FLOWSPECV6_NODE
;
115 return BGP_IPV4_NODE
;
120 return BGP_EVPN_NODE
;
123 // We should never be here but to clarify the switch statement..
124 return BGP_IPV4_NODE
;
128 // Impossible to happen
129 return BGP_IPV4_NODE
;
132 /* Utility function to get address family from current node. */
133 afi_t
bgp_node_afi(struct vty
*vty
)
141 case BGP_FLOWSPECV6_NODE
:
154 /* Utility function to get subsequent address family from current
156 safi_t
bgp_node_safi(struct vty
*vty
)
162 safi
= SAFI_MPLS_VPN
;
166 safi
= SAFI_MULTICAST
;
173 safi
= SAFI_LABELED_UNICAST
;
175 case BGP_FLOWSPECV4_NODE
:
176 case BGP_FLOWSPECV6_NODE
:
177 safi
= SAFI_FLOWSPEC
;
187 * Converts an AFI in string form to afi_t
189 * @param afi string, one of
193 * @return the corresponding afi_t
195 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
197 afi_t afi
= AFI_MAX
; /* unknown */
198 if (strmatch(afi_str
, "ipv4"))
200 else if (strmatch(afi_str
, "ipv6"))
202 else if (strmatch(afi_str
, "l2vpn"))
207 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
211 if (argv_find(argv
, argc
, "ipv4", index
)) {
215 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
223 /* supports <unicast|multicast|vpn|labeled-unicast> */
224 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
226 safi_t safi
= SAFI_MAX
; /* unknown */
227 if (strmatch(safi_str
, "multicast"))
228 safi
= SAFI_MULTICAST
;
229 else if (strmatch(safi_str
, "unicast"))
231 else if (strmatch(safi_str
, "vpn"))
232 safi
= SAFI_MPLS_VPN
;
233 else if (strmatch(safi_str
, "evpn"))
235 else if (strmatch(safi_str
, "labeled-unicast"))
236 safi
= SAFI_LABELED_UNICAST
;
237 else if (strmatch(safi_str
, "flowspec"))
238 safi
= SAFI_FLOWSPEC
;
242 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
246 if (argv_find(argv
, argc
, "unicast", index
)) {
249 *safi
= SAFI_UNICAST
;
250 } else if (argv_find(argv
, argc
, "multicast", index
)) {
253 *safi
= SAFI_MULTICAST
;
254 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
257 *safi
= SAFI_LABELED_UNICAST
;
258 } else if (argv_find(argv
, argc
, "vpn", index
)) {
261 *safi
= SAFI_MPLS_VPN
;
262 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
265 *safi
= SAFI_FLOWSPEC
;
271 * bgp_vty_find_and_parse_afi_safi_bgp
273 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
274 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
275 * to appropriate values for the calling function. This is to allow the
276 * calling function to make decisions appropriate for the show command
277 * that is being parsed.
279 * The show commands are generally of the form:
280 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
281 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
283 * Since we use argv_find if the show command in particular doesn't have:
285 * [<view|vrf> VIEWVRFNAME]
286 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
287 * The command parsing should still be ok.
289 * vty -> The vty for the command so we can output some useful data in
290 * the event of a parse error in the vrf.
291 * argv -> The command tokens
292 * argc -> How many command tokens we have
293 * idx -> The current place in the command, generally should be 0 for this
295 * afi -> The parsed afi if it was included in the show command, returned here
296 * safi -> The parsed safi if it was included in the show command, returned here
297 * bgp -> Pointer to the bgp data structure we need to fill in.
298 * use_json -> json is configured or not
300 * The function returns the correct location in the parse tree for the
303 * Returns 0 for failure to parse correctly, else the idx position of where
304 * it found the last token.
306 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
307 struct cmd_token
**argv
, int argc
,
308 int *idx
, afi_t
*afi
, safi_t
*safi
,
309 struct bgp
**bgp
, bool use_json
)
311 char *vrf_name
= NULL
;
317 if (argv_find(argv
, argc
, "ip", idx
))
320 if (argv_find(argv
, argc
, "view", idx
))
321 vrf_name
= argv
[*idx
+ 1]->arg
;
322 else if (argv_find(argv
, argc
, "vrf", idx
)) {
323 vrf_name
= argv
[*idx
+ 1]->arg
;
324 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
328 if (strmatch(vrf_name
, "all"))
331 *bgp
= bgp_lookup_by_name(vrf_name
);
334 json_object
*json
= NULL
;
335 json
= json_object_new_object();
336 json_object_string_add(
338 "View/Vrf is unknown");
340 json_object_to_json_string_ext(json
,
341 JSON_C_TO_STRING_PRETTY
));
342 json_object_free(json
);
345 vty_out(vty
, "View/Vrf %s is unknown\n",
352 *bgp
= bgp_get_default();
355 json_object
*json
= NULL
;
356 json
= json_object_new_object();
357 json_object_string_add(
359 "Default BGP instance not found");
361 json_object_to_json_string_ext(json
,
362 JSON_C_TO_STRING_PRETTY
));
363 json_object_free(json
);
367 "Default BGP instance not found\n");
373 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
374 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
380 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
382 struct interface
*ifp
= NULL
;
384 if (su
->sa
.sa_family
== AF_INET
)
385 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
386 else if (su
->sa
.sa_family
== AF_INET6
)
387 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
388 su
->sin6
.sin6_scope_id
,
397 /* Utility function for looking up peer from VTY. */
398 /* This is used only for configuration, so disallow if attempted on
399 * a dynamic neighbor.
401 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
403 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
412 ret
= str2sockunion(ip_str
, &su
);
414 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
416 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
419 "%% Malformed address or name: %s\n",
425 peer
= peer_lookup(bgp
, &su
);
428 "%% Specify remote-as or peer-group commands first\n");
431 if (peer_dynamic_neighbor(peer
)) {
433 "%% Operation not allowed on a dynamic neighbor\n");
440 /* Utility function for looking up peer or peer group. */
441 /* This is used only for configuration, so disallow if attempted on
442 * a dynamic neighbor.
444 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
446 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
449 struct peer
*peer
= NULL
;
450 struct peer_group
*group
= NULL
;
456 ret
= str2sockunion(peer_str
, &su
);
458 /* IP address, locate peer. */
459 peer
= peer_lookup(bgp
, &su
);
461 /* Not IP, could match either peer configured on interface or a
463 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
465 group
= peer_group_lookup(bgp
, peer_str
);
469 if (peer_dynamic_neighbor(peer
)) {
471 "%% Operation not allowed on a dynamic neighbor\n");
481 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
486 int bgp_vty_return(struct vty
*vty
, int ret
)
488 const char *str
= NULL
;
491 case BGP_ERR_INVALID_VALUE
:
492 str
= "Invalid value";
494 case BGP_ERR_INVALID_FLAG
:
495 str
= "Invalid flag";
497 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
498 str
= "Peer-group has been shutdown. Activate the peer-group first";
500 case BGP_ERR_PEER_FLAG_CONFLICT
:
501 str
= "Can't set override-capability and strict-capability-match at the same time";
503 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
504 str
= "Specify remote-as or peer-group remote AS first";
506 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
507 str
= "Cannot change the peer-group. Deconfigure first";
509 case BGP_ERR_PEER_GROUP_MISMATCH
:
510 str
= "Peer is not a member of this peer-group";
512 case BGP_ERR_PEER_FILTER_CONFLICT
:
513 str
= "Prefix/distribute list can not co-exist";
515 case BGP_ERR_NOT_INTERNAL_PEER
:
516 str
= "Invalid command. Not an internal neighbor";
518 case BGP_ERR_REMOVE_PRIVATE_AS
:
519 str
= "remove-private-AS cannot be configured for IBGP peers";
521 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
522 str
= "Local-AS allowed only for EBGP peers";
524 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
525 str
= "Cannot have local-as same as BGP AS number";
527 case BGP_ERR_TCPSIG_FAILED
:
528 str
= "Error while applying TCP-Sig to session(s)";
530 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
531 str
= "ebgp-multihop and ttl-security cannot be configured together";
533 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
534 str
= "ttl-security only allowed for EBGP peers";
536 case BGP_ERR_AS_OVERRIDE
:
537 str
= "as-override cannot be configured for IBGP peers";
539 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
540 str
= "Invalid limit for number of dynamic neighbors";
542 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
543 str
= "Dynamic neighbor listen range already exists";
545 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
546 str
= "Operation not allowed on a dynamic neighbor";
548 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
549 str
= "Operation not allowed on a directly connected neighbor";
551 case BGP_ERR_PEER_SAFI_CONFLICT
:
552 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
556 vty_out(vty
, "%% %s\n", str
);
557 return CMD_WARNING_CONFIG_FAILED
;
562 /* BGP clear sort. */
571 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
572 safi_t safi
, int error
)
575 case BGP_ERR_AF_UNCONFIGURED
:
577 "%%BGP: Enable %s address family for the neighbor %s\n",
578 afi_safi_print(afi
, safi
), peer
->host
);
580 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
582 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
590 /* `clear ip bgp' functions. */
591 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
592 enum clear_sort sort
, enum bgp_clear_type stype
,
598 struct listnode
*node
, *nnode
;
600 /* Clear all neighbors. */
602 * Pass along pointer to next node to peer_clear() when walking all
603 * nodes on the BGP instance as that may get freed if it is a
606 if (sort
== clear_all
) {
607 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
608 if (!peer
->afc
[afi
][safi
])
611 if (stype
== BGP_CLEAR_SOFT_NONE
)
612 ret
= peer_clear(peer
, &nnode
);
614 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
617 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
622 /* This is to apply read-only mode on this clear. */
623 if (stype
== BGP_CLEAR_SOFT_NONE
)
624 bgp
->update_delay_over
= 0;
627 vty_out(vty
, "%%BGP: No %s peer configured\n",
628 afi_safi_print(afi
, safi
));
633 /* Clear specified neighbor. */
634 if (sort
== clear_peer
) {
637 /* Make sockunion for lookup. */
638 ret
= str2sockunion(arg
, &su
);
640 peer
= peer_lookup_by_conf_if(bgp
, arg
);
642 peer
= peer_lookup_by_hostname(bgp
, arg
);
645 "Malformed address or name: %s\n",
651 peer
= peer_lookup(bgp
, &su
);
654 "%%BGP: Unknown neighbor - \"%s\"\n",
660 if (!peer
->afc
[afi
][safi
])
661 ret
= BGP_ERR_AF_UNCONFIGURED
;
662 else if (stype
== BGP_CLEAR_SOFT_NONE
)
663 ret
= peer_clear(peer
, NULL
);
665 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
668 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
673 /* Clear all neighbors belonging to a specific peer-group. */
674 if (sort
== clear_group
) {
675 struct peer_group
*group
;
677 group
= peer_group_lookup(bgp
, arg
);
679 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
683 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
684 if (!peer
->afc
[afi
][safi
])
687 if (stype
== BGP_CLEAR_SOFT_NONE
)
688 ret
= peer_clear(peer
, NULL
);
690 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
693 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
700 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
701 afi_safi_print(afi
, safi
), arg
);
706 /* Clear all external (eBGP) neighbors. */
707 if (sort
== clear_external
) {
708 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
709 if (peer
->sort
== BGP_PEER_IBGP
)
712 if (!peer
->afc
[afi
][safi
])
715 if (stype
== BGP_CLEAR_SOFT_NONE
)
716 ret
= peer_clear(peer
, &nnode
);
718 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
721 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
728 "%%BGP: No external %s peer is configured\n",
729 afi_safi_print(afi
, safi
));
734 /* Clear all neighbors belonging to a specific AS. */
735 if (sort
== clear_as
) {
736 as_t as
= strtoul(arg
, NULL
, 10);
738 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
742 if (!peer
->afc
[afi
][safi
])
743 ret
= BGP_ERR_AF_UNCONFIGURED
;
744 else if (stype
== BGP_CLEAR_SOFT_NONE
)
745 ret
= peer_clear(peer
, &nnode
);
747 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
750 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
757 "%%BGP: No %s peer is configured with AS %s\n",
758 afi_safi_print(afi
, safi
), arg
);
766 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
767 safi_t safi
, enum clear_sort sort
,
768 enum bgp_clear_type stype
, const char *arg
)
772 /* BGP structure lookup. */
774 bgp
= bgp_lookup_by_name(name
);
776 vty_out(vty
, "Can't find BGP instance %s\n", name
);
780 bgp
= bgp_get_default();
782 vty_out(vty
, "No BGP process is configured\n");
787 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
790 /* clear soft inbound */
791 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
796 FOREACH_AFI_SAFI (afi
, safi
)
797 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
798 BGP_CLEAR_SOFT_IN
, NULL
);
801 /* clear soft outbound */
802 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
807 FOREACH_AFI_SAFI (afi
, safi
)
808 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
809 BGP_CLEAR_SOFT_OUT
, NULL
);
813 #ifndef VTYSH_EXTRACT_PL
814 #include "bgpd/bgp_vty_clippy.c"
817 /* BGP global configuration. */
818 #if (CONFDATE > 20190601)
819 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
820 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
822 DEFUN_HIDDEN (bgp_multiple_instance_func
,
823 bgp_multiple_instance_cmd
,
824 "bgp multiple-instance",
826 "Enable bgp multiple instance\n")
828 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
832 DEFUN_HIDDEN (no_bgp_multiple_instance
,
833 no_bgp_multiple_instance_cmd
,
834 "no bgp multiple-instance",
837 "BGP multiple instance\n")
841 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
842 vty_out(vty
, "if you are using this please let the developers know\n");
843 zlog_info("Deprecated option: `bgp multiple-instance` being used");
844 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
846 vty_out(vty
, "%% There are more than two BGP instances\n");
847 return CMD_WARNING_CONFIG_FAILED
;
852 DEFUN_HIDDEN (bgp_local_mac
,
854 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
857 "VxLAN Network Identifier\n"
861 "mac-mobility sequence\n"
871 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
872 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
873 vty_out(vty
, "%% Malformed MAC address\n");
876 memset(&ip
, 0, sizeof(ip
));
877 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
879 bgp
= bgp_get_default();
881 vty_out(vty
, "Default BGP instance is not there\n");
885 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
887 vty_out(vty
, "Internal error\n");
894 DEFUN_HIDDEN (no_bgp_local_mac
,
895 no_bgp_local_mac_cmd
,
896 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
900 "VxLAN Network Identifier\n"
911 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
912 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
913 vty_out(vty
, "%% Malformed MAC address\n");
916 memset(&ip
, 0, sizeof(ip
));
918 bgp
= bgp_get_default();
920 vty_out(vty
, "Default BGP instance is not there\n");
924 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
926 vty_out(vty
, "Internal error\n");
933 #if (CONFDATE > 20190601)
934 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
935 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
937 DEFUN_HIDDEN (bgp_config_type
,
939 "bgp config-type <cisco|zebra>",
941 "Configuration type\n"
946 if (argv_find(argv
, argc
, "cisco", &idx
)) {
947 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
948 vty_out(vty
, "if you are using this please let the developers know!\n");
949 zlog_info("Deprecated option: `bgp config-type cisco` being used");
950 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
952 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
957 DEFUN_HIDDEN (no_bgp_config_type
,
958 no_bgp_config_type_cmd
,
959 "no bgp config-type [<cisco|zebra>]",
962 "Display configuration type\n"
966 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
971 DEFUN (no_synchronization
,
972 no_synchronization_cmd
,
973 "no synchronization",
975 "Perform IGP synchronization\n")
980 DEFUN (no_auto_summary
,
984 "Enable automatic network number summarization\n")
989 /* "router bgp" commands. */
990 DEFUN_NOSH (router_bgp
,
992 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
996 BGP_INSTANCE_HELP_STR
)
999 int idx_view_vrf
= 3;
1005 const char *name
= NULL
;
1006 enum bgp_instance_type inst_type
;
1008 // "router bgp" without an ASN
1010 // Pending: Make VRF option available for ASN less config
1011 bgp
= bgp_get_default();
1014 vty_out(vty
, "%% No BGP process is configured\n");
1015 return CMD_WARNING_CONFIG_FAILED
;
1018 if (listcount(bm
->bgp
) > 1) {
1019 vty_out(vty
, "%% Please specify ASN and VRF\n");
1020 return CMD_WARNING_CONFIG_FAILED
;
1026 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1028 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1030 name
= argv
[idx_vrf
]->arg
;
1032 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1033 if (strmatch(name
, VRF_DEFAULT_NAME
))
1036 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1037 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1038 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1041 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1042 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1044 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
1046 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
1048 "Please specify 'bgp multiple-instance' first\n");
1049 return CMD_WARNING_CONFIG_FAILED
;
1050 case BGP_ERR_AS_MISMATCH
:
1051 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1052 return CMD_WARNING_CONFIG_FAILED
;
1053 case BGP_ERR_INSTANCE_MISMATCH
:
1055 "BGP instance name and AS number mismatch\n");
1057 "BGP instance is already running; AS is %u\n",
1059 return CMD_WARNING_CONFIG_FAILED
;
1063 * If we just instantiated the default instance, complete
1064 * any pending VRF-VPN leaking that was configured via
1065 * earlier "router bgp X vrf FOO" blocks.
1067 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1068 vpn_leak_postchange_all();
1070 /* Pending: handle when user tries to change a view to vrf n vv.
1074 /* unset the auto created flag as the user config is now present */
1075 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1076 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1081 /* "no router bgp" commands. */
1082 DEFUN (no_router_bgp
,
1084 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
1089 BGP_INSTANCE_HELP_STR
)
1095 const char *name
= NULL
;
1097 // "no router bgp" without an ASN
1099 // Pending: Make VRF option available for ASN less config
1100 bgp
= bgp_get_default();
1103 vty_out(vty
, "%% No BGP process is configured\n");
1104 return CMD_WARNING_CONFIG_FAILED
;
1107 if (listcount(bm
->bgp
) > 1) {
1108 vty_out(vty
, "%% Please specify ASN and VRF\n");
1109 return CMD_WARNING_CONFIG_FAILED
;
1113 vty_out(vty
, "%% Please unconfigure l3vni %u",
1115 return CMD_WARNING_CONFIG_FAILED
;
1118 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1121 name
= argv
[idx_vrf
]->arg
;
1123 /* Lookup bgp structure. */
1124 bgp
= bgp_lookup(as
, name
);
1126 vty_out(vty
, "%% Can't find BGP instance\n");
1127 return CMD_WARNING_CONFIG_FAILED
;
1131 vty_out(vty
, "%% Please unconfigure l3vni %u",
1133 return CMD_WARNING_CONFIG_FAILED
;
1143 /* BGP router-id. */
1145 DEFPY (bgp_router_id
,
1147 "bgp router-id A.B.C.D",
1149 "Override configured router identifier\n"
1150 "Manually configured router identifier\n")
1152 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1153 bgp_router_id_static_set(bgp
, router_id
);
1157 DEFPY (no_bgp_router_id
,
1158 no_bgp_router_id_cmd
,
1159 "no bgp router-id [A.B.C.D]",
1162 "Override configured router identifier\n"
1163 "Manually configured router identifier\n")
1165 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1167 if (router_id_str
) {
1168 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1169 vty_out(vty
, "%% BGP router-id doesn't match\n");
1170 return CMD_WARNING_CONFIG_FAILED
;
1174 router_id
.s_addr
= 0;
1175 bgp_router_id_static_set(bgp
, router_id
);
1181 /* BGP Cluster ID. */
1182 DEFUN (bgp_cluster_id
,
1184 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1186 "Configure Route-Reflector Cluster-id\n"
1187 "Route-Reflector Cluster-id in IP address format\n"
1188 "Route-Reflector Cluster-id as 32 bit quantity\n")
1190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1193 struct in_addr cluster
;
1195 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1197 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1198 return CMD_WARNING_CONFIG_FAILED
;
1201 bgp_cluster_id_set(bgp
, &cluster
);
1202 bgp_clear_star_soft_out(vty
, bgp
->name
);
1207 DEFUN (no_bgp_cluster_id
,
1208 no_bgp_cluster_id_cmd
,
1209 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1212 "Configure Route-Reflector Cluster-id\n"
1213 "Route-Reflector Cluster-id in IP address format\n"
1214 "Route-Reflector Cluster-id as 32 bit quantity\n")
1216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1217 bgp_cluster_id_unset(bgp
);
1218 bgp_clear_star_soft_out(vty
, bgp
->name
);
1223 DEFUN (bgp_confederation_identifier
,
1224 bgp_confederation_identifier_cmd
,
1225 "bgp confederation identifier (1-4294967295)",
1226 "BGP specific commands\n"
1227 "AS confederation parameters\n"
1229 "Set routing domain confederation AS\n")
1231 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1235 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1237 bgp_confederation_id_set(bgp
, as
);
1242 DEFUN (no_bgp_confederation_identifier
,
1243 no_bgp_confederation_identifier_cmd
,
1244 "no bgp confederation identifier [(1-4294967295)]",
1246 "BGP specific commands\n"
1247 "AS confederation parameters\n"
1249 "Set routing domain confederation AS\n")
1251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1252 bgp_confederation_id_unset(bgp
);
1257 DEFUN (bgp_confederation_peers
,
1258 bgp_confederation_peers_cmd
,
1259 "bgp confederation peers (1-4294967295)...",
1260 "BGP specific commands\n"
1261 "AS confederation parameters\n"
1262 "Peer ASs in BGP confederation\n"
1265 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1270 for (i
= idx_asn
; i
< argc
; i
++) {
1271 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1273 if (bgp
->as
== as
) {
1275 "%% Local member-AS not allowed in confed peer list\n");
1279 bgp_confederation_peers_add(bgp
, as
);
1284 DEFUN (no_bgp_confederation_peers
,
1285 no_bgp_confederation_peers_cmd
,
1286 "no bgp confederation peers (1-4294967295)...",
1288 "BGP specific commands\n"
1289 "AS confederation parameters\n"
1290 "Peer ASs in BGP confederation\n"
1293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1298 for (i
= idx_asn
; i
< argc
; i
++) {
1299 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1301 bgp_confederation_peers_remove(bgp
, as
);
1307 * Central routine for maximum-paths configuration.
1308 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1309 * @set: 1 for setting values, 0 for removing the max-paths config.
1311 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1312 const char *mpaths
, uint16_t options
,
1315 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1316 uint16_t maxpaths
= 0;
1321 afi
= bgp_node_afi(vty
);
1322 safi
= bgp_node_safi(vty
);
1325 maxpaths
= strtol(mpaths
, NULL
, 10);
1326 if (maxpaths
> multipath_num
) {
1328 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1329 maxpaths
, multipath_num
);
1330 return CMD_WARNING_CONFIG_FAILED
;
1332 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1335 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1339 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1340 (set
== 1) ? "" : "un",
1341 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1342 maxpaths
, afi
, safi
);
1343 return CMD_WARNING_CONFIG_FAILED
;
1346 bgp_recalculate_all_bestpaths(bgp
);
1351 DEFUN (bgp_maxmed_admin
,
1352 bgp_maxmed_admin_cmd
,
1353 "bgp max-med administrative ",
1355 "Advertise routes with max-med\n"
1356 "Administratively applied, for an indefinite period\n")
1358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1360 bgp
->v_maxmed_admin
= 1;
1361 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1363 bgp_maxmed_update(bgp
);
1368 DEFUN (bgp_maxmed_admin_medv
,
1369 bgp_maxmed_admin_medv_cmd
,
1370 "bgp max-med administrative (0-4294967295)",
1372 "Advertise routes with max-med\n"
1373 "Administratively applied, for an indefinite period\n"
1374 "Max MED value to be used\n")
1376 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1379 bgp
->v_maxmed_admin
= 1;
1380 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1382 bgp_maxmed_update(bgp
);
1387 DEFUN (no_bgp_maxmed_admin
,
1388 no_bgp_maxmed_admin_cmd
,
1389 "no bgp max-med administrative [(0-4294967295)]",
1392 "Advertise routes with max-med\n"
1393 "Administratively applied, for an indefinite period\n"
1394 "Max MED value to be used\n")
1396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1397 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1398 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1399 bgp_maxmed_update(bgp
);
1404 DEFUN (bgp_maxmed_onstartup
,
1405 bgp_maxmed_onstartup_cmd
,
1406 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1408 "Advertise routes with max-med\n"
1409 "Effective on a startup\n"
1410 "Time (seconds) period for max-med\n"
1411 "Max MED value to be used\n")
1413 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1416 argv_find(argv
, argc
, "(5-86400)", &idx
);
1417 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1418 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1419 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1421 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1423 bgp_maxmed_update(bgp
);
1428 DEFUN (no_bgp_maxmed_onstartup
,
1429 no_bgp_maxmed_onstartup_cmd
,
1430 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1433 "Advertise routes with max-med\n"
1434 "Effective on a startup\n"
1435 "Time (seconds) period for max-med\n"
1436 "Max MED value to be used\n")
1438 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1440 /* Cancel max-med onstartup if its on */
1441 if (bgp
->t_maxmed_onstartup
) {
1442 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1443 bgp
->maxmed_onstartup_over
= 1;
1446 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1447 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1449 bgp_maxmed_update(bgp
);
1454 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1457 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1458 uint16_t update_delay
;
1459 uint16_t establish_wait
;
1461 update_delay
= strtoul(delay
, NULL
, 10);
1463 if (!wait
) /* update-delay <delay> */
1465 bgp
->v_update_delay
= update_delay
;
1466 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1470 /* update-delay <delay> <establish-wait> */
1471 establish_wait
= atoi(wait
);
1472 if (update_delay
< establish_wait
) {
1474 "%%Failed: update-delay less than the establish-wait!\n");
1475 return CMD_WARNING_CONFIG_FAILED
;
1478 bgp
->v_update_delay
= update_delay
;
1479 bgp
->v_establish_wait
= establish_wait
;
1484 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1486 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1488 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1489 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1494 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1496 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1497 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1498 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1499 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1505 /* Update-delay configuration */
1506 DEFUN (bgp_update_delay
,
1507 bgp_update_delay_cmd
,
1508 "update-delay (0-3600)",
1509 "Force initial delay for best-path and updates\n"
1513 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1516 DEFUN (bgp_update_delay_establish_wait
,
1517 bgp_update_delay_establish_wait_cmd
,
1518 "update-delay (0-3600) (1-3600)",
1519 "Force initial delay for best-path and updates\n"
1524 int idx_number_2
= 2;
1525 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1526 argv
[idx_number_2
]->arg
);
1529 /* Update-delay deconfiguration */
1530 DEFUN (no_bgp_update_delay
,
1531 no_bgp_update_delay_cmd
,
1532 "no update-delay [(0-3600) [(1-3600)]]",
1534 "Force initial delay for best-path and updates\n"
1538 return bgp_update_delay_deconfig_vty(vty
);
1542 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1545 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1548 uint32_t quanta
= strtoul(num
, NULL
, 10);
1549 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1550 memory_order_relaxed
);
1552 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1553 memory_order_relaxed
);
1559 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1562 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1565 uint32_t quanta
= strtoul(num
, NULL
, 10);
1566 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1567 memory_order_relaxed
);
1569 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1570 memory_order_relaxed
);
1576 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1579 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1580 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1581 vty_out(vty
, " write-quanta %d\n", quanta
);
1584 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1587 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1588 if (quanta
!= BGP_READ_PACKET_MAX
)
1589 vty_out(vty
, " read-quanta %d\n", quanta
);
1592 /* Packet quanta configuration */
1593 DEFUN (bgp_wpkt_quanta
,
1594 bgp_wpkt_quanta_cmd
,
1595 "write-quanta (1-10)",
1596 "How many packets to write to peer socket per run\n"
1597 "Number of packets\n")
1600 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1603 DEFUN (no_bgp_wpkt_quanta
,
1604 no_bgp_wpkt_quanta_cmd
,
1605 "no write-quanta (1-10)",
1607 "How many packets to write to peer socket per I/O cycle\n"
1608 "Number of packets\n")
1611 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1614 DEFUN (bgp_rpkt_quanta
,
1615 bgp_rpkt_quanta_cmd
,
1616 "read-quanta (1-10)",
1617 "How many packets to read from peer socket per I/O cycle\n"
1618 "Number of packets\n")
1621 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1624 DEFUN (no_bgp_rpkt_quanta
,
1625 no_bgp_rpkt_quanta_cmd
,
1626 "no read-quanta (1-10)",
1628 "How many packets to read from peer socket per I/O cycle\n"
1629 "Number of packets\n")
1632 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1635 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1637 if (!bgp
->heuristic_coalesce
)
1638 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1642 DEFUN (bgp_coalesce_time
,
1643 bgp_coalesce_time_cmd
,
1644 "coalesce-time (0-4294967295)",
1645 "Subgroup coalesce timer\n"
1646 "Subgroup coalesce timer value (in ms)\n")
1648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1651 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1652 bgp
->heuristic_coalesce
= false;
1653 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1657 DEFUN (no_bgp_coalesce_time
,
1658 no_bgp_coalesce_time_cmd
,
1659 "no coalesce-time (0-4294967295)",
1661 "Subgroup coalesce timer\n"
1662 "Subgroup coalesce timer value (in ms)\n")
1664 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1666 bgp
->heuristic_coalesce
= true;
1667 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1671 /* Maximum-paths configuration */
1672 DEFUN (bgp_maxpaths
,
1674 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1675 "Forward packets over multiple paths\n"
1676 "Number of paths\n")
1679 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1680 argv
[idx_number
]->arg
, 0, 1);
1683 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1684 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1685 "Forward packets over multiple paths\n"
1686 "Number of paths\n")
1688 DEFUN (bgp_maxpaths_ibgp
,
1689 bgp_maxpaths_ibgp_cmd
,
1690 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1691 "Forward packets over multiple paths\n"
1693 "Number of paths\n")
1696 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1697 argv
[idx_number
]->arg
, 0, 1);
1700 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1701 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1702 "Forward packets over multiple paths\n"
1704 "Number of paths\n")
1706 DEFUN (bgp_maxpaths_ibgp_cluster
,
1707 bgp_maxpaths_ibgp_cluster_cmd
,
1708 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1709 "Forward packets over multiple paths\n"
1712 "Match the cluster length\n")
1715 return bgp_maxpaths_config_vty(
1716 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1717 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1720 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1721 "maximum-paths ibgp " CMD_RANGE_STR(
1722 1, MULTIPATH_NUM
) " equal-cluster-length",
1723 "Forward packets over multiple paths\n"
1726 "Match the cluster length\n")
1728 DEFUN (no_bgp_maxpaths
,
1729 no_bgp_maxpaths_cmd
,
1730 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1732 "Forward packets over multiple paths\n"
1733 "Number of paths\n")
1735 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1738 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1739 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1740 "Forward packets over multiple paths\n"
1741 "Number of paths\n")
1743 DEFUN (no_bgp_maxpaths_ibgp
,
1744 no_bgp_maxpaths_ibgp_cmd
,
1745 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1747 "Forward packets over multiple paths\n"
1750 "Match the cluster length\n")
1752 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1755 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1756 "no maximum-paths ibgp [" CMD_RANGE_STR(
1757 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1759 "Forward packets over multiple paths\n"
1762 "Match the cluster length\n")
1764 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1767 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1768 vty_out(vty
, " maximum-paths %d\n",
1769 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1772 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1773 vty_out(vty
, " maximum-paths ibgp %d",
1774 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1775 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1776 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1777 vty_out(vty
, " equal-cluster-length");
1786 "timers bgp (0-65535) (0-65535)",
1787 "Adjust routing timers\n"
1789 "Keepalive interval\n"
1792 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1794 int idx_number_2
= 3;
1795 unsigned long keepalive
= 0;
1796 unsigned long holdtime
= 0;
1798 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1799 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1801 /* Holdtime value check. */
1802 if (holdtime
< 3 && holdtime
!= 0) {
1804 "%% hold time value must be either 0 or greater than 3\n");
1805 return CMD_WARNING_CONFIG_FAILED
;
1808 bgp_timers_set(bgp
, keepalive
, holdtime
);
1813 DEFUN (no_bgp_timers
,
1815 "no timers bgp [(0-65535) (0-65535)]",
1817 "Adjust routing timers\n"
1819 "Keepalive interval\n"
1822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1823 bgp_timers_unset(bgp
);
1829 DEFUN (bgp_client_to_client_reflection
,
1830 bgp_client_to_client_reflection_cmd
,
1831 "bgp client-to-client reflection",
1832 "BGP specific commands\n"
1833 "Configure client to client route reflection\n"
1834 "reflection of routes allowed\n")
1836 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1837 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1838 bgp_clear_star_soft_out(vty
, bgp
->name
);
1843 DEFUN (no_bgp_client_to_client_reflection
,
1844 no_bgp_client_to_client_reflection_cmd
,
1845 "no bgp client-to-client reflection",
1847 "BGP specific commands\n"
1848 "Configure client to client route reflection\n"
1849 "reflection of routes allowed\n")
1851 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1852 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1853 bgp_clear_star_soft_out(vty
, bgp
->name
);
1858 /* "bgp always-compare-med" configuration. */
1859 DEFUN (bgp_always_compare_med
,
1860 bgp_always_compare_med_cmd
,
1861 "bgp always-compare-med",
1862 "BGP specific commands\n"
1863 "Allow comparing MED from different neighbors\n")
1865 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1866 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1867 bgp_recalculate_all_bestpaths(bgp
);
1872 DEFUN (no_bgp_always_compare_med
,
1873 no_bgp_always_compare_med_cmd
,
1874 "no bgp always-compare-med",
1876 "BGP specific commands\n"
1877 "Allow comparing MED from different neighbors\n")
1879 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1880 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1881 bgp_recalculate_all_bestpaths(bgp
);
1887 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1888 "bgp ebgp-requires-policy",
1889 "BGP specific commands\n"
1890 "Require in and out policy for eBGP peers (RFC8212)\n")
1892 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1893 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1897 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1898 "no bgp ebgp-requires-policy",
1900 "BGP specific commands\n"
1901 "Require in and out policy for eBGP peers (RFC8212)\n")
1903 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1904 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1909 /* "bgp deterministic-med" configuration. */
1910 DEFUN (bgp_deterministic_med
,
1911 bgp_deterministic_med_cmd
,
1912 "bgp deterministic-med",
1913 "BGP specific commands\n"
1914 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1918 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1919 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1920 bgp_recalculate_all_bestpaths(bgp
);
1926 DEFUN (no_bgp_deterministic_med
,
1927 no_bgp_deterministic_med_cmd
,
1928 "no bgp deterministic-med",
1930 "BGP specific commands\n"
1931 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1933 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1934 int bestpath_per_as_used
;
1938 struct listnode
*node
, *nnode
;
1940 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1941 bestpath_per_as_used
= 0;
1943 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1944 FOREACH_AFI_SAFI (afi
, safi
)
1945 if (bgp_addpath_dmed_required(
1946 peer
->addpath_type
[afi
][safi
])) {
1947 bestpath_per_as_used
= 1;
1951 if (bestpath_per_as_used
)
1955 if (bestpath_per_as_used
) {
1957 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1958 return CMD_WARNING_CONFIG_FAILED
;
1960 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1961 bgp_recalculate_all_bestpaths(bgp
);
1968 /* "bgp graceful-restart" configuration. */
1969 DEFUN (bgp_graceful_restart
,
1970 bgp_graceful_restart_cmd
,
1971 "bgp graceful-restart",
1972 "BGP specific commands\n"
1973 "Graceful restart capability parameters\n")
1975 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1976 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1980 DEFUN (no_bgp_graceful_restart
,
1981 no_bgp_graceful_restart_cmd
,
1982 "no bgp graceful-restart",
1984 "BGP specific commands\n"
1985 "Graceful restart capability parameters\n")
1987 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1988 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1992 DEFUN (bgp_graceful_restart_stalepath_time
,
1993 bgp_graceful_restart_stalepath_time_cmd
,
1994 "bgp graceful-restart stalepath-time (1-4095)",
1995 "BGP specific commands\n"
1996 "Graceful restart capability parameters\n"
1997 "Set the max time to hold onto restarting peer's stale paths\n"
1998 "Delay value (seconds)\n")
2000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2005 bgp
->stalepath_time
= stalepath
;
2009 DEFUN (bgp_graceful_restart_restart_time
,
2010 bgp_graceful_restart_restart_time_cmd
,
2011 "bgp graceful-restart restart-time (1-4095)",
2012 "BGP specific commands\n"
2013 "Graceful restart capability parameters\n"
2014 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2015 "Delay value (seconds)\n")
2017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2021 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2022 bgp
->restart_time
= restart
;
2026 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2027 no_bgp_graceful_restart_stalepath_time_cmd
,
2028 "no bgp graceful-restart stalepath-time [(1-4095)]",
2030 "BGP specific commands\n"
2031 "Graceful restart capability parameters\n"
2032 "Set the max time to hold onto restarting peer's stale paths\n"
2033 "Delay value (seconds)\n")
2035 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2037 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2041 DEFUN (no_bgp_graceful_restart_restart_time
,
2042 no_bgp_graceful_restart_restart_time_cmd
,
2043 "no bgp graceful-restart restart-time [(1-4095)]",
2045 "BGP specific commands\n"
2046 "Graceful restart capability parameters\n"
2047 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2048 "Delay value (seconds)\n")
2050 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2052 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2056 DEFUN (bgp_graceful_restart_preserve_fw
,
2057 bgp_graceful_restart_preserve_fw_cmd
,
2058 "bgp graceful-restart preserve-fw-state",
2059 "BGP specific commands\n"
2060 "Graceful restart capability parameters\n"
2061 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2063 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2064 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2068 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2069 no_bgp_graceful_restart_preserve_fw_cmd
,
2070 "no bgp graceful-restart preserve-fw-state",
2072 "BGP specific commands\n"
2073 "Graceful restart capability parameters\n"
2074 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2076 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2077 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2081 /* "bgp graceful-shutdown" configuration */
2082 DEFUN (bgp_graceful_shutdown
,
2083 bgp_graceful_shutdown_cmd
,
2084 "bgp graceful-shutdown",
2086 "Graceful shutdown parameters\n")
2088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2090 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2091 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2092 bgp_static_redo_import_check(bgp
);
2093 bgp_redistribute_redo(bgp
);
2094 bgp_clear_star_soft_out(vty
, bgp
->name
);
2095 bgp_clear_star_soft_in(vty
, bgp
->name
);
2101 DEFUN (no_bgp_graceful_shutdown
,
2102 no_bgp_graceful_shutdown_cmd
,
2103 "no bgp graceful-shutdown",
2106 "Graceful shutdown parameters\n")
2108 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2110 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2111 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2112 bgp_static_redo_import_check(bgp
);
2113 bgp_redistribute_redo(bgp
);
2114 bgp_clear_star_soft_out(vty
, bgp
->name
);
2115 bgp_clear_star_soft_in(vty
, bgp
->name
);
2121 /* "bgp fast-external-failover" configuration. */
2122 DEFUN (bgp_fast_external_failover
,
2123 bgp_fast_external_failover_cmd
,
2124 "bgp fast-external-failover",
2126 "Immediately reset session if a link to a directly connected external peer goes down\n")
2128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2129 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2133 DEFUN (no_bgp_fast_external_failover
,
2134 no_bgp_fast_external_failover_cmd
,
2135 "no bgp fast-external-failover",
2138 "Immediately reset session if a link to a directly connected external peer goes down\n")
2140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2141 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2145 /* "bgp enforce-first-as" configuration. */
2146 #if CONFDATE > 20190517
2147 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2150 DEFUN_HIDDEN (bgp_enforce_first_as
,
2151 bgp_enforce_first_as_cmd
,
2152 "[no] bgp enforce-first-as",
2155 "Enforce the first AS for EBGP routes\n")
2157 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2159 if (strmatch(argv
[0]->text
, "no"))
2160 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2162 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2167 /* "bgp bestpath compare-routerid" configuration. */
2168 DEFUN (bgp_bestpath_compare_router_id
,
2169 bgp_bestpath_compare_router_id_cmd
,
2170 "bgp bestpath compare-routerid",
2171 "BGP specific commands\n"
2172 "Change the default bestpath selection\n"
2173 "Compare router-id for identical EBGP paths\n")
2175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2176 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2177 bgp_recalculate_all_bestpaths(bgp
);
2182 DEFUN (no_bgp_bestpath_compare_router_id
,
2183 no_bgp_bestpath_compare_router_id_cmd
,
2184 "no bgp bestpath compare-routerid",
2186 "BGP specific commands\n"
2187 "Change the default bestpath selection\n"
2188 "Compare router-id for identical EBGP paths\n")
2190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2191 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2192 bgp_recalculate_all_bestpaths(bgp
);
2197 /* "bgp bestpath as-path ignore" configuration. */
2198 DEFUN (bgp_bestpath_aspath_ignore
,
2199 bgp_bestpath_aspath_ignore_cmd
,
2200 "bgp bestpath as-path ignore",
2201 "BGP specific commands\n"
2202 "Change the default bestpath selection\n"
2203 "AS-path attribute\n"
2204 "Ignore as-path length in selecting a route\n")
2206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2207 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2208 bgp_recalculate_all_bestpaths(bgp
);
2213 DEFUN (no_bgp_bestpath_aspath_ignore
,
2214 no_bgp_bestpath_aspath_ignore_cmd
,
2215 "no bgp bestpath as-path ignore",
2217 "BGP specific commands\n"
2218 "Change the default bestpath selection\n"
2219 "AS-path attribute\n"
2220 "Ignore as-path length in selecting a route\n")
2222 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2223 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2224 bgp_recalculate_all_bestpaths(bgp
);
2229 /* "bgp bestpath as-path confed" configuration. */
2230 DEFUN (bgp_bestpath_aspath_confed
,
2231 bgp_bestpath_aspath_confed_cmd
,
2232 "bgp bestpath as-path confed",
2233 "BGP specific commands\n"
2234 "Change the default bestpath selection\n"
2235 "AS-path attribute\n"
2236 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2239 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2240 bgp_recalculate_all_bestpaths(bgp
);
2245 DEFUN (no_bgp_bestpath_aspath_confed
,
2246 no_bgp_bestpath_aspath_confed_cmd
,
2247 "no bgp bestpath as-path confed",
2249 "BGP specific commands\n"
2250 "Change the default bestpath selection\n"
2251 "AS-path attribute\n"
2252 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2254 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2255 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2256 bgp_recalculate_all_bestpaths(bgp
);
2261 /* "bgp bestpath as-path multipath-relax" configuration. */
2262 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2263 bgp_bestpath_aspath_multipath_relax_cmd
,
2264 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2265 "BGP specific commands\n"
2266 "Change the default bestpath selection\n"
2267 "AS-path attribute\n"
2268 "Allow load sharing across routes that have different AS paths (but same length)\n"
2269 "Generate an AS_SET\n"
2270 "Do not generate an AS_SET\n")
2272 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2274 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2276 /* no-as-set is now the default behavior so we can silently
2278 if (argv_find(argv
, argc
, "as-set", &idx
))
2279 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2281 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2283 bgp_recalculate_all_bestpaths(bgp
);
2288 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2289 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2290 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2292 "BGP specific commands\n"
2293 "Change the default bestpath selection\n"
2294 "AS-path attribute\n"
2295 "Allow load sharing across routes that have different AS paths (but same length)\n"
2296 "Generate an AS_SET\n"
2297 "Do not generate an AS_SET\n")
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2300 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2301 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2302 bgp_recalculate_all_bestpaths(bgp
);
2307 /* "bgp log-neighbor-changes" configuration. */
2308 DEFUN (bgp_log_neighbor_changes
,
2309 bgp_log_neighbor_changes_cmd
,
2310 "bgp log-neighbor-changes",
2311 "BGP specific commands\n"
2312 "Log neighbor up/down and reset reason\n")
2314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2315 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2319 DEFUN (no_bgp_log_neighbor_changes
,
2320 no_bgp_log_neighbor_changes_cmd
,
2321 "no bgp log-neighbor-changes",
2323 "BGP specific commands\n"
2324 "Log neighbor up/down and reset reason\n")
2326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2327 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2331 /* "bgp bestpath med" configuration. */
2332 DEFUN (bgp_bestpath_med
,
2333 bgp_bestpath_med_cmd
,
2334 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2335 "BGP specific commands\n"
2336 "Change the default bestpath selection\n"
2338 "Compare MED among confederation paths\n"
2339 "Treat missing MED as the least preferred one\n"
2340 "Treat missing MED as the least preferred one\n"
2341 "Compare MED among confederation paths\n")
2343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2346 if (argv_find(argv
, argc
, "confed", &idx
))
2347 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2349 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2350 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2352 bgp_recalculate_all_bestpaths(bgp
);
2357 DEFUN (no_bgp_bestpath_med
,
2358 no_bgp_bestpath_med_cmd
,
2359 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2361 "BGP specific commands\n"
2362 "Change the default bestpath selection\n"
2364 "Compare MED among confederation paths\n"
2365 "Treat missing MED as the least preferred one\n"
2366 "Treat missing MED as the least preferred one\n"
2367 "Compare MED among confederation paths\n")
2369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2372 if (argv_find(argv
, argc
, "confed", &idx
))
2373 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2375 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2376 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2378 bgp_recalculate_all_bestpaths(bgp
);
2383 /* "no bgp default ipv4-unicast". */
2384 DEFUN (no_bgp_default_ipv4_unicast
,
2385 no_bgp_default_ipv4_unicast_cmd
,
2386 "no bgp default ipv4-unicast",
2388 "BGP specific commands\n"
2389 "Configure BGP defaults\n"
2390 "Activate ipv4-unicast for a peer by default\n")
2392 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2393 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2397 DEFUN (bgp_default_ipv4_unicast
,
2398 bgp_default_ipv4_unicast_cmd
,
2399 "bgp default ipv4-unicast",
2400 "BGP specific commands\n"
2401 "Configure BGP defaults\n"
2402 "Activate ipv4-unicast for a peer by default\n")
2404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2405 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2409 /* Display hostname in certain command outputs */
2410 DEFUN (bgp_default_show_hostname
,
2411 bgp_default_show_hostname_cmd
,
2412 "bgp default show-hostname",
2413 "BGP specific commands\n"
2414 "Configure BGP defaults\n"
2415 "Show hostname in certain command outputs\n")
2417 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2418 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2422 DEFUN (no_bgp_default_show_hostname
,
2423 no_bgp_default_show_hostname_cmd
,
2424 "no bgp default show-hostname",
2426 "BGP specific commands\n"
2427 "Configure BGP defaults\n"
2428 "Show hostname in certain command outputs\n")
2430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2431 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2435 /* "bgp network import-check" configuration. */
2436 DEFUN (bgp_network_import_check
,
2437 bgp_network_import_check_cmd
,
2438 "bgp network import-check",
2439 "BGP specific commands\n"
2440 "BGP network command\n"
2441 "Check BGP network route exists in IGP\n")
2443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2444 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2445 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2446 bgp_static_redo_import_check(bgp
);
2452 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2453 "bgp network import-check exact",
2454 "BGP specific commands\n"
2455 "BGP network command\n"
2456 "Check BGP network route exists in IGP\n"
2457 "Match route precisely\n")
2459 DEFUN (no_bgp_network_import_check
,
2460 no_bgp_network_import_check_cmd
,
2461 "no bgp network import-check",
2463 "BGP specific commands\n"
2464 "BGP network command\n"
2465 "Check BGP network route exists in IGP\n")
2467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2468 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2469 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2470 bgp_static_redo_import_check(bgp
);
2476 DEFUN (bgp_default_local_preference
,
2477 bgp_default_local_preference_cmd
,
2478 "bgp default local-preference (0-4294967295)",
2479 "BGP specific commands\n"
2480 "Configure BGP defaults\n"
2481 "local preference (higher=more preferred)\n"
2482 "Configure default local preference value\n")
2484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2486 uint32_t local_pref
;
2488 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2490 bgp_default_local_preference_set(bgp
, local_pref
);
2491 bgp_clear_star_soft_in(vty
, bgp
->name
);
2496 DEFUN (no_bgp_default_local_preference
,
2497 no_bgp_default_local_preference_cmd
,
2498 "no bgp default local-preference [(0-4294967295)]",
2500 "BGP specific commands\n"
2501 "Configure BGP defaults\n"
2502 "local preference (higher=more preferred)\n"
2503 "Configure default local preference value\n")
2505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2506 bgp_default_local_preference_unset(bgp
);
2507 bgp_clear_star_soft_in(vty
, bgp
->name
);
2513 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2514 bgp_default_subgroup_pkt_queue_max_cmd
,
2515 "bgp default subgroup-pkt-queue-max (20-100)",
2516 "BGP specific commands\n"
2517 "Configure BGP defaults\n"
2518 "subgroup-pkt-queue-max\n"
2519 "Configure subgroup packet queue max\n")
2521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2525 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2527 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2532 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2533 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2534 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2536 "BGP specific commands\n"
2537 "Configure BGP defaults\n"
2538 "subgroup-pkt-queue-max\n"
2539 "Configure subgroup packet queue max\n")
2541 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2542 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2547 DEFUN (bgp_rr_allow_outbound_policy
,
2548 bgp_rr_allow_outbound_policy_cmd
,
2549 "bgp route-reflector allow-outbound-policy",
2550 "BGP specific commands\n"
2551 "Allow modifications made by out route-map\n"
2552 "on ibgp neighbors\n")
2554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2556 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2557 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2558 update_group_announce_rrclients(bgp
);
2559 bgp_clear_star_soft_out(vty
, bgp
->name
);
2565 DEFUN (no_bgp_rr_allow_outbound_policy
,
2566 no_bgp_rr_allow_outbound_policy_cmd
,
2567 "no bgp route-reflector allow-outbound-policy",
2569 "BGP specific commands\n"
2570 "Allow modifications made by out route-map\n"
2571 "on ibgp neighbors\n")
2573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2575 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2576 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2577 update_group_announce_rrclients(bgp
);
2578 bgp_clear_star_soft_out(vty
, bgp
->name
);
2584 DEFUN (bgp_listen_limit
,
2585 bgp_listen_limit_cmd
,
2586 "bgp listen limit (1-5000)",
2587 "BGP specific commands\n"
2588 "Configure BGP defaults\n"
2589 "maximum number of BGP Dynamic Neighbors that can be created\n"
2590 "Configure Dynamic Neighbors listen limit value\n")
2592 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2596 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2598 bgp_listen_limit_set(bgp
, listen_limit
);
2603 DEFUN (no_bgp_listen_limit
,
2604 no_bgp_listen_limit_cmd
,
2605 "no bgp listen limit [(1-5000)]",
2606 "BGP specific commands\n"
2607 "Configure BGP defaults\n"
2608 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2609 "Configure Dynamic Neighbors listen limit value to default\n"
2610 "Configure Dynamic Neighbors listen limit value\n")
2612 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2613 bgp_listen_limit_unset(bgp
);
2619 * Check if this listen range is already configured. Check for exact
2620 * match or overlap based on input.
2622 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2623 struct prefix
*range
, int exact
)
2625 struct listnode
*node
, *nnode
;
2626 struct listnode
*node1
, *nnode1
;
2627 struct peer_group
*group
;
2632 afi
= family2afi(range
->family
);
2633 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2634 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2637 match
= prefix_same(range
, lr
);
2639 match
= (prefix_match(range
, lr
)
2640 || prefix_match(lr
, range
));
2649 DEFUN (bgp_listen_range
,
2650 bgp_listen_range_cmd
,
2651 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2652 "BGP specific commands\n"
2653 "Configure BGP dynamic neighbors listen range\n"
2654 "Configure BGP dynamic neighbors listen range\n"
2656 "Member of the peer-group\n"
2657 "Peer-group name\n")
2659 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2660 struct prefix range
;
2661 struct peer_group
*group
, *existing_group
;
2666 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2667 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2668 char *prefix
= argv
[idx
]->arg
;
2669 argv_find(argv
, argc
, "PGNAME", &idx
);
2670 char *peergroup
= argv
[idx
]->arg
;
2672 /* Convert IP prefix string to struct prefix. */
2673 ret
= str2prefix(prefix
, &range
);
2675 vty_out(vty
, "%% Malformed listen range\n");
2676 return CMD_WARNING_CONFIG_FAILED
;
2679 afi
= family2afi(range
.family
);
2681 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2683 "%% Malformed listen range (link-local address)\n");
2684 return CMD_WARNING_CONFIG_FAILED
;
2689 /* Check if same listen range is already configured. */
2690 existing_group
= listen_range_exists(bgp
, &range
, 1);
2691 if (existing_group
) {
2692 if (strcmp(existing_group
->name
, peergroup
) == 0)
2696 "%% Same listen range is attached to peer-group %s\n",
2697 existing_group
->name
);
2698 return CMD_WARNING_CONFIG_FAILED
;
2702 /* Check if an overlapping listen range exists. */
2703 if (listen_range_exists(bgp
, &range
, 0)) {
2705 "%% Listen range overlaps with existing listen range\n");
2706 return CMD_WARNING_CONFIG_FAILED
;
2709 group
= peer_group_lookup(bgp
, peergroup
);
2711 vty_out(vty
, "%% Configure the peer-group first\n");
2712 return CMD_WARNING_CONFIG_FAILED
;
2715 ret
= peer_group_listen_range_add(group
, &range
);
2716 return bgp_vty_return(vty
, ret
);
2719 DEFUN (no_bgp_listen_range
,
2720 no_bgp_listen_range_cmd
,
2721 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2723 "BGP specific commands\n"
2724 "Unconfigure BGP dynamic neighbors listen range\n"
2725 "Unconfigure BGP dynamic neighbors listen range\n"
2727 "Member of the peer-group\n"
2728 "Peer-group name\n")
2730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2731 struct prefix range
;
2732 struct peer_group
*group
;
2737 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2738 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2739 char *prefix
= argv
[idx
]->arg
;
2740 argv_find(argv
, argc
, "WORD", &idx
);
2741 char *peergroup
= argv
[idx
]->arg
;
2743 /* Convert IP prefix string to struct prefix. */
2744 ret
= str2prefix(prefix
, &range
);
2746 vty_out(vty
, "%% Malformed listen range\n");
2747 return CMD_WARNING_CONFIG_FAILED
;
2750 afi
= family2afi(range
.family
);
2752 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2754 "%% Malformed listen range (link-local address)\n");
2755 return CMD_WARNING_CONFIG_FAILED
;
2760 group
= peer_group_lookup(bgp
, peergroup
);
2762 vty_out(vty
, "%% Peer-group does not exist\n");
2763 return CMD_WARNING_CONFIG_FAILED
;
2766 ret
= peer_group_listen_range_del(group
, &range
);
2767 return bgp_vty_return(vty
, ret
);
2770 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2772 struct peer_group
*group
;
2773 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2774 struct prefix
*range
;
2776 char buf
[PREFIX2STR_BUFFER
];
2778 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2779 vty_out(vty
, " bgp listen limit %d\n",
2780 bgp
->dynamic_neighbors_limit
);
2782 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2783 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2784 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2786 prefix2str(range
, buf
, sizeof(buf
));
2788 " bgp listen range %s peer-group %s\n",
2796 DEFUN (bgp_disable_connected_route_check
,
2797 bgp_disable_connected_route_check_cmd
,
2798 "bgp disable-ebgp-connected-route-check",
2799 "BGP specific commands\n"
2800 "Disable checking if nexthop is connected on ebgp sessions\n")
2802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2803 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2804 bgp_clear_star_soft_in(vty
, bgp
->name
);
2809 DEFUN (no_bgp_disable_connected_route_check
,
2810 no_bgp_disable_connected_route_check_cmd
,
2811 "no bgp disable-ebgp-connected-route-check",
2813 "BGP specific commands\n"
2814 "Disable checking if nexthop is connected on ebgp sessions\n")
2816 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2817 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2818 bgp_clear_star_soft_in(vty
, bgp
->name
);
2824 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2825 const char *as_str
, afi_t afi
, safi_t safi
)
2827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2830 int as_type
= AS_SPECIFIED
;
2833 if (as_str
[0] == 'i') {
2835 as_type
= AS_INTERNAL
;
2836 } else if (as_str
[0] == 'e') {
2838 as_type
= AS_EXTERNAL
;
2840 /* Get AS number. */
2841 as
= strtoul(as_str
, NULL
, 10);
2844 /* If peer is peer group or interface peer, call proper function. */
2845 ret
= str2sockunion(peer_str
, &su
);
2849 /* Check if existing interface peer */
2850 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2852 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2855 /* if not interface peer, check peer-group settings */
2856 if (ret
< 0 && !peer
) {
2857 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2860 "%% Create the peer-group or interface first\n");
2861 return CMD_WARNING_CONFIG_FAILED
;
2866 if (peer_address_self_check(bgp
, &su
)) {
2868 "%% Can not configure the local system as neighbor\n");
2869 return CMD_WARNING_CONFIG_FAILED
;
2871 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2874 /* This peer belongs to peer group. */
2876 case BGP_ERR_PEER_GROUP_MEMBER
:
2878 "%% Peer-group member cannot override remote-as of peer-group\n");
2879 return CMD_WARNING_CONFIG_FAILED
;
2880 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2882 "%% Peer-group members must be all internal or all external\n");
2883 return CMD_WARNING_CONFIG_FAILED
;
2885 return bgp_vty_return(vty
, ret
);
2888 DEFUN (bgp_default_shutdown
,
2889 bgp_default_shutdown_cmd
,
2890 "[no] bgp default shutdown",
2893 "Configure BGP defaults\n"
2894 "Apply administrative shutdown to newly configured peers\n")
2896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2897 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2901 DEFUN (neighbor_remote_as
,
2902 neighbor_remote_as_cmd
,
2903 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2906 "Specify a BGP neighbor\n"
2908 "Internal BGP peer\n"
2909 "External BGP peer\n")
2912 int idx_remote_as
= 3;
2913 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2914 argv
[idx_remote_as
]->arg
, AFI_IP
,
2918 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2919 afi_t afi
, safi_t safi
, int v6only
,
2920 const char *peer_group_name
,
2923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2925 int as_type
= AS_UNSPECIFIED
;
2927 struct peer_group
*group
;
2931 group
= peer_group_lookup(bgp
, conf_if
);
2934 vty_out(vty
, "%% Name conflict with peer-group \n");
2935 return CMD_WARNING_CONFIG_FAILED
;
2939 if (as_str
[0] == 'i') {
2940 as_type
= AS_INTERNAL
;
2941 } else if (as_str
[0] == 'e') {
2942 as_type
= AS_EXTERNAL
;
2944 /* Get AS number. */
2945 as
= strtoul(as_str
, NULL
, 10);
2946 as_type
= AS_SPECIFIED
;
2950 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2953 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2956 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2957 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2958 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2959 as_type
, 0, 0, NULL
);
2961 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2962 as_type
, afi
, safi
, NULL
);
2965 vty_out(vty
, "%% BGP failed to create peer\n");
2966 return CMD_WARNING_CONFIG_FAILED
;
2970 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2972 /* Request zebra to initiate IPv6 RAs on this interface. We do
2974 * any unnumbered peer in order to not worry about run-time
2976 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2978 * gets deleted later etc.)
2981 bgp_zebra_initiate_radv(bgp
, peer
);
2984 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2985 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2987 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2989 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2991 /* v6only flag changed. Reset bgp seesion */
2992 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2993 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2994 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2995 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2997 bgp_session_reset(peer
);
3000 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3001 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3002 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3003 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3006 if (peer_group_name
) {
3007 group
= peer_group_lookup(bgp
, peer_group_name
);
3009 vty_out(vty
, "%% Configure the peer-group first\n");
3010 return CMD_WARNING_CONFIG_FAILED
;
3013 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3016 return bgp_vty_return(vty
, ret
);
3019 DEFUN (neighbor_interface_config
,
3020 neighbor_interface_config_cmd
,
3021 "neighbor WORD interface [peer-group PGNAME]",
3023 "Interface name or neighbor tag\n"
3024 "Enable BGP on interface\n"
3025 "Member of the peer-group\n"
3026 "Peer-group name\n")
3029 int idx_peer_group_word
= 4;
3031 if (argc
> idx_peer_group_word
)
3032 return peer_conf_interface_get(
3033 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3034 argv
[idx_peer_group_word
]->arg
, NULL
);
3036 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3037 SAFI_UNICAST
, 0, NULL
, NULL
);
3040 DEFUN (neighbor_interface_config_v6only
,
3041 neighbor_interface_config_v6only_cmd
,
3042 "neighbor WORD interface v6only [peer-group PGNAME]",
3044 "Interface name or neighbor tag\n"
3045 "Enable BGP on interface\n"
3046 "Enable BGP with v6 link-local only\n"
3047 "Member of the peer-group\n"
3048 "Peer-group name\n")
3051 int idx_peer_group_word
= 5;
3053 if (argc
> idx_peer_group_word
)
3054 return peer_conf_interface_get(
3055 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3056 argv
[idx_peer_group_word
]->arg
, NULL
);
3058 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3059 SAFI_UNICAST
, 1, NULL
, NULL
);
3063 DEFUN (neighbor_interface_config_remote_as
,
3064 neighbor_interface_config_remote_as_cmd
,
3065 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3067 "Interface name or neighbor tag\n"
3068 "Enable BGP on interface\n"
3069 "Specify a BGP neighbor\n"
3071 "Internal BGP peer\n"
3072 "External BGP peer\n")
3075 int idx_remote_as
= 4;
3076 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3077 SAFI_UNICAST
, 0, NULL
,
3078 argv
[idx_remote_as
]->arg
);
3081 DEFUN (neighbor_interface_v6only_config_remote_as
,
3082 neighbor_interface_v6only_config_remote_as_cmd
,
3083 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3085 "Interface name or neighbor tag\n"
3086 "Enable BGP with v6 link-local only\n"
3087 "Enable BGP on interface\n"
3088 "Specify a BGP neighbor\n"
3090 "Internal BGP peer\n"
3091 "External BGP peer\n")
3094 int idx_remote_as
= 5;
3095 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3096 SAFI_UNICAST
, 1, NULL
,
3097 argv
[idx_remote_as
]->arg
);
3100 DEFUN (neighbor_peer_group
,
3101 neighbor_peer_group_cmd
,
3102 "neighbor WORD peer-group",
3104 "Interface name or neighbor tag\n"
3105 "Configure peer-group\n")
3107 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3110 struct peer_group
*group
;
3112 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3114 vty_out(vty
, "%% Name conflict with interface: \n");
3115 return CMD_WARNING_CONFIG_FAILED
;
3118 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3120 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3121 return CMD_WARNING_CONFIG_FAILED
;
3129 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3133 "Specify a BGP neighbor\n"
3135 "Internal BGP peer\n"
3136 "External BGP peer\n")
3138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3142 struct peer_group
*group
;
3146 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3148 /* look up for neighbor by interface name config. */
3149 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3151 /* Request zebra to terminate IPv6 RAs on this
3154 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3159 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3161 peer_group_delete(group
);
3163 vty_out(vty
, "%% Create the peer-group first\n");
3164 return CMD_WARNING_CONFIG_FAILED
;
3167 peer
= peer_lookup(bgp
, &su
);
3169 if (peer_dynamic_neighbor(peer
)) {
3171 "%% Operation not allowed on a dynamic neighbor\n");
3172 return CMD_WARNING_CONFIG_FAILED
;
3175 other
= peer
->doppelganger
;
3177 if (other
&& other
->status
!= Deleted
)
3185 DEFUN (no_neighbor_interface_config
,
3186 no_neighbor_interface_config_cmd
,
3187 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3191 "Configure BGP on interface\n"
3192 "Enable BGP with v6 link-local only\n"
3193 "Member of the peer-group\n"
3195 "Specify a BGP neighbor\n"
3197 "Internal BGP peer\n"
3198 "External BGP peer\n")
3200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3204 /* look up for neighbor by interface name config. */
3205 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3207 /* Request zebra to terminate IPv6 RAs on this interface. */
3209 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3212 vty_out(vty
, "%% Create the bgp interface first\n");
3213 return CMD_WARNING_CONFIG_FAILED
;
3218 DEFUN (no_neighbor_peer_group
,
3219 no_neighbor_peer_group_cmd
,
3220 "no neighbor WORD peer-group",
3224 "Configure peer-group\n")
3226 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3228 struct peer_group
*group
;
3230 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3232 peer_group_delete(group
);
3234 vty_out(vty
, "%% Create the peer-group first\n");
3235 return CMD_WARNING_CONFIG_FAILED
;
3240 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3241 no_neighbor_interface_peer_group_remote_as_cmd
,
3242 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3245 "Interface name or neighbor tag\n"
3246 "Specify a BGP neighbor\n"
3248 "Internal BGP peer\n"
3249 "External BGP peer\n")
3251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3253 struct peer_group
*group
;
3256 /* look up for neighbor by interface name config. */
3257 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3259 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3263 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3265 peer_group_remote_as_delete(group
);
3267 vty_out(vty
, "%% Create the peer-group or interface first\n");
3268 return CMD_WARNING_CONFIG_FAILED
;
3273 DEFUN (neighbor_local_as
,
3274 neighbor_local_as_cmd
,
3275 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3278 "Specify a local-as number\n"
3279 "AS number used as local AS\n")
3287 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3289 return CMD_WARNING_CONFIG_FAILED
;
3291 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3292 ret
= peer_local_as_set(peer
, as
, 0, 0);
3293 return bgp_vty_return(vty
, ret
);
3296 DEFUN (neighbor_local_as_no_prepend
,
3297 neighbor_local_as_no_prepend_cmd
,
3298 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3301 "Specify a local-as number\n"
3302 "AS number used as local AS\n"
3303 "Do not prepend local-as to updates from ebgp peers\n")
3311 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3313 return CMD_WARNING_CONFIG_FAILED
;
3315 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3316 ret
= peer_local_as_set(peer
, as
, 1, 0);
3317 return bgp_vty_return(vty
, ret
);
3320 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3321 neighbor_local_as_no_prepend_replace_as_cmd
,
3322 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3325 "Specify a local-as number\n"
3326 "AS number used as local AS\n"
3327 "Do not prepend local-as to updates from ebgp peers\n"
3328 "Do not prepend local-as to updates from ibgp peers\n")
3336 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3338 return CMD_WARNING_CONFIG_FAILED
;
3340 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3341 ret
= peer_local_as_set(peer
, as
, 1, 1);
3342 return bgp_vty_return(vty
, ret
);
3345 DEFUN (no_neighbor_local_as
,
3346 no_neighbor_local_as_cmd
,
3347 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3351 "Specify a local-as number\n"
3352 "AS number used as local AS\n"
3353 "Do not prepend local-as to updates from ebgp peers\n"
3354 "Do not prepend local-as to updates from ibgp peers\n")
3360 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3362 return CMD_WARNING_CONFIG_FAILED
;
3364 ret
= peer_local_as_unset(peer
);
3365 return bgp_vty_return(vty
, ret
);
3369 DEFUN (neighbor_solo
,
3371 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3374 "Solo peer - part of its own update group\n")
3380 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3382 return CMD_WARNING_CONFIG_FAILED
;
3384 ret
= update_group_adjust_soloness(peer
, 1);
3385 return bgp_vty_return(vty
, ret
);
3388 DEFUN (no_neighbor_solo
,
3389 no_neighbor_solo_cmd
,
3390 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3394 "Solo peer - part of its own update group\n")
3400 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3402 return CMD_WARNING_CONFIG_FAILED
;
3404 ret
= update_group_adjust_soloness(peer
, 0);
3405 return bgp_vty_return(vty
, ret
);
3408 DEFUN (neighbor_password
,
3409 neighbor_password_cmd
,
3410 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3421 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3423 return CMD_WARNING_CONFIG_FAILED
;
3425 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3426 return bgp_vty_return(vty
, ret
);
3429 DEFUN (no_neighbor_password
,
3430 no_neighbor_password_cmd
,
3431 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3442 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3444 return CMD_WARNING_CONFIG_FAILED
;
3446 ret
= peer_password_unset(peer
);
3447 return bgp_vty_return(vty
, ret
);
3450 DEFUN (neighbor_activate
,
3451 neighbor_activate_cmd
,
3452 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3455 "Enable the Address Family for this Neighbor\n")
3461 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3463 return CMD_WARNING_CONFIG_FAILED
;
3465 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3466 return bgp_vty_return(vty
, ret
);
3469 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3470 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3471 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3472 "Enable the Address Family for this Neighbor\n")
3474 DEFUN (no_neighbor_activate
,
3475 no_neighbor_activate_cmd
,
3476 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3480 "Enable the Address Family for this Neighbor\n")
3487 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3489 return CMD_WARNING_CONFIG_FAILED
;
3491 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3492 return bgp_vty_return(vty
, ret
);
3495 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3496 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3497 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3498 "Enable the Address Family for this Neighbor\n")
3500 DEFUN (neighbor_set_peer_group
,
3501 neighbor_set_peer_group_cmd
,
3502 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3505 "Member of the peer-group\n"
3506 "Peer-group name\n")
3508 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3515 struct peer_group
*group
;
3517 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3519 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3521 vty_out(vty
, "%% Malformed address or name: %s\n",
3522 argv
[idx_peer
]->arg
);
3523 return CMD_WARNING_CONFIG_FAILED
;
3526 if (peer_address_self_check(bgp
, &su
)) {
3528 "%% Can not configure the local system as neighbor\n");
3529 return CMD_WARNING_CONFIG_FAILED
;
3532 /* Disallow for dynamic neighbor. */
3533 peer
= peer_lookup(bgp
, &su
);
3534 if (peer
&& peer_dynamic_neighbor(peer
)) {
3536 "%% Operation not allowed on a dynamic neighbor\n");
3537 return CMD_WARNING_CONFIG_FAILED
;
3541 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3543 vty_out(vty
, "%% Configure the peer-group first\n");
3544 return CMD_WARNING_CONFIG_FAILED
;
3547 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3549 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3551 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3553 return CMD_WARNING_CONFIG_FAILED
;
3556 return bgp_vty_return(vty
, ret
);
3559 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3560 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3561 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3562 "Member of the peer-group\n"
3563 "Peer-group name\n")
3565 DEFUN (no_neighbor_set_peer_group
,
3566 no_neighbor_set_peer_group_cmd
,
3567 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3571 "Member of the peer-group\n"
3572 "Peer-group name\n")
3574 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3579 struct peer_group
*group
;
3581 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3583 return CMD_WARNING_CONFIG_FAILED
;
3585 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3587 vty_out(vty
, "%% Configure the peer-group first\n");
3588 return CMD_WARNING_CONFIG_FAILED
;
3591 ret
= peer_delete(peer
);
3593 return bgp_vty_return(vty
, ret
);
3596 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3597 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3598 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3599 "Member of the peer-group\n"
3600 "Peer-group name\n")
3602 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3603 uint32_t flag
, int set
)
3608 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3610 return CMD_WARNING_CONFIG_FAILED
;
3613 * If 'neighbor <interface>', then this is for directly connected peers,
3614 * we should not accept disable-connected-check.
3616 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3618 "%s is directly connected peer, cannot accept disable-"
3619 "connected-check\n",
3621 return CMD_WARNING_CONFIG_FAILED
;
3624 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3625 peer_tx_shutdown_message_unset(peer
);
3628 ret
= peer_flag_set(peer
, flag
);
3630 ret
= peer_flag_unset(peer
, flag
);
3632 return bgp_vty_return(vty
, ret
);
3635 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3637 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3640 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3643 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3646 /* neighbor passive. */
3647 DEFUN (neighbor_passive
,
3648 neighbor_passive_cmd
,
3649 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3652 "Don't send open messages to this neighbor\n")
3655 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3658 DEFUN (no_neighbor_passive
,
3659 no_neighbor_passive_cmd
,
3660 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3664 "Don't send open messages to this neighbor\n")
3667 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3670 /* neighbor shutdown. */
3671 DEFUN (neighbor_shutdown_msg
,
3672 neighbor_shutdown_msg_cmd
,
3673 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3676 "Administratively shut down this neighbor\n"
3677 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3678 "Shutdown message\n")
3684 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3688 return CMD_WARNING_CONFIG_FAILED
;
3689 message
= argv_concat(argv
, argc
, 4);
3690 peer_tx_shutdown_message_set(peer
, message
);
3691 XFREE(MTYPE_TMP
, message
);
3694 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3697 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3698 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3699 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3700 "Administratively shut down this neighbor\n")
3702 DEFUN (no_neighbor_shutdown_msg
,
3703 no_neighbor_shutdown_msg_cmd
,
3704 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3708 "Administratively shut down this neighbor\n"
3709 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3710 "Shutdown message\n")
3714 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3715 PEER_FLAG_SHUTDOWN
);
3718 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3719 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3720 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3721 "Administratively shut down this neighbor\n")
3723 /* neighbor capability dynamic. */
3724 DEFUN (neighbor_capability_dynamic
,
3725 neighbor_capability_dynamic_cmd
,
3726 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3729 "Advertise capability to the peer\n"
3730 "Advertise dynamic capability to this neighbor\n")
3733 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3734 PEER_FLAG_DYNAMIC_CAPABILITY
);
3737 DEFUN (no_neighbor_capability_dynamic
,
3738 no_neighbor_capability_dynamic_cmd
,
3739 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3743 "Advertise capability to the peer\n"
3744 "Advertise dynamic capability to this neighbor\n")
3747 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3748 PEER_FLAG_DYNAMIC_CAPABILITY
);
3751 /* neighbor dont-capability-negotiate */
3752 DEFUN (neighbor_dont_capability_negotiate
,
3753 neighbor_dont_capability_negotiate_cmd
,
3754 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3757 "Do not perform capability negotiation\n")
3760 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3761 PEER_FLAG_DONT_CAPABILITY
);
3764 DEFUN (no_neighbor_dont_capability_negotiate
,
3765 no_neighbor_dont_capability_negotiate_cmd
,
3766 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3770 "Do not perform capability negotiation\n")
3773 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3774 PEER_FLAG_DONT_CAPABILITY
);
3777 /* neighbor capability extended next hop encoding */
3778 DEFUN (neighbor_capability_enhe
,
3779 neighbor_capability_enhe_cmd
,
3780 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3783 "Advertise capability to the peer\n"
3784 "Advertise extended next-hop capability to the peer\n")
3787 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3788 PEER_FLAG_CAPABILITY_ENHE
);
3791 DEFUN (no_neighbor_capability_enhe
,
3792 no_neighbor_capability_enhe_cmd
,
3793 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3797 "Advertise capability to the peer\n"
3798 "Advertise extended next-hop capability to the peer\n")
3801 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3802 PEER_FLAG_CAPABILITY_ENHE
);
3805 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3806 afi_t afi
, safi_t safi
, uint32_t flag
,
3812 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3814 return CMD_WARNING_CONFIG_FAILED
;
3817 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3819 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3821 return bgp_vty_return(vty
, ret
);
3824 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3825 afi_t afi
, safi_t safi
, uint32_t flag
)
3827 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3830 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3831 afi_t afi
, safi_t safi
, uint32_t flag
)
3833 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3836 /* neighbor capability orf prefix-list. */
3837 DEFUN (neighbor_capability_orf_prefix
,
3838 neighbor_capability_orf_prefix_cmd
,
3839 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3842 "Advertise capability to the peer\n"
3843 "Advertise ORF capability to the peer\n"
3844 "Advertise prefixlist ORF capability to this neighbor\n"
3845 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3846 "Capability to RECEIVE the ORF from this neighbor\n"
3847 "Capability to SEND the ORF to this neighbor\n")
3850 int idx_send_recv
= 5;
3853 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3854 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3855 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3856 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3857 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3858 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3860 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3861 return CMD_WARNING_CONFIG_FAILED
;
3864 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3865 bgp_node_safi(vty
), flag
);
3869 neighbor_capability_orf_prefix
,
3870 neighbor_capability_orf_prefix_hidden_cmd
,
3871 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3872 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3873 "Advertise capability to the peer\n"
3874 "Advertise ORF capability to the peer\n"
3875 "Advertise prefixlist ORF capability to this neighbor\n"
3876 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3877 "Capability to RECEIVE the ORF from this neighbor\n"
3878 "Capability to SEND the ORF to this neighbor\n")
3880 DEFUN (no_neighbor_capability_orf_prefix
,
3881 no_neighbor_capability_orf_prefix_cmd
,
3882 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3886 "Advertise capability to the peer\n"
3887 "Advertise ORF capability to the peer\n"
3888 "Advertise prefixlist ORF capability to this neighbor\n"
3889 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3890 "Capability to RECEIVE the ORF from this neighbor\n"
3891 "Capability to SEND the ORF to this neighbor\n")
3894 int idx_send_recv
= 6;
3897 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3898 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3899 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3900 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3901 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3902 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3904 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3905 return CMD_WARNING_CONFIG_FAILED
;
3908 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3909 bgp_node_afi(vty
), bgp_node_safi(vty
),
3914 no_neighbor_capability_orf_prefix
,
3915 no_neighbor_capability_orf_prefix_hidden_cmd
,
3916 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3917 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3918 "Advertise capability to the peer\n"
3919 "Advertise ORF capability to the peer\n"
3920 "Advertise prefixlist ORF capability to this neighbor\n"
3921 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3922 "Capability to RECEIVE the ORF from this neighbor\n"
3923 "Capability to SEND the ORF to this neighbor\n")
3925 /* neighbor next-hop-self. */
3926 DEFUN (neighbor_nexthop_self
,
3927 neighbor_nexthop_self_cmd
,
3928 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3931 "Disable the next hop calculation for this neighbor\n")
3934 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3935 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3938 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3939 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3940 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3941 "Disable the next hop calculation for this neighbor\n")
3943 /* neighbor next-hop-self. */
3944 DEFUN (neighbor_nexthop_self_force
,
3945 neighbor_nexthop_self_force_cmd
,
3946 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3949 "Disable the next hop calculation for this neighbor\n"
3950 "Set the next hop to self for reflected routes\n")
3953 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3955 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3958 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3959 neighbor_nexthop_self_force_hidden_cmd
,
3960 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3961 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3962 "Disable the next hop calculation for this neighbor\n"
3963 "Set the next hop to self for reflected routes\n")
3965 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3966 neighbor_nexthop_self_all_hidden_cmd
,
3967 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3968 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3969 "Disable the next hop calculation for this neighbor\n"
3970 "Set the next hop to self for reflected routes\n")
3972 DEFUN (no_neighbor_nexthop_self
,
3973 no_neighbor_nexthop_self_cmd
,
3974 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3978 "Disable the next hop calculation for this neighbor\n")
3981 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3982 bgp_node_afi(vty
), bgp_node_safi(vty
),
3983 PEER_FLAG_NEXTHOP_SELF
);
3986 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3987 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3988 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3989 "Disable the next hop calculation for this neighbor\n")
3991 DEFUN (no_neighbor_nexthop_self_force
,
3992 no_neighbor_nexthop_self_force_cmd
,
3993 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3997 "Disable the next hop calculation for this neighbor\n"
3998 "Set the next hop to self for reflected routes\n")
4001 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4002 bgp_node_afi(vty
), bgp_node_safi(vty
),
4003 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4006 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4007 no_neighbor_nexthop_self_force_hidden_cmd
,
4008 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4009 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4010 "Disable the next hop calculation for this neighbor\n"
4011 "Set the next hop to self for reflected routes\n")
4013 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4014 no_neighbor_nexthop_self_all_hidden_cmd
,
4015 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4016 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4017 "Disable the next hop calculation for this neighbor\n"
4018 "Set the next hop to self for reflected routes\n")
4020 /* neighbor as-override */
4021 DEFUN (neighbor_as_override
,
4022 neighbor_as_override_cmd
,
4023 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4026 "Override ASNs in outbound updates if aspath equals remote-as\n")
4029 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4030 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4033 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4034 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4035 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4036 "Override ASNs in outbound updates if aspath equals remote-as\n")
4038 DEFUN (no_neighbor_as_override
,
4039 no_neighbor_as_override_cmd
,
4040 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4044 "Override ASNs in outbound updates if aspath equals remote-as\n")
4047 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4048 bgp_node_afi(vty
), bgp_node_safi(vty
),
4049 PEER_FLAG_AS_OVERRIDE
);
4052 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4053 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4054 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4055 "Override ASNs in outbound updates if aspath equals remote-as\n")
4057 /* neighbor remove-private-AS. */
4058 DEFUN (neighbor_remove_private_as
,
4059 neighbor_remove_private_as_cmd
,
4060 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4063 "Remove private ASNs in outbound updates\n")
4066 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4068 PEER_FLAG_REMOVE_PRIVATE_AS
);
4071 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4072 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4073 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4074 "Remove private ASNs in outbound updates\n")
4076 DEFUN (neighbor_remove_private_as_all
,
4077 neighbor_remove_private_as_all_cmd
,
4078 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4081 "Remove private ASNs in outbound updates\n"
4082 "Apply to all AS numbers\n")
4085 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4087 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4090 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4091 neighbor_remove_private_as_all_hidden_cmd
,
4092 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4093 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4094 "Remove private ASNs in outbound updates\n"
4095 "Apply to all AS numbers")
4097 DEFUN (neighbor_remove_private_as_replace_as
,
4098 neighbor_remove_private_as_replace_as_cmd
,
4099 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4102 "Remove private ASNs in outbound updates\n"
4103 "Replace private ASNs with our ASN in outbound updates\n")
4106 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4108 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4111 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4112 neighbor_remove_private_as_replace_as_hidden_cmd
,
4113 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4114 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4115 "Remove private ASNs in outbound updates\n"
4116 "Replace private ASNs with our ASN in outbound updates\n")
4118 DEFUN (neighbor_remove_private_as_all_replace_as
,
4119 neighbor_remove_private_as_all_replace_as_cmd
,
4120 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4123 "Remove private ASNs in outbound updates\n"
4124 "Apply to all AS numbers\n"
4125 "Replace private ASNs with our ASN in outbound updates\n")
4128 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4130 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4134 neighbor_remove_private_as_all_replace_as
,
4135 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4136 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4137 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4138 "Remove private ASNs in outbound updates\n"
4139 "Apply to all AS numbers\n"
4140 "Replace private ASNs with our ASN in outbound updates\n")
4142 DEFUN (no_neighbor_remove_private_as
,
4143 no_neighbor_remove_private_as_cmd
,
4144 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4148 "Remove private ASNs in outbound updates\n")
4151 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4152 bgp_node_afi(vty
), bgp_node_safi(vty
),
4153 PEER_FLAG_REMOVE_PRIVATE_AS
);
4156 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4157 no_neighbor_remove_private_as_hidden_cmd
,
4158 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4159 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4160 "Remove private ASNs in outbound updates\n")
4162 DEFUN (no_neighbor_remove_private_as_all
,
4163 no_neighbor_remove_private_as_all_cmd
,
4164 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4168 "Remove private ASNs in outbound updates\n"
4169 "Apply to all AS numbers\n")
4172 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4173 bgp_node_afi(vty
), bgp_node_safi(vty
),
4174 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4177 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4178 no_neighbor_remove_private_as_all_hidden_cmd
,
4179 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4180 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4181 "Remove private ASNs in outbound updates\n"
4182 "Apply to all AS numbers\n")
4184 DEFUN (no_neighbor_remove_private_as_replace_as
,
4185 no_neighbor_remove_private_as_replace_as_cmd
,
4186 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4190 "Remove private ASNs in outbound updates\n"
4191 "Replace private ASNs with our ASN in outbound updates\n")
4194 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4195 bgp_node_afi(vty
), bgp_node_safi(vty
),
4196 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4199 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4200 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4201 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4202 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4203 "Remove private ASNs in outbound updates\n"
4204 "Replace private ASNs with our ASN in outbound updates\n")
4206 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4207 no_neighbor_remove_private_as_all_replace_as_cmd
,
4208 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4212 "Remove private ASNs in outbound updates\n"
4213 "Apply to all AS numbers\n"
4214 "Replace private ASNs with our ASN in outbound updates\n")
4217 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4218 bgp_node_afi(vty
), bgp_node_safi(vty
),
4219 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4223 no_neighbor_remove_private_as_all_replace_as
,
4224 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4225 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4226 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4227 "Remove private ASNs in outbound updates\n"
4228 "Apply to all AS numbers\n"
4229 "Replace private ASNs with our ASN in outbound updates\n")
4232 /* neighbor send-community. */
4233 DEFUN (neighbor_send_community
,
4234 neighbor_send_community_cmd
,
4235 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4238 "Send Community attribute to this neighbor\n")
4242 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4244 PEER_FLAG_SEND_COMMUNITY
);
4247 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4248 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4249 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4250 "Send Community attribute to this neighbor\n")
4252 DEFUN (no_neighbor_send_community
,
4253 no_neighbor_send_community_cmd
,
4254 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4258 "Send Community attribute to this neighbor\n")
4262 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4263 bgp_node_afi(vty
), bgp_node_safi(vty
),
4264 PEER_FLAG_SEND_COMMUNITY
);
4267 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4268 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4269 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4270 "Send Community attribute to this neighbor\n")
4272 /* neighbor send-community extended. */
4273 DEFUN (neighbor_send_community_type
,
4274 neighbor_send_community_type_cmd
,
4275 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4278 "Send Community attribute to this neighbor\n"
4279 "Send Standard and Extended Community attributes\n"
4280 "Send Standard, Large and Extended Community attributes\n"
4281 "Send Extended Community attributes\n"
4282 "Send Standard Community attributes\n"
4283 "Send Large Community attributes\n")
4287 const char *type
= argv
[argc
- 1]->text
;
4289 if (strmatch(type
, "standard")) {
4290 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4291 } else if (strmatch(type
, "extended")) {
4292 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4293 } else if (strmatch(type
, "large")) {
4294 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4295 } else if (strmatch(type
, "both")) {
4296 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4297 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4298 } else { /* if (strmatch(type, "all")) */
4299 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4300 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4301 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4304 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4305 bgp_node_safi(vty
), flag
);
4309 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4310 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4311 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4312 "Send Community attribute to this neighbor\n"
4313 "Send Standard and Extended Community attributes\n"
4314 "Send Standard, Large and Extended Community attributes\n"
4315 "Send Extended Community attributes\n"
4316 "Send Standard Community attributes\n"
4317 "Send Large Community attributes\n")
4319 DEFUN (no_neighbor_send_community_type
,
4320 no_neighbor_send_community_type_cmd
,
4321 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4325 "Send Community attribute to this neighbor\n"
4326 "Send Standard and Extended Community attributes\n"
4327 "Send Standard, Large and Extended Community attributes\n"
4328 "Send Extended Community attributes\n"
4329 "Send Standard Community attributes\n"
4330 "Send Large Community attributes\n")
4334 const char *type
= argv
[argc
- 1]->text
;
4336 if (strmatch(type
, "standard")) {
4337 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4338 } else if (strmatch(type
, "extended")) {
4339 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4340 } else if (strmatch(type
, "large")) {
4341 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4342 } else if (strmatch(type
, "both")) {
4343 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4344 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4345 } else { /* if (strmatch(type, "all")) */
4346 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4347 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4348 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4351 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4352 bgp_node_afi(vty
), bgp_node_safi(vty
),
4357 no_neighbor_send_community_type
,
4358 no_neighbor_send_community_type_hidden_cmd
,
4359 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4360 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4361 "Send Community attribute to this neighbor\n"
4362 "Send Standard and Extended Community attributes\n"
4363 "Send Standard, Large and Extended Community attributes\n"
4364 "Send Extended Community attributes\n"
4365 "Send Standard Community attributes\n"
4366 "Send Large Community attributes\n")
4368 /* neighbor soft-reconfig. */
4369 DEFUN (neighbor_soft_reconfiguration
,
4370 neighbor_soft_reconfiguration_cmd
,
4371 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4374 "Per neighbor soft reconfiguration\n"
4375 "Allow inbound soft reconfiguration for this neighbor\n")
4378 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4380 PEER_FLAG_SOFT_RECONFIG
);
4383 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4384 neighbor_soft_reconfiguration_hidden_cmd
,
4385 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4386 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4387 "Per neighbor soft reconfiguration\n"
4388 "Allow inbound soft reconfiguration for this neighbor\n")
4390 DEFUN (no_neighbor_soft_reconfiguration
,
4391 no_neighbor_soft_reconfiguration_cmd
,
4392 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4396 "Per neighbor soft reconfiguration\n"
4397 "Allow inbound soft reconfiguration for this neighbor\n")
4400 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4401 bgp_node_afi(vty
), bgp_node_safi(vty
),
4402 PEER_FLAG_SOFT_RECONFIG
);
4405 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4406 no_neighbor_soft_reconfiguration_hidden_cmd
,
4407 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4408 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4409 "Per neighbor soft reconfiguration\n"
4410 "Allow inbound soft reconfiguration for this neighbor\n")
4412 DEFUN (neighbor_route_reflector_client
,
4413 neighbor_route_reflector_client_cmd
,
4414 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4417 "Configure a neighbor as Route Reflector client\n")
4423 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4425 return CMD_WARNING_CONFIG_FAILED
;
4427 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4429 PEER_FLAG_REFLECTOR_CLIENT
);
4432 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4433 neighbor_route_reflector_client_hidden_cmd
,
4434 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4435 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4436 "Configure a neighbor as Route Reflector client\n")
4438 DEFUN (no_neighbor_route_reflector_client
,
4439 no_neighbor_route_reflector_client_cmd
,
4440 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4444 "Configure a neighbor as Route Reflector client\n")
4447 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4448 bgp_node_afi(vty
), bgp_node_safi(vty
),
4449 PEER_FLAG_REFLECTOR_CLIENT
);
4452 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4453 no_neighbor_route_reflector_client_hidden_cmd
,
4454 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4455 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4456 "Configure a neighbor as Route Reflector client\n")
4458 /* neighbor route-server-client. */
4459 DEFUN (neighbor_route_server_client
,
4460 neighbor_route_server_client_cmd
,
4461 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4464 "Configure a neighbor as Route Server client\n")
4469 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4471 return CMD_WARNING_CONFIG_FAILED
;
4472 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4474 PEER_FLAG_RSERVER_CLIENT
);
4477 ALIAS_HIDDEN(neighbor_route_server_client
,
4478 neighbor_route_server_client_hidden_cmd
,
4479 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4480 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4481 "Configure a neighbor as Route Server client\n")
4483 DEFUN (no_neighbor_route_server_client
,
4484 no_neighbor_route_server_client_cmd
,
4485 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4489 "Configure a neighbor as Route Server client\n")
4492 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4493 bgp_node_afi(vty
), bgp_node_safi(vty
),
4494 PEER_FLAG_RSERVER_CLIENT
);
4497 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4498 no_neighbor_route_server_client_hidden_cmd
,
4499 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4500 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4501 "Configure a neighbor as Route Server client\n")
4503 DEFUN (neighbor_nexthop_local_unchanged
,
4504 neighbor_nexthop_local_unchanged_cmd
,
4505 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4508 "Configure treatment of outgoing link-local nexthop attribute\n"
4509 "Leave link-local nexthop unchanged for this peer\n")
4512 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4514 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4517 DEFUN (no_neighbor_nexthop_local_unchanged
,
4518 no_neighbor_nexthop_local_unchanged_cmd
,
4519 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4523 "Configure treatment of outgoing link-local-nexthop attribute\n"
4524 "Leave link-local nexthop unchanged for this peer\n")
4527 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4528 bgp_node_afi(vty
), bgp_node_safi(vty
),
4529 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4532 DEFUN (neighbor_attr_unchanged
,
4533 neighbor_attr_unchanged_cmd
,
4534 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4537 "BGP attribute is propagated unchanged to this neighbor\n"
4538 "As-path attribute\n"
4539 "Nexthop attribute\n"
4543 char *peer_str
= argv
[1]->arg
;
4546 afi_t afi
= bgp_node_afi(vty
);
4547 safi_t safi
= bgp_node_safi(vty
);
4549 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4551 return CMD_WARNING_CONFIG_FAILED
;
4553 if (argv_find(argv
, argc
, "as-path", &idx
))
4554 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4556 if (argv_find(argv
, argc
, "next-hop", &idx
))
4557 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4559 if (argv_find(argv
, argc
, "med", &idx
))
4560 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4562 /* no flags means all of them! */
4564 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4565 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4566 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4568 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4569 && peer_af_flag_check(peer
, afi
, safi
,
4570 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4571 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4572 PEER_FLAG_AS_PATH_UNCHANGED
);
4575 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4576 && peer_af_flag_check(peer
, afi
, safi
,
4577 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4578 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4579 PEER_FLAG_NEXTHOP_UNCHANGED
);
4582 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4583 && peer_af_flag_check(peer
, afi
, safi
,
4584 PEER_FLAG_MED_UNCHANGED
)) {
4585 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4586 PEER_FLAG_MED_UNCHANGED
);
4590 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4594 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4595 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4596 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4597 "BGP attribute is propagated unchanged to this neighbor\n"
4598 "As-path attribute\n"
4599 "Nexthop attribute\n"
4602 DEFUN (no_neighbor_attr_unchanged
,
4603 no_neighbor_attr_unchanged_cmd
,
4604 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4608 "BGP attribute is propagated unchanged to this neighbor\n"
4609 "As-path attribute\n"
4610 "Nexthop attribute\n"
4614 char *peer
= argv
[2]->arg
;
4617 if (argv_find(argv
, argc
, "as-path", &idx
))
4618 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4620 if (argv_find(argv
, argc
, "next-hop", &idx
))
4621 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4623 if (argv_find(argv
, argc
, "med", &idx
))
4624 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4626 if (!flags
) // no flags means all of them!
4628 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4629 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4630 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4633 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4634 bgp_node_safi(vty
), flags
);
4638 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4639 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4640 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4641 "BGP attribute is propagated unchanged to this neighbor\n"
4642 "As-path attribute\n"
4643 "Nexthop attribute\n"
4646 /* EBGP multihop configuration. */
4647 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4648 const char *ttl_str
)
4653 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4655 return CMD_WARNING_CONFIG_FAILED
;
4658 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4663 ttl
= strtoul(ttl_str
, NULL
, 10);
4665 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4668 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4672 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4674 return CMD_WARNING_CONFIG_FAILED
;
4676 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4679 /* neighbor ebgp-multihop. */
4680 DEFUN (neighbor_ebgp_multihop
,
4681 neighbor_ebgp_multihop_cmd
,
4682 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4685 "Allow EBGP neighbors not on directly connected networks\n")
4688 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4691 DEFUN (neighbor_ebgp_multihop_ttl
,
4692 neighbor_ebgp_multihop_ttl_cmd
,
4693 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4696 "Allow EBGP neighbors not on directly connected networks\n"
4697 "maximum hop count\n")
4701 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4702 argv
[idx_number
]->arg
);
4705 DEFUN (no_neighbor_ebgp_multihop
,
4706 no_neighbor_ebgp_multihop_cmd
,
4707 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4711 "Allow EBGP neighbors not on directly connected networks\n"
4712 "maximum hop count\n")
4715 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4719 /* disable-connected-check */
4720 DEFUN (neighbor_disable_connected_check
,
4721 neighbor_disable_connected_check_cmd
,
4722 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4725 "one-hop away EBGP peer using loopback address\n"
4726 "Enforce EBGP neighbors perform multihop\n")
4729 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4730 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4733 DEFUN (no_neighbor_disable_connected_check
,
4734 no_neighbor_disable_connected_check_cmd
,
4735 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4739 "one-hop away EBGP peer using loopback address\n"
4740 "Enforce EBGP neighbors perform multihop\n")
4743 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4744 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4748 /* enforce-first-as */
4749 DEFUN (neighbor_enforce_first_as
,
4750 neighbor_enforce_first_as_cmd
,
4751 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4754 "Enforce the first AS for EBGP routes\n")
4758 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4759 PEER_FLAG_ENFORCE_FIRST_AS
);
4762 DEFUN (no_neighbor_enforce_first_as
,
4763 no_neighbor_enforce_first_as_cmd
,
4764 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4768 "Enforce the first AS for EBGP routes\n")
4772 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4773 PEER_FLAG_ENFORCE_FIRST_AS
);
4777 DEFUN (neighbor_description
,
4778 neighbor_description_cmd
,
4779 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4782 "Neighbor specific description\n"
4783 "Up to 80 characters describing this neighbor\n")
4790 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4792 return CMD_WARNING_CONFIG_FAILED
;
4794 str
= argv_concat(argv
, argc
, idx_line
);
4796 peer_description_set(peer
, str
);
4798 XFREE(MTYPE_TMP
, str
);
4803 DEFUN (no_neighbor_description
,
4804 no_neighbor_description_cmd
,
4805 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4809 "Neighbor specific description\n")
4814 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4816 return CMD_WARNING_CONFIG_FAILED
;
4818 peer_description_unset(peer
);
4823 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4824 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4825 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4826 "Neighbor specific description\n"
4827 "Up to 80 characters describing this neighbor\n")
4829 /* Neighbor update-source. */
4830 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4831 const char *source_str
)
4837 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4839 return CMD_WARNING_CONFIG_FAILED
;
4845 if (str2sockunion(source_str
, &su
) == 0)
4846 peer_update_source_addr_set(peer
, &su
);
4848 if (str2prefix(source_str
, &p
)) {
4850 "%% Invalid update-source, remove prefix length \n");
4851 return CMD_WARNING_CONFIG_FAILED
;
4853 peer_update_source_if_set(peer
, source_str
);
4856 peer_update_source_unset(peer
);
4861 #define BGP_UPDATE_SOURCE_HELP_STR \
4864 "Interface name (requires zebra to be running)\n"
4866 DEFUN (neighbor_update_source
,
4867 neighbor_update_source_cmd
,
4868 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4871 "Source of routing updates\n"
4872 BGP_UPDATE_SOURCE_HELP_STR
)
4876 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4877 argv
[idx_peer_2
]->arg
);
4880 DEFUN (no_neighbor_update_source
,
4881 no_neighbor_update_source_cmd
,
4882 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4886 "Source of routing updates\n"
4887 BGP_UPDATE_SOURCE_HELP_STR
)
4890 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4893 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4894 afi_t afi
, safi_t safi
,
4895 const char *rmap
, int set
)
4899 struct route_map
*route_map
= NULL
;
4901 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4903 return CMD_WARNING_CONFIG_FAILED
;
4907 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4908 ret
= peer_default_originate_set(peer
, afi
, safi
,
4911 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4913 return bgp_vty_return(vty
, ret
);
4916 /* neighbor default-originate. */
4917 DEFUN (neighbor_default_originate
,
4918 neighbor_default_originate_cmd
,
4919 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4922 "Originate default route to this neighbor\n")
4925 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4927 bgp_node_safi(vty
), NULL
, 1);
4930 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4931 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4932 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4933 "Originate default route to this neighbor\n")
4935 DEFUN (neighbor_default_originate_rmap
,
4936 neighbor_default_originate_rmap_cmd
,
4937 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4940 "Originate default route to this neighbor\n"
4941 "Route-map to specify criteria to originate default\n"
4946 return peer_default_originate_set_vty(
4947 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4948 argv
[idx_word
]->arg
, 1);
4952 neighbor_default_originate_rmap
,
4953 neighbor_default_originate_rmap_hidden_cmd
,
4954 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4955 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4956 "Originate default route to this neighbor\n"
4957 "Route-map to specify criteria to originate default\n"
4960 DEFUN (no_neighbor_default_originate
,
4961 no_neighbor_default_originate_cmd
,
4962 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4966 "Originate default route to this neighbor\n"
4967 "Route-map to specify criteria to originate default\n"
4971 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4973 bgp_node_safi(vty
), NULL
, 0);
4977 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4978 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4979 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4980 "Originate default route to this neighbor\n"
4981 "Route-map to specify criteria to originate default\n"
4985 /* Set neighbor's BGP port. */
4986 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4987 const char *port_str
)
4993 peer
= peer_lookup_vty(vty
, ip_str
);
4995 return CMD_WARNING_CONFIG_FAILED
;
4998 sp
= getservbyname("bgp", "tcp");
4999 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5001 port
= strtoul(port_str
, NULL
, 10);
5004 peer_port_set(peer
, port
);
5009 /* Set specified peer's BGP port. */
5010 DEFUN (neighbor_port
,
5012 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5015 "Neighbor's BGP port\n"
5016 "TCP port number\n")
5020 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5021 argv
[idx_number
]->arg
);
5024 DEFUN (no_neighbor_port
,
5025 no_neighbor_port_cmd
,
5026 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5030 "Neighbor's BGP port\n"
5031 "TCP port number\n")
5034 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5038 /* neighbor weight. */
5039 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5040 safi_t safi
, const char *weight_str
)
5044 unsigned long weight
;
5046 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5048 return CMD_WARNING_CONFIG_FAILED
;
5050 weight
= strtoul(weight_str
, NULL
, 10);
5052 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5053 return bgp_vty_return(vty
, ret
);
5056 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5062 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5064 return CMD_WARNING_CONFIG_FAILED
;
5066 ret
= peer_weight_unset(peer
, afi
, safi
);
5067 return bgp_vty_return(vty
, ret
);
5070 DEFUN (neighbor_weight
,
5071 neighbor_weight_cmd
,
5072 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5075 "Set default weight for routes from this neighbor\n"
5080 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5081 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5084 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5085 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5086 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5087 "Set default weight for routes from this neighbor\n"
5090 DEFUN (no_neighbor_weight
,
5091 no_neighbor_weight_cmd
,
5092 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5096 "Set default weight for routes from this neighbor\n"
5100 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5101 bgp_node_afi(vty
), bgp_node_safi(vty
));
5104 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5105 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5106 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5107 "Set default weight for routes from this neighbor\n"
5111 /* Override capability negotiation. */
5112 DEFUN (neighbor_override_capability
,
5113 neighbor_override_capability_cmd
,
5114 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5117 "Override capability negotiation result\n")
5120 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5121 PEER_FLAG_OVERRIDE_CAPABILITY
);
5124 DEFUN (no_neighbor_override_capability
,
5125 no_neighbor_override_capability_cmd
,
5126 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5130 "Override capability negotiation result\n")
5133 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5134 PEER_FLAG_OVERRIDE_CAPABILITY
);
5137 DEFUN (neighbor_strict_capability
,
5138 neighbor_strict_capability_cmd
,
5139 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5142 "Strict capability negotiation match\n")
5146 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5147 PEER_FLAG_STRICT_CAP_MATCH
);
5150 DEFUN (no_neighbor_strict_capability
,
5151 no_neighbor_strict_capability_cmd
,
5152 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5156 "Strict capability negotiation match\n")
5160 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5161 PEER_FLAG_STRICT_CAP_MATCH
);
5164 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5165 const char *keep_str
, const char *hold_str
)
5172 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5174 return CMD_WARNING_CONFIG_FAILED
;
5176 keepalive
= strtoul(keep_str
, NULL
, 10);
5177 holdtime
= strtoul(hold_str
, NULL
, 10);
5179 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5181 return bgp_vty_return(vty
, ret
);
5184 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5189 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5191 return CMD_WARNING_CONFIG_FAILED
;
5193 ret
= peer_timers_unset(peer
);
5195 return bgp_vty_return(vty
, ret
);
5198 DEFUN (neighbor_timers
,
5199 neighbor_timers_cmd
,
5200 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5203 "BGP per neighbor timers\n"
5204 "Keepalive interval\n"
5209 int idx_number_2
= 4;
5210 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5211 argv
[idx_number
]->arg
,
5212 argv
[idx_number_2
]->arg
);
5215 DEFUN (no_neighbor_timers
,
5216 no_neighbor_timers_cmd
,
5217 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5221 "BGP per neighbor timers\n"
5222 "Keepalive interval\n"
5226 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5230 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5231 const char *time_str
)
5237 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5239 return CMD_WARNING_CONFIG_FAILED
;
5241 connect
= strtoul(time_str
, NULL
, 10);
5243 ret
= peer_timers_connect_set(peer
, connect
);
5245 return bgp_vty_return(vty
, ret
);
5248 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5253 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5255 return CMD_WARNING_CONFIG_FAILED
;
5257 ret
= peer_timers_connect_unset(peer
);
5259 return bgp_vty_return(vty
, ret
);
5262 DEFUN (neighbor_timers_connect
,
5263 neighbor_timers_connect_cmd
,
5264 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5267 "BGP per neighbor timers\n"
5268 "BGP connect timer\n"
5273 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5274 argv
[idx_number
]->arg
);
5277 DEFUN (no_neighbor_timers_connect
,
5278 no_neighbor_timers_connect_cmd
,
5279 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5283 "BGP per neighbor timers\n"
5284 "BGP connect timer\n"
5288 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5292 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5293 const char *time_str
, int set
)
5297 uint32_t routeadv
= 0;
5299 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5301 return CMD_WARNING_CONFIG_FAILED
;
5304 routeadv
= strtoul(time_str
, NULL
, 10);
5307 ret
= peer_advertise_interval_set(peer
, routeadv
);
5309 ret
= peer_advertise_interval_unset(peer
);
5311 return bgp_vty_return(vty
, ret
);
5314 DEFUN (neighbor_advertise_interval
,
5315 neighbor_advertise_interval_cmd
,
5316 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5319 "Minimum interval between sending BGP routing updates\n"
5320 "time in seconds\n")
5324 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5325 argv
[idx_number
]->arg
, 1);
5328 DEFUN (no_neighbor_advertise_interval
,
5329 no_neighbor_advertise_interval_cmd
,
5330 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5334 "Minimum interval between sending BGP routing updates\n"
5335 "time in seconds\n")
5338 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5342 /* Time to wait before processing route-map updates */
5343 DEFUN (bgp_set_route_map_delay_timer
,
5344 bgp_set_route_map_delay_timer_cmd
,
5345 "bgp route-map delay-timer (0-600)",
5347 "BGP route-map delay timer\n"
5348 "Time in secs to wait before processing route-map changes\n"
5349 "0 disables the timer, no route updates happen when route-maps change\n")
5352 uint32_t rmap_delay_timer
;
5354 if (argv
[idx_number
]->arg
) {
5355 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5356 bm
->rmap_update_timer
= rmap_delay_timer
;
5358 /* if the dynamic update handling is being disabled, and a timer
5360 * running, stop the timer and act as if the timer has already
5363 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5364 BGP_TIMER_OFF(bm
->t_rmap_update
);
5365 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5370 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5371 return CMD_WARNING_CONFIG_FAILED
;
5375 DEFUN (no_bgp_set_route_map_delay_timer
,
5376 no_bgp_set_route_map_delay_timer_cmd
,
5377 "no bgp route-map delay-timer [(0-600)]",
5380 "Default BGP route-map delay timer\n"
5381 "Reset to default time to wait for processing route-map changes\n"
5382 "0 disables the timer, no route updates happen when route-maps change\n")
5385 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5391 /* neighbor interface */
5392 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5397 peer
= peer_lookup_vty(vty
, ip_str
);
5398 if (!peer
|| peer
->conf_if
) {
5399 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5400 return CMD_WARNING_CONFIG_FAILED
;
5404 peer_interface_set(peer
, str
);
5406 peer_interface_unset(peer
);
5411 DEFUN (neighbor_interface
,
5412 neighbor_interface_cmd
,
5413 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5421 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5424 DEFUN (no_neighbor_interface
,
5425 no_neighbor_interface_cmd
,
5426 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5434 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5437 DEFUN (neighbor_distribute_list
,
5438 neighbor_distribute_list_cmd
,
5439 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5442 "Filter updates to/from this neighbor\n"
5443 "IP access-list number\n"
5444 "IP access-list number (expanded range)\n"
5445 "IP Access-list name\n"
5446 "Filter incoming updates\n"
5447 "Filter outgoing updates\n")
5454 const char *pstr
= argv
[idx_peer
]->arg
;
5455 const char *acl
= argv
[idx_acl
]->arg
;
5456 const char *inout
= argv
[argc
- 1]->text
;
5458 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5460 return CMD_WARNING_CONFIG_FAILED
;
5462 /* Check filter direction. */
5463 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5464 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5467 return bgp_vty_return(vty
, ret
);
5471 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5472 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5473 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5474 "Filter updates to/from this neighbor\n"
5475 "IP access-list number\n"
5476 "IP access-list number (expanded range)\n"
5477 "IP Access-list name\n"
5478 "Filter incoming updates\n"
5479 "Filter outgoing updates\n")
5481 DEFUN (no_neighbor_distribute_list
,
5482 no_neighbor_distribute_list_cmd
,
5483 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5487 "Filter updates to/from this neighbor\n"
5488 "IP access-list number\n"
5489 "IP access-list number (expanded range)\n"
5490 "IP Access-list name\n"
5491 "Filter incoming updates\n"
5492 "Filter outgoing updates\n")
5498 const char *pstr
= argv
[idx_peer
]->arg
;
5499 const char *inout
= argv
[argc
- 1]->text
;
5501 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5503 return CMD_WARNING_CONFIG_FAILED
;
5505 /* Check filter direction. */
5506 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5507 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5510 return bgp_vty_return(vty
, ret
);
5514 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5515 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5516 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5517 "Filter updates to/from this neighbor\n"
5518 "IP access-list number\n"
5519 "IP access-list number (expanded range)\n"
5520 "IP Access-list name\n"
5521 "Filter incoming updates\n"
5522 "Filter outgoing updates\n")
5524 /* Set prefix list to the peer. */
5525 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5526 afi_t afi
, safi_t safi
,
5527 const char *name_str
,
5528 const char *direct_str
)
5531 int direct
= FILTER_IN
;
5534 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5536 return CMD_WARNING_CONFIG_FAILED
;
5538 /* Check filter direction. */
5539 if (strncmp(direct_str
, "i", 1) == 0)
5541 else if (strncmp(direct_str
, "o", 1) == 0)
5542 direct
= FILTER_OUT
;
5544 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5546 return bgp_vty_return(vty
, ret
);
5549 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5550 afi_t afi
, safi_t safi
,
5551 const char *direct_str
)
5555 int direct
= FILTER_IN
;
5557 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5559 return CMD_WARNING_CONFIG_FAILED
;
5561 /* Check filter direction. */
5562 if (strncmp(direct_str
, "i", 1) == 0)
5564 else if (strncmp(direct_str
, "o", 1) == 0)
5565 direct
= FILTER_OUT
;
5567 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5569 return bgp_vty_return(vty
, ret
);
5572 DEFUN (neighbor_prefix_list
,
5573 neighbor_prefix_list_cmd
,
5574 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5577 "Filter updates to/from this neighbor\n"
5578 "Name of a prefix list\n"
5579 "Filter incoming updates\n"
5580 "Filter outgoing updates\n")
5585 return peer_prefix_list_set_vty(
5586 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5587 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5590 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5591 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5592 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5593 "Filter updates to/from this neighbor\n"
5594 "Name of a prefix list\n"
5595 "Filter incoming updates\n"
5596 "Filter outgoing updates\n")
5598 DEFUN (no_neighbor_prefix_list
,
5599 no_neighbor_prefix_list_cmd
,
5600 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5604 "Filter updates to/from this neighbor\n"
5605 "Name of a prefix list\n"
5606 "Filter incoming updates\n"
5607 "Filter outgoing updates\n")
5611 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5612 bgp_node_afi(vty
), bgp_node_safi(vty
),
5613 argv
[idx_in_out
]->arg
);
5616 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5617 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5618 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5619 "Filter updates to/from this neighbor\n"
5620 "Name of a prefix list\n"
5621 "Filter incoming updates\n"
5622 "Filter outgoing updates\n")
5624 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5625 safi_t safi
, const char *name_str
,
5626 const char *direct_str
)
5630 int direct
= FILTER_IN
;
5632 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5634 return CMD_WARNING_CONFIG_FAILED
;
5636 /* Check filter direction. */
5637 if (strncmp(direct_str
, "i", 1) == 0)
5639 else if (strncmp(direct_str
, "o", 1) == 0)
5640 direct
= FILTER_OUT
;
5642 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5644 return bgp_vty_return(vty
, ret
);
5647 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5648 safi_t safi
, const char *direct_str
)
5652 int direct
= FILTER_IN
;
5654 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5656 return CMD_WARNING_CONFIG_FAILED
;
5658 /* Check filter direction. */
5659 if (strncmp(direct_str
, "i", 1) == 0)
5661 else if (strncmp(direct_str
, "o", 1) == 0)
5662 direct
= FILTER_OUT
;
5664 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5666 return bgp_vty_return(vty
, ret
);
5669 DEFUN (neighbor_filter_list
,
5670 neighbor_filter_list_cmd
,
5671 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5674 "Establish BGP filters\n"
5675 "AS path access-list name\n"
5676 "Filter incoming routes\n"
5677 "Filter outgoing routes\n")
5682 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5683 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5684 argv
[idx_in_out
]->arg
);
5687 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5688 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5689 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5690 "Establish BGP filters\n"
5691 "AS path access-list name\n"
5692 "Filter incoming routes\n"
5693 "Filter outgoing routes\n")
5695 DEFUN (no_neighbor_filter_list
,
5696 no_neighbor_filter_list_cmd
,
5697 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5701 "Establish BGP filters\n"
5702 "AS path access-list name\n"
5703 "Filter incoming routes\n"
5704 "Filter outgoing routes\n")
5708 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5709 bgp_node_afi(vty
), bgp_node_safi(vty
),
5710 argv
[idx_in_out
]->arg
);
5713 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5714 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5715 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5716 "Establish BGP filters\n"
5717 "AS path access-list name\n"
5718 "Filter incoming routes\n"
5719 "Filter outgoing routes\n")
5721 /* Set route-map to the peer. */
5722 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5723 afi_t afi
, safi_t safi
, const char *name_str
,
5724 const char *direct_str
)
5728 int direct
= RMAP_IN
;
5729 struct route_map
*route_map
;
5731 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5733 return CMD_WARNING_CONFIG_FAILED
;
5735 /* Check filter direction. */
5736 if (strncmp(direct_str
, "in", 2) == 0)
5738 else if (strncmp(direct_str
, "o", 1) == 0)
5741 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5742 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5744 return bgp_vty_return(vty
, ret
);
5747 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5748 afi_t afi
, safi_t safi
,
5749 const char *direct_str
)
5753 int direct
= RMAP_IN
;
5755 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5757 return CMD_WARNING_CONFIG_FAILED
;
5759 /* Check filter direction. */
5760 if (strncmp(direct_str
, "in", 2) == 0)
5762 else if (strncmp(direct_str
, "o", 1) == 0)
5765 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5767 return bgp_vty_return(vty
, ret
);
5770 DEFUN (neighbor_route_map
,
5771 neighbor_route_map_cmd
,
5772 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5775 "Apply route map to neighbor\n"
5776 "Name of route map\n"
5777 "Apply map to incoming routes\n"
5778 "Apply map to outbound routes\n")
5783 return peer_route_map_set_vty(
5784 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5785 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5788 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5789 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5790 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5791 "Apply route map to neighbor\n"
5792 "Name of route map\n"
5793 "Apply map to incoming routes\n"
5794 "Apply map to outbound routes\n")
5796 DEFUN (no_neighbor_route_map
,
5797 no_neighbor_route_map_cmd
,
5798 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5802 "Apply route map to neighbor\n"
5803 "Name of route map\n"
5804 "Apply map to incoming routes\n"
5805 "Apply map to outbound routes\n")
5809 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5810 bgp_node_afi(vty
), bgp_node_safi(vty
),
5811 argv
[idx_in_out
]->arg
);
5814 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5815 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5816 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5817 "Apply route map to neighbor\n"
5818 "Name of route map\n"
5819 "Apply map to incoming routes\n"
5820 "Apply map to outbound routes\n")
5822 /* Set unsuppress-map to the peer. */
5823 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5824 afi_t afi
, safi_t safi
,
5825 const char *name_str
)
5829 struct route_map
*route_map
;
5831 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5833 return CMD_WARNING_CONFIG_FAILED
;
5835 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5836 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5838 return bgp_vty_return(vty
, ret
);
5841 /* Unset route-map from the peer. */
5842 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5843 afi_t afi
, safi_t safi
)
5848 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5850 return CMD_WARNING_CONFIG_FAILED
;
5852 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5854 return bgp_vty_return(vty
, ret
);
5857 DEFUN (neighbor_unsuppress_map
,
5858 neighbor_unsuppress_map_cmd
,
5859 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5862 "Route-map to selectively unsuppress suppressed routes\n"
5863 "Name of route map\n")
5867 return peer_unsuppress_map_set_vty(
5868 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5869 argv
[idx_word
]->arg
);
5872 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5873 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5874 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5875 "Route-map to selectively unsuppress suppressed routes\n"
5876 "Name of route map\n")
5878 DEFUN (no_neighbor_unsuppress_map
,
5879 no_neighbor_unsuppress_map_cmd
,
5880 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5884 "Route-map to selectively unsuppress suppressed routes\n"
5885 "Name of route map\n")
5888 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5890 bgp_node_safi(vty
));
5893 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5894 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5895 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5896 "Route-map to selectively unsuppress suppressed routes\n"
5897 "Name of route map\n")
5899 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5900 afi_t afi
, safi_t safi
,
5901 const char *num_str
,
5902 const char *threshold_str
, int warning
,
5903 const char *restart_str
)
5911 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5913 return CMD_WARNING_CONFIG_FAILED
;
5915 max
= strtoul(num_str
, NULL
, 10);
5917 threshold
= atoi(threshold_str
);
5919 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5922 restart
= atoi(restart_str
);
5926 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5929 return bgp_vty_return(vty
, ret
);
5932 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5933 afi_t afi
, safi_t safi
)
5938 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5940 return CMD_WARNING_CONFIG_FAILED
;
5942 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5944 return bgp_vty_return(vty
, ret
);
5947 /* Maximum number of prefix configuration. prefix count is different
5948 for each peer configuration. So this configuration can be set for
5949 each peer configuration. */
5950 DEFUN (neighbor_maximum_prefix
,
5951 neighbor_maximum_prefix_cmd
,
5952 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5955 "Maximum number of prefix accept from this peer\n"
5956 "maximum no. of prefix limit\n")
5960 return peer_maximum_prefix_set_vty(
5961 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5962 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5965 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5966 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5967 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5968 "Maximum number of prefix accept from this peer\n"
5969 "maximum no. of prefix limit\n")
5971 DEFUN (neighbor_maximum_prefix_threshold
,
5972 neighbor_maximum_prefix_threshold_cmd
,
5973 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5976 "Maximum number of prefix accept from this peer\n"
5977 "maximum no. of prefix limit\n"
5978 "Threshold value (%) at which to generate a warning msg\n")
5982 int idx_number_2
= 4;
5983 return peer_maximum_prefix_set_vty(
5984 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5985 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5989 neighbor_maximum_prefix_threshold
,
5990 neighbor_maximum_prefix_threshold_hidden_cmd
,
5991 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5992 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5993 "Maximum number of prefix accept from this peer\n"
5994 "maximum no. of prefix limit\n"
5995 "Threshold value (%) at which to generate a warning msg\n")
5997 DEFUN (neighbor_maximum_prefix_warning
,
5998 neighbor_maximum_prefix_warning_cmd
,
5999 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6002 "Maximum number of prefix accept from this peer\n"
6003 "maximum no. of prefix limit\n"
6004 "Only give warning message when limit is exceeded\n")
6008 return peer_maximum_prefix_set_vty(
6009 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6010 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6014 neighbor_maximum_prefix_warning
,
6015 neighbor_maximum_prefix_warning_hidden_cmd
,
6016 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6017 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6018 "Maximum number of prefix accept from this peer\n"
6019 "maximum no. of prefix limit\n"
6020 "Only give warning message when limit is exceeded\n")
6022 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6023 neighbor_maximum_prefix_threshold_warning_cmd
,
6024 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6027 "Maximum number of prefix accept from this peer\n"
6028 "maximum no. of prefix limit\n"
6029 "Threshold value (%) at which to generate a warning msg\n"
6030 "Only give warning message when limit is exceeded\n")
6034 int idx_number_2
= 4;
6035 return peer_maximum_prefix_set_vty(
6036 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6037 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6041 neighbor_maximum_prefix_threshold_warning
,
6042 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6043 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6044 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6045 "Maximum number of prefix accept from this peer\n"
6046 "maximum no. of prefix limit\n"
6047 "Threshold value (%) at which to generate a warning msg\n"
6048 "Only give warning message when limit is exceeded\n")
6050 DEFUN (neighbor_maximum_prefix_restart
,
6051 neighbor_maximum_prefix_restart_cmd
,
6052 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6055 "Maximum number of prefix accept from this peer\n"
6056 "maximum no. of prefix limit\n"
6057 "Restart bgp connection after limit is exceeded\n"
6058 "Restart interval in minutes\n")
6062 int idx_number_2
= 5;
6063 return peer_maximum_prefix_set_vty(
6064 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6065 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6069 neighbor_maximum_prefix_restart
,
6070 neighbor_maximum_prefix_restart_hidden_cmd
,
6071 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6072 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6073 "Maximum number of prefix accept from this peer\n"
6074 "maximum no. of prefix limit\n"
6075 "Restart bgp connection after limit is exceeded\n"
6076 "Restart interval in minutes\n")
6078 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6079 neighbor_maximum_prefix_threshold_restart_cmd
,
6080 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6083 "Maximum number of prefixes to accept from this peer\n"
6084 "maximum no. of prefix limit\n"
6085 "Threshold value (%) at which to generate a warning msg\n"
6086 "Restart bgp connection after limit is exceeded\n"
6087 "Restart interval in minutes\n")
6091 int idx_number_2
= 4;
6092 int idx_number_3
= 6;
6093 return peer_maximum_prefix_set_vty(
6094 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6095 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6096 argv
[idx_number_3
]->arg
);
6100 neighbor_maximum_prefix_threshold_restart
,
6101 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6102 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6103 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6104 "Maximum number of prefixes to accept from this peer\n"
6105 "maximum no. of prefix limit\n"
6106 "Threshold value (%) at which to generate a warning msg\n"
6107 "Restart bgp connection after limit is exceeded\n"
6108 "Restart interval in minutes\n")
6110 DEFUN (no_neighbor_maximum_prefix
,
6111 no_neighbor_maximum_prefix_cmd
,
6112 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6116 "Maximum number of prefixes to accept from this peer\n"
6117 "maximum no. of prefix limit\n"
6118 "Threshold value (%) at which to generate a warning msg\n"
6119 "Restart bgp connection after limit is exceeded\n"
6120 "Restart interval in minutes\n"
6121 "Only give warning message when limit is exceeded\n")
6124 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6126 bgp_node_safi(vty
));
6130 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6131 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6132 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6133 "Maximum number of prefixes to accept from this peer\n"
6134 "maximum no. of prefix limit\n"
6135 "Threshold value (%) at which to generate a warning msg\n"
6136 "Restart bgp connection after limit is exceeded\n"
6137 "Restart interval in minutes\n"
6138 "Only give warning message when limit is exceeded\n")
6141 /* "neighbor allowas-in" */
6142 DEFUN (neighbor_allowas_in
,
6143 neighbor_allowas_in_cmd
,
6144 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6147 "Accept as-path with my AS present in it\n"
6148 "Number of occurences of AS number\n"
6149 "Only accept my AS in the as-path if the route was originated in my AS\n")
6152 int idx_number_origin
= 3;
6158 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6160 return CMD_WARNING_CONFIG_FAILED
;
6162 if (argc
<= idx_number_origin
)
6165 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6168 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6171 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6174 return bgp_vty_return(vty
, ret
);
6178 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6179 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6180 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6181 "Accept as-path with my AS present in it\n"
6182 "Number of occurences of AS number\n"
6183 "Only accept my AS in the as-path if the route was originated in my AS\n")
6185 DEFUN (no_neighbor_allowas_in
,
6186 no_neighbor_allowas_in_cmd
,
6187 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6191 "allow local ASN appears in aspath attribute\n"
6192 "Number of occurences of AS number\n"
6193 "Only accept my AS in the as-path if the route was originated in my AS\n")
6199 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6201 return CMD_WARNING_CONFIG_FAILED
;
6203 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6204 bgp_node_safi(vty
));
6206 return bgp_vty_return(vty
, ret
);
6210 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6211 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6212 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6213 "allow local ASN appears in aspath attribute\n"
6214 "Number of occurences of AS number\n"
6215 "Only accept my AS in the as-path if the route was originated in my AS\n")
6217 DEFUN (neighbor_ttl_security
,
6218 neighbor_ttl_security_cmd
,
6219 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6222 "BGP ttl-security parameters\n"
6223 "Specify the maximum number of hops to the BGP peer\n"
6224 "Number of hops to BGP peer\n")
6231 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6233 return CMD_WARNING_CONFIG_FAILED
;
6235 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6238 * If 'neighbor swpX', then this is for directly connected peers,
6239 * we should not accept a ttl-security hops value greater than 1.
6241 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6243 "%s is directly connected peer, hops cannot exceed 1\n",
6244 argv
[idx_peer
]->arg
);
6245 return CMD_WARNING_CONFIG_FAILED
;
6248 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6251 DEFUN (no_neighbor_ttl_security
,
6252 no_neighbor_ttl_security_cmd
,
6253 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6257 "BGP ttl-security parameters\n"
6258 "Specify the maximum number of hops to the BGP peer\n"
6259 "Number of hops to BGP peer\n")
6264 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6266 return CMD_WARNING_CONFIG_FAILED
;
6268 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6271 DEFUN (neighbor_addpath_tx_all_paths
,
6272 neighbor_addpath_tx_all_paths_cmd
,
6273 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6276 "Use addpath to advertise all paths to a neighbor\n")
6281 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6283 return CMD_WARNING_CONFIG_FAILED
;
6285 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6290 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6291 neighbor_addpath_tx_all_paths_hidden_cmd
,
6292 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6293 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6294 "Use addpath to advertise all paths to a neighbor\n")
6296 DEFUN (no_neighbor_addpath_tx_all_paths
,
6297 no_neighbor_addpath_tx_all_paths_cmd
,
6298 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6302 "Use addpath to advertise all paths to a neighbor\n")
6307 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6309 return CMD_WARNING_CONFIG_FAILED
;
6311 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6312 != BGP_ADDPATH_ALL
) {
6314 "%% Peer not currently configured to transmit all paths.");
6315 return CMD_WARNING_CONFIG_FAILED
;
6318 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6324 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6325 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6326 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6327 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6328 "Use addpath to advertise all paths to a neighbor\n")
6330 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6331 neighbor_addpath_tx_bestpath_per_as_cmd
,
6332 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6335 "Use addpath to advertise the bestpath per each neighboring AS\n")
6340 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6342 return CMD_WARNING_CONFIG_FAILED
;
6344 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6345 BGP_ADDPATH_BEST_PER_AS
);
6350 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6351 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6352 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6353 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6354 "Use addpath to advertise the bestpath per each neighboring AS\n")
6356 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6357 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6358 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6362 "Use addpath to advertise the bestpath per each neighboring AS\n")
6367 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6369 return CMD_WARNING_CONFIG_FAILED
;
6371 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6372 != BGP_ADDPATH_BEST_PER_AS
) {
6374 "%% Peer not currently configured to transmit all best path per as.");
6375 return CMD_WARNING_CONFIG_FAILED
;
6378 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6384 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6385 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6386 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6387 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6388 "Use addpath to advertise the bestpath per each neighboring AS\n")
6390 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6391 struct ecommunity
**list
)
6393 struct ecommunity
*ecom
= NULL
;
6394 struct ecommunity
*ecomadd
;
6396 for (; argc
; --argc
, ++argv
) {
6398 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6399 ECOMMUNITY_ROUTE_TARGET
, 0);
6401 vty_out(vty
, "Malformed community-list value\n");
6403 ecommunity_free(&ecom
);
6404 return CMD_WARNING_CONFIG_FAILED
;
6408 ecommunity_merge(ecom
, ecomadd
);
6409 ecommunity_free(&ecomadd
);
6416 ecommunity_free(&*list
);
6424 * v2vimport is true if we are handling a `import vrf ...` command
6426 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6430 switch (vty
->node
) {
6439 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6444 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6445 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6446 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6447 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6449 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6453 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6454 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6455 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6456 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6458 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6465 DEFPY (af_rd_vpn_export
,
6466 af_rd_vpn_export_cmd
,
6467 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6469 "Specify route distinguisher\n"
6470 "Between current address-family and vpn\n"
6471 "For routes leaked from current address-family to vpn\n"
6472 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6474 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6475 struct prefix_rd prd
;
6481 if (argv_find(argv
, argc
, "no", &idx
))
6485 ret
= str2prefix_rd(rd_str
, &prd
);
6487 vty_out(vty
, "%% Malformed rd\n");
6488 return CMD_WARNING_CONFIG_FAILED
;
6492 afi
= vpn_policy_getafi(vty
, bgp
, false);
6494 return CMD_WARNING_CONFIG_FAILED
;
6497 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6499 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6500 bgp_get_default(), bgp
);
6503 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6504 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6505 BGP_VPN_POLICY_TOVPN_RD_SET
);
6507 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6508 BGP_VPN_POLICY_TOVPN_RD_SET
);
6511 /* post-change: re-export vpn routes */
6512 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6513 bgp_get_default(), bgp
);
6518 ALIAS (af_rd_vpn_export
,
6519 af_no_rd_vpn_export_cmd
,
6522 "Specify route distinguisher\n"
6523 "Between current address-family and vpn\n"
6524 "For routes leaked from current address-family to vpn\n")
6526 DEFPY (af_label_vpn_export
,
6527 af_label_vpn_export_cmd
,
6528 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6530 "label value for VRF\n"
6531 "Between current address-family and vpn\n"
6532 "For routes leaked from current address-family to vpn\n"
6533 "Label Value <0-1048575>\n"
6534 "Automatically assign a label\n")
6536 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6537 mpls_label_t label
= MPLS_LABEL_NONE
;
6542 if (argv_find(argv
, argc
, "no", &idx
))
6545 /* If "no ...", squash trailing parameter */
6551 label
= label_val
; /* parser should force unsigned */
6554 afi
= vpn_policy_getafi(vty
, bgp
, false);
6556 return CMD_WARNING_CONFIG_FAILED
;
6559 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6560 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6565 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6567 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6568 bgp_get_default(), bgp
);
6570 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6571 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6573 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6576 * label has previously been automatically
6577 * assigned by labelpool: release it
6579 * NB if tovpn_label == MPLS_LABEL_NONE it
6580 * means the automatic assignment is in flight
6581 * and therefore the labelpool callback must
6582 * detect that the auto label is not needed.
6585 bgp_lp_release(LP_TYPE_VRF
,
6586 &bgp
->vpn_policy
[afi
],
6587 bgp
->vpn_policy
[afi
].tovpn_label
);
6589 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6590 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6593 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6595 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6596 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6597 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6598 vpn_leak_label_callback
);
6601 /* post-change: re-export vpn routes */
6602 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6603 bgp_get_default(), bgp
);
6608 ALIAS (af_label_vpn_export
,
6609 af_no_label_vpn_export_cmd
,
6610 "no label vpn export",
6612 "label value for VRF\n"
6613 "Between current address-family and vpn\n"
6614 "For routes leaked from current address-family to vpn\n")
6616 DEFPY (af_nexthop_vpn_export
,
6617 af_nexthop_vpn_export_cmd
,
6618 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6620 "Specify next hop to use for VRF advertised prefixes\n"
6621 "Between current address-family and vpn\n"
6622 "For routes leaked from current address-family to vpn\n"
6626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6632 if (argv_find(argv
, argc
, "no", &idx
))
6636 if (!sockunion2hostprefix(nexthop_str
, &p
))
6637 return CMD_WARNING_CONFIG_FAILED
;
6640 afi
= vpn_policy_getafi(vty
, bgp
, false);
6642 return CMD_WARNING_CONFIG_FAILED
;
6645 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6647 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6648 bgp_get_default(), bgp
);
6651 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6652 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6653 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6655 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6656 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6659 /* post-change: re-export vpn routes */
6660 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6661 bgp_get_default(), bgp
);
6666 ALIAS (af_nexthop_vpn_export
,
6667 af_no_nexthop_vpn_export_cmd
,
6668 "no nexthop vpn export",
6670 "Specify next hop to use for VRF advertised prefixes\n"
6671 "Between current address-family and vpn\n"
6672 "For routes leaked from current address-family to vpn\n")
6674 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6676 if (!strcmp(dstr
, "import")) {
6677 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6678 } else if (!strcmp(dstr
, "export")) {
6679 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6680 } else if (!strcmp(dstr
, "both")) {
6681 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6682 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6684 vty_out(vty
, "%% direction parse error\n");
6685 return CMD_WARNING_CONFIG_FAILED
;
6690 DEFPY (af_rt_vpn_imexport
,
6691 af_rt_vpn_imexport_cmd
,
6692 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6694 "Specify route target list\n"
6695 "Specify route target list\n"
6696 "Between current address-family and vpn\n"
6697 "For routes leaked from vpn to current address-family: match any\n"
6698 "For routes leaked from current address-family to vpn: set\n"
6699 "both import: match any and export: set\n"
6700 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6702 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6704 struct ecommunity
*ecom
= NULL
;
6705 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6706 vpn_policy_direction_t dir
;
6711 if (argv_find(argv
, argc
, "no", &idx
))
6714 afi
= vpn_policy_getafi(vty
, bgp
, false);
6716 return CMD_WARNING_CONFIG_FAILED
;
6718 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6719 if (ret
!= CMD_SUCCESS
)
6723 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6724 vty_out(vty
, "%% Missing RTLIST\n");
6725 return CMD_WARNING_CONFIG_FAILED
;
6727 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6728 if (ret
!= CMD_SUCCESS
) {
6733 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6737 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6740 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6742 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6743 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6744 ecommunity_dup(ecom
);
6746 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6748 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6749 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6752 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6756 ecommunity_free(&ecom
);
6761 ALIAS (af_rt_vpn_imexport
,
6762 af_no_rt_vpn_imexport_cmd
,
6763 "no <rt|route-target> vpn <import|export|both>$direction_str",
6765 "Specify route target list\n"
6766 "Specify route target list\n"
6767 "Between current address-family and vpn\n"
6768 "For routes leaked from vpn to current address-family\n"
6769 "For routes leaked from current address-family to vpn\n"
6770 "both import and export\n")
6772 DEFPY (af_route_map_vpn_imexport
,
6773 af_route_map_vpn_imexport_cmd
,
6774 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6775 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6777 "Specify route map\n"
6778 "Between current address-family and vpn\n"
6779 "For routes leaked from vpn to current address-family\n"
6780 "For routes leaked from current address-family to vpn\n"
6781 "name of route-map\n")
6783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6785 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6786 vpn_policy_direction_t dir
;
6791 if (argv_find(argv
, argc
, "no", &idx
))
6794 afi
= vpn_policy_getafi(vty
, bgp
, false);
6796 return CMD_WARNING_CONFIG_FAILED
;
6798 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6799 if (ret
!= CMD_SUCCESS
)
6802 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6806 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6809 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6810 XFREE(MTYPE_ROUTE_MAP_NAME
,
6811 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6812 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6813 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6814 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6815 route_map_lookup_warn_noexist(vty
, rmap_str
);
6816 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6819 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6820 XFREE(MTYPE_ROUTE_MAP_NAME
,
6821 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6822 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6823 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6826 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6832 ALIAS (af_route_map_vpn_imexport
,
6833 af_no_route_map_vpn_imexport_cmd
,
6834 "no route-map vpn <import|export>$direction_str",
6836 "Specify route map\n"
6837 "Between current address-family and vpn\n"
6838 "For routes leaked from vpn to current address-family\n"
6839 "For routes leaked from current address-family to vpn\n")
6841 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6842 "[no] import vrf route-map RMAP$rmap_str",
6844 "Import routes from another VRF\n"
6845 "Vrf routes being filtered\n"
6846 "Specify route map\n"
6847 "name of route-map\n")
6849 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6850 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6854 struct bgp
*bgp_default
;
6856 if (argv_find(argv
, argc
, "no", &idx
))
6859 afi
= vpn_policy_getafi(vty
, bgp
, true);
6861 return CMD_WARNING_CONFIG_FAILED
;
6863 bgp_default
= bgp_get_default();
6868 /* Auto-create assuming the same AS */
6869 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6870 BGP_INSTANCE_TYPE_DEFAULT
);
6874 "VRF default is not configured as a bgp instance\n");
6879 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6882 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6883 XFREE(MTYPE_ROUTE_MAP_NAME
,
6884 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6885 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6886 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6887 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6888 route_map_lookup_warn_noexist(vty
, rmap_str
);
6889 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6892 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6893 XFREE(MTYPE_ROUTE_MAP_NAME
,
6894 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6895 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6896 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6899 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6904 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6905 "no import vrf route-map",
6907 "Import routes from another VRF\n"
6908 "Vrf routes being filtered\n"
6909 "Specify route map\n")
6911 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6912 "[no] import vrf VIEWVRFNAME$import_name",
6914 "Import routes from another VRF\n"
6915 "VRF to import from\n"
6916 "The name of the VRF\n")
6918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6919 struct listnode
*node
;
6920 struct bgp
*vrf_bgp
, *bgp_default
;
6923 bool remove
= false;
6926 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6930 if (import_name
== NULL
) {
6931 vty_out(vty
, "%% Missing import name\n");
6935 if (argv_find(argv
, argc
, "no", &idx
))
6938 afi
= vpn_policy_getafi(vty
, bgp
, true);
6940 return CMD_WARNING_CONFIG_FAILED
;
6942 safi
= bgp_node_safi(vty
);
6944 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6945 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6946 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6947 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6948 remove
? "unimport" : "import", import_name
);
6952 bgp_default
= bgp_get_default();
6954 /* Auto-create assuming the same AS */
6955 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6956 BGP_INSTANCE_TYPE_DEFAULT
);
6960 "VRF default is not configured as a bgp instance\n");
6965 vrf_bgp
= bgp_lookup_by_name(import_name
);
6967 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6968 vrf_bgp
= bgp_default
;
6970 /* Auto-create assuming the same AS */
6971 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6975 "VRF %s is not configured as a bgp instance\n",
6982 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6984 /* Already importing from "import_vrf"? */
6985 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6987 if (strcmp(vname
, import_name
) == 0)
6991 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6997 /* This command is valid only in a bgp vrf instance or the default instance */
6998 DEFPY (bgp_imexport_vpn
,
6999 bgp_imexport_vpn_cmd
,
7000 "[no] <import|export>$direction_str vpn",
7002 "Import routes to this address-family\n"
7003 "Export routes from this address-family\n"
7004 "to/from default instance VPN RIB\n")
7006 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7013 vpn_policy_direction_t dir
;
7015 if (argv_find(argv
, argc
, "no", &idx
))
7018 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7019 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7021 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7022 return CMD_WARNING_CONFIG_FAILED
;
7025 afi
= bgp_node_afi(vty
);
7026 safi
= bgp_node_safi(vty
);
7027 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7028 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7029 return CMD_WARNING_CONFIG_FAILED
;
7032 if (!strcmp(direction_str
, "import")) {
7033 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7034 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7035 } else if (!strcmp(direction_str
, "export")) {
7036 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7037 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7039 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7040 return CMD_WARNING_CONFIG_FAILED
;
7043 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7046 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7047 if (!previous_state
) {
7048 /* trigger export current vrf */
7049 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7052 if (previous_state
) {
7053 /* trigger un-export current vrf */
7054 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7056 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7062 DEFPY (af_routetarget_import
,
7063 af_routetarget_import_cmd
,
7064 "[no] <rt|route-target> redirect import RTLIST...",
7066 "Specify route target list\n"
7067 "Specify route target list\n"
7068 "Flow-spec redirect type route target\n"
7069 "Import routes to this address-family\n"
7070 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7072 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7074 struct ecommunity
*ecom
= NULL
;
7079 if (argv_find(argv
, argc
, "no", &idx
))
7082 afi
= vpn_policy_getafi(vty
, bgp
, false);
7084 return CMD_WARNING_CONFIG_FAILED
;
7087 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7088 vty_out(vty
, "%% Missing RTLIST\n");
7089 return CMD_WARNING_CONFIG_FAILED
;
7091 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7092 if (ret
!= CMD_SUCCESS
)
7097 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7098 ecommunity_free(&bgp
->vpn_policy
[afi
]
7099 .import_redirect_rtlist
);
7100 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7101 ecommunity_dup(ecom
);
7103 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7104 ecommunity_free(&bgp
->vpn_policy
[afi
]
7105 .import_redirect_rtlist
);
7106 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7110 ecommunity_free(&ecom
);
7115 DEFUN_NOSH (address_family_ipv4_safi
,
7116 address_family_ipv4_safi_cmd
,
7117 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7118 "Enter Address Family command mode\n"
7120 BGP_SAFI_WITH_LABEL_HELP_STR
)
7124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7125 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7126 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7127 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7128 && safi
!= SAFI_EVPN
) {
7130 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7131 return CMD_WARNING_CONFIG_FAILED
;
7133 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7135 vty
->node
= BGP_IPV4_NODE
;
7140 DEFUN_NOSH (address_family_ipv6_safi
,
7141 address_family_ipv6_safi_cmd
,
7142 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7143 "Enter Address Family command mode\n"
7145 BGP_SAFI_WITH_LABEL_HELP_STR
)
7148 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7149 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7150 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7151 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7152 && safi
!= SAFI_EVPN
) {
7154 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7155 return CMD_WARNING_CONFIG_FAILED
;
7157 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7159 vty
->node
= BGP_IPV6_NODE
;
7164 #ifdef KEEP_OLD_VPN_COMMANDS
7165 DEFUN_NOSH (address_family_vpnv4
,
7166 address_family_vpnv4_cmd
,
7167 "address-family vpnv4 [unicast]",
7168 "Enter Address Family command mode\n"
7170 "Address Family modifier\n")
7172 vty
->node
= BGP_VPNV4_NODE
;
7176 DEFUN_NOSH (address_family_vpnv6
,
7177 address_family_vpnv6_cmd
,
7178 "address-family vpnv6 [unicast]",
7179 "Enter Address Family command mode\n"
7181 "Address Family modifier\n")
7183 vty
->node
= BGP_VPNV6_NODE
;
7186 #endif /* KEEP_OLD_VPN_COMMANDS */
7188 DEFUN_NOSH (address_family_evpn
,
7189 address_family_evpn_cmd
,
7190 "address-family l2vpn evpn",
7191 "Enter Address Family command mode\n"
7193 "Address Family modifier\n")
7195 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7196 vty
->node
= BGP_EVPN_NODE
;
7200 DEFUN_NOSH (exit_address_family
,
7201 exit_address_family_cmd
,
7202 "exit-address-family",
7203 "Exit from Address Family configuration mode\n")
7205 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7206 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7207 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7208 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7209 || vty
->node
== BGP_EVPN_NODE
7210 || vty
->node
== BGP_FLOWSPECV4_NODE
7211 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7212 vty
->node
= BGP_NODE
;
7216 /* Recalculate bestpath and re-advertise a prefix */
7217 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7218 const char *ip_str
, afi_t afi
, safi_t safi
,
7219 struct prefix_rd
*prd
)
7222 struct prefix match
;
7223 struct bgp_node
*rn
;
7224 struct bgp_node
*rm
;
7226 struct bgp_table
*table
;
7227 struct bgp_table
*rib
;
7229 /* BGP structure lookup. */
7231 bgp
= bgp_lookup_by_name(view_name
);
7233 vty_out(vty
, "%% Can't find BGP instance %s\n",
7238 bgp
= bgp_get_default();
7240 vty_out(vty
, "%% No BGP process is configured\n");
7245 /* Check IP address argument. */
7246 ret
= str2prefix(ip_str
, &match
);
7248 vty_out(vty
, "%% address is malformed\n");
7252 match
.family
= afi2family(afi
);
7253 rib
= bgp
->rib
[afi
][safi
];
7255 if (safi
== SAFI_MPLS_VPN
) {
7256 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7257 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7260 table
= bgp_node_get_bgp_table_info(rn
);
7261 if (table
!= NULL
) {
7263 if ((rm
= bgp_node_match(table
, &match
))
7266 == match
.prefixlen
) {
7268 BGP_NODE_USER_CLEAR
);
7269 bgp_process(bgp
, rm
, afi
, safi
);
7271 bgp_unlock_node(rm
);
7276 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7277 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7278 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7279 bgp_process(bgp
, rn
, afi
, safi
);
7281 bgp_unlock_node(rn
);
7288 /* one clear bgp command to rule them all */
7289 DEFUN (clear_ip_bgp_all
,
7290 clear_ip_bgp_all_cmd
,
7291 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7295 BGP_INSTANCE_HELP_STR
7298 BGP_SAFI_WITH_LABEL_HELP_STR
7299 "Address Family modifier\n"
7301 "BGP neighbor address to clear\n"
7302 "BGP IPv6 neighbor to clear\n"
7303 "BGP neighbor on interface to clear\n"
7304 "Clear peers with the AS number\n"
7305 "Clear all external peers\n"
7306 "Clear all members of peer-group\n"
7307 "BGP peer-group name\n"
7312 "Push out prefix-list ORF and do inbound soft reconfig\n"
7317 afi_t afi
= AFI_IP6
;
7318 safi_t safi
= SAFI_UNICAST
;
7319 enum clear_sort clr_sort
= clear_peer
;
7320 enum bgp_clear_type clr_type
;
7321 char *clr_arg
= NULL
;
7325 /* clear [ip] bgp */
7326 if (argv_find(argv
, argc
, "ip", &idx
))
7329 /* [<vrf> VIEWVRFNAME] */
7330 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7331 vrf
= argv
[idx
+ 1]->arg
;
7333 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7335 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7336 /* [<view> VIEWVRFNAME] */
7337 vrf
= argv
[idx
+ 1]->arg
;
7340 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7341 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7342 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7344 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7345 if (argv_find(argv
, argc
, "*", &idx
)) {
7346 clr_sort
= clear_all
;
7347 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7348 clr_sort
= clear_peer
;
7349 clr_arg
= argv
[idx
]->arg
;
7350 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7351 clr_sort
= clear_peer
;
7352 clr_arg
= argv
[idx
]->arg
;
7353 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7354 clr_sort
= clear_group
;
7356 clr_arg
= argv
[idx
]->arg
;
7357 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7358 clr_sort
= clear_peer
;
7359 clr_arg
= argv
[idx
]->arg
;
7360 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7361 clr_sort
= clear_as
;
7362 clr_arg
= argv
[idx
]->arg
;
7363 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7364 clr_sort
= clear_external
;
7367 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7368 if (argv_find(argv
, argc
, "soft", &idx
)) {
7369 if (argv_find(argv
, argc
, "in", &idx
)
7370 || argv_find(argv
, argc
, "out", &idx
))
7371 clr_type
= strmatch(argv
[idx
]->text
, "in")
7373 : BGP_CLEAR_SOFT_OUT
;
7375 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7376 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7377 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7378 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7379 : BGP_CLEAR_SOFT_IN
;
7380 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7381 clr_type
= BGP_CLEAR_SOFT_OUT
;
7383 clr_type
= BGP_CLEAR_SOFT_NONE
;
7385 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7388 DEFUN (clear_ip_bgp_prefix
,
7389 clear_ip_bgp_prefix_cmd
,
7390 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7394 BGP_INSTANCE_HELP_STR
7395 "Clear bestpath and re-advertise\n"
7399 char *prefix
= NULL
;
7403 /* [<view|vrf> VIEWVRFNAME] */
7404 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7405 vrf
= argv
[idx
+ 1]->arg
;
7407 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7409 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7410 /* [<view> VIEWVRFNAME] */
7411 vrf
= argv
[idx
+ 1]->arg
;
7415 prefix
= argv
[argc
- 1]->arg
;
7417 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7420 DEFUN (clear_bgp_ipv6_safi_prefix
,
7421 clear_bgp_ipv6_safi_prefix_cmd
,
7422 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7428 "Clear bestpath and re-advertise\n"
7432 int idx_ipv6_prefix
= 0;
7433 safi_t safi
= SAFI_UNICAST
;
7434 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7435 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7437 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7438 return bgp_clear_prefix(
7439 vty
, NULL
, prefix
, AFI_IP6
,
7443 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7444 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7445 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7449 BGP_INSTANCE_HELP_STR
7452 "Clear bestpath and re-advertise\n"
7456 int idx_vrfview
= 0;
7457 int idx_ipv6_prefix
= 0;
7458 safi_t safi
= SAFI_UNICAST
;
7459 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7460 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7461 char *vrfview
= NULL
;
7463 /* [<view|vrf> VIEWVRFNAME] */
7464 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7465 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7466 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7468 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7469 /* [<view> VIEWVRFNAME] */
7470 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7472 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7474 return bgp_clear_prefix(
7475 vty
, vrfview
, prefix
,
7476 AFI_IP6
, safi
, NULL
);
7479 DEFUN (show_bgp_views
,
7481 "show [ip] bgp views",
7485 "Show the defined BGP views\n")
7487 struct list
*inst
= bm
->bgp
;
7488 struct listnode
*node
;
7491 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7492 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7496 vty_out(vty
, "Defined BGP views:\n");
7497 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7499 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7501 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7508 DEFUN (show_bgp_vrfs
,
7510 "show [ip] bgp vrfs [json]",
7517 char buf
[ETHER_ADDR_STRLEN
];
7518 struct list
*inst
= bm
->bgp
;
7519 struct listnode
*node
;
7521 bool uj
= use_json(argc
, argv
);
7522 json_object
*json
= NULL
;
7523 json_object
*json_vrfs
= NULL
;
7526 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7527 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7532 json
= json_object_new_object();
7533 json_vrfs
= json_object_new_object();
7536 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7537 const char *name
, *type
;
7539 struct listnode
*node2
, *nnode2
;
7540 int peers_cfg
, peers_estb
;
7541 json_object
*json_vrf
= NULL
;
7544 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7548 if (!uj
&& count
== 1)
7550 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7551 "Type", "Id", "routerId", "#PeersVfg",
7552 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7554 peers_cfg
= peers_estb
= 0;
7556 json_vrf
= json_object_new_object();
7559 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7560 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7563 if (peer
->status
== Established
)
7567 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7568 name
= VRF_DEFAULT_NAME
;
7577 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7579 : (int64_t)bgp
->vrf_id
;
7580 json_object_string_add(json_vrf
, "type", type
);
7581 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7582 json_object_string_add(json_vrf
, "routerId",
7583 inet_ntoa(bgp
->router_id
));
7584 json_object_int_add(json_vrf
, "numConfiguredPeers",
7586 json_object_int_add(json_vrf
, "numEstablishedPeers",
7589 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7590 json_object_string_add(
7592 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7593 json_object_object_add(json_vrfs
, name
, json_vrf
);
7596 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7598 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7600 inet_ntoa(bgp
->router_id
), peers_cfg
,
7601 peers_estb
, name
, bgp
->l3vni
,
7602 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7606 json_object_object_add(json
, "vrfs", json_vrfs
);
7608 json_object_int_add(json
, "totalVrfs", count
);
7610 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7611 json
, JSON_C_TO_STRING_PRETTY
));
7612 json_object_free(json
);
7616 "\nTotal number of VRFs (including default): %d\n",
7623 DEFUN (show_bgp_mac_hash
,
7624 show_bgp_mac_hash_cmd
,
7625 "show bgp mac hash",
7629 "Mac Address database\n")
7631 bgp_mac_dump_table(vty
);
7636 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7638 struct vty
*vty
= (struct vty
*)args
;
7639 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7641 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7645 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7647 vty_out(vty
, "self nexthop database:\n");
7648 bgp_nexthop_show_address_hash(vty
, bgp
);
7650 vty_out(vty
, "Tunnel-ip database:\n");
7651 hash_iterate(bgp
->tip_hash
,
7652 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7656 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7657 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7658 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7659 "martian next-hops\n"
7660 "martian next-hop database\n")
7662 struct bgp
*bgp
= NULL
;
7666 /* [<vrf> VIEWVRFNAME] */
7667 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7668 name
= argv
[idx
+ 1]->arg
;
7669 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7671 } else if (argv_find(argv
, argc
, "view", &idx
))
7672 /* [<view> VIEWVRFNAME] */
7673 name
= argv
[idx
+ 1]->arg
;
7675 bgp
= bgp_lookup_by_name(name
);
7677 bgp
= bgp_get_default();
7680 vty_out(vty
, "%% No BGP process is configured\n");
7683 bgp_show_martian_nexthops(vty
, bgp
);
7688 DEFUN (show_bgp_memory
,
7689 show_bgp_memory_cmd
,
7690 "show [ip] bgp memory",
7694 "Global BGP memory statistics\n")
7696 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7697 unsigned long count
;
7699 /* RIB related usage stats */
7700 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7701 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7702 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7703 count
* sizeof(struct bgp_node
)));
7705 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7706 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7707 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7708 count
* sizeof(struct bgp_path_info
)));
7709 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7710 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7713 memstrbuf
, sizeof(memstrbuf
),
7714 count
* sizeof(struct bgp_path_info_extra
)));
7716 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7717 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7718 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7719 count
* sizeof(struct bgp_static
)));
7721 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7722 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7723 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7724 count
* sizeof(struct bpacket
)));
7727 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7728 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7729 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7730 count
* sizeof(struct bgp_adj_in
)));
7731 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7732 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7733 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7734 count
* sizeof(struct bgp_adj_out
)));
7736 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7737 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7739 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7740 count
* sizeof(struct bgp_nexthop_cache
)));
7742 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7743 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7745 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7746 count
* sizeof(struct bgp_damp_info
)));
7749 count
= attr_count();
7750 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7751 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7752 count
* sizeof(struct attr
)));
7754 if ((count
= attr_unknown_count()))
7755 vty_out(vty
, "%ld unknown attributes\n", count
);
7757 /* AS_PATH attributes */
7758 count
= aspath_count();
7759 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7760 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7761 count
* sizeof(struct aspath
)));
7763 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7764 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7765 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7766 count
* sizeof(struct assegment
)));
7768 /* Other attributes */
7769 if ((count
= community_count()))
7770 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7771 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7772 count
* sizeof(struct community
)));
7773 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7774 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7775 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7776 count
* sizeof(struct ecommunity
)));
7777 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7779 "%ld BGP large-community entries, using %s of memory\n",
7780 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7781 count
* sizeof(struct lcommunity
)));
7783 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7784 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7785 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7786 count
* sizeof(struct cluster_list
)));
7788 /* Peer related usage */
7789 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7790 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7791 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7792 count
* sizeof(struct peer
)));
7794 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7795 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7796 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7797 count
* sizeof(struct peer_group
)));
7800 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7801 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7802 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7803 count
* sizeof(struct hash
)));
7804 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7805 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7806 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7807 count
* sizeof(struct hash_bucket
)));
7808 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7809 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7810 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7811 count
* sizeof(regex_t
)));
7815 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7817 json_object
*bestpath
= json_object_new_object();
7819 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7820 json_object_string_add(bestpath
, "asPath", "ignore");
7822 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7823 json_object_string_add(bestpath
, "asPath", "confed");
7825 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7826 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7827 json_object_string_add(bestpath
, "multiPathRelax",
7830 json_object_string_add(bestpath
, "multiPathRelax",
7833 json_object_string_add(bestpath
, "multiPathRelax", "false");
7835 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7836 json_object_string_add(bestpath
, "compareRouterId", "true");
7837 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7838 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7839 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7840 json_object_string_add(bestpath
, "med", "confed");
7841 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7842 json_object_string_add(bestpath
, "med",
7843 "missing-as-worst");
7845 json_object_string_add(bestpath
, "med", "true");
7848 json_object_object_add(json
, "bestPath", bestpath
);
7851 /* Show BGP peer's summary information. */
7852 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7853 bool use_json
, json_object
*json
)
7856 struct listnode
*node
, *nnode
;
7857 unsigned int count
= 0, dn_count
= 0;
7858 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7859 char neighbor_buf
[VTY_BUFSIZ
];
7860 int neighbor_col_default_width
= 16;
7862 int max_neighbor_width
= 0;
7864 json_object
*json_peer
= NULL
;
7865 json_object
*json_peers
= NULL
;
7866 struct peer_af
*paf
;
7868 /* labeled-unicast routes are installed in the unicast table so in order
7870 * display the correct PfxRcd value we must look at SAFI_UNICAST
7872 if (safi
== SAFI_LABELED_UNICAST
)
7873 pfx_rcd_safi
= SAFI_UNICAST
;
7875 pfx_rcd_safi
= safi
;
7879 json
= json_object_new_object();
7881 json_peers
= json_object_new_object();
7883 /* Loop over all neighbors that will be displayed to determine
7885 * characters are needed for the Neighbor column
7887 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7888 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7891 if (peer
->afc
[afi
][safi
]) {
7892 memset(dn_flag
, '\0', sizeof(dn_flag
));
7893 if (peer_dynamic_neighbor(peer
))
7897 && bgp_flag_check(bgp
,
7898 BGP_FLAG_SHOW_HOSTNAME
))
7899 sprintf(neighbor_buf
, "%s%s(%s) ",
7900 dn_flag
, peer
->hostname
,
7903 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7906 len
= strlen(neighbor_buf
);
7908 if (len
> max_neighbor_width
)
7909 max_neighbor_width
= len
;
7913 /* Originally we displayed the Neighbor column as 16
7914 * characters wide so make that the default
7916 if (max_neighbor_width
< neighbor_col_default_width
)
7917 max_neighbor_width
= neighbor_col_default_width
;
7920 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7921 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7924 if (!peer
->afc
[afi
][safi
])
7929 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7932 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7934 : (int64_t)bgp
->vrf_id
;
7936 /* Usage summary and header */
7938 json_object_string_add(
7940 inet_ntoa(bgp
->router_id
));
7941 json_object_int_add(json
, "as", bgp
->as
);
7942 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7943 json_object_string_add(
7946 == BGP_INSTANCE_TYPE_DEFAULT
)
7951 "BGP router identifier %s, local AS number %u vrf-id %d",
7952 inet_ntoa(bgp
->router_id
), bgp
->as
,
7953 bgp
->vrf_id
== VRF_UNKNOWN
7955 : (int)bgp
->vrf_id
);
7959 if (bgp_update_delay_configured(bgp
)) {
7961 json_object_int_add(
7962 json
, "updateDelayLimit",
7963 bgp
->v_update_delay
);
7965 if (bgp
->v_update_delay
7966 != bgp
->v_establish_wait
)
7967 json_object_int_add(
7969 "updateDelayEstablishWait",
7970 bgp
->v_establish_wait
);
7972 if (bgp_update_delay_active(bgp
)) {
7973 json_object_string_add(
7975 "updateDelayFirstNeighbor",
7976 bgp
->update_delay_begin_time
);
7977 json_object_boolean_true_add(
7979 "updateDelayInProgress");
7981 if (bgp
->update_delay_over
) {
7982 json_object_string_add(
7984 "updateDelayFirstNeighbor",
7985 bgp
->update_delay_begin_time
);
7986 json_object_string_add(
7988 "updateDelayBestpathResumed",
7989 bgp
->update_delay_end_time
);
7990 json_object_string_add(
7992 "updateDelayZebraUpdateResume",
7993 bgp
->update_delay_zebra_resume_time
);
7994 json_object_string_add(
7996 "updateDelayPeerUpdateResume",
7997 bgp
->update_delay_peers_resume_time
);
8002 "Read-only mode update-delay limit: %d seconds\n",
8003 bgp
->v_update_delay
);
8004 if (bgp
->v_update_delay
8005 != bgp
->v_establish_wait
)
8007 " Establish wait: %d seconds\n",
8008 bgp
->v_establish_wait
);
8010 if (bgp_update_delay_active(bgp
)) {
8012 " First neighbor established: %s\n",
8013 bgp
->update_delay_begin_time
);
8015 " Delay in progress\n");
8017 if (bgp
->update_delay_over
) {
8019 " First neighbor established: %s\n",
8020 bgp
->update_delay_begin_time
);
8022 " Best-paths resumed: %s\n",
8023 bgp
->update_delay_end_time
);
8025 " zebra update resumed: %s\n",
8026 bgp
->update_delay_zebra_resume_time
);
8028 " peers update resumed: %s\n",
8029 bgp
->update_delay_peers_resume_time
);
8036 if (bgp_maxmed_onstartup_configured(bgp
)
8037 && bgp
->maxmed_active
)
8038 json_object_boolean_true_add(
8039 json
, "maxMedOnStartup");
8040 if (bgp
->v_maxmed_admin
)
8041 json_object_boolean_true_add(
8042 json
, "maxMedAdministrative");
8044 json_object_int_add(
8045 json
, "tableVersion",
8046 bgp_table_version(bgp
->rib
[afi
][safi
]));
8048 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8049 json_object_int_add(json
, "ribCount", ents
);
8050 json_object_int_add(
8052 ents
* sizeof(struct bgp_node
));
8054 ents
= bgp
->af_peer_count
[afi
][safi
];
8055 json_object_int_add(json
, "peerCount", ents
);
8056 json_object_int_add(json
, "peerMemory",
8057 ents
* sizeof(struct peer
));
8059 if ((ents
= listcount(bgp
->group
))) {
8060 json_object_int_add(
8061 json
, "peerGroupCount", ents
);
8062 json_object_int_add(
8063 json
, "peerGroupMemory",
8064 ents
* sizeof(struct
8068 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8069 BGP_CONFIG_DAMPENING
))
8070 json_object_boolean_true_add(
8071 json
, "dampeningEnabled");
8073 if (bgp_maxmed_onstartup_configured(bgp
)
8074 && bgp
->maxmed_active
)
8076 "Max-med on-startup active\n");
8077 if (bgp
->v_maxmed_admin
)
8079 "Max-med administrative active\n");
8081 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8082 bgp_table_version(bgp
->rib
[afi
][safi
]));
8084 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8086 "RIB entries %ld, using %s of memory\n",
8088 mtype_memstr(memstrbuf
,
8090 ents
* sizeof(struct
8093 /* Peer related usage */
8094 ents
= bgp
->af_peer_count
[afi
][safi
];
8095 vty_out(vty
, "Peers %ld, using %s of memory\n",
8098 memstrbuf
, sizeof(memstrbuf
),
8099 ents
* sizeof(struct peer
)));
8101 if ((ents
= listcount(bgp
->group
)))
8103 "Peer groups %ld, using %s of memory\n",
8108 ents
* sizeof(struct
8111 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8112 BGP_CONFIG_DAMPENING
))
8113 vty_out(vty
, "Dampening enabled.\n");
8116 /* Subtract 8 here because 'Neighbor' is
8118 vty_out(vty
, "Neighbor");
8119 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8122 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8129 json_peer
= json_object_new_object();
8131 if (peer_dynamic_neighbor(peer
)) {
8133 json_object_boolean_true_add(json_peer
,
8138 json_object_string_add(json_peer
, "hostname",
8141 if (peer
->domainname
)
8142 json_object_string_add(json_peer
, "domainname",
8145 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8146 json_object_int_add(json_peer
, "version", 4);
8147 json_object_int_add(json_peer
, "msgRcvd",
8148 PEER_TOTAL_RX(peer
));
8149 json_object_int_add(json_peer
, "msgSent",
8150 PEER_TOTAL_TX(peer
));
8152 json_object_int_add(json_peer
, "tableVersion",
8153 peer
->version
[afi
][safi
]);
8154 json_object_int_add(json_peer
, "outq",
8156 json_object_int_add(json_peer
, "inq", 0);
8157 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8158 use_json
, json_peer
);
8161 * Adding "pfxRcd" field to match with the corresponding
8162 * CLI. "prefixReceivedCount" will be deprecated in
8165 json_object_int_add(json_peer
, "prefixReceivedCount",
8166 peer
->pcount
[afi
][pfx_rcd_safi
]);
8167 json_object_int_add(json_peer
, "pfxRcd",
8168 peer
->pcount
[afi
][pfx_rcd_safi
]);
8170 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8171 if (paf
&& PAF_SUBGRP(paf
))
8172 json_object_int_add(json_peer
,
8174 (PAF_SUBGRP(paf
))->scount
);
8176 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8177 json_object_string_add(json_peer
, "state",
8179 else if (peer
->afc_recv
[afi
][safi
])
8180 json_object_string_add(
8182 lookup_msg(bgp_status_msg
, peer
->status
,
8184 else if (CHECK_FLAG(peer
->sflags
,
8185 PEER_STATUS_PREFIX_OVERFLOW
))
8186 json_object_string_add(json_peer
, "state",
8189 json_object_string_add(
8191 lookup_msg(bgp_status_msg
, peer
->status
,
8195 json_object_string_add(json_peer
, "idType",
8197 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8198 json_object_string_add(json_peer
, "idType",
8200 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8201 json_object_string_add(json_peer
, "idType",
8204 json_object_object_add(json_peers
, peer
->host
,
8207 memset(dn_flag
, '\0', sizeof(dn_flag
));
8208 if (peer_dynamic_neighbor(peer
)) {
8214 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8215 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8216 peer
->hostname
, peer
->host
);
8218 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8220 /* pad the neighbor column with spaces */
8221 if (len
< max_neighbor_width
)
8222 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8225 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8226 peer
->as
, PEER_TOTAL_RX(peer
),
8227 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8228 0, peer
->obuf
->count
,
8229 peer_uptime(peer
->uptime
, timebuf
,
8230 BGP_UPTIME_LEN
, 0, NULL
));
8232 if (peer
->status
== Established
)
8233 if (peer
->afc_recv
[afi
][safi
])
8234 vty_out(vty
, " %12" PRIu32
,
8238 vty_out(vty
, " NoNeg");
8240 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8241 vty_out(vty
, " Idle (Admin)");
8242 else if (CHECK_FLAG(
8244 PEER_STATUS_PREFIX_OVERFLOW
))
8245 vty_out(vty
, " Idle (PfxCt)");
8247 vty_out(vty
, " %12s",
8248 lookup_msg(bgp_status_msg
,
8249 peer
->status
, NULL
));
8256 json_object_object_add(json
, "peers", json_peers
);
8258 json_object_int_add(json
, "totalPeers", count
);
8259 json_object_int_add(json
, "dynamicPeers", dn_count
);
8261 bgp_show_bestpath_json(bgp
, json
);
8263 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8264 json
, JSON_C_TO_STRING_PRETTY
));
8265 json_object_free(json
);
8268 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8270 vty_out(vty
, "No %s neighbor is configured\n",
8271 afi_safi_print(afi
, safi
));
8275 vty_out(vty
, "* - dynamic neighbor\n");
8276 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8277 dn_count
, bgp
->dynamic_neighbors_limit
);
8284 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8285 int safi
, bool use_json
,
8289 int afi_wildcard
= (afi
== AFI_MAX
);
8290 int safi_wildcard
= (safi
== SAFI_MAX
);
8291 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8292 bool nbr_output
= false;
8294 if (use_json
&& is_wildcard
)
8295 vty_out(vty
, "{\n");
8297 afi
= 1; /* AFI_IP */
8298 while (afi
< AFI_MAX
) {
8300 safi
= 1; /* SAFI_UNICAST */
8301 while (safi
< SAFI_MAX
) {
8302 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8306 * So limit output to those afi/safi
8308 * actualy have something interesting in
8312 json
= json_object_new_object();
8315 vty_out(vty
, ",\n");
8319 vty_out(vty
, "\"%s\":",
8323 vty_out(vty
, "\n%s Summary:\n",
8328 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8340 if (use_json
&& is_wildcard
)
8341 vty_out(vty
, "}\n");
8342 else if (!nbr_output
) {
8344 vty_out(vty
, "{}\n");
8346 vty_out(vty
, "%% No BGP neighbors found\n");
8350 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8351 safi_t safi
, bool use_json
)
8353 struct listnode
*node
, *nnode
;
8355 json_object
*json
= NULL
;
8357 bool nbr_output
= false;
8360 vty_out(vty
, "{\n");
8362 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8365 json
= json_object_new_object();
8368 vty_out(vty
, ",\n");
8372 vty_out(vty
, "\"%s\":",
8373 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8377 vty_out(vty
, "\nInstance %s:\n",
8378 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8382 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8386 vty_out(vty
, "}\n");
8387 else if (!nbr_output
)
8388 vty_out(vty
, "%% BGP instance not found\n");
8391 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8392 safi_t safi
, bool use_json
)
8397 if (strmatch(name
, "all")) {
8398 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8402 bgp
= bgp_lookup_by_name(name
);
8406 vty_out(vty
, "{}\n");
8409 "%% BGP instance not found\n");
8413 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8419 bgp
= bgp_get_default();
8422 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8425 vty_out(vty
, "{}\n");
8427 vty_out(vty
, "%% BGP instance not found\n");
8434 /* `show [ip] bgp summary' commands. */
8435 DEFUN (show_ip_bgp_summary
,
8436 show_ip_bgp_summary_cmd
,
8437 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8441 BGP_INSTANCE_HELP_STR
8443 BGP_SAFI_WITH_LABEL_HELP_STR
8444 "Summary of BGP neighbor status\n"
8448 afi_t afi
= AFI_MAX
;
8449 safi_t safi
= SAFI_MAX
;
8454 if (argv_find(argv
, argc
, "ip", &idx
))
8456 /* [<vrf> VIEWVRFNAME] */
8457 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8458 vrf
= argv
[idx
+ 1]->arg
;
8459 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8461 } else if (argv_find(argv
, argc
, "view", &idx
))
8462 /* [<view> VIEWVRFNAME] */
8463 vrf
= argv
[idx
+ 1]->arg
;
8464 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8465 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8466 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8469 bool uj
= use_json(argc
, argv
);
8471 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8474 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8476 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8477 return "IPv4 Unicast";
8478 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8479 return "IPv4 Multicast";
8480 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8481 return "IPv4 Labeled Unicast";
8482 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8484 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8485 return "IPv4 Encap";
8486 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8487 return "IPv4 Flowspec";
8488 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8489 return "IPv6 Unicast";
8490 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8491 return "IPv6 Multicast";
8492 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8493 return "IPv6 Labeled Unicast";
8494 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8496 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8497 return "IPv6 Encap";
8498 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8499 return "IPv6 Flowspec";
8500 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8501 return "L2VPN EVPN";
8507 * Please note that we have intentionally camelCased
8508 * the return strings here. So if you want
8509 * to use this function, please ensure you
8510 * are doing this within json output
8512 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8514 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8515 return "ipv4Unicast";
8516 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8517 return "ipv4Multicast";
8518 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8519 return "ipv4LabeledUnicast";
8520 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8522 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8524 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8525 return "ipv4Flowspec";
8526 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8527 return "ipv6Unicast";
8528 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8529 return "ipv6Multicast";
8530 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8531 return "ipv6LabeledUnicast";
8532 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8534 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8536 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8537 return "ipv6Flowspec";
8538 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8544 /* Show BGP peer's information. */
8545 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8547 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8548 afi_t afi
, safi_t safi
,
8549 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8550 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8551 bool use_json
, json_object
*json_pref
)
8554 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8555 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8557 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8558 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8559 json_object_string_add(json_pref
, "sendMode",
8560 "advertisedAndReceived");
8561 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8562 json_object_string_add(json_pref
, "sendMode",
8564 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8565 json_object_string_add(json_pref
, "sendMode",
8568 vty_out(vty
, " Send-mode: ");
8569 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8570 vty_out(vty
, "advertised");
8571 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8572 vty_out(vty
, "%sreceived",
8573 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8582 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8583 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8585 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8586 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8587 json_object_string_add(json_pref
, "recvMode",
8588 "advertisedAndReceived");
8589 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8590 json_object_string_add(json_pref
, "recvMode",
8592 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8593 json_object_string_add(json_pref
, "recvMode",
8596 vty_out(vty
, " Receive-mode: ");
8597 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8598 vty_out(vty
, "advertised");
8599 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8600 vty_out(vty
, "%sreceived",
8601 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8610 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8611 safi_t safi
, bool use_json
,
8612 json_object
*json_neigh
)
8614 struct bgp_filter
*filter
;
8615 struct peer_af
*paf
;
8616 char orf_pfx_name
[BUFSIZ
];
8618 json_object
*json_af
= NULL
;
8619 json_object
*json_prefA
= NULL
;
8620 json_object
*json_prefB
= NULL
;
8621 json_object
*json_addr
= NULL
;
8624 json_addr
= json_object_new_object();
8625 json_af
= json_object_new_object();
8626 filter
= &p
->filter
[afi
][safi
];
8628 if (peer_group_active(p
))
8629 json_object_string_add(json_addr
, "peerGroupMember",
8632 paf
= peer_af_find(p
, afi
, safi
);
8633 if (paf
&& PAF_SUBGRP(paf
)) {
8634 json_object_int_add(json_addr
, "updateGroupId",
8635 PAF_UPDGRP(paf
)->id
);
8636 json_object_int_add(json_addr
, "subGroupId",
8637 PAF_SUBGRP(paf
)->id
);
8638 json_object_int_add(json_addr
, "packetQueueLength",
8639 bpacket_queue_virtual_length(paf
));
8642 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8643 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8644 PEER_CAP_ORF_PREFIX_SM_RCV
)
8645 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8646 PEER_CAP_ORF_PREFIX_RM_ADV
)
8647 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8648 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8649 json_object_int_add(json_af
, "orfType",
8651 json_prefA
= json_object_new_object();
8652 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8653 PEER_CAP_ORF_PREFIX_SM_ADV
,
8654 PEER_CAP_ORF_PREFIX_RM_ADV
,
8655 PEER_CAP_ORF_PREFIX_SM_RCV
,
8656 PEER_CAP_ORF_PREFIX_RM_RCV
,
8657 use_json
, json_prefA
);
8658 json_object_object_add(json_af
, "orfPrefixList",
8662 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8663 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8664 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8665 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8666 PEER_CAP_ORF_PREFIX_RM_ADV
)
8667 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8668 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8669 json_object_int_add(json_af
, "orfOldType",
8670 ORF_TYPE_PREFIX_OLD
);
8671 json_prefB
= json_object_new_object();
8672 bgp_show_peer_afi_orf_cap(
8673 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8674 PEER_CAP_ORF_PREFIX_RM_ADV
,
8675 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8676 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8678 json_object_object_add(json_af
, "orfOldPrefixList",
8682 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8683 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8684 PEER_CAP_ORF_PREFIX_SM_RCV
)
8685 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8686 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8687 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8688 PEER_CAP_ORF_PREFIX_RM_ADV
)
8689 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8690 PEER_CAP_ORF_PREFIX_RM_RCV
)
8691 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8692 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8693 json_object_object_add(json_addr
, "afDependentCap",
8696 json_object_free(json_af
);
8698 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8699 orf_pfx_count
= prefix_bgp_show_prefix_list(
8700 NULL
, afi
, orf_pfx_name
, use_json
);
8702 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8703 PEER_STATUS_ORF_PREFIX_SEND
)
8705 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8706 PEER_STATUS_ORF_PREFIX_SEND
))
8707 json_object_boolean_true_add(json_neigh
,
8710 json_object_int_add(json_addr
, "orfRecvCounter",
8713 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8714 PEER_STATUS_ORF_WAIT_REFRESH
))
8715 json_object_string_add(
8716 json_addr
, "orfFirstUpdate",
8717 "deferredUntilORFOrRouteRefreshRecvd");
8719 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8720 PEER_FLAG_REFLECTOR_CLIENT
))
8721 json_object_boolean_true_add(json_addr
,
8722 "routeReflectorClient");
8723 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8724 PEER_FLAG_RSERVER_CLIENT
))
8725 json_object_boolean_true_add(json_addr
,
8726 "routeServerClient");
8727 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8728 json_object_boolean_true_add(json_addr
,
8729 "inboundSoftConfigPermit");
8731 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8732 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8733 json_object_boolean_true_add(
8735 "privateAsNumsAllReplacedInUpdatesToNbr");
8736 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8737 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8738 json_object_boolean_true_add(
8740 "privateAsNumsReplacedInUpdatesToNbr");
8741 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8742 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8743 json_object_boolean_true_add(
8745 "privateAsNumsAllRemovedInUpdatesToNbr");
8746 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8747 PEER_FLAG_REMOVE_PRIVATE_AS
))
8748 json_object_boolean_true_add(
8750 "privateAsNumsRemovedInUpdatesToNbr");
8752 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8753 json_object_boolean_true_add(
8755 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8758 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8759 json_object_string_add(json_addr
,
8760 "overrideASNsInOutboundUpdates",
8761 "ifAspathEqualRemoteAs");
8763 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8764 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8765 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8766 json_object_boolean_true_add(json_addr
,
8767 "routerAlwaysNextHop");
8768 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8769 PEER_FLAG_AS_PATH_UNCHANGED
))
8770 json_object_boolean_true_add(
8771 json_addr
, "unchangedAsPathPropogatedToNbr");
8772 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8773 PEER_FLAG_NEXTHOP_UNCHANGED
))
8774 json_object_boolean_true_add(
8775 json_addr
, "unchangedNextHopPropogatedToNbr");
8776 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8777 json_object_boolean_true_add(
8778 json_addr
, "unchangedMedPropogatedToNbr");
8779 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8780 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8781 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8782 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8783 PEER_FLAG_SEND_COMMUNITY
)
8784 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8785 PEER_FLAG_SEND_EXT_COMMUNITY
))
8786 json_object_string_add(json_addr
,
8787 "commAttriSentToNbr",
8788 "extendedAndStandard");
8789 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8790 PEER_FLAG_SEND_EXT_COMMUNITY
))
8791 json_object_string_add(json_addr
,
8792 "commAttriSentToNbr",
8795 json_object_string_add(json_addr
,
8796 "commAttriSentToNbr",
8799 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8800 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8801 if (p
->default_rmap
[afi
][safi
].name
)
8802 json_object_string_add(
8803 json_addr
, "defaultRouteMap",
8804 p
->default_rmap
[afi
][safi
].name
);
8806 if (paf
&& PAF_SUBGRP(paf
)
8807 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8808 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8809 json_object_boolean_true_add(json_addr
,
8812 json_object_boolean_true_add(json_addr
,
8816 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8817 if (is_evpn_enabled())
8818 json_object_boolean_true_add(
8819 json_addr
, "advertiseAllVnis");
8822 if (filter
->plist
[FILTER_IN
].name
8823 || filter
->dlist
[FILTER_IN
].name
8824 || filter
->aslist
[FILTER_IN
].name
8825 || filter
->map
[RMAP_IN
].name
)
8826 json_object_boolean_true_add(json_addr
,
8827 "inboundPathPolicyConfig");
8828 if (filter
->plist
[FILTER_OUT
].name
8829 || filter
->dlist
[FILTER_OUT
].name
8830 || filter
->aslist
[FILTER_OUT
].name
8831 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8832 json_object_boolean_true_add(
8833 json_addr
, "outboundPathPolicyConfig");
8836 if (filter
->plist
[FILTER_IN
].name
)
8837 json_object_string_add(json_addr
,
8838 "incomingUpdatePrefixFilterList",
8839 filter
->plist
[FILTER_IN
].name
);
8840 if (filter
->plist
[FILTER_OUT
].name
)
8841 json_object_string_add(json_addr
,
8842 "outgoingUpdatePrefixFilterList",
8843 filter
->plist
[FILTER_OUT
].name
);
8845 /* distribute-list */
8846 if (filter
->dlist
[FILTER_IN
].name
)
8847 json_object_string_add(
8848 json_addr
, "incomingUpdateNetworkFilterList",
8849 filter
->dlist
[FILTER_IN
].name
);
8850 if (filter
->dlist
[FILTER_OUT
].name
)
8851 json_object_string_add(
8852 json_addr
, "outgoingUpdateNetworkFilterList",
8853 filter
->dlist
[FILTER_OUT
].name
);
8856 if (filter
->aslist
[FILTER_IN
].name
)
8857 json_object_string_add(json_addr
,
8858 "incomingUpdateAsPathFilterList",
8859 filter
->aslist
[FILTER_IN
].name
);
8860 if (filter
->aslist
[FILTER_OUT
].name
)
8861 json_object_string_add(json_addr
,
8862 "outgoingUpdateAsPathFilterList",
8863 filter
->aslist
[FILTER_OUT
].name
);
8866 if (filter
->map
[RMAP_IN
].name
)
8867 json_object_string_add(
8868 json_addr
, "routeMapForIncomingAdvertisements",
8869 filter
->map
[RMAP_IN
].name
);
8870 if (filter
->map
[RMAP_OUT
].name
)
8871 json_object_string_add(
8872 json_addr
, "routeMapForOutgoingAdvertisements",
8873 filter
->map
[RMAP_OUT
].name
);
8875 /* ebgp-requires-policy (inbound) */
8876 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8877 && !bgp_inbound_policy_exists(p
, filter
))
8878 json_object_string_add(
8879 json_addr
, "inboundEbgpRequiresPolicy",
8880 "Inbound updates discarded due to missing policy");
8882 /* ebgp-requires-policy (outbound) */
8883 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8884 && (!bgp_outbound_policy_exists(p
, filter
)))
8885 json_object_string_add(
8886 json_addr
, "outboundEbgpRequiresPolicy",
8887 "Outbound updates discarded due to missing policy");
8889 /* unsuppress-map */
8890 if (filter
->usmap
.name
)
8891 json_object_string_add(json_addr
,
8892 "selectiveUnsuppressRouteMap",
8893 filter
->usmap
.name
);
8895 /* Receive prefix count */
8896 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8897 p
->pcount
[afi
][safi
]);
8898 if (paf
&& PAF_SUBGRP(paf
))
8899 json_object_int_add(json_addr
, "sentPrefixCounter",
8900 (PAF_SUBGRP(paf
))->scount
);
8902 /* Maximum prefix */
8903 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8904 json_object_int_add(json_addr
, "prefixAllowedMax",
8905 p
->pmax
[afi
][safi
]);
8906 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8907 PEER_FLAG_MAX_PREFIX_WARNING
))
8908 json_object_boolean_true_add(
8909 json_addr
, "prefixAllowedMaxWarning");
8910 json_object_int_add(json_addr
,
8911 "prefixAllowedWarningThresh",
8912 p
->pmax_threshold
[afi
][safi
]);
8913 if (p
->pmax_restart
[afi
][safi
])
8914 json_object_int_add(
8916 "prefixAllowedRestartIntervalMsecs",
8917 p
->pmax_restart
[afi
][safi
] * 60000);
8919 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8923 filter
= &p
->filter
[afi
][safi
];
8925 vty_out(vty
, " For address family: %s\n",
8926 afi_safi_print(afi
, safi
));
8928 if (peer_group_active(p
))
8929 vty_out(vty
, " %s peer-group member\n",
8932 paf
= peer_af_find(p
, afi
, safi
);
8933 if (paf
&& PAF_SUBGRP(paf
)) {
8934 vty_out(vty
, " Update group %" PRIu64
8935 ", subgroup %" PRIu64
"\n",
8936 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8937 vty_out(vty
, " Packet Queue length %d\n",
8938 bpacket_queue_virtual_length(paf
));
8940 vty_out(vty
, " Not part of any update group\n");
8942 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8943 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8944 PEER_CAP_ORF_PREFIX_SM_RCV
)
8945 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8946 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8947 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8948 PEER_CAP_ORF_PREFIX_RM_ADV
)
8949 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8950 PEER_CAP_ORF_PREFIX_RM_RCV
)
8951 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8952 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8953 vty_out(vty
, " AF-dependant capabilities:\n");
8955 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8956 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8957 PEER_CAP_ORF_PREFIX_SM_RCV
)
8958 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8959 PEER_CAP_ORF_PREFIX_RM_ADV
)
8960 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8961 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8963 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8965 bgp_show_peer_afi_orf_cap(
8966 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8967 PEER_CAP_ORF_PREFIX_RM_ADV
,
8968 PEER_CAP_ORF_PREFIX_SM_RCV
,
8969 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8971 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8972 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8973 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8974 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8975 PEER_CAP_ORF_PREFIX_RM_ADV
)
8976 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8977 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8979 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8980 ORF_TYPE_PREFIX_OLD
);
8981 bgp_show_peer_afi_orf_cap(
8982 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8983 PEER_CAP_ORF_PREFIX_RM_ADV
,
8984 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8985 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8988 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8989 orf_pfx_count
= prefix_bgp_show_prefix_list(
8990 NULL
, afi
, orf_pfx_name
, use_json
);
8992 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8993 PEER_STATUS_ORF_PREFIX_SEND
)
8995 vty_out(vty
, " Outbound Route Filter (ORF):");
8996 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8997 PEER_STATUS_ORF_PREFIX_SEND
))
8998 vty_out(vty
, " sent;");
9000 vty_out(vty
, " received (%d entries)",
9004 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9005 PEER_STATUS_ORF_WAIT_REFRESH
))
9007 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
9009 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9010 PEER_FLAG_REFLECTOR_CLIENT
))
9011 vty_out(vty
, " Route-Reflector Client\n");
9012 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9013 PEER_FLAG_RSERVER_CLIENT
))
9014 vty_out(vty
, " Route-Server Client\n");
9015 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9017 " Inbound soft reconfiguration allowed\n");
9019 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9020 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9022 " Private AS numbers (all) replaced in updates to this neighbor\n");
9023 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9024 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9026 " Private AS numbers replaced in updates to this neighbor\n");
9027 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9028 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9030 " Private AS numbers (all) removed in updates to this neighbor\n");
9031 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9032 PEER_FLAG_REMOVE_PRIVATE_AS
))
9034 " Private AS numbers removed in updates to this neighbor\n");
9036 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9037 vty_out(vty
, " %s\n",
9038 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9039 ->human_description
);
9041 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9043 " Override ASNs in outbound updates if aspath equals remote-as\n");
9045 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9046 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9047 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9048 vty_out(vty
, " NEXT_HOP is always this router\n");
9049 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9050 PEER_FLAG_AS_PATH_UNCHANGED
))
9052 " AS_PATH is propagated unchanged to this neighbor\n");
9053 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9054 PEER_FLAG_NEXTHOP_UNCHANGED
))
9056 " NEXT_HOP is propagated unchanged to this neighbor\n");
9057 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9059 " MED is propagated unchanged to this neighbor\n");
9060 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9061 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9062 PEER_FLAG_SEND_EXT_COMMUNITY
)
9063 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9064 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9066 " Community attribute sent to this neighbor");
9067 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9068 PEER_FLAG_SEND_COMMUNITY
)
9069 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9070 PEER_FLAG_SEND_EXT_COMMUNITY
)
9071 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9072 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9073 vty_out(vty
, "(all)\n");
9074 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9075 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9076 vty_out(vty
, "(large)\n");
9077 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9078 PEER_FLAG_SEND_EXT_COMMUNITY
))
9079 vty_out(vty
, "(extended)\n");
9081 vty_out(vty
, "(standard)\n");
9083 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9084 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9085 vty_out(vty
, " Default information originate,");
9087 if (p
->default_rmap
[afi
][safi
].name
)
9088 vty_out(vty
, " default route-map %s%s,",
9089 p
->default_rmap
[afi
][safi
].map
? "*"
9091 p
->default_rmap
[afi
][safi
].name
);
9092 if (paf
&& PAF_SUBGRP(paf
)
9093 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9094 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9095 vty_out(vty
, " default sent\n");
9097 vty_out(vty
, " default not sent\n");
9100 /* advertise-vni-all */
9101 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9102 if (is_evpn_enabled())
9103 vty_out(vty
, " advertise-all-vni\n");
9106 if (filter
->plist
[FILTER_IN
].name
9107 || filter
->dlist
[FILTER_IN
].name
9108 || filter
->aslist
[FILTER_IN
].name
9109 || filter
->map
[RMAP_IN
].name
)
9110 vty_out(vty
, " Inbound path policy configured\n");
9111 if (filter
->plist
[FILTER_OUT
].name
9112 || filter
->dlist
[FILTER_OUT
].name
9113 || filter
->aslist
[FILTER_OUT
].name
9114 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9115 vty_out(vty
, " Outbound path policy configured\n");
9118 if (filter
->plist
[FILTER_IN
].name
)
9120 " Incoming update prefix filter list is %s%s\n",
9121 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9122 filter
->plist
[FILTER_IN
].name
);
9123 if (filter
->plist
[FILTER_OUT
].name
)
9125 " Outgoing update prefix filter list is %s%s\n",
9126 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9127 filter
->plist
[FILTER_OUT
].name
);
9129 /* distribute-list */
9130 if (filter
->dlist
[FILTER_IN
].name
)
9132 " Incoming update network filter list is %s%s\n",
9133 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9134 filter
->dlist
[FILTER_IN
].name
);
9135 if (filter
->dlist
[FILTER_OUT
].name
)
9137 " Outgoing update network filter list is %s%s\n",
9138 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9139 filter
->dlist
[FILTER_OUT
].name
);
9142 if (filter
->aslist
[FILTER_IN
].name
)
9144 " Incoming update AS path filter list is %s%s\n",
9145 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9146 filter
->aslist
[FILTER_IN
].name
);
9147 if (filter
->aslist
[FILTER_OUT
].name
)
9149 " Outgoing update AS path filter list is %s%s\n",
9150 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9151 filter
->aslist
[FILTER_OUT
].name
);
9154 if (filter
->map
[RMAP_IN
].name
)
9156 " Route map for incoming advertisements is %s%s\n",
9157 filter
->map
[RMAP_IN
].map
? "*" : "",
9158 filter
->map
[RMAP_IN
].name
);
9159 if (filter
->map
[RMAP_OUT
].name
)
9161 " Route map for outgoing advertisements is %s%s\n",
9162 filter
->map
[RMAP_OUT
].map
? "*" : "",
9163 filter
->map
[RMAP_OUT
].name
);
9165 /* ebgp-requires-policy (inbound) */
9166 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9167 && !bgp_inbound_policy_exists(p
, filter
))
9169 " Inbound updates discarded due to missing policy\n");
9171 /* ebgp-requires-policy (outbound) */
9172 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9173 && !bgp_outbound_policy_exists(p
, filter
))
9175 " Outbound updates discarded due to missing policy\n");
9177 /* unsuppress-map */
9178 if (filter
->usmap
.name
)
9180 " Route map for selective unsuppress is %s%s\n",
9181 filter
->usmap
.map
? "*" : "",
9182 filter
->usmap
.name
);
9184 /* Receive prefix count */
9185 vty_out(vty
, " %" PRIu32
" accepted prefixes\n",
9186 p
->pcount
[afi
][safi
]);
9188 /* Maximum prefix */
9189 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9191 " Maximum prefixes allowed %" PRIu32
"%s\n",
9193 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9194 PEER_FLAG_MAX_PREFIX_WARNING
)
9197 vty_out(vty
, " Threshold for warning message %d%%",
9198 p
->pmax_threshold
[afi
][safi
]);
9199 if (p
->pmax_restart
[afi
][safi
])
9200 vty_out(vty
, ", restart interval %d min",
9201 p
->pmax_restart
[afi
][safi
]);
9209 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9213 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9214 char timebuf
[BGP_UPTIME_LEN
];
9216 const char *subcode_str
;
9217 const char *code_str
;
9222 json_object
*json_neigh
= NULL
;
9228 json_neigh
= json_object_new_object();
9230 memset(dn_flag
, '\0', sizeof(dn_flag
));
9231 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9235 if (p
->conf_if
) /* Configured interface name. */
9236 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9237 BGP_PEER_SU_UNSPEC(p
)
9239 : sockunion2str(&p
->su
, buf
,
9241 else /* Configured IP address. */
9242 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9247 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9248 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9250 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9251 json_object_string_add(
9252 json_neigh
, "bgpNeighborAddr",
9253 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9255 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9257 if (p
->change_local_as
)
9258 json_object_int_add(json_neigh
, "localAs",
9259 p
->change_local_as
);
9261 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9263 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9264 json_object_boolean_true_add(json_neigh
,
9265 "localAsNoPrepend");
9267 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9268 json_object_boolean_true_add(json_neigh
,
9269 "localAsReplaceAs");
9271 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9272 || (p
->as_type
== AS_INTERNAL
))
9273 vty_out(vty
, "remote AS %u, ", p
->as
);
9275 vty_out(vty
, "remote AS Unspecified, ");
9276 vty_out(vty
, "local AS %u%s%s, ",
9277 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9278 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9281 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9285 /* peer type internal or confed-internal */
9286 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9288 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9289 json_object_boolean_true_add(
9290 json_neigh
, "nbrConfedInternalLink");
9292 json_object_boolean_true_add(json_neigh
,
9295 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9296 vty_out(vty
, "confed-internal link\n");
9298 vty_out(vty
, "internal link\n");
9300 /* peer type external or confed-external */
9301 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9303 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9304 json_object_boolean_true_add(
9305 json_neigh
, "nbrConfedExternalLink");
9307 json_object_boolean_true_add(json_neigh
,
9310 if (bgp_confederation_peers_check(bgp
, p
->as
))
9311 vty_out(vty
, "confed-external link\n");
9313 vty_out(vty
, "external link\n");
9317 json_object_boolean_true_add(json_neigh
,
9318 "nbrUnspecifiedLink");
9320 vty_out(vty
, "unspecified link\n");
9326 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9328 vty_out(vty
, " Description: %s\n", p
->desc
);
9334 json_object_string_add(json_neigh
, "hostname",
9338 json_object_string_add(json_neigh
, "domainname",
9341 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9342 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9345 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9352 json_object_string_add(json_neigh
, "peerGroup",
9356 struct prefix prefix
, *range
= NULL
;
9358 sockunion2hostprefix(&(p
->su
), &prefix
);
9359 range
= peer_group_lookup_dynamic_neighbor_range(
9363 prefix2str(range
, buf1
, sizeof(buf1
));
9364 json_object_string_add(
9366 "peerSubnetRangeGroup", buf1
);
9371 " Member of peer-group %s for session parameters\n",
9375 struct prefix prefix
, *range
= NULL
;
9377 sockunion2hostprefix(&(p
->su
), &prefix
);
9378 range
= peer_group_lookup_dynamic_neighbor_range(
9382 prefix2str(range
, buf1
, sizeof(buf1
));
9384 " Belongs to the subnet range group: %s\n",
9392 /* Administrative shutdown. */
9393 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9394 json_object_boolean_true_add(json_neigh
,
9398 json_object_int_add(json_neigh
, "bgpVersion", 4);
9399 json_object_string_add(
9400 json_neigh
, "remoteRouterId",
9401 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9402 json_object_string_add(
9403 json_neigh
, "localRouterId",
9404 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9408 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9409 && bgp_confederation_peers_check(bgp
, p
->as
))
9410 json_object_boolean_true_add(json_neigh
,
9414 json_object_string_add(
9415 json_neigh
, "bgpState",
9416 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9418 if (p
->status
== Established
) {
9421 uptime
= bgp_clock();
9422 uptime
-= p
->uptime
;
9423 epoch_tbuf
= time(NULL
) - uptime
;
9425 #if CONFDATE > 20200101
9427 "bgpTimerUp should be deprecated and can be removed now");
9430 * bgpTimerUp was miliseconds that was accurate
9431 * up to 1 day, then the value returned
9432 * became garbage. So in order to provide
9433 * some level of backwards compatability,
9434 * we still provde the data, but now
9435 * we are returning the correct value
9436 * and also adding a new bgpTimerUpMsec
9437 * which will allow us to deprecate
9440 json_object_int_add(json_neigh
, "bgpTimerUp",
9442 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9444 json_object_string_add(json_neigh
, "bgpTimerUpString",
9445 peer_uptime(p
->uptime
, timebuf
,
9448 json_object_int_add(json_neigh
,
9449 "bgpTimerUpEstablishedEpoch",
9453 else if (p
->status
== Active
) {
9454 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9455 json_object_string_add(json_neigh
, "bgpStateIs",
9457 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9458 json_object_string_add(json_neigh
, "bgpStateIs",
9466 uptime
= bgp_clock();
9467 uptime
-= p
->readtime
;
9468 tm
= gmtime(&uptime
);
9469 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9470 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9471 + (tm
->tm_hour
* 3600000));
9473 uptime
= bgp_clock();
9474 uptime
-= p
->last_write
;
9475 tm
= gmtime(&uptime
);
9476 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9477 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9478 + (tm
->tm_hour
* 3600000));
9480 uptime
= bgp_clock();
9481 uptime
-= p
->update_time
;
9482 tm
= gmtime(&uptime
);
9483 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9484 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9485 + (tm
->tm_hour
* 3600000));
9487 /* Configured timer values. */
9488 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9489 p
->v_holdtime
* 1000);
9490 json_object_int_add(json_neigh
,
9491 "bgpTimerKeepAliveIntervalMsecs",
9492 p
->v_keepalive
* 1000);
9493 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9494 json_object_int_add(json_neigh
,
9495 "bgpTimerConfiguredHoldTimeMsecs",
9496 p
->holdtime
* 1000);
9497 json_object_int_add(
9499 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9500 p
->keepalive
* 1000);
9501 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9502 || (bgp
->default_keepalive
9503 != BGP_DEFAULT_KEEPALIVE
)) {
9504 json_object_int_add(json_neigh
,
9505 "bgpTimerConfiguredHoldTimeMsecs",
9506 bgp
->default_holdtime
);
9507 json_object_int_add(
9509 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9510 bgp
->default_keepalive
);
9513 /* Administrative shutdown. */
9514 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9515 vty_out(vty
, " Administratively shut down\n");
9518 vty_out(vty
, " BGP version 4");
9519 vty_out(vty
, ", remote router ID %s",
9520 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9521 vty_out(vty
, ", local router ID %s\n",
9522 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9526 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9527 && bgp_confederation_peers_check(bgp
, p
->as
))
9529 " Neighbor under common administration\n");
9532 vty_out(vty
, " BGP state = %s",
9533 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9535 if (p
->status
== Established
)
9536 vty_out(vty
, ", up for %8s",
9537 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9540 else if (p
->status
== Active
) {
9541 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9542 vty_out(vty
, " (passive)");
9543 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9544 vty_out(vty
, " (NSF passive)");
9549 vty_out(vty
, " Last read %s",
9550 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9552 vty_out(vty
, ", Last write %s\n",
9553 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9556 /* Configured timer values. */
9558 " Hold time is %d, keepalive interval is %d seconds\n",
9559 p
->v_holdtime
, p
->v_keepalive
);
9560 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9561 vty_out(vty
, " Configured hold time is %d",
9563 vty_out(vty
, ", keepalive interval is %d seconds\n",
9565 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9566 || (bgp
->default_keepalive
9567 != BGP_DEFAULT_KEEPALIVE
)) {
9568 vty_out(vty
, " Configured hold time is %d",
9569 bgp
->default_holdtime
);
9570 vty_out(vty
, ", keepalive interval is %d seconds\n",
9571 bgp
->default_keepalive
);
9575 if (p
->status
== Established
) {
9576 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9577 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9578 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9579 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9580 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9581 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9582 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9583 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9584 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9585 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9586 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9587 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9588 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9589 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9590 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9591 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9592 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9593 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9594 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9595 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9597 json_object
*json_cap
= NULL
;
9599 json_cap
= json_object_new_object();
9602 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9603 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9604 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9605 && CHECK_FLAG(p
->cap
,
9607 json_object_string_add(
9608 json_cap
, "4byteAs",
9609 "advertisedAndReceived");
9610 else if (CHECK_FLAG(p
->cap
,
9612 json_object_string_add(
9613 json_cap
, "4byteAs",
9615 else if (CHECK_FLAG(p
->cap
,
9617 json_object_string_add(
9618 json_cap
, "4byteAs",
9623 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9624 || CHECK_FLAG(p
->cap
,
9625 PEER_CAP_ADDPATH_ADV
)) {
9626 json_object
*json_add
= NULL
;
9627 const char *print_store
;
9629 json_add
= json_object_new_object();
9631 FOREACH_AFI_SAFI (afi
, safi
) {
9632 json_object
*json_sub
= NULL
;
9634 json_object_new_object();
9635 print_store
= afi_safi_print(
9641 PEER_CAP_ADDPATH_AF_TX_ADV
)
9645 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9650 PEER_CAP_ADDPATH_AF_TX_ADV
)
9655 PEER_CAP_ADDPATH_AF_TX_RCV
))
9656 json_object_boolean_true_add(
9658 "txAdvertisedAndReceived");
9664 PEER_CAP_ADDPATH_AF_TX_ADV
))
9665 json_object_boolean_true_add(
9673 PEER_CAP_ADDPATH_AF_TX_RCV
))
9674 json_object_boolean_true_add(
9682 PEER_CAP_ADDPATH_AF_RX_ADV
)
9686 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9691 PEER_CAP_ADDPATH_AF_RX_ADV
)
9696 PEER_CAP_ADDPATH_AF_RX_RCV
))
9697 json_object_boolean_true_add(
9699 "rxAdvertisedAndReceived");
9705 PEER_CAP_ADDPATH_AF_RX_ADV
))
9706 json_object_boolean_true_add(
9714 PEER_CAP_ADDPATH_AF_RX_RCV
))
9715 json_object_boolean_true_add(
9723 PEER_CAP_ADDPATH_AF_TX_ADV
)
9727 PEER_CAP_ADDPATH_AF_TX_RCV
)
9731 PEER_CAP_ADDPATH_AF_RX_ADV
)
9735 PEER_CAP_ADDPATH_AF_RX_RCV
))
9736 json_object_object_add(
9745 json_object_object_add(
9746 json_cap
, "addPath", json_add
);
9750 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9751 || CHECK_FLAG(p
->cap
,
9752 PEER_CAP_DYNAMIC_ADV
)) {
9753 if (CHECK_FLAG(p
->cap
,
9754 PEER_CAP_DYNAMIC_ADV
)
9755 && CHECK_FLAG(p
->cap
,
9756 PEER_CAP_DYNAMIC_RCV
))
9757 json_object_string_add(
9758 json_cap
, "dynamic",
9759 "advertisedAndReceived");
9760 else if (CHECK_FLAG(
9762 PEER_CAP_DYNAMIC_ADV
))
9763 json_object_string_add(
9764 json_cap
, "dynamic",
9766 else if (CHECK_FLAG(
9768 PEER_CAP_DYNAMIC_RCV
))
9769 json_object_string_add(
9770 json_cap
, "dynamic",
9774 /* Extended nexthop */
9775 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9776 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9777 json_object
*json_nxt
= NULL
;
9778 const char *print_store
;
9781 if (CHECK_FLAG(p
->cap
,
9783 && CHECK_FLAG(p
->cap
,
9785 json_object_string_add(
9788 "advertisedAndReceived");
9789 else if (CHECK_FLAG(p
->cap
,
9791 json_object_string_add(
9795 else if (CHECK_FLAG(p
->cap
,
9797 json_object_string_add(
9802 if (CHECK_FLAG(p
->cap
,
9803 PEER_CAP_ENHE_RCV
)) {
9805 json_object_new_object();
9807 for (safi
= SAFI_UNICAST
;
9808 safi
< SAFI_MAX
; safi
++) {
9813 PEER_CAP_ENHE_AF_RCV
)) {
9814 print_store
= afi_safi_print(
9817 json_object_string_add(
9820 "recieved"); /* misspelled for compatibility */
9823 json_object_object_add(
9825 "extendedNexthopFamililesByPeer",
9831 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9832 || CHECK_FLAG(p
->cap
,
9833 PEER_CAP_REFRESH_NEW_RCV
)
9834 || CHECK_FLAG(p
->cap
,
9835 PEER_CAP_REFRESH_OLD_RCV
)) {
9836 if (CHECK_FLAG(p
->cap
,
9837 PEER_CAP_REFRESH_ADV
)
9840 PEER_CAP_REFRESH_NEW_RCV
)
9843 PEER_CAP_REFRESH_OLD_RCV
))) {
9846 PEER_CAP_REFRESH_OLD_RCV
)
9849 PEER_CAP_REFRESH_NEW_RCV
))
9850 json_object_string_add(
9853 "advertisedAndReceivedOldNew");
9857 PEER_CAP_REFRESH_OLD_RCV
))
9858 json_object_string_add(
9861 "advertisedAndReceivedOld");
9863 json_object_string_add(
9866 "advertisedAndReceivedNew");
9871 PEER_CAP_REFRESH_ADV
))
9872 json_object_string_add(
9879 PEER_CAP_REFRESH_NEW_RCV
)
9882 PEER_CAP_REFRESH_OLD_RCV
))
9883 json_object_string_add(
9889 /* Multiprotocol Extensions */
9890 json_object
*json_multi
= NULL
;
9891 json_multi
= json_object_new_object();
9893 FOREACH_AFI_SAFI (afi
, safi
) {
9894 if (p
->afc_adv
[afi
][safi
]
9895 || p
->afc_recv
[afi
][safi
]) {
9896 json_object
*json_exten
= NULL
;
9898 json_object_new_object();
9900 if (p
->afc_adv
[afi
][safi
]
9901 && p
->afc_recv
[afi
][safi
])
9902 json_object_boolean_true_add(
9904 "advertisedAndReceived");
9905 else if (p
->afc_adv
[afi
][safi
])
9906 json_object_boolean_true_add(
9909 else if (p
->afc_recv
[afi
][safi
])
9910 json_object_boolean_true_add(
9914 json_object_object_add(
9921 json_object_object_add(
9922 json_cap
, "multiprotocolExtensions",
9925 /* Hostname capabilities */
9926 json_object
*json_hname
= NULL
;
9928 json_hname
= json_object_new_object();
9930 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9931 json_object_string_add(
9932 json_hname
, "advHostName",
9933 bgp
->peer_self
->hostname
9937 json_object_string_add(
9938 json_hname
, "advDomainName",
9939 bgp
->peer_self
->domainname
9946 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9947 json_object_string_add(
9948 json_hname
, "rcvHostName",
9949 p
->hostname
? p
->hostname
9951 json_object_string_add(
9952 json_hname
, "rcvDomainName",
9953 p
->domainname
? p
->domainname
9957 json_object_object_add(json_cap
, "hostName",
9960 /* Gracefull Restart */
9961 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9962 || CHECK_FLAG(p
->cap
,
9963 PEER_CAP_RESTART_ADV
)) {
9964 if (CHECK_FLAG(p
->cap
,
9965 PEER_CAP_RESTART_ADV
)
9966 && CHECK_FLAG(p
->cap
,
9967 PEER_CAP_RESTART_RCV
))
9968 json_object_string_add(
9971 "advertisedAndReceived");
9972 else if (CHECK_FLAG(
9974 PEER_CAP_RESTART_ADV
))
9975 json_object_string_add(
9977 "gracefulRestartCapability",
9979 else if (CHECK_FLAG(
9981 PEER_CAP_RESTART_RCV
))
9982 json_object_string_add(
9984 "gracefulRestartCapability",
9987 if (CHECK_FLAG(p
->cap
,
9988 PEER_CAP_RESTART_RCV
)) {
9989 int restart_af_count
= 0;
9990 json_object
*json_restart
=
9993 json_object_new_object();
9995 json_object_int_add(
9997 "gracefulRestartRemoteTimerMsecs",
9998 p
->v_gr_restart
* 1000);
10000 FOREACH_AFI_SAFI (afi
, safi
) {
10005 PEER_CAP_RESTART_AF_RCV
)) {
10010 json_object_new_object();
10016 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10017 json_object_boolean_true_add(
10020 restart_af_count
++;
10021 json_object_object_add(
10029 if (!restart_af_count
) {
10030 json_object_string_add(
10032 "addressFamiliesByPeer",
10037 json_object_object_add(
10039 "addressFamiliesByPeer",
10043 json_object_object_add(json_neigh
,
10044 "neighborCapabilities",
10047 vty_out(vty
, " Neighbor capabilities:\n");
10050 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10051 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10052 vty_out(vty
, " 4 Byte AS:");
10053 if (CHECK_FLAG(p
->cap
,
10055 vty_out(vty
, " advertised");
10056 if (CHECK_FLAG(p
->cap
,
10058 vty_out(vty
, " %sreceived",
10064 vty_out(vty
, "\n");
10068 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10069 || CHECK_FLAG(p
->cap
,
10070 PEER_CAP_ADDPATH_ADV
)) {
10071 vty_out(vty
, " AddPath:\n");
10073 FOREACH_AFI_SAFI (afi
, safi
) {
10077 PEER_CAP_ADDPATH_AF_TX_ADV
)
10081 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10092 PEER_CAP_ADDPATH_AF_TX_ADV
))
10103 PEER_CAP_ADDPATH_AF_TX_RCV
))
10110 PEER_CAP_ADDPATH_AF_TX_ADV
)
10114 vty_out(vty
, "\n");
10120 PEER_CAP_ADDPATH_AF_RX_ADV
)
10124 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10135 PEER_CAP_ADDPATH_AF_RX_ADV
))
10146 PEER_CAP_ADDPATH_AF_RX_RCV
))
10153 PEER_CAP_ADDPATH_AF_RX_ADV
)
10157 vty_out(vty
, "\n");
10163 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10164 || CHECK_FLAG(p
->cap
,
10165 PEER_CAP_DYNAMIC_ADV
)) {
10166 vty_out(vty
, " Dynamic:");
10167 if (CHECK_FLAG(p
->cap
,
10168 PEER_CAP_DYNAMIC_ADV
))
10169 vty_out(vty
, " advertised");
10170 if (CHECK_FLAG(p
->cap
,
10171 PEER_CAP_DYNAMIC_RCV
))
10172 vty_out(vty
, " %sreceived",
10175 PEER_CAP_DYNAMIC_ADV
)
10178 vty_out(vty
, "\n");
10181 /* Extended nexthop */
10182 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10183 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10184 vty_out(vty
, " Extended nexthop:");
10185 if (CHECK_FLAG(p
->cap
,
10186 PEER_CAP_ENHE_ADV
))
10187 vty_out(vty
, " advertised");
10188 if (CHECK_FLAG(p
->cap
,
10189 PEER_CAP_ENHE_RCV
))
10190 vty_out(vty
, " %sreceived",
10196 vty_out(vty
, "\n");
10198 if (CHECK_FLAG(p
->cap
,
10199 PEER_CAP_ENHE_RCV
)) {
10201 " Address families by peer:\n ");
10202 for (safi
= SAFI_UNICAST
;
10203 safi
< SAFI_MAX
; safi
++)
10208 PEER_CAP_ENHE_AF_RCV
))
10217 /* Route Refresh */
10218 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10219 || CHECK_FLAG(p
->cap
,
10220 PEER_CAP_REFRESH_NEW_RCV
)
10221 || CHECK_FLAG(p
->cap
,
10222 PEER_CAP_REFRESH_OLD_RCV
)) {
10223 vty_out(vty
, " Route refresh:");
10224 if (CHECK_FLAG(p
->cap
,
10225 PEER_CAP_REFRESH_ADV
))
10226 vty_out(vty
, " advertised");
10227 if (CHECK_FLAG(p
->cap
,
10228 PEER_CAP_REFRESH_NEW_RCV
)
10231 PEER_CAP_REFRESH_OLD_RCV
))
10232 vty_out(vty
, " %sreceived(%s)",
10235 PEER_CAP_REFRESH_ADV
)
10240 PEER_CAP_REFRESH_OLD_RCV
)
10243 PEER_CAP_REFRESH_NEW_RCV
))
10247 PEER_CAP_REFRESH_OLD_RCV
)
10251 vty_out(vty
, "\n");
10254 /* Multiprotocol Extensions */
10255 FOREACH_AFI_SAFI (afi
, safi
)
10256 if (p
->afc_adv
[afi
][safi
]
10257 || p
->afc_recv
[afi
][safi
]) {
10259 " Address Family %s:",
10260 afi_safi_print(afi
,
10262 if (p
->afc_adv
[afi
][safi
])
10265 if (p
->afc_recv
[afi
][safi
])
10272 vty_out(vty
, "\n");
10275 /* Hostname capability */
10276 vty_out(vty
, " Hostname Capability:");
10278 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10280 " advertised (name: %s,domain name: %s)",
10281 bgp
->peer_self
->hostname
10285 bgp
->peer_self
->domainname
10290 vty_out(vty
, " not advertised");
10293 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10295 " received (name: %s,domain name: %s)",
10296 p
->hostname
? p
->hostname
10298 p
->domainname
? p
->domainname
10301 vty_out(vty
, " not received");
10304 vty_out(vty
, "\n");
10306 /* Gracefull Restart */
10307 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10308 || CHECK_FLAG(p
->cap
,
10309 PEER_CAP_RESTART_ADV
)) {
10311 " Graceful Restart Capabilty:");
10312 if (CHECK_FLAG(p
->cap
,
10313 PEER_CAP_RESTART_ADV
))
10314 vty_out(vty
, " advertised");
10315 if (CHECK_FLAG(p
->cap
,
10316 PEER_CAP_RESTART_RCV
))
10317 vty_out(vty
, " %sreceived",
10320 PEER_CAP_RESTART_ADV
)
10323 vty_out(vty
, "\n");
10325 if (CHECK_FLAG(p
->cap
,
10326 PEER_CAP_RESTART_RCV
)) {
10327 int restart_af_count
= 0;
10330 " Remote Restart timer is %d seconds\n",
10333 " Address families by peer:\n ");
10335 FOREACH_AFI_SAFI (afi
, safi
)
10340 PEER_CAP_RESTART_AF_RCV
)) {
10353 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10355 : "not preserved");
10356 restart_af_count
++;
10358 if (!restart_af_count
)
10359 vty_out(vty
, "none");
10360 vty_out(vty
, "\n");
10367 /* graceful restart information */
10368 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10369 || p
->t_gr_stale
) {
10370 json_object
*json_grace
= NULL
;
10371 json_object
*json_grace_send
= NULL
;
10372 json_object
*json_grace_recv
= NULL
;
10373 int eor_send_af_count
= 0;
10374 int eor_receive_af_count
= 0;
10377 json_grace
= json_object_new_object();
10378 json_grace_send
= json_object_new_object();
10379 json_grace_recv
= json_object_new_object();
10381 if (p
->status
== Established
) {
10382 FOREACH_AFI_SAFI (afi
, safi
) {
10383 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10384 PEER_STATUS_EOR_SEND
)) {
10385 json_object_boolean_true_add(
10387 afi_safi_print(afi
,
10389 eor_send_af_count
++;
10392 FOREACH_AFI_SAFI (afi
, safi
) {
10394 p
->af_sflags
[afi
][safi
],
10395 PEER_STATUS_EOR_RECEIVED
)) {
10396 json_object_boolean_true_add(
10398 afi_safi_print(afi
,
10400 eor_receive_af_count
++;
10405 json_object_object_add(json_grace
, "endOfRibSend",
10407 json_object_object_add(json_grace
, "endOfRibRecv",
10410 if (p
->t_gr_restart
)
10411 json_object_int_add(json_grace
,
10412 "gracefulRestartTimerMsecs",
10413 thread_timer_remain_second(
10418 json_object_int_add(
10420 "gracefulStalepathTimerMsecs",
10421 thread_timer_remain_second(
10425 json_object_object_add(
10426 json_neigh
, "gracefulRestartInfo", json_grace
);
10428 vty_out(vty
, " Graceful restart information:\n");
10429 if (p
->status
== Established
) {
10430 vty_out(vty
, " End-of-RIB send: ");
10431 FOREACH_AFI_SAFI (afi
, safi
) {
10432 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10433 PEER_STATUS_EOR_SEND
)) {
10434 vty_out(vty
, "%s%s",
10435 eor_send_af_count
? ", "
10437 afi_safi_print(afi
,
10439 eor_send_af_count
++;
10442 vty_out(vty
, "\n");
10443 vty_out(vty
, " End-of-RIB received: ");
10444 FOREACH_AFI_SAFI (afi
, safi
) {
10446 p
->af_sflags
[afi
][safi
],
10447 PEER_STATUS_EOR_RECEIVED
)) {
10448 vty_out(vty
, "%s%s",
10449 eor_receive_af_count
10452 afi_safi_print(afi
,
10454 eor_receive_af_count
++;
10457 vty_out(vty
, "\n");
10460 if (p
->t_gr_restart
)
10462 " The remaining time of restart timer is %ld\n",
10463 thread_timer_remain_second(
10468 " The remaining time of stalepath timer is %ld\n",
10469 thread_timer_remain_second(
10474 json_object
*json_stat
= NULL
;
10475 json_stat
= json_object_new_object();
10476 /* Packet counts. */
10477 json_object_int_add(json_stat
, "depthInq", 0);
10478 json_object_int_add(json_stat
, "depthOutq",
10479 (unsigned long)p
->obuf
->count
);
10480 json_object_int_add(json_stat
, "opensSent",
10481 atomic_load_explicit(&p
->open_out
,
10482 memory_order_relaxed
));
10483 json_object_int_add(json_stat
, "opensRecv",
10484 atomic_load_explicit(&p
->open_in
,
10485 memory_order_relaxed
));
10486 json_object_int_add(json_stat
, "notificationsSent",
10487 atomic_load_explicit(&p
->notify_out
,
10488 memory_order_relaxed
));
10489 json_object_int_add(json_stat
, "notificationsRecv",
10490 atomic_load_explicit(&p
->notify_in
,
10491 memory_order_relaxed
));
10492 json_object_int_add(json_stat
, "updatesSent",
10493 atomic_load_explicit(&p
->update_out
,
10494 memory_order_relaxed
));
10495 json_object_int_add(json_stat
, "updatesRecv",
10496 atomic_load_explicit(&p
->update_in
,
10497 memory_order_relaxed
));
10498 json_object_int_add(json_stat
, "keepalivesSent",
10499 atomic_load_explicit(&p
->keepalive_out
,
10500 memory_order_relaxed
));
10501 json_object_int_add(json_stat
, "keepalivesRecv",
10502 atomic_load_explicit(&p
->keepalive_in
,
10503 memory_order_relaxed
));
10504 json_object_int_add(json_stat
, "routeRefreshSent",
10505 atomic_load_explicit(&p
->refresh_out
,
10506 memory_order_relaxed
));
10507 json_object_int_add(json_stat
, "routeRefreshRecv",
10508 atomic_load_explicit(&p
->refresh_in
,
10509 memory_order_relaxed
));
10510 json_object_int_add(json_stat
, "capabilitySent",
10511 atomic_load_explicit(&p
->dynamic_cap_out
,
10512 memory_order_relaxed
));
10513 json_object_int_add(json_stat
, "capabilityRecv",
10514 atomic_load_explicit(&p
->dynamic_cap_in
,
10515 memory_order_relaxed
));
10516 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10517 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10518 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10520 /* Packet counts. */
10521 vty_out(vty
, " Message statistics:\n");
10522 vty_out(vty
, " Inq depth is 0\n");
10523 vty_out(vty
, " Outq depth is %lu\n",
10524 (unsigned long)p
->obuf
->count
);
10525 vty_out(vty
, " Sent Rcvd\n");
10526 vty_out(vty
, " Opens: %10d %10d\n",
10527 atomic_load_explicit(&p
->open_out
,
10528 memory_order_relaxed
),
10529 atomic_load_explicit(&p
->open_in
,
10530 memory_order_relaxed
));
10531 vty_out(vty
, " Notifications: %10d %10d\n",
10532 atomic_load_explicit(&p
->notify_out
,
10533 memory_order_relaxed
),
10534 atomic_load_explicit(&p
->notify_in
,
10535 memory_order_relaxed
));
10536 vty_out(vty
, " Updates: %10d %10d\n",
10537 atomic_load_explicit(&p
->update_out
,
10538 memory_order_relaxed
),
10539 atomic_load_explicit(&p
->update_in
,
10540 memory_order_relaxed
));
10541 vty_out(vty
, " Keepalives: %10d %10d\n",
10542 atomic_load_explicit(&p
->keepalive_out
,
10543 memory_order_relaxed
),
10544 atomic_load_explicit(&p
->keepalive_in
,
10545 memory_order_relaxed
));
10546 vty_out(vty
, " Route Refresh: %10d %10d\n",
10547 atomic_load_explicit(&p
->refresh_out
,
10548 memory_order_relaxed
),
10549 atomic_load_explicit(&p
->refresh_in
,
10550 memory_order_relaxed
));
10551 vty_out(vty
, " Capability: %10d %10d\n",
10552 atomic_load_explicit(&p
->dynamic_cap_out
,
10553 memory_order_relaxed
),
10554 atomic_load_explicit(&p
->dynamic_cap_in
,
10555 memory_order_relaxed
));
10556 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10561 /* advertisement-interval */
10562 json_object_int_add(json_neigh
,
10563 "minBtwnAdvertisementRunsTimerMsecs",
10564 p
->v_routeadv
* 1000);
10566 /* Update-source. */
10567 if (p
->update_if
|| p
->update_source
) {
10569 json_object_string_add(json_neigh
,
10572 else if (p
->update_source
)
10573 json_object_string_add(
10574 json_neigh
, "updateSource",
10575 sockunion2str(p
->update_source
, buf1
,
10579 /* advertisement-interval */
10581 " Minimum time between advertisement runs is %d seconds\n",
10584 /* Update-source. */
10585 if (p
->update_if
|| p
->update_source
) {
10586 vty_out(vty
, " Update source is ");
10588 vty_out(vty
, "%s", p
->update_if
);
10589 else if (p
->update_source
)
10591 sockunion2str(p
->update_source
, buf1
,
10593 vty_out(vty
, "\n");
10596 vty_out(vty
, "\n");
10599 /* Address Family Information */
10600 json_object
*json_hold
= NULL
;
10603 json_hold
= json_object_new_object();
10605 FOREACH_AFI_SAFI (afi
, safi
)
10606 if (p
->afc
[afi
][safi
])
10607 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10611 json_object_object_add(json_neigh
, "addressFamilyInfo",
10613 json_object_int_add(json_neigh
, "connectionsEstablished",
10615 json_object_int_add(json_neigh
, "connectionsDropped",
10618 vty_out(vty
, " Connections established %d; dropped %d\n",
10619 p
->established
, p
->dropped
);
10621 if (!p
->last_reset
) {
10623 json_object_string_add(json_neigh
, "lastReset",
10626 vty_out(vty
, " Last reset never\n");
10632 uptime
= bgp_clock();
10633 uptime
-= p
->resettime
;
10634 tm
= gmtime(&uptime
);
10635 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10636 (tm
->tm_sec
* 1000)
10637 + (tm
->tm_min
* 60000)
10638 + (tm
->tm_hour
* 3600000));
10639 json_object_string_add(
10640 json_neigh
, "lastResetDueTo",
10641 peer_down_str
[(int)p
->last_reset
]);
10642 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10643 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10644 char errorcodesubcode_hexstr
[5];
10645 char errorcodesubcode_str
[256];
10647 code_str
= bgp_notify_code_str(p
->notify
.code
);
10648 subcode_str
= bgp_notify_subcode_str(
10649 p
->notify
.code
, p
->notify
.subcode
);
10651 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10652 p
->notify
.code
, p
->notify
.subcode
);
10653 json_object_string_add(json_neigh
,
10654 "lastErrorCodeSubcode",
10655 errorcodesubcode_hexstr
);
10656 snprintf(errorcodesubcode_str
, 255, "%s%s",
10657 code_str
, subcode_str
);
10658 json_object_string_add(json_neigh
,
10659 "lastNotificationReason",
10660 errorcodesubcode_str
);
10661 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10662 && p
->notify
.code
== BGP_NOTIFY_CEASE
10663 && (p
->notify
.subcode
10664 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10665 || p
->notify
.subcode
10666 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10667 && p
->notify
.length
) {
10669 const char *msg_str
;
10671 msg_str
= bgp_notify_admin_message(
10672 msgbuf
, sizeof(msgbuf
),
10673 (uint8_t *)p
->notify
.data
,
10676 json_object_string_add(
10678 "lastShutdownDescription",
10683 vty_out(vty
, " Last reset %s, ",
10684 peer_uptime(p
->resettime
, timebuf
,
10685 BGP_UPTIME_LEN
, 0, NULL
));
10687 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10688 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10689 code_str
= bgp_notify_code_str(p
->notify
.code
);
10690 subcode_str
= bgp_notify_subcode_str(
10691 p
->notify
.code
, p
->notify
.subcode
);
10692 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10693 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10696 code_str
, subcode_str
);
10697 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10698 && p
->notify
.code
== BGP_NOTIFY_CEASE
10699 && (p
->notify
.subcode
10700 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10701 || p
->notify
.subcode
10702 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10703 && p
->notify
.length
) {
10705 const char *msg_str
;
10707 msg_str
= bgp_notify_admin_message(
10708 msgbuf
, sizeof(msgbuf
),
10709 (uint8_t *)p
->notify
.data
,
10713 " Message: \"%s\"\n",
10717 vty_out(vty
, "due to %s\n",
10718 peer_down_str
[(int)p
->last_reset
]);
10721 if (p
->last_reset_cause_size
) {
10722 msg
= p
->last_reset_cause
;
10724 " Message received that caused BGP to send a NOTIFICATION:\n ");
10725 for (i
= 1; i
<= p
->last_reset_cause_size
;
10727 vty_out(vty
, "%02X", *msg
++);
10729 if (i
!= p
->last_reset_cause_size
) {
10731 vty_out(vty
, "\n ");
10732 } else if (i
% 4 == 0) {
10737 vty_out(vty
, "\n");
10742 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10744 json_object_boolean_true_add(json_neigh
,
10745 "prefixesConfigExceedMax");
10748 " Peer had exceeded the max. no. of prefixes configured.\n");
10750 if (p
->t_pmax_restart
) {
10752 json_object_boolean_true_add(
10753 json_neigh
, "reducePrefixNumFrom");
10754 json_object_int_add(json_neigh
,
10755 "restartInTimerMsec",
10756 thread_timer_remain_second(
10761 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10762 p
->host
, thread_timer_remain_second(
10763 p
->t_pmax_restart
));
10766 json_object_boolean_true_add(
10768 "reducePrefixNumAndClearIpBgp");
10771 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10776 /* EBGP Multihop and GTSM */
10777 if (p
->sort
!= BGP_PEER_IBGP
) {
10779 if (p
->gtsm_hops
> 0)
10780 json_object_int_add(json_neigh
,
10781 "externalBgpNbrMaxHopsAway",
10783 else if (p
->ttl
> 1)
10784 json_object_int_add(json_neigh
,
10785 "externalBgpNbrMaxHopsAway",
10788 if (p
->gtsm_hops
> 0)
10790 " External BGP neighbor may be up to %d hops away.\n",
10792 else if (p
->ttl
> 1)
10794 " External BGP neighbor may be up to %d hops away.\n",
10798 if (p
->gtsm_hops
> 0) {
10800 json_object_int_add(json_neigh
,
10801 "internalBgpNbrMaxHopsAway",
10805 " Internal BGP neighbor may be up to %d hops away.\n",
10810 /* Local address. */
10813 json_object_string_add(json_neigh
, "hostLocal",
10814 sockunion2str(p
->su_local
, buf1
,
10816 json_object_int_add(json_neigh
, "portLocal",
10817 ntohs(p
->su_local
->sin
.sin_port
));
10819 vty_out(vty
, "Local host: %s, Local port: %d\n",
10820 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10821 ntohs(p
->su_local
->sin
.sin_port
));
10824 /* Remote address. */
10825 if (p
->su_remote
) {
10827 json_object_string_add(json_neigh
, "hostForeign",
10828 sockunion2str(p
->su_remote
, buf1
,
10830 json_object_int_add(json_neigh
, "portForeign",
10831 ntohs(p
->su_remote
->sin
.sin_port
));
10833 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10834 sockunion2str(p
->su_remote
, buf1
,
10836 ntohs(p
->su_remote
->sin
.sin_port
));
10839 /* Nexthop display. */
10842 json_object_string_add(json_neigh
, "nexthop",
10844 &p
->nexthop
.v4
, buf1
,
10846 json_object_string_add(json_neigh
, "nexthopGlobal",
10847 inet_ntop(AF_INET6
,
10848 &p
->nexthop
.v6_global
,
10849 buf1
, sizeof(buf1
)));
10850 json_object_string_add(json_neigh
, "nexthopLocal",
10851 inet_ntop(AF_INET6
,
10852 &p
->nexthop
.v6_local
,
10853 buf1
, sizeof(buf1
)));
10854 if (p
->shared_network
)
10855 json_object_string_add(json_neigh
,
10859 json_object_string_add(json_neigh
,
10861 "nonSharedNetwork");
10863 vty_out(vty
, "Nexthop: %s\n",
10864 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10866 vty_out(vty
, "Nexthop global: %s\n",
10867 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10869 vty_out(vty
, "Nexthop local: %s\n",
10870 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10872 vty_out(vty
, "BGP connection: %s\n",
10873 p
->shared_network
? "shared network"
10874 : "non shared network");
10878 /* Timer information. */
10880 json_object_int_add(json_neigh
, "connectRetryTimer",
10882 if (p
->status
== Established
&& p
->rtt
)
10883 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10886 json_object_int_add(
10887 json_neigh
, "nextStartTimerDueInMsecs",
10888 thread_timer_remain_second(p
->t_start
) * 1000);
10890 json_object_int_add(
10891 json_neigh
, "nextConnectTimerDueInMsecs",
10892 thread_timer_remain_second(p
->t_connect
)
10894 if (p
->t_routeadv
) {
10895 json_object_int_add(json_neigh
, "mraiInterval",
10897 json_object_int_add(
10898 json_neigh
, "mraiTimerExpireInMsecs",
10899 thread_timer_remain_second(p
->t_routeadv
)
10903 json_object_int_add(json_neigh
, "authenticationEnabled",
10907 json_object_string_add(json_neigh
, "readThread", "on");
10909 json_object_string_add(json_neigh
, "readThread", "off");
10911 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10912 json_object_string_add(json_neigh
, "writeThread", "on");
10914 json_object_string_add(json_neigh
, "writeThread",
10917 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10919 if (p
->status
== Established
&& p
->rtt
)
10920 vty_out(vty
, "Estimated round trip time: %d ms\n",
10923 vty_out(vty
, "Next start timer due in %ld seconds\n",
10924 thread_timer_remain_second(p
->t_start
));
10926 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10927 thread_timer_remain_second(p
->t_connect
));
10930 "MRAI (interval %u) timer expires in %ld seconds\n",
10932 thread_timer_remain_second(p
->t_routeadv
));
10934 vty_out(vty
, "Peer Authentication Enabled\n");
10936 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10937 p
->t_read
? "on" : "off",
10938 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10943 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10944 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10945 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10948 vty_out(vty
, "\n");
10950 /* BFD information. */
10951 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10954 if (p
->conf_if
) /* Configured interface name. */
10955 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10956 else /* Configured IP address. */
10957 json_object_object_add(json
, p
->host
, json_neigh
);
10961 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10962 enum show_type type
, union sockunion
*su
,
10963 const char *conf_if
, bool use_json
,
10966 struct listnode
*node
, *nnode
;
10969 bool nbr_output
= false;
10970 afi_t afi
= AFI_MAX
;
10971 safi_t safi
= SAFI_MAX
;
10973 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10975 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10979 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10980 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10985 bgp_show_peer(vty
, peer
, use_json
, json
);
10991 && !strcmp(peer
->conf_if
, conf_if
))
10993 && !strcmp(peer
->hostname
, conf_if
))) {
10995 bgp_show_peer(vty
, peer
, use_json
,
10999 if (sockunion_same(&peer
->su
, su
)) {
11001 bgp_show_peer(vty
, peer
, use_json
,
11006 case show_ipv4_peer
:
11007 case show_ipv6_peer
:
11008 FOREACH_SAFI (safi
) {
11009 if (peer
->afc
[afi
][safi
]) {
11012 && !strcmp(peer
->conf_if
, conf_if
))
11014 && !strcmp(peer
->hostname
, conf_if
))) {
11016 bgp_show_peer(vty
, peer
, use_json
,
11021 if (sockunion_same(&peer
->su
, su
)) {
11023 bgp_show_peer(vty
, peer
, use_json
,
11031 case show_ipv4_all
:
11032 case show_ipv6_all
:
11033 FOREACH_SAFI (safi
) {
11034 if (peer
->afc
[afi
][safi
]) {
11035 bgp_show_peer(vty
, peer
, use_json
, json
);
11044 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11045 type
== show_ipv6_peer
) && !find
) {
11047 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11049 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11052 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11053 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11054 vty_out(vty
, "%% No BGP neighbors found\n");
11057 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11058 json
, JSON_C_TO_STRING_PRETTY
));
11060 vty_out(vty
, "\n");
11063 return CMD_SUCCESS
;
11066 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11067 enum show_type type
,
11068 const char *ip_str
,
11071 struct listnode
*node
, *nnode
;
11073 union sockunion su
;
11074 json_object
*json
= NULL
;
11075 int ret
, is_first
= 1;
11076 bool nbr_output
= false;
11079 vty_out(vty
, "{\n");
11081 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11084 if (!(json
= json_object_new_object())) {
11086 EC_BGP_JSON_MEM_ERROR
,
11087 "Unable to allocate memory for JSON object");
11089 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11093 json_object_int_add(json
, "vrfId",
11094 (bgp
->vrf_id
== VRF_UNKNOWN
)
11096 : (int64_t)bgp
->vrf_id
);
11097 json_object_string_add(
11099 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11104 vty_out(vty
, ",\n");
11108 vty_out(vty
, "\"%s\":",
11109 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11113 vty_out(vty
, "\nInstance %s:\n",
11114 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11119 if (type
== show_peer
|| type
== show_ipv4_peer
||
11120 type
== show_ipv6_peer
) {
11121 ret
= str2sockunion(ip_str
, &su
);
11123 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11126 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11129 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11132 json_object_free(json
);
11136 vty_out(vty
, "}\n");
11137 json_object_free(json
);
11139 else if (!nbr_output
)
11140 vty_out(vty
, "%% BGP instance not found\n");
11143 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11144 enum show_type type
, const char *ip_str
,
11149 union sockunion su
;
11150 json_object
*json
= NULL
;
11153 if (strmatch(name
, "all")) {
11154 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11156 return CMD_SUCCESS
;
11158 bgp
= bgp_lookup_by_name(name
);
11161 json
= json_object_new_object();
11162 vty_out(vty
, "%s\n",
11163 json_object_to_json_string_ext(
11165 JSON_C_TO_STRING_PRETTY
));
11166 json_object_free(json
);
11169 "%% BGP instance not found\n");
11171 return CMD_WARNING
;
11175 bgp
= bgp_get_default();
11179 json
= json_object_new_object();
11181 ret
= str2sockunion(ip_str
, &su
);
11183 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11186 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11189 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11192 json_object_free(json
);
11195 vty_out(vty
, "{}\n");
11197 vty_out(vty
, "%% BGP instance not found\n");
11200 return CMD_SUCCESS
;
11203 /* "show [ip] bgp neighbors" commands. */
11204 DEFUN (show_ip_bgp_neighbors
,
11205 show_ip_bgp_neighbors_cmd
,
11206 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11210 BGP_INSTANCE_HELP_STR
11213 "Detailed information on TCP and BGP neighbor connections\n"
11214 "Neighbor to display information about\n"
11215 "Neighbor to display information about\n"
11216 "Neighbor on BGP configured interface\n"
11220 char *sh_arg
= NULL
;
11221 enum show_type sh_type
;
11222 afi_t afi
= AFI_MAX
;
11224 bool uj
= use_json(argc
, argv
);
11228 /* [<vrf> VIEWVRFNAME] */
11229 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11230 vrf
= argv
[idx
+ 1]->arg
;
11231 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11233 } else if (argv_find(argv
, argc
, "view", &idx
))
11234 /* [<view> VIEWVRFNAME] */
11235 vrf
= argv
[idx
+ 1]->arg
;
11239 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11240 sh_type
= show_ipv4_all
;
11242 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11243 sh_type
= show_ipv6_all
;
11246 sh_type
= show_all
;
11249 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11250 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11251 || argv_find(argv
, argc
, "WORD", &idx
)) {
11252 sh_type
= show_peer
;
11253 sh_arg
= argv
[idx
]->arg
;
11256 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11257 sh_type
= show_ipv4_peer
;
11258 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11259 sh_type
= show_ipv6_peer
;
11262 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11265 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11266 paths' and `show ip mbgp paths'. Those functions results are the
11268 DEFUN (show_ip_bgp_paths
,
11269 show_ip_bgp_paths_cmd
,
11270 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11275 "Path information\n")
11277 vty_out(vty
, "Address Refcnt Path\n");
11278 aspath_print_all_vty(vty
);
11279 return CMD_SUCCESS
;
11284 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11287 struct community
*com
;
11289 com
= (struct community
*)bucket
->data
;
11290 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11291 community_str(com
, false));
11294 /* Show BGP's community internal data. */
11295 DEFUN (show_ip_bgp_community_info
,
11296 show_ip_bgp_community_info_cmd
,
11297 "show [ip] bgp community-info",
11301 "List all bgp community information\n")
11303 vty_out(vty
, "Address Refcnt Community\n");
11305 hash_iterate(community_hash(),
11306 (void (*)(struct hash_bucket
*,
11307 void *))community_show_all_iterator
,
11310 return CMD_SUCCESS
;
11313 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11316 struct lcommunity
*lcom
;
11318 lcom
= (struct lcommunity
*)bucket
->data
;
11319 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11320 lcommunity_str(lcom
, false));
11323 /* Show BGP's community internal data. */
11324 DEFUN (show_ip_bgp_lcommunity_info
,
11325 show_ip_bgp_lcommunity_info_cmd
,
11326 "show ip bgp large-community-info",
11330 "List all bgp large-community information\n")
11332 vty_out(vty
, "Address Refcnt Large-community\n");
11334 hash_iterate(lcommunity_hash(),
11335 (void (*)(struct hash_bucket
*,
11336 void *))lcommunity_show_all_iterator
,
11339 return CMD_SUCCESS
;
11343 DEFUN (show_ip_bgp_attr_info
,
11344 show_ip_bgp_attr_info_cmd
,
11345 "show [ip] bgp attribute-info",
11349 "List all bgp attribute information\n")
11351 attr_show_all(vty
);
11352 return CMD_SUCCESS
;
11355 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11356 afi_t afi
, safi_t safi
,
11357 bool use_json
, json_object
*json
)
11360 struct listnode
*node
;
11362 char buf1
[INET6_ADDRSTRLEN
];
11364 vpn_policy_direction_t dir
;
11367 json_object
*json_import_vrfs
= NULL
;
11368 json_object
*json_export_vrfs
= NULL
;
11370 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11373 vty_out(vty
, "%s\n",
11374 json_object_to_json_string_ext(
11376 JSON_C_TO_STRING_PRETTY
));
11377 json_object_free(json
);
11379 return CMD_WARNING
;
11382 /* Provide context for the block */
11383 json_object_string_add(json
, "vrf", name
? name
: "default");
11384 json_object_string_add(json
, "afiSafi",
11385 afi_safi_print(afi
, safi
));
11387 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11388 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11389 json_object_string_add(json
, "importFromVrfs", "none");
11390 json_object_string_add(json
, "importRts", "none");
11392 json_import_vrfs
= json_object_new_array();
11394 for (ALL_LIST_ELEMENTS_RO(
11395 bgp
->vpn_policy
[afi
].import_vrf
,
11397 json_object_array_add(json_import_vrfs
,
11398 json_object_new_string(vname
));
11400 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11401 ecom_str
= ecommunity_ecom2str(
11402 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11403 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11404 json_object_object_add(json
, "importFromVrfs",
11406 json_object_string_add(json
, "importRts", ecom_str
);
11408 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11411 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11412 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11413 json_object_string_add(json
, "exportToVrfs", "none");
11414 json_object_string_add(json
, "routeDistinguisher",
11416 json_object_string_add(json
, "exportRts", "none");
11418 json_export_vrfs
= json_object_new_array();
11420 for (ALL_LIST_ELEMENTS_RO(
11421 bgp
->vpn_policy
[afi
].export_vrf
,
11423 json_object_array_add(json_export_vrfs
,
11424 json_object_new_string(vname
));
11425 json_object_object_add(json
, "exportToVrfs",
11427 json_object_string_add(json
, "routeDistinguisher",
11428 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11429 buf1
, RD_ADDRSTRLEN
));
11431 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11432 ecom_str
= ecommunity_ecom2str(
11433 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11434 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11435 json_object_string_add(json
, "exportRts", ecom_str
);
11437 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11441 vty_out(vty
, "%s\n",
11442 json_object_to_json_string_ext(json
,
11443 JSON_C_TO_STRING_PRETTY
));
11444 json_object_free(json
);
11447 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11450 vty_out(vty
, "%% No such BGP instance exist\n");
11451 return CMD_WARNING
;
11454 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11455 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11457 "This VRF is not importing %s routes from any other VRF\n",
11458 afi_safi_print(afi
, safi
));
11461 "This VRF is importing %s routes from the following VRFs:\n",
11462 afi_safi_print(afi
, safi
));
11464 for (ALL_LIST_ELEMENTS_RO(
11465 bgp
->vpn_policy
[afi
].import_vrf
,
11467 vty_out(vty
, " %s\n", vname
);
11469 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11470 ecom_str
= ecommunity_ecom2str(
11471 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11472 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11473 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11475 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11478 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11479 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11481 "This VRF is not exporting %s routes to any other VRF\n",
11482 afi_safi_print(afi
, safi
));
11485 "This VRF is exporting %s routes to the following VRFs:\n",
11486 afi_safi_print(afi
, safi
));
11488 for (ALL_LIST_ELEMENTS_RO(
11489 bgp
->vpn_policy
[afi
].export_vrf
,
11491 vty_out(vty
, " %s\n", vname
);
11493 vty_out(vty
, "RD: %s\n",
11494 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11495 buf1
, RD_ADDRSTRLEN
));
11497 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11498 ecom_str
= ecommunity_ecom2str(
11499 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11500 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11501 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11502 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11506 return CMD_SUCCESS
;
11509 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11510 safi_t safi
, bool use_json
)
11512 struct listnode
*node
, *nnode
;
11514 char *vrf_name
= NULL
;
11515 json_object
*json
= NULL
;
11516 json_object
*json_vrf
= NULL
;
11517 json_object
*json_vrfs
= NULL
;
11520 json
= json_object_new_object();
11521 json_vrfs
= json_object_new_object();
11524 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11526 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11527 vrf_name
= bgp
->name
;
11530 json_vrf
= json_object_new_object();
11532 vty_out(vty
, "\nInstance %s:\n",
11533 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11534 ? VRF_DEFAULT_NAME
: bgp
->name
);
11536 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11538 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11539 json_object_object_add(json_vrfs
,
11540 VRF_DEFAULT_NAME
, json_vrf
);
11542 json_object_object_add(json_vrfs
, vrf_name
,
11548 json_object_object_add(json
, "vrfs", json_vrfs
);
11549 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11550 JSON_C_TO_STRING_PRETTY
));
11551 json_object_free(json
);
11554 return CMD_SUCCESS
;
11557 /* "show [ip] bgp route-leak" command. */
11558 DEFUN (show_ip_bgp_route_leak
,
11559 show_ip_bgp_route_leak_cmd
,
11560 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11564 BGP_INSTANCE_HELP_STR
11567 "Route leaking information\n"
11571 afi_t afi
= AFI_MAX
;
11572 safi_t safi
= SAFI_MAX
;
11574 bool uj
= use_json(argc
, argv
);
11576 json_object
*json
= NULL
;
11578 /* show [ip] bgp */
11579 if (argv_find(argv
, argc
, "ip", &idx
)) {
11581 safi
= SAFI_UNICAST
;
11583 /* [vrf VIEWVRFNAME] */
11584 if (argv_find(argv
, argc
, "view", &idx
)) {
11586 "%% This command is not applicable to BGP views\n");
11587 return CMD_WARNING
;
11590 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11591 vrf
= argv
[idx
+ 1]->arg
;
11592 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11595 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11596 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11597 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11600 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11602 "%% This command is applicable only for unicast ipv4|ipv6\n");
11603 return CMD_WARNING
;
11606 if (vrf
&& strmatch(vrf
, "all"))
11607 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11610 json
= json_object_new_object();
11612 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11615 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11618 struct listnode
*node
, *nnode
;
11621 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11622 vty_out(vty
, "\nInstance %s:\n",
11623 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11626 update_group_show(bgp
, afi
, safi
, vty
, 0);
11630 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11631 int safi
, uint64_t subgrp_id
)
11636 if (strmatch(name
, "all")) {
11637 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11638 return CMD_SUCCESS
;
11640 bgp
= bgp_lookup_by_name(name
);
11643 bgp
= bgp_get_default();
11647 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11648 return CMD_SUCCESS
;
11651 DEFUN (show_ip_bgp_updgrps
,
11652 show_ip_bgp_updgrps_cmd
,
11653 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11657 BGP_INSTANCE_HELP_STR
11659 BGP_SAFI_WITH_LABEL_HELP_STR
11660 "Detailed info about dynamic update groups\n"
11661 "Specific subgroup to display detailed info for\n")
11664 afi_t afi
= AFI_IP6
;
11665 safi_t safi
= SAFI_UNICAST
;
11666 uint64_t subgrp_id
= 0;
11670 /* show [ip] bgp */
11671 if (argv_find(argv
, argc
, "ip", &idx
))
11673 /* [<vrf> VIEWVRFNAME] */
11674 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11675 vrf
= argv
[idx
+ 1]->arg
;
11676 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11678 } else if (argv_find(argv
, argc
, "view", &idx
))
11679 /* [<view> VIEWVRFNAME] */
11680 vrf
= argv
[idx
+ 1]->arg
;
11681 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11682 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11683 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11686 /* get subgroup id, if provided */
11688 if (argv
[idx
]->type
== VARIABLE_TKN
)
11689 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11691 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11694 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11695 show_bgp_instance_all_ipv6_updgrps_cmd
,
11696 "show [ip] bgp <view|vrf> all update-groups",
11700 BGP_INSTANCE_ALL_HELP_STR
11701 "Detailed info about dynamic update groups\n")
11703 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11704 return CMD_SUCCESS
;
11707 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11708 show_bgp_l2vpn_evpn_updgrps_cmd
,
11709 "show [ip] bgp l2vpn evpn update-groups",
11713 "l2vpn address family\n"
11714 "evpn sub-address family\n"
11715 "Detailed info about dynamic update groups\n")
11718 uint64_t subgrp_id
= 0;
11720 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11721 return CMD_SUCCESS
;
11724 DEFUN (show_bgp_updgrps_stats
,
11725 show_bgp_updgrps_stats_cmd
,
11726 "show [ip] bgp update-groups statistics",
11730 "Detailed info about dynamic update groups\n"
11735 bgp
= bgp_get_default();
11737 update_group_show_stats(bgp
, vty
);
11739 return CMD_SUCCESS
;
11742 DEFUN (show_bgp_instance_updgrps_stats
,
11743 show_bgp_instance_updgrps_stats_cmd
,
11744 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11748 BGP_INSTANCE_HELP_STR
11749 "Detailed info about dynamic update groups\n"
11755 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11757 update_group_show_stats(bgp
, vty
);
11759 return CMD_SUCCESS
;
11762 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11763 afi_t afi
, safi_t safi
,
11764 const char *what
, uint64_t subgrp_id
)
11769 bgp
= bgp_lookup_by_name(name
);
11771 bgp
= bgp_get_default();
11774 if (!strcmp(what
, "advertise-queue"))
11775 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11777 else if (!strcmp(what
, "advertised-routes"))
11778 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11780 else if (!strcmp(what
, "packet-queue"))
11781 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11786 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11787 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11788 "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",
11789 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11791 "Detailed info about dynamic update groups\n"
11792 "Specific subgroup to display info for\n"
11793 "Advertisement queue\n"
11794 "Announced routes\n"
11797 uint64_t subgrp_id
= 0;
11801 subgrp_id
= strtoull(sgid
, NULL
, 10);
11806 afiz
= bgp_vty_afi_from_str(afi
);
11810 afiz
= bgp_vty_afi_from_str(afi
);
11811 if (afiz
!= AFI_IP
)
11813 "%% Cannot specify both 'ip' and 'ipv6'\n");
11814 return CMD_WARNING
;
11817 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11819 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11820 return CMD_SUCCESS
;
11823 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11825 struct listnode
*node
, *nnode
;
11826 struct prefix
*range
;
11829 char buf
[PREFIX2STR_BUFFER
];
11832 const char *peer_status
;
11833 const char *af_str
;
11838 conf
= group
->conf
;
11840 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11841 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11842 group
->name
, conf
->as
);
11843 } else if (conf
->as_type
== AS_INTERNAL
) {
11844 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11845 group
->name
, group
->bgp
->as
);
11847 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11850 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11851 vty_out(vty
, " Peer-group type is internal\n");
11853 vty_out(vty
, " Peer-group type is external\n");
11855 /* Display AFs configured. */
11856 vty_out(vty
, " Configured address-families:");
11857 FOREACH_AFI_SAFI (afi
, safi
) {
11858 if (conf
->afc
[afi
][safi
]) {
11860 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11864 vty_out(vty
, " none\n");
11866 vty_out(vty
, "\n");
11868 /* Display listen ranges (for dynamic neighbors), if any */
11869 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11872 else if (afi
== AFI_IP6
)
11876 lr_count
= listcount(group
->listen_range
[afi
]);
11878 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11882 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11884 prefix2str(range
, buf
, sizeof(buf
));
11885 vty_out(vty
, " %s\n", buf
);
11890 /* Display group members and their status */
11891 if (listcount(group
->peer
)) {
11892 vty_out(vty
, " Peer-group members:\n");
11893 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11894 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11895 peer_status
= "Idle (Admin)";
11896 else if (CHECK_FLAG(peer
->sflags
,
11897 PEER_STATUS_PREFIX_OVERFLOW
))
11898 peer_status
= "Idle (PfxCt)";
11900 peer_status
= lookup_msg(bgp_status_msg
,
11901 peer
->status
, NULL
);
11903 dynamic
= peer_dynamic_neighbor(peer
);
11904 vty_out(vty
, " %s %s %s \n", peer
->host
,
11905 dynamic
? "(dynamic)" : "", peer_status
);
11909 return CMD_SUCCESS
;
11912 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11913 const char *group_name
)
11916 struct listnode
*node
, *nnode
;
11917 struct peer_group
*group
;
11918 bool found
= false;
11920 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11923 vty_out(vty
, "%% BGP instance not found\n");
11924 return CMD_WARNING
;
11927 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11929 if (strmatch(group
->name
, group_name
)) {
11930 bgp_show_one_peer_group(vty
, group
);
11935 bgp_show_one_peer_group(vty
, group
);
11939 if (group_name
&& !found
)
11940 vty_out(vty
, "%% No such peer-group\n");
11942 return CMD_SUCCESS
;
11945 DEFUN (show_ip_bgp_peer_groups
,
11946 show_ip_bgp_peer_groups_cmd
,
11947 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11951 BGP_INSTANCE_HELP_STR
11952 "Detailed information on BGP peer groups\n"
11953 "Peer group name\n")
11958 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11960 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11962 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11966 /* Redistribute VTY commands. */
11968 DEFUN (bgp_redistribute_ipv4
,
11969 bgp_redistribute_ipv4_cmd
,
11970 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11971 "Redistribute information from another routing protocol\n"
11972 FRR_IP_REDIST_HELP_STR_BGPD
)
11974 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11975 int idx_protocol
= 1;
11978 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11980 vty_out(vty
, "%% Invalid route type\n");
11981 return CMD_WARNING_CONFIG_FAILED
;
11984 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11985 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11989 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11990 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11991 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11993 DEFUN (bgp_redistribute_ipv4_rmap
,
11994 bgp_redistribute_ipv4_rmap_cmd
,
11995 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11996 "Redistribute information from another routing protocol\n"
11997 FRR_IP_REDIST_HELP_STR_BGPD
11998 "Route map reference\n"
11999 "Pointer to route-map entries\n")
12001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12002 int idx_protocol
= 1;
12005 struct bgp_redist
*red
;
12007 struct route_map
*route_map
= route_map_lookup_warn_noexist(
12008 vty
, argv
[idx_word
]->arg
);
12010 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12012 vty_out(vty
, "%% Invalid route type\n");
12013 return CMD_WARNING_CONFIG_FAILED
;
12016 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12018 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12019 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12023 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12024 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12025 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12026 "Route map reference\n"
12027 "Pointer to route-map entries\n")
12029 DEFUN (bgp_redistribute_ipv4_metric
,
12030 bgp_redistribute_ipv4_metric_cmd
,
12031 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12032 "Redistribute information from another routing protocol\n"
12033 FRR_IP_REDIST_HELP_STR_BGPD
12034 "Metric for redistributed routes\n"
12035 "Default metric\n")
12037 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12038 int idx_protocol
= 1;
12039 int idx_number
= 3;
12042 struct bgp_redist
*red
;
12045 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12047 vty_out(vty
, "%% Invalid route type\n");
12048 return CMD_WARNING_CONFIG_FAILED
;
12050 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12052 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12053 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12054 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12058 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12059 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12060 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12061 "Metric for redistributed routes\n"
12062 "Default metric\n")
12064 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12065 bgp_redistribute_ipv4_rmap_metric_cmd
,
12066 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12067 "Redistribute information from another routing protocol\n"
12068 FRR_IP_REDIST_HELP_STR_BGPD
12069 "Route map reference\n"
12070 "Pointer to route-map entries\n"
12071 "Metric for redistributed routes\n"
12072 "Default metric\n")
12074 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12075 int idx_protocol
= 1;
12077 int idx_number
= 5;
12080 struct bgp_redist
*red
;
12082 struct route_map
*route_map
=
12083 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12085 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12087 vty_out(vty
, "%% Invalid route type\n");
12088 return CMD_WARNING_CONFIG_FAILED
;
12090 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12092 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12094 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12095 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12096 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12100 bgp_redistribute_ipv4_rmap_metric
,
12101 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12102 "redistribute " FRR_IP_REDIST_STR_BGPD
12103 " route-map WORD metric (0-4294967295)",
12104 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12105 "Route map reference\n"
12106 "Pointer to route-map entries\n"
12107 "Metric for redistributed routes\n"
12108 "Default metric\n")
12110 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12111 bgp_redistribute_ipv4_metric_rmap_cmd
,
12112 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12113 "Redistribute information from another routing protocol\n"
12114 FRR_IP_REDIST_HELP_STR_BGPD
12115 "Metric for redistributed routes\n"
12117 "Route map reference\n"
12118 "Pointer to route-map entries\n")
12120 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12121 int idx_protocol
= 1;
12122 int idx_number
= 3;
12126 struct bgp_redist
*red
;
12128 struct route_map
*route_map
=
12129 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12131 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12133 vty_out(vty
, "%% Invalid route type\n");
12134 return CMD_WARNING_CONFIG_FAILED
;
12136 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12138 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12139 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12141 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12142 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12146 bgp_redistribute_ipv4_metric_rmap
,
12147 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12148 "redistribute " FRR_IP_REDIST_STR_BGPD
12149 " metric (0-4294967295) route-map WORD",
12150 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12151 "Metric for redistributed routes\n"
12153 "Route map reference\n"
12154 "Pointer to route-map entries\n")
12156 DEFUN (bgp_redistribute_ipv4_ospf
,
12157 bgp_redistribute_ipv4_ospf_cmd
,
12158 "redistribute <ospf|table> (1-65535)",
12159 "Redistribute information from another routing protocol\n"
12160 "Open Shortest Path First (OSPFv2)\n"
12161 "Non-main Kernel Routing Table\n"
12162 "Instance ID/Table ID\n")
12164 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12165 int idx_ospf_table
= 1;
12166 int idx_number
= 2;
12167 unsigned short instance
;
12168 unsigned short protocol
;
12170 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12172 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12173 protocol
= ZEBRA_ROUTE_OSPF
;
12175 protocol
= ZEBRA_ROUTE_TABLE
;
12177 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12178 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12181 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12182 "redistribute <ospf|table> (1-65535)",
12183 "Redistribute information from another routing protocol\n"
12184 "Open Shortest Path First (OSPFv2)\n"
12185 "Non-main Kernel Routing Table\n"
12186 "Instance ID/Table ID\n")
12188 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12189 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12190 "redistribute <ospf|table> (1-65535) route-map WORD",
12191 "Redistribute information from another routing protocol\n"
12192 "Open Shortest Path First (OSPFv2)\n"
12193 "Non-main Kernel Routing Table\n"
12194 "Instance ID/Table ID\n"
12195 "Route map reference\n"
12196 "Pointer to route-map entries\n")
12198 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12199 int idx_ospf_table
= 1;
12200 int idx_number
= 2;
12202 struct bgp_redist
*red
;
12203 unsigned short instance
;
12206 struct route_map
*route_map
=
12207 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12209 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12210 protocol
= ZEBRA_ROUTE_OSPF
;
12212 protocol
= ZEBRA_ROUTE_TABLE
;
12214 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12215 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12217 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12218 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12221 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12222 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12223 "redistribute <ospf|table> (1-65535) route-map WORD",
12224 "Redistribute information from another routing protocol\n"
12225 "Open Shortest Path First (OSPFv2)\n"
12226 "Non-main Kernel Routing Table\n"
12227 "Instance ID/Table ID\n"
12228 "Route map reference\n"
12229 "Pointer to route-map entries\n")
12231 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12232 bgp_redistribute_ipv4_ospf_metric_cmd
,
12233 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12234 "Redistribute information from another routing protocol\n"
12235 "Open Shortest Path First (OSPFv2)\n"
12236 "Non-main Kernel Routing Table\n"
12237 "Instance ID/Table ID\n"
12238 "Metric for redistributed routes\n"
12239 "Default metric\n")
12241 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12242 int idx_ospf_table
= 1;
12243 int idx_number
= 2;
12244 int idx_number_2
= 4;
12246 struct bgp_redist
*red
;
12247 unsigned short instance
;
12251 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12252 protocol
= ZEBRA_ROUTE_OSPF
;
12254 protocol
= ZEBRA_ROUTE_TABLE
;
12256 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12257 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12259 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12260 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12262 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12265 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12266 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12267 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12268 "Redistribute information from another routing protocol\n"
12269 "Open Shortest Path First (OSPFv2)\n"
12270 "Non-main Kernel Routing Table\n"
12271 "Instance ID/Table ID\n"
12272 "Metric for redistributed routes\n"
12273 "Default metric\n")
12275 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12276 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12277 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12278 "Redistribute information from another routing protocol\n"
12279 "Open Shortest Path First (OSPFv2)\n"
12280 "Non-main Kernel Routing Table\n"
12281 "Instance ID/Table ID\n"
12282 "Route map reference\n"
12283 "Pointer to route-map entries\n"
12284 "Metric for redistributed routes\n"
12285 "Default metric\n")
12287 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12288 int idx_ospf_table
= 1;
12289 int idx_number
= 2;
12291 int idx_number_2
= 6;
12293 struct bgp_redist
*red
;
12294 unsigned short instance
;
12297 struct route_map
*route_map
=
12298 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12300 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12301 protocol
= ZEBRA_ROUTE_OSPF
;
12303 protocol
= ZEBRA_ROUTE_TABLE
;
12305 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12306 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12308 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12310 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12311 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12313 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12317 bgp_redistribute_ipv4_ospf_rmap_metric
,
12318 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12319 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12320 "Redistribute information from another routing protocol\n"
12321 "Open Shortest Path First (OSPFv2)\n"
12322 "Non-main Kernel Routing Table\n"
12323 "Instance ID/Table ID\n"
12324 "Route map reference\n"
12325 "Pointer to route-map entries\n"
12326 "Metric for redistributed routes\n"
12327 "Default metric\n")
12329 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12330 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12331 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12332 "Redistribute information from another routing protocol\n"
12333 "Open Shortest Path First (OSPFv2)\n"
12334 "Non-main Kernel Routing Table\n"
12335 "Instance ID/Table ID\n"
12336 "Metric for redistributed routes\n"
12338 "Route map reference\n"
12339 "Pointer to route-map entries\n")
12341 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12342 int idx_ospf_table
= 1;
12343 int idx_number
= 2;
12344 int idx_number_2
= 4;
12347 struct bgp_redist
*red
;
12348 unsigned short instance
;
12351 struct route_map
*route_map
=
12352 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12354 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12355 protocol
= ZEBRA_ROUTE_OSPF
;
12357 protocol
= ZEBRA_ROUTE_TABLE
;
12359 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12360 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12362 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12363 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12366 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12367 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12371 bgp_redistribute_ipv4_ospf_metric_rmap
,
12372 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12373 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12374 "Redistribute information from another routing protocol\n"
12375 "Open Shortest Path First (OSPFv2)\n"
12376 "Non-main Kernel Routing Table\n"
12377 "Instance ID/Table ID\n"
12378 "Metric for redistributed routes\n"
12380 "Route map reference\n"
12381 "Pointer to route-map entries\n")
12383 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12384 no_bgp_redistribute_ipv4_ospf_cmd
,
12385 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12387 "Redistribute information from another routing protocol\n"
12388 "Open Shortest Path First (OSPFv2)\n"
12389 "Non-main Kernel Routing Table\n"
12390 "Instance ID/Table ID\n"
12391 "Metric for redistributed routes\n"
12393 "Route map reference\n"
12394 "Pointer to route-map entries\n")
12396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12397 int idx_ospf_table
= 2;
12398 int idx_number
= 3;
12399 unsigned short instance
;
12402 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12403 protocol
= ZEBRA_ROUTE_OSPF
;
12405 protocol
= ZEBRA_ROUTE_TABLE
;
12407 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12408 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12412 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12413 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12415 "Redistribute information from another routing protocol\n"
12416 "Open Shortest Path First (OSPFv2)\n"
12417 "Non-main Kernel Routing Table\n"
12418 "Instance ID/Table ID\n"
12419 "Metric for redistributed routes\n"
12421 "Route map reference\n"
12422 "Pointer to route-map entries\n")
12424 DEFUN (no_bgp_redistribute_ipv4
,
12425 no_bgp_redistribute_ipv4_cmd
,
12426 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12428 "Redistribute information from another routing protocol\n"
12429 FRR_IP_REDIST_HELP_STR_BGPD
12430 "Metric for redistributed routes\n"
12432 "Route map reference\n"
12433 "Pointer to route-map entries\n")
12435 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12436 int idx_protocol
= 2;
12439 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12441 vty_out(vty
, "%% Invalid route type\n");
12442 return CMD_WARNING_CONFIG_FAILED
;
12444 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12448 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12449 "no redistribute " FRR_IP_REDIST_STR_BGPD
12450 " [metric (0-4294967295)] [route-map WORD]",
12452 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12453 "Metric for redistributed routes\n"
12455 "Route map reference\n"
12456 "Pointer to route-map entries\n")
12458 DEFUN (bgp_redistribute_ipv6
,
12459 bgp_redistribute_ipv6_cmd
,
12460 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12461 "Redistribute information from another routing protocol\n"
12462 FRR_IP6_REDIST_HELP_STR_BGPD
)
12464 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12465 int idx_protocol
= 1;
12468 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12470 vty_out(vty
, "%% Invalid route type\n");
12471 return CMD_WARNING_CONFIG_FAILED
;
12474 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12475 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12478 DEFUN (bgp_redistribute_ipv6_rmap
,
12479 bgp_redistribute_ipv6_rmap_cmd
,
12480 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12481 "Redistribute information from another routing protocol\n"
12482 FRR_IP6_REDIST_HELP_STR_BGPD
12483 "Route map reference\n"
12484 "Pointer to route-map entries\n")
12486 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12487 int idx_protocol
= 1;
12490 struct bgp_redist
*red
;
12492 struct route_map
*route_map
=
12493 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12495 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12497 vty_out(vty
, "%% Invalid route type\n");
12498 return CMD_WARNING_CONFIG_FAILED
;
12501 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12503 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12504 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12507 DEFUN (bgp_redistribute_ipv6_metric
,
12508 bgp_redistribute_ipv6_metric_cmd
,
12509 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12510 "Redistribute information from another routing protocol\n"
12511 FRR_IP6_REDIST_HELP_STR_BGPD
12512 "Metric for redistributed routes\n"
12513 "Default metric\n")
12515 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12516 int idx_protocol
= 1;
12517 int idx_number
= 3;
12520 struct bgp_redist
*red
;
12523 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12525 vty_out(vty
, "%% Invalid route type\n");
12526 return CMD_WARNING_CONFIG_FAILED
;
12528 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12530 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12531 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12532 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12535 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12536 bgp_redistribute_ipv6_rmap_metric_cmd
,
12537 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12538 "Redistribute information from another routing protocol\n"
12539 FRR_IP6_REDIST_HELP_STR_BGPD
12540 "Route map reference\n"
12541 "Pointer to route-map entries\n"
12542 "Metric for redistributed routes\n"
12543 "Default metric\n")
12545 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12546 int idx_protocol
= 1;
12548 int idx_number
= 5;
12551 struct bgp_redist
*red
;
12553 struct route_map
*route_map
=
12554 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12556 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12558 vty_out(vty
, "%% Invalid route type\n");
12559 return CMD_WARNING_CONFIG_FAILED
;
12561 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12563 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12565 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12566 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12568 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12571 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12572 bgp_redistribute_ipv6_metric_rmap_cmd
,
12573 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12574 "Redistribute information from another routing protocol\n"
12575 FRR_IP6_REDIST_HELP_STR_BGPD
12576 "Metric for redistributed routes\n"
12578 "Route map reference\n"
12579 "Pointer to route-map entries\n")
12581 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12582 int idx_protocol
= 1;
12583 int idx_number
= 3;
12587 struct bgp_redist
*red
;
12589 struct route_map
*route_map
=
12590 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12592 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12594 vty_out(vty
, "%% Invalid route type\n");
12595 return CMD_WARNING_CONFIG_FAILED
;
12597 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12599 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12600 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12603 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12604 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12607 DEFUN (no_bgp_redistribute_ipv6
,
12608 no_bgp_redistribute_ipv6_cmd
,
12609 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12611 "Redistribute information from another routing protocol\n"
12612 FRR_IP6_REDIST_HELP_STR_BGPD
12613 "Metric for redistributed routes\n"
12615 "Route map reference\n"
12616 "Pointer to route-map entries\n")
12618 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12619 int idx_protocol
= 2;
12622 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12624 vty_out(vty
, "%% Invalid route type\n");
12625 return CMD_WARNING_CONFIG_FAILED
;
12628 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12631 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12636 /* Unicast redistribution only. */
12637 if (safi
!= SAFI_UNICAST
)
12640 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12641 /* Redistribute BGP does not make sense. */
12642 if (i
!= ZEBRA_ROUTE_BGP
) {
12643 struct list
*red_list
;
12644 struct listnode
*node
;
12645 struct bgp_redist
*red
;
12647 red_list
= bgp
->redist
[afi
][i
];
12651 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12652 /* "redistribute" configuration. */
12653 vty_out(vty
, " redistribute %s",
12654 zebra_route_string(i
));
12656 vty_out(vty
, " %d", red
->instance
);
12657 if (red
->redist_metric_flag
)
12658 vty_out(vty
, " metric %u",
12659 red
->redist_metric
);
12660 if (red
->rmap
.name
)
12661 vty_out(vty
, " route-map %s",
12663 vty_out(vty
, "\n");
12669 /* This is part of the address-family block (unicast only) */
12670 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12675 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12676 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12677 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12678 bgp
->vpn_policy
[afi
]
12679 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12681 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12682 bgp
->vpn_policy
[afi
]
12683 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12685 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12686 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12687 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12688 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12691 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12692 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12694 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12697 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12698 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12699 bgp
->vpn_policy
[afi
].tovpn_label
);
12702 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12703 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12704 char buf
[RD_ADDRSTRLEN
];
12705 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12706 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12709 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12710 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12712 char buf
[PREFIX_STRLEN
];
12713 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12714 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12717 vty_out(vty
, "%*snexthop vpn export %s\n",
12721 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12722 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12724 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12725 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12727 char *b
= ecommunity_ecom2str(
12728 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12729 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12730 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12731 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12733 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12734 char *b
= ecommunity_ecom2str(
12735 bgp
->vpn_policy
[afi
]
12736 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12737 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12738 ECOMMUNITY_ROUTE_TARGET
);
12739 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12740 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12742 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12743 char *b
= ecommunity_ecom2str(
12744 bgp
->vpn_policy
[afi
]
12745 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12746 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12747 ECOMMUNITY_ROUTE_TARGET
);
12748 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12749 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12753 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12754 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12755 bgp
->vpn_policy
[afi
]
12756 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12758 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12759 char *b
= ecommunity_ecom2str(
12760 bgp
->vpn_policy
[afi
]
12761 .import_redirect_rtlist
,
12762 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12763 ECOMMUNITY_ROUTE_TARGET
);
12765 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12766 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12771 /* BGP node structure. */
12772 static struct cmd_node bgp_node
= {
12773 BGP_NODE
, "%s(config-router)# ", 1,
12776 static struct cmd_node bgp_ipv4_unicast_node
= {
12777 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12780 static struct cmd_node bgp_ipv4_multicast_node
= {
12781 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12784 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12785 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12788 static struct cmd_node bgp_ipv6_unicast_node
= {
12789 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12792 static struct cmd_node bgp_ipv6_multicast_node
= {
12793 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12796 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12797 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12800 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12801 "%s(config-router-af)# ", 1};
12803 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12804 "%s(config-router-af-vpnv6)# ", 1};
12806 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12807 "%s(config-router-evpn)# ", 1};
12809 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12810 "%s(config-router-af-vni)# ", 1};
12812 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12813 "%s(config-router-af)# ", 1};
12815 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12816 "%s(config-router-af-vpnv6)# ", 1};
12818 static void community_list_vty(void);
12820 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12824 struct listnode
*lnbgp
, *lnpeer
;
12826 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12827 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12828 /* only provide suggestions on the appropriate input
12830 * they'll otherwise show up multiple times */
12831 enum cmd_token_type match_type
;
12832 char *name
= peer
->host
;
12834 if (peer
->conf_if
) {
12835 match_type
= VARIABLE_TKN
;
12836 name
= peer
->conf_if
;
12837 } else if (strchr(peer
->host
, ':'))
12838 match_type
= IPV6_TKN
;
12840 match_type
= IPV4_TKN
;
12842 if (token
->type
!= match_type
)
12845 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12850 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12851 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12852 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12853 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12854 {.completions
= NULL
}};
12856 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12859 struct peer_group
*group
;
12860 struct listnode
*lnbgp
, *lnpeer
;
12862 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12863 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12864 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12869 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12870 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12871 {.completions
= NULL
} };
12873 void bgp_vty_init(void)
12875 cmd_variable_handler_register(bgp_var_neighbor
);
12876 cmd_variable_handler_register(bgp_var_peergroup
);
12878 /* Install bgp top node. */
12879 install_node(&bgp_node
, bgp_config_write
);
12880 install_node(&bgp_ipv4_unicast_node
, NULL
);
12881 install_node(&bgp_ipv4_multicast_node
, NULL
);
12882 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12883 install_node(&bgp_ipv6_unicast_node
, NULL
);
12884 install_node(&bgp_ipv6_multicast_node
, NULL
);
12885 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12886 install_node(&bgp_vpnv4_node
, NULL
);
12887 install_node(&bgp_vpnv6_node
, NULL
);
12888 install_node(&bgp_evpn_node
, NULL
);
12889 install_node(&bgp_evpn_vni_node
, NULL
);
12890 install_node(&bgp_flowspecv4_node
, NULL
);
12891 install_node(&bgp_flowspecv6_node
, NULL
);
12893 /* Install default VTY commands to new nodes. */
12894 install_default(BGP_NODE
);
12895 install_default(BGP_IPV4_NODE
);
12896 install_default(BGP_IPV4M_NODE
);
12897 install_default(BGP_IPV4L_NODE
);
12898 install_default(BGP_IPV6_NODE
);
12899 install_default(BGP_IPV6M_NODE
);
12900 install_default(BGP_IPV6L_NODE
);
12901 install_default(BGP_VPNV4_NODE
);
12902 install_default(BGP_VPNV6_NODE
);
12903 install_default(BGP_FLOWSPECV4_NODE
);
12904 install_default(BGP_FLOWSPECV6_NODE
);
12905 install_default(BGP_EVPN_NODE
);
12906 install_default(BGP_EVPN_VNI_NODE
);
12908 /* "bgp multiple-instance" commands. */
12909 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12910 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12912 /* "bgp config-type" commands. */
12913 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12914 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12916 /* "bgp local-mac" hidden commands. */
12917 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12918 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12920 /* bgp route-map delay-timer commands. */
12921 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12922 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12924 /* Dummy commands (Currently not supported) */
12925 install_element(BGP_NODE
, &no_synchronization_cmd
);
12926 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12928 /* "router bgp" commands. */
12929 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12931 /* "no router bgp" commands. */
12932 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12934 /* "bgp router-id" commands. */
12935 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12936 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12938 /* "bgp cluster-id" commands. */
12939 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12940 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12942 /* "bgp confederation" commands. */
12943 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12944 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12946 /* "bgp confederation peers" commands. */
12947 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12948 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12950 /* bgp max-med command */
12951 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12952 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12953 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12954 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12955 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12957 /* bgp disable-ebgp-connected-nh-check */
12958 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12959 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12961 /* bgp update-delay command */
12962 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12963 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12964 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12966 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12967 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12968 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12969 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12971 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12972 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12974 /* "maximum-paths" commands. */
12975 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12976 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12977 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12978 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12979 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12980 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12981 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12982 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12983 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12984 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12985 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12986 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12987 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12988 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12989 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12991 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12992 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12993 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12994 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12995 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12997 /* "timers bgp" commands. */
12998 install_element(BGP_NODE
, &bgp_timers_cmd
);
12999 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
13001 /* route-map delay-timer commands - per instance for backwards compat.
13003 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13004 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13006 /* "bgp client-to-client reflection" commands */
13007 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
13008 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
13010 /* "bgp always-compare-med" commands */
13011 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
13012 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
13014 /* bgp ebgp-requires-policy */
13015 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
13016 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
13018 /* "bgp deterministic-med" commands */
13019 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
13020 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
13022 /* "bgp graceful-restart" commands */
13023 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
13024 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
13025 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
13026 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
13027 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
13028 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
13030 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
13031 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
13033 /* "bgp graceful-shutdown" commands */
13034 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
13035 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13037 /* "bgp fast-external-failover" commands */
13038 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13039 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13041 /* "bgp enforce-first-as" commands */
13042 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
13044 /* "bgp bestpath compare-routerid" commands */
13045 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13046 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13048 /* "bgp bestpath as-path ignore" commands */
13049 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13050 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13052 /* "bgp bestpath as-path confed" commands */
13053 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13054 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13056 /* "bgp bestpath as-path multipath-relax" commands */
13057 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13058 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13060 /* "bgp log-neighbor-changes" commands */
13061 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13062 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13064 /* "bgp bestpath med" commands */
13065 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13066 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13068 /* "no bgp default ipv4-unicast" commands. */
13069 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13070 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13072 /* "bgp network import-check" commands. */
13073 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13074 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13075 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13077 /* "bgp default local-preference" commands. */
13078 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13079 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13081 /* bgp default show-hostname */
13082 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13083 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13085 /* "bgp default subgroup-pkt-queue-max" commands. */
13086 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13087 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13089 /* bgp ibgp-allow-policy-mods command */
13090 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13091 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13093 /* "bgp listen limit" commands. */
13094 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13095 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13097 /* "bgp listen range" commands. */
13098 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13099 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13101 /* "bgp default shutdown" command */
13102 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13104 /* "neighbor remote-as" commands. */
13105 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13106 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13107 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13108 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13109 install_element(BGP_NODE
,
13110 &neighbor_interface_v6only_config_remote_as_cmd
);
13111 install_element(BGP_NODE
, &no_neighbor_cmd
);
13112 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13114 /* "neighbor peer-group" commands. */
13115 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13116 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13117 install_element(BGP_NODE
,
13118 &no_neighbor_interface_peer_group_remote_as_cmd
);
13120 /* "neighbor local-as" commands. */
13121 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13122 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13123 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13124 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13126 /* "neighbor solo" commands. */
13127 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13128 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13130 /* "neighbor password" commands. */
13131 install_element(BGP_NODE
, &neighbor_password_cmd
);
13132 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13134 /* "neighbor activate" commands. */
13135 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13136 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13137 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13138 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13139 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13140 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13141 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13142 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13143 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13144 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13145 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13146 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13148 /* "no neighbor activate" commands. */
13149 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13150 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13151 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13152 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13153 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13154 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13155 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13156 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13157 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13158 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13159 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13160 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13162 /* "neighbor peer-group" set commands. */
13163 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13164 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13165 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13166 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13167 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13168 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13169 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13170 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13171 install_element(BGP_FLOWSPECV4_NODE
,
13172 &neighbor_set_peer_group_hidden_cmd
);
13173 install_element(BGP_FLOWSPECV6_NODE
,
13174 &neighbor_set_peer_group_hidden_cmd
);
13176 /* "no neighbor peer-group unset" commands. */
13177 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13178 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13179 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13180 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13181 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13182 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13183 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13184 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13185 install_element(BGP_FLOWSPECV4_NODE
,
13186 &no_neighbor_set_peer_group_hidden_cmd
);
13187 install_element(BGP_FLOWSPECV6_NODE
,
13188 &no_neighbor_set_peer_group_hidden_cmd
);
13190 /* "neighbor softreconfiguration inbound" commands.*/
13191 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13192 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13193 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13194 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13195 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13196 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13197 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13198 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13199 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13200 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13201 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13202 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13203 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13204 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13205 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13206 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13207 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13208 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13209 install_element(BGP_FLOWSPECV4_NODE
,
13210 &neighbor_soft_reconfiguration_cmd
);
13211 install_element(BGP_FLOWSPECV4_NODE
,
13212 &no_neighbor_soft_reconfiguration_cmd
);
13213 install_element(BGP_FLOWSPECV6_NODE
,
13214 &neighbor_soft_reconfiguration_cmd
);
13215 install_element(BGP_FLOWSPECV6_NODE
,
13216 &no_neighbor_soft_reconfiguration_cmd
);
13217 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13218 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13220 /* "neighbor attribute-unchanged" commands. */
13221 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13222 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13223 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13224 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13225 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13226 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13227 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13228 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13229 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13230 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13231 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13232 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13233 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13234 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13235 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13236 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13237 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13238 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13240 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13241 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13243 /* "nexthop-local unchanged" commands */
13244 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13245 install_element(BGP_IPV6_NODE
,
13246 &no_neighbor_nexthop_local_unchanged_cmd
);
13248 /* "neighbor next-hop-self" commands. */
13249 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13250 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13251 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13252 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13253 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13254 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13255 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13256 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13257 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13258 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13259 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13260 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13261 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13262 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13263 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13264 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13265 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13266 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13267 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13268 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13270 /* "neighbor next-hop-self force" commands. */
13271 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13272 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13273 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13274 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13275 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13276 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13277 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13278 install_element(BGP_IPV4_NODE
,
13279 &no_neighbor_nexthop_self_all_hidden_cmd
);
13280 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13281 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13282 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13283 install_element(BGP_IPV4M_NODE
,
13284 &no_neighbor_nexthop_self_all_hidden_cmd
);
13285 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13286 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13287 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13288 install_element(BGP_IPV4L_NODE
,
13289 &no_neighbor_nexthop_self_all_hidden_cmd
);
13290 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13291 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13292 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13293 install_element(BGP_IPV6_NODE
,
13294 &no_neighbor_nexthop_self_all_hidden_cmd
);
13295 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13296 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13297 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13298 install_element(BGP_IPV6M_NODE
,
13299 &no_neighbor_nexthop_self_all_hidden_cmd
);
13300 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13301 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13302 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13303 install_element(BGP_IPV6L_NODE
,
13304 &no_neighbor_nexthop_self_all_hidden_cmd
);
13305 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13306 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13307 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13308 install_element(BGP_VPNV4_NODE
,
13309 &no_neighbor_nexthop_self_all_hidden_cmd
);
13310 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13311 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13312 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13313 install_element(BGP_VPNV6_NODE
,
13314 &no_neighbor_nexthop_self_all_hidden_cmd
);
13316 /* "neighbor as-override" commands. */
13317 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13318 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13319 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13320 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13321 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13322 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13323 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13324 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13325 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13326 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13327 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13328 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13329 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13330 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13331 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13332 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13333 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13334 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13336 /* "neighbor remove-private-AS" commands. */
13337 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13338 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13339 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13340 install_element(BGP_NODE
,
13341 &no_neighbor_remove_private_as_all_hidden_cmd
);
13342 install_element(BGP_NODE
,
13343 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13344 install_element(BGP_NODE
,
13345 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13346 install_element(BGP_NODE
,
13347 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13350 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13351 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13352 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13353 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13354 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13355 install_element(BGP_IPV4_NODE
,
13356 &neighbor_remove_private_as_replace_as_cmd
);
13357 install_element(BGP_IPV4_NODE
,
13358 &no_neighbor_remove_private_as_replace_as_cmd
);
13359 install_element(BGP_IPV4_NODE
,
13360 &neighbor_remove_private_as_all_replace_as_cmd
);
13361 install_element(BGP_IPV4_NODE
,
13362 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13363 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13364 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13365 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13366 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13367 install_element(BGP_IPV4M_NODE
,
13368 &neighbor_remove_private_as_replace_as_cmd
);
13369 install_element(BGP_IPV4M_NODE
,
13370 &no_neighbor_remove_private_as_replace_as_cmd
);
13371 install_element(BGP_IPV4M_NODE
,
13372 &neighbor_remove_private_as_all_replace_as_cmd
);
13373 install_element(BGP_IPV4M_NODE
,
13374 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13375 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13376 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13377 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13378 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13379 install_element(BGP_IPV4L_NODE
,
13380 &neighbor_remove_private_as_replace_as_cmd
);
13381 install_element(BGP_IPV4L_NODE
,
13382 &no_neighbor_remove_private_as_replace_as_cmd
);
13383 install_element(BGP_IPV4L_NODE
,
13384 &neighbor_remove_private_as_all_replace_as_cmd
);
13385 install_element(BGP_IPV4L_NODE
,
13386 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13387 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13388 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13389 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13390 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13391 install_element(BGP_IPV6_NODE
,
13392 &neighbor_remove_private_as_replace_as_cmd
);
13393 install_element(BGP_IPV6_NODE
,
13394 &no_neighbor_remove_private_as_replace_as_cmd
);
13395 install_element(BGP_IPV6_NODE
,
13396 &neighbor_remove_private_as_all_replace_as_cmd
);
13397 install_element(BGP_IPV6_NODE
,
13398 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13399 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13400 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13401 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13402 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13403 install_element(BGP_IPV6M_NODE
,
13404 &neighbor_remove_private_as_replace_as_cmd
);
13405 install_element(BGP_IPV6M_NODE
,
13406 &no_neighbor_remove_private_as_replace_as_cmd
);
13407 install_element(BGP_IPV6M_NODE
,
13408 &neighbor_remove_private_as_all_replace_as_cmd
);
13409 install_element(BGP_IPV6M_NODE
,
13410 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13411 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13412 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13413 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13414 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13415 install_element(BGP_IPV6L_NODE
,
13416 &neighbor_remove_private_as_replace_as_cmd
);
13417 install_element(BGP_IPV6L_NODE
,
13418 &no_neighbor_remove_private_as_replace_as_cmd
);
13419 install_element(BGP_IPV6L_NODE
,
13420 &neighbor_remove_private_as_all_replace_as_cmd
);
13421 install_element(BGP_IPV6L_NODE
,
13422 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13423 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13424 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13425 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13426 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13427 install_element(BGP_VPNV4_NODE
,
13428 &neighbor_remove_private_as_replace_as_cmd
);
13429 install_element(BGP_VPNV4_NODE
,
13430 &no_neighbor_remove_private_as_replace_as_cmd
);
13431 install_element(BGP_VPNV4_NODE
,
13432 &neighbor_remove_private_as_all_replace_as_cmd
);
13433 install_element(BGP_VPNV4_NODE
,
13434 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13435 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13436 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13437 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13438 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13439 install_element(BGP_VPNV6_NODE
,
13440 &neighbor_remove_private_as_replace_as_cmd
);
13441 install_element(BGP_VPNV6_NODE
,
13442 &no_neighbor_remove_private_as_replace_as_cmd
);
13443 install_element(BGP_VPNV6_NODE
,
13444 &neighbor_remove_private_as_all_replace_as_cmd
);
13445 install_element(BGP_VPNV6_NODE
,
13446 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13448 /* "neighbor send-community" commands.*/
13449 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13450 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13451 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13452 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13453 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13454 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13455 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13456 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13457 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13458 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13459 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13460 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13461 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13462 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13463 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13464 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13465 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13466 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13467 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13468 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13469 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13470 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13471 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13472 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13473 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13474 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13475 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13476 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13477 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13478 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13479 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13480 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13481 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13482 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13483 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13484 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13486 /* "neighbor route-reflector" commands.*/
13487 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13488 install_element(BGP_NODE
,
13489 &no_neighbor_route_reflector_client_hidden_cmd
);
13490 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13491 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13492 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13493 install_element(BGP_IPV4M_NODE
,
13494 &no_neighbor_route_reflector_client_cmd
);
13495 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13496 install_element(BGP_IPV4L_NODE
,
13497 &no_neighbor_route_reflector_client_cmd
);
13498 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13499 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13500 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13501 install_element(BGP_IPV6M_NODE
,
13502 &no_neighbor_route_reflector_client_cmd
);
13503 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13504 install_element(BGP_IPV6L_NODE
,
13505 &no_neighbor_route_reflector_client_cmd
);
13506 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13507 install_element(BGP_VPNV4_NODE
,
13508 &no_neighbor_route_reflector_client_cmd
);
13509 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13510 install_element(BGP_VPNV6_NODE
,
13511 &no_neighbor_route_reflector_client_cmd
);
13512 install_element(BGP_FLOWSPECV4_NODE
,
13513 &neighbor_route_reflector_client_cmd
);
13514 install_element(BGP_FLOWSPECV4_NODE
,
13515 &no_neighbor_route_reflector_client_cmd
);
13516 install_element(BGP_FLOWSPECV6_NODE
,
13517 &neighbor_route_reflector_client_cmd
);
13518 install_element(BGP_FLOWSPECV6_NODE
,
13519 &no_neighbor_route_reflector_client_cmd
);
13520 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13521 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13523 /* "neighbor route-server" commands.*/
13524 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13525 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13526 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13527 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13528 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13529 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13530 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13531 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13532 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13533 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13534 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13535 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13536 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13537 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13538 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13539 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13540 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13541 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13542 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13543 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13544 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13545 install_element(BGP_FLOWSPECV4_NODE
,
13546 &no_neighbor_route_server_client_cmd
);
13547 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13548 install_element(BGP_FLOWSPECV6_NODE
,
13549 &no_neighbor_route_server_client_cmd
);
13551 /* "neighbor addpath-tx-all-paths" commands.*/
13552 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13553 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13554 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13555 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13556 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13557 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13558 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13559 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13560 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13561 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13562 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13563 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13564 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13565 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13566 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13567 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13568 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13569 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13571 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13572 install_element(BGP_NODE
,
13573 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13574 install_element(BGP_NODE
,
13575 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13576 install_element(BGP_IPV4_NODE
,
13577 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13578 install_element(BGP_IPV4_NODE
,
13579 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13580 install_element(BGP_IPV4M_NODE
,
13581 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13582 install_element(BGP_IPV4M_NODE
,
13583 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13584 install_element(BGP_IPV4L_NODE
,
13585 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13586 install_element(BGP_IPV4L_NODE
,
13587 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13588 install_element(BGP_IPV6_NODE
,
13589 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13590 install_element(BGP_IPV6_NODE
,
13591 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13592 install_element(BGP_IPV6M_NODE
,
13593 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13594 install_element(BGP_IPV6M_NODE
,
13595 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13596 install_element(BGP_IPV6L_NODE
,
13597 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13598 install_element(BGP_IPV6L_NODE
,
13599 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13600 install_element(BGP_VPNV4_NODE
,
13601 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13602 install_element(BGP_VPNV4_NODE
,
13603 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13604 install_element(BGP_VPNV6_NODE
,
13605 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13606 install_element(BGP_VPNV6_NODE
,
13607 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13609 /* "neighbor passive" commands. */
13610 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13611 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13614 /* "neighbor shutdown" commands. */
13615 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13616 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13617 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13618 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13620 /* "neighbor capability extended-nexthop" commands.*/
13621 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13622 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13624 /* "neighbor capability orf prefix-list" commands.*/
13625 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13626 install_element(BGP_NODE
,
13627 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13628 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13629 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13630 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13631 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13632 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13633 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13634 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13635 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13636 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13637 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13638 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13639 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13641 /* "neighbor capability dynamic" commands.*/
13642 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13643 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13645 /* "neighbor dont-capability-negotiate" commands. */
13646 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13647 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13649 /* "neighbor ebgp-multihop" commands. */
13650 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13651 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13652 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13654 /* "neighbor disable-connected-check" commands. */
13655 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13656 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13658 /* "neighbor enforce-first-as" commands. */
13659 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13660 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13662 /* "neighbor description" commands. */
13663 install_element(BGP_NODE
, &neighbor_description_cmd
);
13664 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13665 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13667 /* "neighbor update-source" commands. "*/
13668 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13669 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13671 /* "neighbor default-originate" commands. */
13672 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13673 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13674 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13675 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13676 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13677 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13678 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13679 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13680 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13681 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13682 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13683 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13684 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13685 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13686 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13687 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13688 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13689 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13690 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13691 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13692 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13694 /* "neighbor port" commands. */
13695 install_element(BGP_NODE
, &neighbor_port_cmd
);
13696 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13698 /* "neighbor weight" commands. */
13699 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13700 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13702 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13703 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13704 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13705 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13706 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13707 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13708 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13709 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13710 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13711 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13712 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13713 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13714 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13715 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13716 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13717 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13719 /* "neighbor override-capability" commands. */
13720 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13721 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13723 /* "neighbor strict-capability-match" commands. */
13724 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13725 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13727 /* "neighbor timers" commands. */
13728 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13729 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13731 /* "neighbor timers connect" commands. */
13732 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13733 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13735 /* "neighbor advertisement-interval" commands. */
13736 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13737 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13739 /* "neighbor interface" commands. */
13740 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13741 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13743 /* "neighbor distribute" commands. */
13744 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13745 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13746 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13747 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13748 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13749 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13750 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13751 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13752 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13753 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13754 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13755 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13756 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13757 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13758 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13759 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13760 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13761 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13763 /* "neighbor prefix-list" commands. */
13764 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13765 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13766 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13767 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13768 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13769 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13770 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13771 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13772 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13773 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13774 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13775 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13776 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13777 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13778 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13779 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13780 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13781 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13782 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13783 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13784 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13785 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13787 /* "neighbor filter-list" commands. */
13788 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13789 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13790 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13791 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13792 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13793 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13794 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13795 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13796 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13797 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13798 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13799 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13800 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13801 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13802 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13803 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13804 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13805 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13806 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13807 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13808 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13809 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13811 /* "neighbor route-map" commands. */
13812 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13813 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13814 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13815 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13816 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13817 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13818 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13819 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13820 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13821 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13822 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13823 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13824 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13825 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13826 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13827 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13828 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13829 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13830 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13831 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13832 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13833 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13834 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13835 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13837 /* "neighbor unsuppress-map" commands. */
13838 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13839 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13840 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13841 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13842 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13843 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13844 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13845 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13846 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13847 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13848 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13849 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13850 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13851 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13852 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13853 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13854 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13855 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13857 /* "neighbor maximum-prefix" commands. */
13858 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13859 install_element(BGP_NODE
,
13860 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13861 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13862 install_element(BGP_NODE
,
13863 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13864 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13865 install_element(BGP_NODE
,
13866 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13867 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13868 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13869 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13870 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13871 install_element(BGP_IPV4_NODE
,
13872 &neighbor_maximum_prefix_threshold_warning_cmd
);
13873 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13874 install_element(BGP_IPV4_NODE
,
13875 &neighbor_maximum_prefix_threshold_restart_cmd
);
13876 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13877 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13878 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13879 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13880 install_element(BGP_IPV4M_NODE
,
13881 &neighbor_maximum_prefix_threshold_warning_cmd
);
13882 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13883 install_element(BGP_IPV4M_NODE
,
13884 &neighbor_maximum_prefix_threshold_restart_cmd
);
13885 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13886 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13887 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13888 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13889 install_element(BGP_IPV4L_NODE
,
13890 &neighbor_maximum_prefix_threshold_warning_cmd
);
13891 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13892 install_element(BGP_IPV4L_NODE
,
13893 &neighbor_maximum_prefix_threshold_restart_cmd
);
13894 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13895 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13896 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13897 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13898 install_element(BGP_IPV6_NODE
,
13899 &neighbor_maximum_prefix_threshold_warning_cmd
);
13900 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13901 install_element(BGP_IPV6_NODE
,
13902 &neighbor_maximum_prefix_threshold_restart_cmd
);
13903 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13904 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13905 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13906 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13907 install_element(BGP_IPV6M_NODE
,
13908 &neighbor_maximum_prefix_threshold_warning_cmd
);
13909 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13910 install_element(BGP_IPV6M_NODE
,
13911 &neighbor_maximum_prefix_threshold_restart_cmd
);
13912 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13913 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13914 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13915 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13916 install_element(BGP_IPV6L_NODE
,
13917 &neighbor_maximum_prefix_threshold_warning_cmd
);
13918 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13919 install_element(BGP_IPV6L_NODE
,
13920 &neighbor_maximum_prefix_threshold_restart_cmd
);
13921 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13922 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13923 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13924 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13925 install_element(BGP_VPNV4_NODE
,
13926 &neighbor_maximum_prefix_threshold_warning_cmd
);
13927 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13928 install_element(BGP_VPNV4_NODE
,
13929 &neighbor_maximum_prefix_threshold_restart_cmd
);
13930 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13931 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13932 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13933 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13934 install_element(BGP_VPNV6_NODE
,
13935 &neighbor_maximum_prefix_threshold_warning_cmd
);
13936 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13937 install_element(BGP_VPNV6_NODE
,
13938 &neighbor_maximum_prefix_threshold_restart_cmd
);
13939 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13941 /* "neighbor allowas-in" */
13942 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13943 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13944 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13945 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13946 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13947 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13948 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13949 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13950 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13951 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13952 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13953 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13954 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13955 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13956 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13957 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13958 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13959 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13960 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13961 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13963 /* address-family commands. */
13964 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13965 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13966 #ifdef KEEP_OLD_VPN_COMMANDS
13967 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13968 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13969 #endif /* KEEP_OLD_VPN_COMMANDS */
13971 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13973 /* "exit-address-family" command. */
13974 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13975 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13976 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13977 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13978 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13979 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13980 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13981 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13982 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13983 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13984 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13986 /* "clear ip bgp commands" */
13987 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13989 /* clear ip bgp prefix */
13990 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13991 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13992 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13994 /* "show [ip] bgp summary" commands. */
13995 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13996 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13997 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13998 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13999 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
14000 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
14001 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
14003 /* "show [ip] bgp neighbors" commands. */
14004 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
14006 /* "show [ip] bgp peer-group" commands. */
14007 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
14009 /* "show [ip] bgp paths" commands. */
14010 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
14012 /* "show [ip] bgp community" commands. */
14013 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
14015 /* "show ip bgp large-community" commands. */
14016 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
14017 /* "show [ip] bgp attribute-info" commands. */
14018 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
14019 /* "show [ip] bgp route-leak" command */
14020 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
14022 /* "redistribute" commands. */
14023 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
14024 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
14025 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
14026 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
14027 install_element(BGP_NODE
,
14028 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
14029 install_element(BGP_NODE
,
14030 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
14031 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
14032 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
14033 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
14034 install_element(BGP_NODE
,
14035 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
14036 install_element(BGP_NODE
,
14037 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
14038 install_element(BGP_NODE
,
14039 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
14040 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
14041 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
14042 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
14043 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
14044 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
14045 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
14046 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
14047 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
14048 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
14049 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
14050 install_element(BGP_IPV4_NODE
,
14051 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
14052 install_element(BGP_IPV4_NODE
,
14053 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
14054 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
14055 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
14056 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
14057 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
14058 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
14059 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
14061 /* import|export vpn [route-map WORD] */
14062 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14063 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14065 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14066 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14068 /* ttl_security commands */
14069 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14070 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14072 /* "show [ip] bgp memory" commands. */
14073 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14075 /* "show bgp martian next-hop" */
14076 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14078 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14080 /* "show [ip] bgp views" commands. */
14081 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14083 /* "show [ip] bgp vrfs" commands. */
14084 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14086 /* Community-list. */
14087 community_list_vty();
14089 /* vpn-policy commands */
14090 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14091 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14092 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14093 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14094 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14095 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14096 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14097 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14098 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14099 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14100 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14101 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14103 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14104 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14106 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14107 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14108 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14109 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14110 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14111 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14112 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14113 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14114 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14115 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14116 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14117 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14120 #include "memory.h"
14121 #include "bgp_regex.h"
14122 #include "bgp_clist.h"
14123 #include "bgp_ecommunity.h"
14125 /* VTY functions. */
14127 /* Direction value to string conversion. */
14128 static const char *community_direct_str(int direct
)
14131 case COMMUNITY_DENY
:
14133 case COMMUNITY_PERMIT
:
14140 /* Display error string. */
14141 static void community_list_perror(struct vty
*vty
, int ret
)
14144 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14145 vty_out(vty
, "%% Can't find community-list\n");
14147 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14148 vty_out(vty
, "%% Malformed community-list value\n");
14150 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14152 "%% Community name conflict, previously defined as standard community\n");
14154 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14156 "%% Community name conflict, previously defined as expanded community\n");
14161 /* "community-list" keyword help string. */
14162 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14164 /*community-list standard */
14165 DEFUN (community_list_standard
,
14166 bgp_community_list_standard_cmd
,
14167 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14170 "Community list number (standard)\n"
14171 "Add an standard community-list entry\n"
14172 "Community list name\n"
14173 "Specify community to reject\n"
14174 "Specify community to accept\n"
14177 char *cl_name_or_number
= NULL
;
14179 int style
= COMMUNITY_LIST_STANDARD
;
14183 if (argv_find(argv
, argc
, "ip", &idx
)) {
14184 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14185 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14186 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14187 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14190 argv_find(argv
, argc
, "(1-99)", &idx
);
14191 argv_find(argv
, argc
, "WORD", &idx
);
14192 cl_name_or_number
= argv
[idx
]->arg
;
14193 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14195 argv_find(argv
, argc
, "AA:NN", &idx
);
14196 char *str
= argv_concat(argv
, argc
, idx
);
14198 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14201 XFREE(MTYPE_TMP
, str
);
14204 /* Display error string. */
14205 community_list_perror(vty
, ret
);
14206 return CMD_WARNING_CONFIG_FAILED
;
14209 return CMD_SUCCESS
;
14212 #if CONFDATE > 20191005
14213 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14215 ALIAS (community_list_standard
,
14216 ip_community_list_standard_cmd
,
14217 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14220 "Community list number (standard)\n"
14221 "Add an standard community-list entry\n"
14222 "Community list name\n"
14223 "Specify community to reject\n"
14224 "Specify community to accept\n"
14227 DEFUN (no_community_list_standard_all
,
14228 no_bgp_community_list_standard_all_cmd
,
14229 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14233 "Community list number (standard)\n"
14234 "Add an standard community-list entry\n"
14235 "Community list name\n"
14236 "Specify community to reject\n"
14237 "Specify community to accept\n"
14240 char *cl_name_or_number
= NULL
;
14243 int style
= COMMUNITY_LIST_STANDARD
;
14247 if (argv_find(argv
, argc
, "ip", &idx
)) {
14248 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14249 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14250 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14251 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14254 argv_find(argv
, argc
, "permit", &idx
);
14255 argv_find(argv
, argc
, "deny", &idx
);
14258 direct
= argv_find(argv
, argc
, "permit", &idx
)
14263 argv_find(argv
, argc
, "AA:NN", &idx
);
14264 str
= argv_concat(argv
, argc
, idx
);
14268 argv_find(argv
, argc
, "(1-99)", &idx
);
14269 argv_find(argv
, argc
, "WORD", &idx
);
14270 cl_name_or_number
= argv
[idx
]->arg
;
14272 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14275 XFREE(MTYPE_TMP
, str
);
14278 community_list_perror(vty
, ret
);
14279 return CMD_WARNING_CONFIG_FAILED
;
14282 return CMD_SUCCESS
;
14284 ALIAS (no_community_list_standard_all
,
14285 no_ip_community_list_standard_all_cmd
,
14286 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14290 "Community list number (standard)\n"
14291 "Add an standard community-list entry\n"
14292 "Community list name\n"
14293 "Specify community to reject\n"
14294 "Specify community to accept\n"
14297 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14298 "no bgp community-list <(1-99)|standard WORD>",
14299 NO_STR BGP_STR COMMUNITY_LIST_STR
14300 "Community list number (standard)\n"
14301 "Add an standard community-list entry\n"
14302 "Community list name\n")
14304 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14305 "no ip community-list <(1-99)|standard WORD>",
14306 NO_STR BGP_STR COMMUNITY_LIST_STR
14307 "Community list number (standard)\n"
14308 "Add an standard community-list entry\n"
14309 "Community list name\n")
14311 /*community-list expanded */
14312 DEFUN (community_list_expanded_all
,
14313 bgp_community_list_expanded_all_cmd
,
14314 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14317 "Community list number (expanded)\n"
14318 "Add an expanded community-list entry\n"
14319 "Community list name\n"
14320 "Specify community to reject\n"
14321 "Specify community to accept\n"
14324 char *cl_name_or_number
= NULL
;
14326 int style
= COMMUNITY_LIST_EXPANDED
;
14329 if (argv_find(argv
, argc
, "ip", &idx
)) {
14330 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14331 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14332 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14333 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14335 argv_find(argv
, argc
, "(100-500)", &idx
);
14336 argv_find(argv
, argc
, "WORD", &idx
);
14337 cl_name_or_number
= argv
[idx
]->arg
;
14338 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14340 argv_find(argv
, argc
, "AA:NN", &idx
);
14341 char *str
= argv_concat(argv
, argc
, idx
);
14343 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14346 XFREE(MTYPE_TMP
, str
);
14349 /* Display error string. */
14350 community_list_perror(vty
, ret
);
14351 return CMD_WARNING_CONFIG_FAILED
;
14354 return CMD_SUCCESS
;
14357 ALIAS (community_list_expanded_all
,
14358 ip_community_list_expanded_all_cmd
,
14359 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14362 "Community list number (expanded)\n"
14363 "Add an expanded community-list entry\n"
14364 "Community list name\n"
14365 "Specify community to reject\n"
14366 "Specify community to accept\n"
14369 DEFUN (no_community_list_expanded_all
,
14370 no_bgp_community_list_expanded_all_cmd
,
14371 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14375 "Community list number (expanded)\n"
14376 "Add an expanded community-list entry\n"
14377 "Community list name\n"
14378 "Specify community to reject\n"
14379 "Specify community to accept\n"
14382 char *cl_name_or_number
= NULL
;
14385 int style
= COMMUNITY_LIST_EXPANDED
;
14388 if (argv_find(argv
, argc
, "ip", &idx
)) {
14389 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14390 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14391 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14392 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14396 argv_find(argv
, argc
, "permit", &idx
);
14397 argv_find(argv
, argc
, "deny", &idx
);
14400 direct
= argv_find(argv
, argc
, "permit", &idx
)
14405 argv_find(argv
, argc
, "AA:NN", &idx
);
14406 str
= argv_concat(argv
, argc
, idx
);
14410 argv_find(argv
, argc
, "(100-500)", &idx
);
14411 argv_find(argv
, argc
, "WORD", &idx
);
14412 cl_name_or_number
= argv
[idx
]->arg
;
14414 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14417 XFREE(MTYPE_TMP
, str
);
14420 community_list_perror(vty
, ret
);
14421 return CMD_WARNING_CONFIG_FAILED
;
14424 return CMD_SUCCESS
;
14427 ALIAS (no_community_list_expanded_all
,
14428 no_ip_community_list_expanded_all_cmd
,
14429 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14433 "Community list number (expanded)\n"
14434 "Add an expanded community-list entry\n"
14435 "Community list name\n"
14436 "Specify community to reject\n"
14437 "Specify community to accept\n"
14440 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14441 "no bgp community-list <(100-500)|expanded WORD>",
14442 NO_STR IP_STR COMMUNITY_LIST_STR
14443 "Community list number (expanded)\n"
14444 "Add an expanded community-list entry\n"
14445 "Community list name\n")
14447 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14448 "no ip community-list <(100-500)|expanded WORD>",
14449 NO_STR IP_STR COMMUNITY_LIST_STR
14450 "Community list number (expanded)\n"
14451 "Add an expanded community-list entry\n"
14452 "Community list name\n")
14454 /* Return configuration string of community-list entry. */
14455 static const char *community_list_config_str(struct community_entry
*entry
)
14462 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14463 str
= community_str(entry
->u
.com
, false);
14464 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14465 str
= lcommunity_str(entry
->u
.lcom
, false);
14467 str
= entry
->config
;
14472 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14474 struct community_entry
*entry
;
14476 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14477 if (entry
== list
->head
) {
14478 if (all_digit(list
->name
))
14479 vty_out(vty
, "Community %s list %s\n",
14480 entry
->style
== COMMUNITY_LIST_STANDARD
14482 : "(expanded) access",
14485 vty_out(vty
, "Named Community %s list %s\n",
14486 entry
->style
== COMMUNITY_LIST_STANDARD
14492 vty_out(vty
, " %s\n",
14493 community_direct_str(entry
->direct
));
14495 vty_out(vty
, " %s %s\n",
14496 community_direct_str(entry
->direct
),
14497 community_list_config_str(entry
));
14501 DEFUN (show_community_list
,
14502 show_bgp_community_list_cmd
,
14503 "show bgp community-list",
14506 "List community-list\n")
14508 struct community_list
*list
;
14509 struct community_list_master
*cm
;
14512 if (argv_find(argv
, argc
, "ip", &idx
)) {
14513 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14514 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14515 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14516 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14518 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14520 return CMD_SUCCESS
;
14522 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14523 community_list_show(vty
, list
);
14525 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14526 community_list_show(vty
, list
);
14528 return CMD_SUCCESS
;
14531 ALIAS (show_community_list
,
14532 show_ip_community_list_cmd
,
14533 "show ip community-list",
14536 "List community-list\n")
14538 DEFUN (show_community_list_arg
,
14539 show_bgp_community_list_arg_cmd
,
14540 "show bgp community-list <(1-500)|WORD>",
14543 "List community-list\n"
14544 "Community-list number\n"
14545 "Community-list name\n")
14547 int idx_comm_list
= 3;
14548 struct community_list
*list
;
14551 if (argv_find(argv
, argc
, "ip", &idx
)) {
14552 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14553 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14554 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14555 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14557 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14558 COMMUNITY_LIST_MASTER
);
14560 vty_out(vty
, "%% Can't find community-list\n");
14561 return CMD_WARNING
;
14564 community_list_show(vty
, list
);
14566 return CMD_SUCCESS
;
14569 ALIAS (show_community_list_arg
,
14570 show_ip_community_list_arg_cmd
,
14571 "show ip community-list <(1-500)|WORD>",
14574 "List community-list\n"
14575 "Community-list number\n"
14576 "Community-list name\n")
14579 * Large Community code.
14581 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14582 struct cmd_token
**argv
, int style
,
14583 int reject_all_digit_name
)
14591 if (argv_find(argv
, argc
, "ip", &idx
)) {
14592 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14593 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14594 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14595 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14597 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14600 /* All digit name check. */
14602 argv_find(argv
, argc
, "WORD", &idx
);
14603 argv_find(argv
, argc
, "(1-99)", &idx
);
14604 argv_find(argv
, argc
, "(100-500)", &idx
);
14605 cl_name
= argv
[idx
]->arg
;
14606 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14607 vty_out(vty
, "%% Community name cannot have all digits\n");
14608 return CMD_WARNING_CONFIG_FAILED
;
14612 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14613 argv_find(argv
, argc
, "LINE", &idx
);
14614 /* Concat community string argument. */
14616 str
= argv_concat(argv
, argc
, idx
);
14620 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14622 /* Free temporary community list string allocated by
14624 XFREE(MTYPE_TMP
, str
);
14627 community_list_perror(vty
, ret
);
14628 return CMD_WARNING_CONFIG_FAILED
;
14630 return CMD_SUCCESS
;
14633 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14634 struct cmd_token
**argv
, int style
)
14641 if (argv_find(argv
, argc
, "ip", &idx
)) {
14642 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14643 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14644 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14645 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14647 argv_find(argv
, argc
, "permit", &idx
);
14648 argv_find(argv
, argc
, "deny", &idx
);
14651 /* Check the list direct. */
14652 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14653 direct
= COMMUNITY_PERMIT
;
14655 direct
= COMMUNITY_DENY
;
14658 argv_find(argv
, argc
, "LINE", &idx
);
14659 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14660 /* Concat community string argument. */
14661 str
= argv_concat(argv
, argc
, idx
);
14665 argv_find(argv
, argc
, "(1-99)", &idx
);
14666 argv_find(argv
, argc
, "(100-500)", &idx
);
14667 argv_find(argv
, argc
, "WORD", &idx
);
14669 /* Unset community list. */
14670 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14673 /* Free temporary community list string allocated by
14675 XFREE(MTYPE_TMP
, str
);
14678 community_list_perror(vty
, ret
);
14679 return CMD_WARNING_CONFIG_FAILED
;
14682 return CMD_SUCCESS
;
14685 /* "large-community-list" keyword help string. */
14686 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14687 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14689 #if CONFDATE > 20191005
14690 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14692 DEFUN (lcommunity_list_standard
,
14693 bgp_lcommunity_list_standard_cmd
,
14694 "bgp large-community-list (1-99) <deny|permit>",
14696 LCOMMUNITY_LIST_STR
14697 "Large Community list number (standard)\n"
14698 "Specify large community to reject\n"
14699 "Specify large community to accept\n")
14701 return lcommunity_list_set_vty(vty
, argc
, argv
,
14702 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14705 ALIAS (lcommunity_list_standard
,
14706 ip_lcommunity_list_standard_cmd
,
14707 "ip large-community-list (1-99) <deny|permit>",
14709 LCOMMUNITY_LIST_STR
14710 "Large Community list number (standard)\n"
14711 "Specify large community to reject\n"
14712 "Specify large community to accept\n")
14714 DEFUN (lcommunity_list_standard1
,
14715 bgp_lcommunity_list_standard1_cmd
,
14716 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14718 LCOMMUNITY_LIST_STR
14719 "Large Community list number (standard)\n"
14720 "Specify large community to reject\n"
14721 "Specify large community to accept\n"
14722 LCOMMUNITY_VAL_STR
)
14724 return lcommunity_list_set_vty(vty
, argc
, argv
,
14725 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14728 ALIAS (lcommunity_list_standard1
,
14729 ip_lcommunity_list_standard1_cmd
,
14730 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14732 LCOMMUNITY_LIST_STR
14733 "Large Community list number (standard)\n"
14734 "Specify large community to reject\n"
14735 "Specify large community to accept\n"
14736 LCOMMUNITY_VAL_STR
)
14738 DEFUN (lcommunity_list_expanded
,
14739 bgp_lcommunity_list_expanded_cmd
,
14740 "bgp large-community-list (100-500) <deny|permit> LINE...",
14742 LCOMMUNITY_LIST_STR
14743 "Large Community list number (expanded)\n"
14744 "Specify large community to reject\n"
14745 "Specify large community to accept\n"
14746 "An ordered list as a regular-expression\n")
14748 return lcommunity_list_set_vty(vty
, argc
, argv
,
14749 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14752 ALIAS (lcommunity_list_expanded
,
14753 ip_lcommunity_list_expanded_cmd
,
14754 "ip large-community-list (100-500) <deny|permit> LINE...",
14756 LCOMMUNITY_LIST_STR
14757 "Large Community list number (expanded)\n"
14758 "Specify large community to reject\n"
14759 "Specify large community to accept\n"
14760 "An ordered list as a regular-expression\n")
14762 DEFUN (lcommunity_list_name_standard
,
14763 bgp_lcommunity_list_name_standard_cmd
,
14764 "bgp large-community-list standard WORD <deny|permit>",
14766 LCOMMUNITY_LIST_STR
14767 "Specify standard large-community-list\n"
14768 "Large Community list name\n"
14769 "Specify large community to reject\n"
14770 "Specify large community to accept\n")
14772 return lcommunity_list_set_vty(vty
, argc
, argv
,
14773 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14776 ALIAS (lcommunity_list_name_standard
,
14777 ip_lcommunity_list_name_standard_cmd
,
14778 "ip large-community-list standard WORD <deny|permit>",
14780 LCOMMUNITY_LIST_STR
14781 "Specify standard large-community-list\n"
14782 "Large Community list name\n"
14783 "Specify large community to reject\n"
14784 "Specify large community to accept\n")
14786 DEFUN (lcommunity_list_name_standard1
,
14787 bgp_lcommunity_list_name_standard1_cmd
,
14788 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14790 LCOMMUNITY_LIST_STR
14791 "Specify standard large-community-list\n"
14792 "Large Community list name\n"
14793 "Specify large community to reject\n"
14794 "Specify large community to accept\n"
14795 LCOMMUNITY_VAL_STR
)
14797 return lcommunity_list_set_vty(vty
, argc
, argv
,
14798 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14801 ALIAS (lcommunity_list_name_standard1
,
14802 ip_lcommunity_list_name_standard1_cmd
,
14803 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14805 LCOMMUNITY_LIST_STR
14806 "Specify standard large-community-list\n"
14807 "Large Community list name\n"
14808 "Specify large community to reject\n"
14809 "Specify large community to accept\n"
14810 LCOMMUNITY_VAL_STR
)
14812 DEFUN (lcommunity_list_name_expanded
,
14813 bgp_lcommunity_list_name_expanded_cmd
,
14814 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14816 LCOMMUNITY_LIST_STR
14817 "Specify expanded large-community-list\n"
14818 "Large Community list name\n"
14819 "Specify large community to reject\n"
14820 "Specify large community to accept\n"
14821 "An ordered list as a regular-expression\n")
14823 return lcommunity_list_set_vty(vty
, argc
, argv
,
14824 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14827 ALIAS (lcommunity_list_name_expanded
,
14828 ip_lcommunity_list_name_expanded_cmd
,
14829 "ip large-community-list expanded WORD <deny|permit> LINE...",
14831 LCOMMUNITY_LIST_STR
14832 "Specify expanded large-community-list\n"
14833 "Large Community list name\n"
14834 "Specify large community to reject\n"
14835 "Specify large community to accept\n"
14836 "An ordered list as a regular-expression\n")
14838 DEFUN (no_lcommunity_list_standard_all
,
14839 no_bgp_lcommunity_list_standard_all_cmd
,
14840 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14843 LCOMMUNITY_LIST_STR
14844 "Large Community list number (standard)\n"
14845 "Large Community list number (expanded)\n"
14846 "Large Community list name\n")
14848 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14849 LARGE_COMMUNITY_LIST_STANDARD
);
14852 ALIAS (no_lcommunity_list_standard_all
,
14853 no_ip_lcommunity_list_standard_all_cmd
,
14854 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14857 LCOMMUNITY_LIST_STR
14858 "Large Community list number (standard)\n"
14859 "Large Community list number (expanded)\n"
14860 "Large Community list name\n")
14862 DEFUN (no_lcommunity_list_name_expanded_all
,
14863 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14864 "no bgp large-community-list expanded WORD",
14867 LCOMMUNITY_LIST_STR
14868 "Specify expanded large-community-list\n"
14869 "Large Community list name\n")
14871 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14872 LARGE_COMMUNITY_LIST_EXPANDED
);
14875 ALIAS (no_lcommunity_list_name_expanded_all
,
14876 no_ip_lcommunity_list_name_expanded_all_cmd
,
14877 "no ip large-community-list expanded WORD",
14880 LCOMMUNITY_LIST_STR
14881 "Specify expanded large-community-list\n"
14882 "Large Community list name\n")
14884 DEFUN (no_lcommunity_list_standard
,
14885 no_bgp_lcommunity_list_standard_cmd
,
14886 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14889 LCOMMUNITY_LIST_STR
14890 "Large Community list number (standard)\n"
14891 "Specify large community to reject\n"
14892 "Specify large community to accept\n"
14893 LCOMMUNITY_VAL_STR
)
14895 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14896 LARGE_COMMUNITY_LIST_STANDARD
);
14899 ALIAS (no_lcommunity_list_standard
,
14900 no_ip_lcommunity_list_standard_cmd
,
14901 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14904 LCOMMUNITY_LIST_STR
14905 "Large Community list number (standard)\n"
14906 "Specify large community to reject\n"
14907 "Specify large community to accept\n"
14908 LCOMMUNITY_VAL_STR
)
14910 DEFUN (no_lcommunity_list_expanded
,
14911 no_bgp_lcommunity_list_expanded_cmd
,
14912 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14915 LCOMMUNITY_LIST_STR
14916 "Large Community list number (expanded)\n"
14917 "Specify large community to reject\n"
14918 "Specify large community to accept\n"
14919 "An ordered list as a regular-expression\n")
14921 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14922 LARGE_COMMUNITY_LIST_EXPANDED
);
14925 ALIAS (no_lcommunity_list_expanded
,
14926 no_ip_lcommunity_list_expanded_cmd
,
14927 "no ip large-community-list (100-500) <deny|permit> LINE...",
14930 LCOMMUNITY_LIST_STR
14931 "Large Community list number (expanded)\n"
14932 "Specify large community to reject\n"
14933 "Specify large community to accept\n"
14934 "An ordered list as a regular-expression\n")
14936 DEFUN (no_lcommunity_list_name_standard
,
14937 no_bgp_lcommunity_list_name_standard_cmd
,
14938 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14941 LCOMMUNITY_LIST_STR
14942 "Specify standard large-community-list\n"
14943 "Large Community list name\n"
14944 "Specify large community to reject\n"
14945 "Specify large community to accept\n"
14946 LCOMMUNITY_VAL_STR
)
14948 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14949 LARGE_COMMUNITY_LIST_STANDARD
);
14952 ALIAS (no_lcommunity_list_name_standard
,
14953 no_ip_lcommunity_list_name_standard_cmd
,
14954 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14957 LCOMMUNITY_LIST_STR
14958 "Specify standard large-community-list\n"
14959 "Large Community list name\n"
14960 "Specify large community to reject\n"
14961 "Specify large community to accept\n"
14962 LCOMMUNITY_VAL_STR
)
14964 DEFUN (no_lcommunity_list_name_expanded
,
14965 no_bgp_lcommunity_list_name_expanded_cmd
,
14966 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14969 LCOMMUNITY_LIST_STR
14970 "Specify expanded large-community-list\n"
14971 "Large community list name\n"
14972 "Specify large community to reject\n"
14973 "Specify large community to accept\n"
14974 "An ordered list as a regular-expression\n")
14976 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14977 LARGE_COMMUNITY_LIST_EXPANDED
);
14980 ALIAS (no_lcommunity_list_name_expanded
,
14981 no_ip_lcommunity_list_name_expanded_cmd
,
14982 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14985 LCOMMUNITY_LIST_STR
14986 "Specify expanded large-community-list\n"
14987 "Large community list name\n"
14988 "Specify large community to reject\n"
14989 "Specify large community to accept\n"
14990 "An ordered list as a regular-expression\n")
14992 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14994 struct community_entry
*entry
;
14996 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14997 if (entry
== list
->head
) {
14998 if (all_digit(list
->name
))
14999 vty_out(vty
, "Large community %s list %s\n",
15001 LARGE_COMMUNITY_LIST_STANDARD
15003 : "(expanded) access",
15007 "Named large community %s list %s\n",
15009 LARGE_COMMUNITY_LIST_STANDARD
15015 vty_out(vty
, " %s\n",
15016 community_direct_str(entry
->direct
));
15018 vty_out(vty
, " %s %s\n",
15019 community_direct_str(entry
->direct
),
15020 community_list_config_str(entry
));
15024 DEFUN (show_lcommunity_list
,
15025 show_bgp_lcommunity_list_cmd
,
15026 "show bgp large-community-list",
15029 "List large-community list\n")
15031 struct community_list
*list
;
15032 struct community_list_master
*cm
;
15035 if (argv_find(argv
, argc
, "ip", &idx
)) {
15036 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15037 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15038 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15039 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15042 cm
= community_list_master_lookup(bgp_clist
,
15043 LARGE_COMMUNITY_LIST_MASTER
);
15045 return CMD_SUCCESS
;
15047 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15048 lcommunity_list_show(vty
, list
);
15050 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15051 lcommunity_list_show(vty
, list
);
15053 return CMD_SUCCESS
;
15056 ALIAS (show_lcommunity_list
,
15057 show_ip_lcommunity_list_cmd
,
15058 "show ip large-community-list",
15061 "List large-community list\n")
15063 DEFUN (show_lcommunity_list_arg
,
15064 show_bgp_lcommunity_list_arg_cmd
,
15065 "show bgp large-community-list <(1-500)|WORD>",
15068 "List large-community list\n"
15069 "large-community-list number\n"
15070 "large-community-list name\n")
15072 struct community_list
*list
;
15075 if (argv_find(argv
, argc
, "ip", &idx
)) {
15076 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15077 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15078 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15079 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15082 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
15083 LARGE_COMMUNITY_LIST_MASTER
);
15085 vty_out(vty
, "%% Can't find extcommunity-list\n");
15086 return CMD_WARNING
;
15089 lcommunity_list_show(vty
, list
);
15091 return CMD_SUCCESS
;
15094 ALIAS (show_lcommunity_list_arg
,
15095 show_ip_lcommunity_list_arg_cmd
,
15096 "show ip large-community-list <(1-500)|WORD>",
15099 "List large-community list\n"
15100 "large-community-list number\n"
15101 "large-community-list name\n")
15103 /* "extcommunity-list" keyword help string. */
15104 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15105 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15107 DEFUN (extcommunity_list_standard
,
15108 bgp_extcommunity_list_standard_cmd
,
15109 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15111 EXTCOMMUNITY_LIST_STR
15112 "Extended Community list number (standard)\n"
15113 "Specify standard extcommunity-list\n"
15114 "Community list name\n"
15115 "Specify community to reject\n"
15116 "Specify community to accept\n"
15117 EXTCOMMUNITY_VAL_STR
)
15119 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15121 char *cl_number_or_name
= NULL
;
15124 if (argv_find(argv
, argc
, "ip", &idx
)) {
15125 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15126 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15127 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15128 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15130 argv_find(argv
, argc
, "(1-99)", &idx
);
15131 argv_find(argv
, argc
, "WORD", &idx
);
15132 cl_number_or_name
= argv
[idx
]->arg
;
15133 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15135 argv_find(argv
, argc
, "AA:NN", &idx
);
15136 char *str
= argv_concat(argv
, argc
, idx
);
15138 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15141 XFREE(MTYPE_TMP
, str
);
15144 community_list_perror(vty
, ret
);
15145 return CMD_WARNING_CONFIG_FAILED
;
15148 return CMD_SUCCESS
;
15151 #if CONFDATE > 20191005
15152 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15154 ALIAS (extcommunity_list_standard
,
15155 ip_extcommunity_list_standard_cmd
,
15156 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15158 EXTCOMMUNITY_LIST_STR
15159 "Extended Community list number (standard)\n"
15160 "Specify standard extcommunity-list\n"
15161 "Community list name\n"
15162 "Specify community to reject\n"
15163 "Specify community to accept\n"
15164 EXTCOMMUNITY_VAL_STR
)
15166 DEFUN (extcommunity_list_name_expanded
,
15167 bgp_extcommunity_list_name_expanded_cmd
,
15168 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15170 EXTCOMMUNITY_LIST_STR
15171 "Extended Community list number (expanded)\n"
15172 "Specify expanded extcommunity-list\n"
15173 "Extended Community list name\n"
15174 "Specify community to reject\n"
15175 "Specify community to accept\n"
15176 "An ordered list as a regular-expression\n")
15178 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15180 char *cl_number_or_name
= NULL
;
15183 if (argv_find(argv
, argc
, "ip", &idx
)) {
15184 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15185 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15186 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15187 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15190 argv_find(argv
, argc
, "(100-500)", &idx
);
15191 argv_find(argv
, argc
, "WORD", &idx
);
15192 cl_number_or_name
= argv
[idx
]->arg
;
15193 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15195 argv_find(argv
, argc
, "LINE", &idx
);
15196 char *str
= argv_concat(argv
, argc
, idx
);
15198 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15201 XFREE(MTYPE_TMP
, str
);
15204 community_list_perror(vty
, ret
);
15205 return CMD_WARNING_CONFIG_FAILED
;
15208 return CMD_SUCCESS
;
15211 ALIAS (extcommunity_list_name_expanded
,
15212 ip_extcommunity_list_name_expanded_cmd
,
15213 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15215 EXTCOMMUNITY_LIST_STR
15216 "Extended Community list number (expanded)\n"
15217 "Specify expanded extcommunity-list\n"
15218 "Extended Community list name\n"
15219 "Specify community to reject\n"
15220 "Specify community to accept\n"
15221 "An ordered list as a regular-expression\n")
15223 DEFUN (no_extcommunity_list_standard_all
,
15224 no_bgp_extcommunity_list_standard_all_cmd
,
15225 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15228 EXTCOMMUNITY_LIST_STR
15229 "Extended Community list number (standard)\n"
15230 "Specify standard extcommunity-list\n"
15231 "Community list name\n"
15232 "Specify community to reject\n"
15233 "Specify community to accept\n"
15234 EXTCOMMUNITY_VAL_STR
)
15236 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15238 char *cl_number_or_name
= NULL
;
15242 if (argv_find(argv
, argc
, "ip", &idx
)) {
15243 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15244 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15245 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15246 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15250 argv_find(argv
, argc
, "permit", &idx
);
15251 argv_find(argv
, argc
, "deny", &idx
);
15254 direct
= argv_find(argv
, argc
, "permit", &idx
)
15259 argv_find(argv
, argc
, "AA:NN", &idx
);
15260 str
= argv_concat(argv
, argc
, idx
);
15264 argv_find(argv
, argc
, "(1-99)", &idx
);
15265 argv_find(argv
, argc
, "WORD", &idx
);
15266 cl_number_or_name
= argv
[idx
]->arg
;
15268 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15271 XFREE(MTYPE_TMP
, str
);
15274 community_list_perror(vty
, ret
);
15275 return CMD_WARNING_CONFIG_FAILED
;
15278 return CMD_SUCCESS
;
15281 ALIAS (no_extcommunity_list_standard_all
,
15282 no_ip_extcommunity_list_standard_all_cmd
,
15283 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15286 EXTCOMMUNITY_LIST_STR
15287 "Extended Community list number (standard)\n"
15288 "Specify standard extcommunity-list\n"
15289 "Community list name\n"
15290 "Specify community to reject\n"
15291 "Specify community to accept\n"
15292 EXTCOMMUNITY_VAL_STR
)
15294 ALIAS(no_extcommunity_list_standard_all
,
15295 no_bgp_extcommunity_list_standard_all_list_cmd
,
15296 "no bgp extcommunity-list <(1-99)|standard WORD>",
15297 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15298 "Extended Community list number (standard)\n"
15299 "Specify standard extcommunity-list\n"
15300 "Community list name\n")
15302 ALIAS(no_extcommunity_list_standard_all
,
15303 no_ip_extcommunity_list_standard_all_list_cmd
,
15304 "no ip extcommunity-list <(1-99)|standard WORD>",
15305 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15306 "Extended Community list number (standard)\n"
15307 "Specify standard extcommunity-list\n"
15308 "Community list name\n")
15310 DEFUN (no_extcommunity_list_expanded_all
,
15311 no_bgp_extcommunity_list_expanded_all_cmd
,
15312 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15315 EXTCOMMUNITY_LIST_STR
15316 "Extended Community list number (expanded)\n"
15317 "Specify expanded extcommunity-list\n"
15318 "Extended Community list name\n"
15319 "Specify community to reject\n"
15320 "Specify community to accept\n"
15321 "An ordered list as a regular-expression\n")
15323 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15325 char *cl_number_or_name
= NULL
;
15329 if (argv_find(argv
, argc
, "ip", &idx
)) {
15330 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15331 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15332 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15333 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15337 argv_find(argv
, argc
, "permit", &idx
);
15338 argv_find(argv
, argc
, "deny", &idx
);
15341 direct
= argv_find(argv
, argc
, "permit", &idx
)
15346 argv_find(argv
, argc
, "LINE", &idx
);
15347 str
= argv_concat(argv
, argc
, idx
);
15351 argv_find(argv
, argc
, "(100-500)", &idx
);
15352 argv_find(argv
, argc
, "WORD", &idx
);
15353 cl_number_or_name
= argv
[idx
]->arg
;
15355 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15358 XFREE(MTYPE_TMP
, str
);
15361 community_list_perror(vty
, ret
);
15362 return CMD_WARNING_CONFIG_FAILED
;
15365 return CMD_SUCCESS
;
15368 ALIAS (no_extcommunity_list_expanded_all
,
15369 no_ip_extcommunity_list_expanded_all_cmd
,
15370 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15373 EXTCOMMUNITY_LIST_STR
15374 "Extended Community list number (expanded)\n"
15375 "Specify expanded extcommunity-list\n"
15376 "Extended Community list name\n"
15377 "Specify community to reject\n"
15378 "Specify community to accept\n"
15379 "An ordered list as a regular-expression\n")
15381 ALIAS(no_extcommunity_list_expanded_all
,
15382 no_ip_extcommunity_list_expanded_all_list_cmd
,
15383 "no ip extcommunity-list <(100-500)|expanded WORD>",
15384 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15385 "Extended Community list number (expanded)\n"
15386 "Specify expanded extcommunity-list\n"
15387 "Extended Community list name\n")
15389 ALIAS(no_extcommunity_list_expanded_all
,
15390 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15391 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15392 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15393 "Extended Community list number (expanded)\n"
15394 "Specify expanded extcommunity-list\n"
15395 "Extended Community list name\n")
15397 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15399 struct community_entry
*entry
;
15401 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15402 if (entry
== list
->head
) {
15403 if (all_digit(list
->name
))
15404 vty_out(vty
, "Extended community %s list %s\n",
15405 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15407 : "(expanded) access",
15411 "Named extended community %s list %s\n",
15412 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15418 vty_out(vty
, " %s\n",
15419 community_direct_str(entry
->direct
));
15421 vty_out(vty
, " %s %s\n",
15422 community_direct_str(entry
->direct
),
15423 community_list_config_str(entry
));
15427 DEFUN (show_extcommunity_list
,
15428 show_bgp_extcommunity_list_cmd
,
15429 "show bgp extcommunity-list",
15432 "List extended-community list\n")
15434 struct community_list
*list
;
15435 struct community_list_master
*cm
;
15438 if (argv_find(argv
, argc
, "ip", &idx
)) {
15439 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15440 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15441 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15442 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15444 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15446 return CMD_SUCCESS
;
15448 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15449 extcommunity_list_show(vty
, list
);
15451 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15452 extcommunity_list_show(vty
, list
);
15454 return CMD_SUCCESS
;
15457 ALIAS (show_extcommunity_list
,
15458 show_ip_extcommunity_list_cmd
,
15459 "show ip extcommunity-list",
15462 "List extended-community list\n")
15464 DEFUN (show_extcommunity_list_arg
,
15465 show_bgp_extcommunity_list_arg_cmd
,
15466 "show bgp extcommunity-list <(1-500)|WORD>",
15469 "List extended-community list\n"
15470 "Extcommunity-list number\n"
15471 "Extcommunity-list name\n")
15473 int idx_comm_list
= 3;
15474 struct community_list
*list
;
15477 if (argv_find(argv
, argc
, "ip", &idx
)) {
15478 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15479 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15480 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15481 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15483 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15484 EXTCOMMUNITY_LIST_MASTER
);
15486 vty_out(vty
, "%% Can't find extcommunity-list\n");
15487 return CMD_WARNING
;
15490 extcommunity_list_show(vty
, list
);
15492 return CMD_SUCCESS
;
15495 ALIAS (show_extcommunity_list_arg
,
15496 show_ip_extcommunity_list_arg_cmd
,
15497 "show ip extcommunity-list <(1-500)|WORD>",
15500 "List extended-community list\n"
15501 "Extcommunity-list number\n"
15502 "Extcommunity-list name\n")
15504 /* Display community-list and extcommunity-list configuration. */
15505 static int community_list_config_write(struct vty
*vty
)
15507 struct community_list
*list
;
15508 struct community_entry
*entry
;
15509 struct community_list_master
*cm
;
15512 /* Community-list. */
15513 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15515 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15516 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15517 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15518 community_direct_str(entry
->direct
),
15519 community_list_config_str(entry
));
15522 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15523 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15524 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15525 entry
->style
== COMMUNITY_LIST_STANDARD
15528 list
->name
, community_direct_str(entry
->direct
),
15529 community_list_config_str(entry
));
15533 /* Extcommunity-list. */
15534 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15536 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15537 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15538 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15539 list
->name
, community_direct_str(entry
->direct
),
15540 community_list_config_str(entry
));
15543 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15544 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15545 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15546 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15549 list
->name
, community_direct_str(entry
->direct
),
15550 community_list_config_str(entry
));
15555 /* lcommunity-list. */
15556 cm
= community_list_master_lookup(bgp_clist
,
15557 LARGE_COMMUNITY_LIST_MASTER
);
15559 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15560 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15561 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15562 list
->name
, community_direct_str(entry
->direct
),
15563 community_list_config_str(entry
));
15566 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15567 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15568 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15569 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15572 list
->name
, community_direct_str(entry
->direct
),
15573 community_list_config_str(entry
));
15580 static struct cmd_node community_list_node
= {
15581 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15584 static void community_list_vty(void)
15586 install_node(&community_list_node
, community_list_config_write
);
15588 /* Community-list. */
15589 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15590 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15591 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15592 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15593 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15594 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15595 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15596 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15597 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15598 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15599 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15600 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15601 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15602 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15603 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15604 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15606 /* Extcommunity-list. */
15607 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15608 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15609 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15610 install_element(CONFIG_NODE
,
15611 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15612 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15613 install_element(CONFIG_NODE
,
15614 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15615 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15616 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15617 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15618 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15619 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15620 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15621 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15622 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15623 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15624 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15626 /* Large Community List */
15627 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15628 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15629 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15630 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15631 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15632 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15633 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15634 install_element(CONFIG_NODE
,
15635 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15636 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15637 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15638 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15639 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15640 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15641 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15642 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15643 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15644 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15645 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15646 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15647 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15648 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15649 install_element(CONFIG_NODE
,
15650 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15651 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15652 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15653 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15654 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15655 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15656 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);