2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "memory_vty.h"
39 #include "bgpd/bgpd.h"
40 #include "bgpd/bgp_advertise.h"
41 #include "bgpd/bgp_attr.h"
42 #include "bgpd/bgp_aspath.h"
43 #include "bgpd/bgp_community.h"
44 #include "bgpd/bgp_ecommunity.h"
45 #include "bgpd/bgp_lcommunity.h"
46 #include "bgpd/bgp_damp.h"
47 #include "bgpd/bgp_debug.h"
48 #include "bgpd/bgp_errors.h"
49 #include "bgpd/bgp_fsm.h"
50 #include "bgpd/bgp_nexthop.h"
51 #include "bgpd/bgp_open.h"
52 #include "bgpd/bgp_regex.h"
53 #include "bgpd/bgp_route.h"
54 #include "bgpd/bgp_mplsvpn.h"
55 #include "bgpd/bgp_zebra.h"
56 #include "bgpd/bgp_table.h"
57 #include "bgpd/bgp_vty.h"
58 #include "bgpd/bgp_mpath.h"
59 #include "bgpd/bgp_packet.h"
60 #include "bgpd/bgp_updgrp.h"
61 #include "bgpd/bgp_bfd.h"
62 #include "bgpd/bgp_io.h"
63 #include "bgpd/bgp_evpn.h"
64 #include "bgpd/bgp_addpath.h"
66 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
67 struct prefix
*range
, int exact
);
69 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
78 return BGP_IPV4M_NODE
;
80 case SAFI_LABELED_UNICAST
:
81 return BGP_IPV4L_NODE
;
84 return BGP_VPNV4_NODE
;
87 return BGP_FLOWSPECV4_NODE
;
100 return BGP_IPV6M_NODE
;
102 case SAFI_LABELED_UNICAST
:
103 return BGP_IPV6L_NODE
;
106 return BGP_VPNV6_NODE
;
109 return BGP_FLOWSPECV6_NODE
;
112 return BGP_IPV4_NODE
;
117 return BGP_EVPN_NODE
;
120 // We should never be here but to clarify the switch statement..
121 return BGP_IPV4_NODE
;
125 // Impossible to happen
126 return BGP_IPV4_NODE
;
129 /* Utility function to get address family from current node. */
130 afi_t
bgp_node_afi(struct vty
*vty
)
138 case BGP_FLOWSPECV6_NODE
:
151 /* Utility function to get subsequent address family from current
153 safi_t
bgp_node_safi(struct vty
*vty
)
159 safi
= SAFI_MPLS_VPN
;
163 safi
= SAFI_MULTICAST
;
170 safi
= SAFI_LABELED_UNICAST
;
172 case BGP_FLOWSPECV4_NODE
:
173 case BGP_FLOWSPECV6_NODE
:
174 safi
= SAFI_FLOWSPEC
;
184 * Converts an AFI in string form to afi_t
186 * @param afi string, one of
190 * @return the corresponding afi_t
192 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
194 afi_t afi
= AFI_MAX
; /* unknown */
195 if (strmatch(afi_str
, "ipv4"))
197 else if (strmatch(afi_str
, "ipv6"))
199 else if (strmatch(afi_str
, "l2vpn"))
204 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
208 if (argv_find(argv
, argc
, "ipv4", index
)) {
212 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
220 /* supports <unicast|multicast|vpn|labeled-unicast> */
221 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
223 safi_t safi
= SAFI_MAX
; /* unknown */
224 if (strmatch(safi_str
, "multicast"))
225 safi
= SAFI_MULTICAST
;
226 else if (strmatch(safi_str
, "unicast"))
228 else if (strmatch(safi_str
, "vpn"))
229 safi
= SAFI_MPLS_VPN
;
230 else if (strmatch(safi_str
, "evpn"))
232 else if (strmatch(safi_str
, "labeled-unicast"))
233 safi
= SAFI_LABELED_UNICAST
;
234 else if (strmatch(safi_str
, "flowspec"))
235 safi
= SAFI_FLOWSPEC
;
239 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
243 if (argv_find(argv
, argc
, "unicast", index
)) {
246 *safi
= SAFI_UNICAST
;
247 } else if (argv_find(argv
, argc
, "multicast", index
)) {
250 *safi
= SAFI_MULTICAST
;
251 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
254 *safi
= SAFI_LABELED_UNICAST
;
255 } else if (argv_find(argv
, argc
, "vpn", index
)) {
258 *safi
= SAFI_MPLS_VPN
;
259 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
262 *safi
= SAFI_FLOWSPEC
;
268 * bgp_vty_find_and_parse_afi_safi_bgp
270 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
271 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
272 * to appropriate values for the calling function. This is to allow the
273 * calling function to make decisions appropriate for the show command
274 * that is being parsed.
276 * The show commands are generally of the form:
277 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
278 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
280 * Since we use argv_find if the show command in particular doesn't have:
282 * [<view|vrf> VIEWVRFNAME]
283 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
284 * The command parsing should still be ok.
286 * vty -> The vty for the command so we can output some useful data in
287 * the event of a parse error in the vrf.
288 * argv -> The command tokens
289 * argc -> How many command tokens we have
290 * idx -> The current place in the command, generally should be 0 for this
292 * afi -> The parsed afi if it was included in the show command, returned here
293 * safi -> The parsed safi if it was included in the show command, returned here
294 * bgp -> Pointer to the bgp data structure we need to fill in.
296 * The function returns the correct location in the parse tree for the
299 * Returns 0 for failure to parse correctly, else the idx position of where
300 * it found the last token.
302 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
303 struct cmd_token
**argv
, int argc
,
304 int *idx
, afi_t
*afi
, safi_t
*safi
,
305 struct bgp
**bgp
, bool use_json
)
307 char *vrf_name
= NULL
;
313 if (argv_find(argv
, argc
, "ip", idx
))
316 if (argv_find(argv
, argc
, "view", idx
))
317 vrf_name
= argv
[*idx
+ 1]->arg
;
318 else if (argv_find(argv
, argc
, "vrf", idx
)) {
319 vrf_name
= argv
[*idx
+ 1]->arg
;
320 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
324 if (strmatch(vrf_name
, "all"))
327 *bgp
= bgp_lookup_by_name(vrf_name
);
330 vty_out(vty
, "{}\n");
332 vty_out(vty
, "View/Vrf %s is unknown\n",
339 *bgp
= bgp_get_default();
342 vty_out(vty
, "{}\n");
345 "Default BGP instance not found\n");
351 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
352 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
358 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
360 struct interface
*ifp
= NULL
;
362 if (su
->sa
.sa_family
== AF_INET
)
363 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
364 else if (su
->sa
.sa_family
== AF_INET6
)
365 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
366 su
->sin6
.sin6_scope_id
,
375 /* Utility function for looking up peer from VTY. */
376 /* This is used only for configuration, so disallow if attempted on
377 * a dynamic neighbor.
379 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
381 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
390 ret
= str2sockunion(ip_str
, &su
);
392 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
394 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
397 "%% Malformed address or name: %s\n",
403 peer
= peer_lookup(bgp
, &su
);
406 "%% Specify remote-as or peer-group commands first\n");
409 if (peer_dynamic_neighbor(peer
)) {
411 "%% Operation not allowed on a dynamic neighbor\n");
418 /* Utility function for looking up peer or peer group. */
419 /* This is used only for configuration, so disallow if attempted on
420 * a dynamic neighbor.
422 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
424 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
427 struct peer
*peer
= NULL
;
428 struct peer_group
*group
= NULL
;
434 ret
= str2sockunion(peer_str
, &su
);
436 /* IP address, locate peer. */
437 peer
= peer_lookup(bgp
, &su
);
439 /* Not IP, could match either peer configured on interface or a
441 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
443 group
= peer_group_lookup(bgp
, peer_str
);
447 if (peer_dynamic_neighbor(peer
)) {
449 "%% Operation not allowed on a dynamic neighbor\n");
459 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
464 int bgp_vty_return(struct vty
*vty
, int ret
)
466 const char *str
= NULL
;
469 case BGP_ERR_INVALID_VALUE
:
470 str
= "Invalid value";
472 case BGP_ERR_INVALID_FLAG
:
473 str
= "Invalid flag";
475 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
476 str
= "Peer-group has been shutdown. Activate the peer-group first";
478 case BGP_ERR_PEER_FLAG_CONFLICT
:
479 str
= "Can't set override-capability and strict-capability-match at the same time";
481 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
482 str
= "Specify remote-as or peer-group remote AS first";
484 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
485 str
= "Cannot change the peer-group. Deconfigure first";
487 case BGP_ERR_PEER_GROUP_MISMATCH
:
488 str
= "Peer is not a member of this peer-group";
490 case BGP_ERR_PEER_FILTER_CONFLICT
:
491 str
= "Prefix/distribute list can not co-exist";
493 case BGP_ERR_NOT_INTERNAL_PEER
:
494 str
= "Invalid command. Not an internal neighbor";
496 case BGP_ERR_REMOVE_PRIVATE_AS
:
497 str
= "remove-private-AS cannot be configured for IBGP peers";
499 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
500 str
= "Local-AS allowed only for EBGP peers";
502 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
503 str
= "Cannot have local-as same as BGP AS number";
505 case BGP_ERR_TCPSIG_FAILED
:
506 str
= "Error while applying TCP-Sig to session(s)";
508 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
509 str
= "ebgp-multihop and ttl-security cannot be configured together";
511 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
512 str
= "ttl-security only allowed for EBGP peers";
514 case BGP_ERR_AS_OVERRIDE
:
515 str
= "as-override cannot be configured for IBGP peers";
517 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
518 str
= "Invalid limit for number of dynamic neighbors";
520 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
521 str
= "Dynamic neighbor listen range already exists";
523 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
524 str
= "Operation not allowed on a dynamic neighbor";
526 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
527 str
= "Operation not allowed on a directly connected neighbor";
529 case BGP_ERR_PEER_SAFI_CONFLICT
:
530 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
534 vty_out(vty
, "%% %s\n", str
);
535 return CMD_WARNING_CONFIG_FAILED
;
540 /* BGP clear sort. */
549 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
550 safi_t safi
, int error
)
553 case BGP_ERR_AF_UNCONFIGURED
:
555 "%%BGP: Enable %s address family for the neighbor %s\n",
556 afi_safi_print(afi
, safi
), peer
->host
);
558 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
560 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
568 /* `clear ip bgp' functions. */
569 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
570 enum clear_sort sort
, enum bgp_clear_type stype
,
576 struct listnode
*node
, *nnode
;
578 /* Clear all neighbors. */
580 * Pass along pointer to next node to peer_clear() when walking all
581 * nodes on the BGP instance as that may get freed if it is a
584 if (sort
== clear_all
) {
585 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
586 if (!peer
->afc
[afi
][safi
])
589 if (stype
== BGP_CLEAR_SOFT_NONE
)
590 ret
= peer_clear(peer
, &nnode
);
592 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
595 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
600 /* This is to apply read-only mode on this clear. */
601 if (stype
== BGP_CLEAR_SOFT_NONE
)
602 bgp
->update_delay_over
= 0;
605 vty_out(vty
, "%%BGP: No %s peer configured",
606 afi_safi_print(afi
, safi
));
611 /* Clear specified neighbor. */
612 if (sort
== clear_peer
) {
615 /* Make sockunion for lookup. */
616 ret
= str2sockunion(arg
, &su
);
618 peer
= peer_lookup_by_conf_if(bgp
, arg
);
620 peer
= peer_lookup_by_hostname(bgp
, arg
);
623 "Malformed address or name: %s\n",
629 peer
= peer_lookup(bgp
, &su
);
632 "%%BGP: Unknown neighbor - \"%s\"\n",
638 if (!peer
->afc
[afi
][safi
])
639 ret
= BGP_ERR_AF_UNCONFIGURED
;
640 else if (stype
== BGP_CLEAR_SOFT_NONE
)
641 ret
= peer_clear(peer
, NULL
);
643 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
646 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
651 /* Clear all neighbors belonging to a specific peer-group. */
652 if (sort
== clear_group
) {
653 struct peer_group
*group
;
655 group
= peer_group_lookup(bgp
, arg
);
657 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
661 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
662 if (!peer
->afc
[afi
][safi
])
665 if (stype
== BGP_CLEAR_SOFT_NONE
)
666 ret
= peer_clear(peer
, NULL
);
668 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
671 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
678 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
679 afi_safi_print(afi
, safi
), arg
);
684 /* Clear all external (eBGP) neighbors. */
685 if (sort
== clear_external
) {
686 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
687 if (peer
->sort
== BGP_PEER_IBGP
)
690 if (!peer
->afc
[afi
][safi
])
693 if (stype
== BGP_CLEAR_SOFT_NONE
)
694 ret
= peer_clear(peer
, &nnode
);
696 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
699 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
706 "%%BGP: No external %s peer is configured\n",
707 afi_safi_print(afi
, safi
));
712 /* Clear all neighbors belonging to a specific AS. */
713 if (sort
== clear_as
) {
714 as_t as
= strtoul(arg
, NULL
, 10);
716 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
720 if (!peer
->afc
[afi
][safi
])
721 ret
= BGP_ERR_AF_UNCONFIGURED
;
722 else if (stype
== BGP_CLEAR_SOFT_NONE
)
723 ret
= peer_clear(peer
, &nnode
);
725 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
728 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
735 "%%BGP: No %s peer is configured with AS %s\n",
736 afi_safi_print(afi
, safi
), arg
);
744 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
745 safi_t safi
, enum clear_sort sort
,
746 enum bgp_clear_type stype
, const char *arg
)
750 /* BGP structure lookup. */
752 bgp
= bgp_lookup_by_name(name
);
754 vty_out(vty
, "Can't find BGP instance %s\n", name
);
758 bgp
= bgp_get_default();
760 vty_out(vty
, "No BGP process is configured\n");
765 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
768 /* clear soft inbound */
769 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
771 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
772 BGP_CLEAR_SOFT_IN
, NULL
);
773 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
774 BGP_CLEAR_SOFT_IN
, NULL
);
777 /* clear soft outbound */
778 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
780 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
781 BGP_CLEAR_SOFT_OUT
, NULL
);
782 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
783 BGP_CLEAR_SOFT_OUT
, NULL
);
787 #ifndef VTYSH_EXTRACT_PL
788 #include "bgpd/bgp_vty_clippy.c"
791 /* BGP global configuration. */
792 #if (CONFDATE > 20190601)
793 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
794 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
796 DEFUN_HIDDEN (bgp_multiple_instance_func
,
797 bgp_multiple_instance_cmd
,
798 "bgp multiple-instance",
800 "Enable bgp multiple instance\n")
802 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
806 DEFUN_HIDDEN (no_bgp_multiple_instance
,
807 no_bgp_multiple_instance_cmd
,
808 "no bgp multiple-instance",
811 "BGP multiple instance\n")
815 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
816 vty_out(vty
, "if you are using this please let the developers know\n");
817 zlog_info("Deprecated option: `bgp multiple-instance` being used");
818 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
820 vty_out(vty
, "%% There are more than two BGP instances\n");
821 return CMD_WARNING_CONFIG_FAILED
;
826 DEFUN_HIDDEN (bgp_local_mac
,
828 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
831 "VxLAN Network Identifier\n"
835 "mac-mobility sequence\n"
845 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
846 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
847 vty_out(vty
, "%% Malformed MAC address\n");
850 memset(&ip
, 0, sizeof(ip
));
851 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
853 bgp
= bgp_get_default();
855 vty_out(vty
, "Default BGP instance is not there\n");
859 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
861 vty_out(vty
, "Internal error\n");
868 DEFUN_HIDDEN (no_bgp_local_mac
,
869 no_bgp_local_mac_cmd
,
870 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
874 "VxLAN Network Identifier\n"
885 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
886 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
887 vty_out(vty
, "%% Malformed MAC address\n");
890 memset(&ip
, 0, sizeof(ip
));
892 bgp
= bgp_get_default();
894 vty_out(vty
, "Default BGP instance is not there\n");
898 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
);
900 vty_out(vty
, "Internal error\n");
907 #if (CONFDATE > 20190601)
908 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
909 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
911 DEFUN_HIDDEN (bgp_config_type
,
913 "bgp config-type <cisco|zebra>",
915 "Configuration type\n"
920 if (argv_find(argv
, argc
, "cisco", &idx
)) {
921 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
922 vty_out(vty
, "if you are using this please let the developers know!\n");
923 zlog_info("Deprecated option: `bgp config-type cisco` being used");
924 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
926 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
931 DEFUN_HIDDEN (no_bgp_config_type
,
932 no_bgp_config_type_cmd
,
933 "no bgp config-type [<cisco|zebra>]",
936 "Display configuration type\n"
940 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
945 DEFUN (no_synchronization
,
946 no_synchronization_cmd
,
947 "no synchronization",
949 "Perform IGP synchronization\n")
954 DEFUN (no_auto_summary
,
958 "Enable automatic network number summarization\n")
963 /* "router bgp" commands. */
964 DEFUN_NOSH (router_bgp
,
966 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
970 BGP_INSTANCE_HELP_STR
)
973 int idx_view_vrf
= 3;
979 const char *name
= NULL
;
980 enum bgp_instance_type inst_type
;
982 // "router bgp" without an ASN
984 // Pending: Make VRF option available for ASN less config
985 bgp
= bgp_get_default();
988 vty_out(vty
, "%% No BGP process is configured\n");
989 return CMD_WARNING_CONFIG_FAILED
;
992 if (listcount(bm
->bgp
) > 1) {
993 vty_out(vty
, "%% Please specify ASN and VRF\n");
994 return CMD_WARNING_CONFIG_FAILED
;
1000 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1002 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1004 name
= argv
[idx_vrf
]->arg
;
1006 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1007 if (strmatch(name
, VRF_DEFAULT_NAME
))
1010 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1011 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1012 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1015 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1016 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1018 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
1020 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
1022 "Please specify 'bgp multiple-instance' first\n");
1023 return CMD_WARNING_CONFIG_FAILED
;
1024 case BGP_ERR_AS_MISMATCH
:
1025 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1026 return CMD_WARNING_CONFIG_FAILED
;
1027 case BGP_ERR_INSTANCE_MISMATCH
:
1029 "BGP instance name and AS number mismatch\n");
1031 "BGP instance is already running; AS is %u\n",
1033 return CMD_WARNING_CONFIG_FAILED
;
1037 * If we just instantiated the default instance, complete
1038 * any pending VRF-VPN leaking that was configured via
1039 * earlier "router bgp X vrf FOO" blocks.
1041 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1042 vpn_leak_postchange_all();
1044 /* Pending: handle when user tries to change a view to vrf n vv.
1048 /* unset the auto created flag as the user config is now present */
1049 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1050 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1055 /* "no router bgp" commands. */
1056 DEFUN (no_router_bgp
,
1058 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
1063 BGP_INSTANCE_HELP_STR
)
1069 const char *name
= NULL
;
1071 // "no router bgp" without an ASN
1073 // Pending: Make VRF option available for ASN less config
1074 bgp
= bgp_get_default();
1077 vty_out(vty
, "%% No BGP process is configured\n");
1078 return CMD_WARNING_CONFIG_FAILED
;
1081 if (listcount(bm
->bgp
) > 1) {
1082 vty_out(vty
, "%% Please specify ASN and VRF\n");
1083 return CMD_WARNING_CONFIG_FAILED
;
1087 vty_out(vty
, "%% Please unconfigure l3vni %u",
1089 return CMD_WARNING_CONFIG_FAILED
;
1092 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1095 name
= argv
[idx_vrf
]->arg
;
1097 /* Lookup bgp structure. */
1098 bgp
= bgp_lookup(as
, name
);
1100 vty_out(vty
, "%% Can't find BGP instance\n");
1101 return CMD_WARNING_CONFIG_FAILED
;
1105 vty_out(vty
, "%% Please unconfigure l3vni %u",
1107 return CMD_WARNING_CONFIG_FAILED
;
1117 /* BGP router-id. */
1119 DEFPY (bgp_router_id
,
1121 "bgp router-id A.B.C.D",
1123 "Override configured router identifier\n"
1124 "Manually configured router identifier\n")
1126 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1127 bgp_router_id_static_set(bgp
, router_id
);
1131 DEFPY (no_bgp_router_id
,
1132 no_bgp_router_id_cmd
,
1133 "no bgp router-id [A.B.C.D]",
1136 "Override configured router identifier\n"
1137 "Manually configured router identifier\n")
1139 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1141 if (router_id_str
) {
1142 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1143 vty_out(vty
, "%% BGP router-id doesn't match\n");
1144 return CMD_WARNING_CONFIG_FAILED
;
1148 router_id
.s_addr
= 0;
1149 bgp_router_id_static_set(bgp
, router_id
);
1155 /* BGP Cluster ID. */
1156 DEFUN (bgp_cluster_id
,
1158 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1160 "Configure Route-Reflector Cluster-id\n"
1161 "Route-Reflector Cluster-id in IP address format\n"
1162 "Route-Reflector Cluster-id as 32 bit quantity\n")
1164 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1167 struct in_addr cluster
;
1169 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1171 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1172 return CMD_WARNING_CONFIG_FAILED
;
1175 bgp_cluster_id_set(bgp
, &cluster
);
1176 bgp_clear_star_soft_out(vty
, bgp
->name
);
1181 DEFUN (no_bgp_cluster_id
,
1182 no_bgp_cluster_id_cmd
,
1183 "no 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
);
1191 bgp_cluster_id_unset(bgp
);
1192 bgp_clear_star_soft_out(vty
, bgp
->name
);
1197 DEFUN (bgp_confederation_identifier
,
1198 bgp_confederation_identifier_cmd
,
1199 "bgp confederation identifier (1-4294967295)",
1200 "BGP specific commands\n"
1201 "AS confederation parameters\n"
1203 "Set routing domain confederation AS\n")
1205 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1209 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1211 bgp_confederation_id_set(bgp
, as
);
1216 DEFUN (no_bgp_confederation_identifier
,
1217 no_bgp_confederation_identifier_cmd
,
1218 "no bgp confederation identifier [(1-4294967295)]",
1220 "BGP specific commands\n"
1221 "AS confederation parameters\n"
1223 "Set routing domain confederation AS\n")
1225 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1226 bgp_confederation_id_unset(bgp
);
1231 DEFUN (bgp_confederation_peers
,
1232 bgp_confederation_peers_cmd
,
1233 "bgp confederation peers (1-4294967295)...",
1234 "BGP specific commands\n"
1235 "AS confederation parameters\n"
1236 "Peer ASs in BGP confederation\n"
1239 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1244 for (i
= idx_asn
; i
< argc
; i
++) {
1245 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1247 if (bgp
->as
== as
) {
1249 "%% Local member-AS not allowed in confed peer list\n");
1253 bgp_confederation_peers_add(bgp
, as
);
1258 DEFUN (no_bgp_confederation_peers
,
1259 no_bgp_confederation_peers_cmd
,
1260 "no bgp confederation peers (1-4294967295)...",
1262 "BGP specific commands\n"
1263 "AS confederation parameters\n"
1264 "Peer ASs in BGP confederation\n"
1267 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1272 for (i
= idx_asn
; i
< argc
; i
++) {
1273 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1275 bgp_confederation_peers_remove(bgp
, as
);
1281 * Central routine for maximum-paths configuration.
1282 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1283 * @set: 1 for setting values, 0 for removing the max-paths config.
1285 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1286 const char *mpaths
, uint16_t options
,
1289 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1290 uint16_t maxpaths
= 0;
1295 afi
= bgp_node_afi(vty
);
1296 safi
= bgp_node_safi(vty
);
1299 maxpaths
= strtol(mpaths
, NULL
, 10);
1300 if (maxpaths
> multipath_num
) {
1302 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1303 maxpaths
, multipath_num
);
1304 return CMD_WARNING_CONFIG_FAILED
;
1306 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1309 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1313 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1314 (set
== 1) ? "" : "un",
1315 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1316 maxpaths
, afi
, safi
);
1317 return CMD_WARNING_CONFIG_FAILED
;
1320 bgp_recalculate_all_bestpaths(bgp
);
1325 DEFUN (bgp_maxmed_admin
,
1326 bgp_maxmed_admin_cmd
,
1327 "bgp max-med administrative ",
1329 "Advertise routes with max-med\n"
1330 "Administratively applied, for an indefinite period\n")
1332 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1334 bgp
->v_maxmed_admin
= 1;
1335 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1337 bgp_maxmed_update(bgp
);
1342 DEFUN (bgp_maxmed_admin_medv
,
1343 bgp_maxmed_admin_medv_cmd
,
1344 "bgp max-med administrative (0-4294967295)",
1346 "Advertise routes with max-med\n"
1347 "Administratively applied, for an indefinite period\n"
1348 "Max MED value to be used\n")
1350 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1353 bgp
->v_maxmed_admin
= 1;
1354 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1356 bgp_maxmed_update(bgp
);
1361 DEFUN (no_bgp_maxmed_admin
,
1362 no_bgp_maxmed_admin_cmd
,
1363 "no bgp max-med administrative [(0-4294967295)]",
1366 "Advertise routes with max-med\n"
1367 "Administratively applied, for an indefinite period\n"
1368 "Max MED value to be used\n")
1370 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1371 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1372 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1373 bgp_maxmed_update(bgp
);
1378 DEFUN (bgp_maxmed_onstartup
,
1379 bgp_maxmed_onstartup_cmd
,
1380 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1382 "Advertise routes with max-med\n"
1383 "Effective on a startup\n"
1384 "Time (seconds) period for max-med\n"
1385 "Max MED value to be used\n")
1387 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1390 argv_find(argv
, argc
, "(5-86400)", &idx
);
1391 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1392 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1393 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1395 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1397 bgp_maxmed_update(bgp
);
1402 DEFUN (no_bgp_maxmed_onstartup
,
1403 no_bgp_maxmed_onstartup_cmd
,
1404 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1407 "Advertise routes with max-med\n"
1408 "Effective on a startup\n"
1409 "Time (seconds) period for max-med\n"
1410 "Max MED value to be used\n")
1412 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1414 /* Cancel max-med onstartup if its on */
1415 if (bgp
->t_maxmed_onstartup
) {
1416 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1417 bgp
->maxmed_onstartup_over
= 1;
1420 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1421 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1423 bgp_maxmed_update(bgp
);
1428 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1431 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1432 uint16_t update_delay
;
1433 uint16_t establish_wait
;
1435 update_delay
= strtoul(delay
, NULL
, 10);
1437 if (!wait
) /* update-delay <delay> */
1439 bgp
->v_update_delay
= update_delay
;
1440 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1444 /* update-delay <delay> <establish-wait> */
1445 establish_wait
= atoi(wait
);
1446 if (update_delay
< establish_wait
) {
1448 "%%Failed: update-delay less than the establish-wait!\n");
1449 return CMD_WARNING_CONFIG_FAILED
;
1452 bgp
->v_update_delay
= update_delay
;
1453 bgp
->v_establish_wait
= establish_wait
;
1458 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1460 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1462 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1463 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1468 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1470 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1471 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1472 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1473 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1479 /* Update-delay configuration */
1480 DEFUN (bgp_update_delay
,
1481 bgp_update_delay_cmd
,
1482 "update-delay (0-3600)",
1483 "Force initial delay for best-path and updates\n"
1487 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1490 DEFUN (bgp_update_delay_establish_wait
,
1491 bgp_update_delay_establish_wait_cmd
,
1492 "update-delay (0-3600) (1-3600)",
1493 "Force initial delay for best-path and updates\n"
1498 int idx_number_2
= 2;
1499 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1500 argv
[idx_number_2
]->arg
);
1503 /* Update-delay deconfiguration */
1504 DEFUN (no_bgp_update_delay
,
1505 no_bgp_update_delay_cmd
,
1506 "no update-delay [(0-3600) [(1-3600)]]",
1508 "Force initial delay for best-path and updates\n"
1512 return bgp_update_delay_deconfig_vty(vty
);
1516 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1519 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1522 uint32_t quanta
= strtoul(num
, NULL
, 10);
1523 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1524 memory_order_relaxed
);
1526 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1527 memory_order_relaxed
);
1533 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1536 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1539 uint32_t quanta
= strtoul(num
, NULL
, 10);
1540 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1541 memory_order_relaxed
);
1543 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1544 memory_order_relaxed
);
1550 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1553 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1554 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1555 vty_out(vty
, " write-quanta %d\n", quanta
);
1558 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1561 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1562 if (quanta
!= BGP_READ_PACKET_MAX
)
1563 vty_out(vty
, " read-quanta %d\n", quanta
);
1566 /* Packet quanta configuration */
1567 DEFUN (bgp_wpkt_quanta
,
1568 bgp_wpkt_quanta_cmd
,
1569 "write-quanta (1-10)",
1570 "How many packets to write to peer socket per run\n"
1571 "Number of packets\n")
1574 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1577 DEFUN (no_bgp_wpkt_quanta
,
1578 no_bgp_wpkt_quanta_cmd
,
1579 "no write-quanta (1-10)",
1581 "How many packets to write to peer socket per I/O cycle\n"
1582 "Number of packets\n")
1585 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1588 DEFUN (bgp_rpkt_quanta
,
1589 bgp_rpkt_quanta_cmd
,
1590 "read-quanta (1-10)",
1591 "How many packets to read from peer socket per I/O cycle\n"
1592 "Number of packets\n")
1595 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1598 DEFUN (no_bgp_rpkt_quanta
,
1599 no_bgp_rpkt_quanta_cmd
,
1600 "no read-quanta (1-10)",
1602 "How many packets to read from peer socket per I/O cycle\n"
1603 "Number of packets\n")
1606 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1609 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1611 if (!bgp
->heuristic_coalesce
)
1612 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1616 DEFUN (bgp_coalesce_time
,
1617 bgp_coalesce_time_cmd
,
1618 "coalesce-time (0-4294967295)",
1619 "Subgroup coalesce timer\n"
1620 "Subgroup coalesce timer value (in ms)\n")
1622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1625 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1626 bgp
->heuristic_coalesce
= false;
1627 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1631 DEFUN (no_bgp_coalesce_time
,
1632 no_bgp_coalesce_time_cmd
,
1633 "no coalesce-time (0-4294967295)",
1635 "Subgroup coalesce timer\n"
1636 "Subgroup coalesce timer value (in ms)\n")
1638 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1640 bgp
->heuristic_coalesce
= true;
1641 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1645 /* Maximum-paths configuration */
1646 DEFUN (bgp_maxpaths
,
1648 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1649 "Forward packets over multiple paths\n"
1650 "Number of paths\n")
1653 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1654 argv
[idx_number
]->arg
, 0, 1);
1657 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1658 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1659 "Forward packets over multiple paths\n"
1660 "Number of paths\n")
1662 DEFUN (bgp_maxpaths_ibgp
,
1663 bgp_maxpaths_ibgp_cmd
,
1664 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1665 "Forward packets over multiple paths\n"
1667 "Number of paths\n")
1670 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1671 argv
[idx_number
]->arg
, 0, 1);
1674 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1675 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1676 "Forward packets over multiple paths\n"
1678 "Number of paths\n")
1680 DEFUN (bgp_maxpaths_ibgp_cluster
,
1681 bgp_maxpaths_ibgp_cluster_cmd
,
1682 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1683 "Forward packets over multiple paths\n"
1686 "Match the cluster length\n")
1689 return bgp_maxpaths_config_vty(
1690 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1691 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1694 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1695 "maximum-paths ibgp " CMD_RANGE_STR(
1696 1, MULTIPATH_NUM
) " equal-cluster-length",
1697 "Forward packets over multiple paths\n"
1700 "Match the cluster length\n")
1702 DEFUN (no_bgp_maxpaths
,
1703 no_bgp_maxpaths_cmd
,
1704 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1706 "Forward packets over multiple paths\n"
1707 "Number of paths\n")
1709 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1712 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1713 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1714 "Forward packets over multiple paths\n"
1715 "Number of paths\n")
1717 DEFUN (no_bgp_maxpaths_ibgp
,
1718 no_bgp_maxpaths_ibgp_cmd
,
1719 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1721 "Forward packets over multiple paths\n"
1724 "Match the cluster length\n")
1726 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1729 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1730 "no maximum-paths ibgp [" CMD_RANGE_STR(
1731 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1733 "Forward packets over multiple paths\n"
1736 "Match the cluster length\n")
1738 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1741 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1742 vty_out(vty
, " maximum-paths %d\n",
1743 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1746 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1747 vty_out(vty
, " maximum-paths ibgp %d",
1748 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1749 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1750 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1751 vty_out(vty
, " equal-cluster-length");
1760 "timers bgp (0-65535) (0-65535)",
1761 "Adjust routing timers\n"
1763 "Keepalive interval\n"
1766 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1768 int idx_number_2
= 3;
1769 unsigned long keepalive
= 0;
1770 unsigned long holdtime
= 0;
1772 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1773 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1775 /* Holdtime value check. */
1776 if (holdtime
< 3 && holdtime
!= 0) {
1778 "%% hold time value must be either 0 or greater than 3\n");
1779 return CMD_WARNING_CONFIG_FAILED
;
1782 bgp_timers_set(bgp
, keepalive
, holdtime
);
1787 DEFUN (no_bgp_timers
,
1789 "no timers bgp [(0-65535) (0-65535)]",
1791 "Adjust routing timers\n"
1793 "Keepalive interval\n"
1796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1797 bgp_timers_unset(bgp
);
1803 DEFUN (bgp_client_to_client_reflection
,
1804 bgp_client_to_client_reflection_cmd
,
1805 "bgp client-to-client reflection",
1806 "BGP specific commands\n"
1807 "Configure client to client route reflection\n"
1808 "reflection of routes allowed\n")
1810 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1811 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1812 bgp_clear_star_soft_out(vty
, bgp
->name
);
1817 DEFUN (no_bgp_client_to_client_reflection
,
1818 no_bgp_client_to_client_reflection_cmd
,
1819 "no bgp client-to-client reflection",
1821 "BGP specific commands\n"
1822 "Configure client to client route reflection\n"
1823 "reflection of routes allowed\n")
1825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1826 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1827 bgp_clear_star_soft_out(vty
, bgp
->name
);
1832 /* "bgp always-compare-med" configuration. */
1833 DEFUN (bgp_always_compare_med
,
1834 bgp_always_compare_med_cmd
,
1835 "bgp always-compare-med",
1836 "BGP specific commands\n"
1837 "Allow comparing MED from different neighbors\n")
1839 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1840 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1841 bgp_recalculate_all_bestpaths(bgp
);
1846 DEFUN (no_bgp_always_compare_med
,
1847 no_bgp_always_compare_med_cmd
,
1848 "no bgp always-compare-med",
1850 "BGP specific commands\n"
1851 "Allow comparing MED from different neighbors\n")
1853 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1854 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1855 bgp_recalculate_all_bestpaths(bgp
);
1860 /* "bgp deterministic-med" configuration. */
1861 DEFUN (bgp_deterministic_med
,
1862 bgp_deterministic_med_cmd
,
1863 "bgp deterministic-med",
1864 "BGP specific commands\n"
1865 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1869 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1870 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1871 bgp_recalculate_all_bestpaths(bgp
);
1877 DEFUN (no_bgp_deterministic_med
,
1878 no_bgp_deterministic_med_cmd
,
1879 "no bgp deterministic-med",
1881 "BGP specific commands\n"
1882 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1885 int bestpath_per_as_used
;
1889 struct listnode
*node
, *nnode
;
1891 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1892 bestpath_per_as_used
= 0;
1894 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1895 FOREACH_AFI_SAFI (afi
, safi
)
1896 if (bgp_addpath_dmed_required(
1897 peer
->addpath_type
[afi
][safi
])) {
1898 bestpath_per_as_used
= 1;
1902 if (bestpath_per_as_used
)
1906 if (bestpath_per_as_used
) {
1908 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1909 return CMD_WARNING_CONFIG_FAILED
;
1911 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1912 bgp_recalculate_all_bestpaths(bgp
);
1919 /* "bgp graceful-restart" configuration. */
1920 DEFUN (bgp_graceful_restart
,
1921 bgp_graceful_restart_cmd
,
1922 "bgp graceful-restart",
1923 "BGP specific commands\n"
1924 "Graceful restart capability parameters\n")
1926 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1927 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1931 DEFUN (no_bgp_graceful_restart
,
1932 no_bgp_graceful_restart_cmd
,
1933 "no bgp graceful-restart",
1935 "BGP specific commands\n"
1936 "Graceful restart capability parameters\n")
1938 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1939 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1943 DEFUN (bgp_graceful_restart_stalepath_time
,
1944 bgp_graceful_restart_stalepath_time_cmd
,
1945 "bgp graceful-restart stalepath-time (1-3600)",
1946 "BGP specific commands\n"
1947 "Graceful restart capability parameters\n"
1948 "Set the max time to hold onto restarting peer's stale paths\n"
1949 "Delay value (seconds)\n")
1951 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1955 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1956 bgp
->stalepath_time
= stalepath
;
1960 DEFUN (bgp_graceful_restart_restart_time
,
1961 bgp_graceful_restart_restart_time_cmd
,
1962 "bgp graceful-restart restart-time (1-3600)",
1963 "BGP specific commands\n"
1964 "Graceful restart capability parameters\n"
1965 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1966 "Delay value (seconds)\n")
1968 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1972 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1973 bgp
->restart_time
= restart
;
1977 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1978 no_bgp_graceful_restart_stalepath_time_cmd
,
1979 "no bgp graceful-restart stalepath-time [(1-3600)]",
1981 "BGP specific commands\n"
1982 "Graceful restart capability parameters\n"
1983 "Set the max time to hold onto restarting peer's stale paths\n"
1984 "Delay value (seconds)\n")
1986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1988 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1992 DEFUN (no_bgp_graceful_restart_restart_time
,
1993 no_bgp_graceful_restart_restart_time_cmd
,
1994 "no bgp graceful-restart restart-time [(1-3600)]",
1996 "BGP specific commands\n"
1997 "Graceful restart capability parameters\n"
1998 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1999 "Delay value (seconds)\n")
2001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2003 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2007 DEFUN (bgp_graceful_restart_preserve_fw
,
2008 bgp_graceful_restart_preserve_fw_cmd
,
2009 "bgp graceful-restart preserve-fw-state",
2010 "BGP specific commands\n"
2011 "Graceful restart capability parameters\n"
2012 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2014 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2015 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2019 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2020 no_bgp_graceful_restart_preserve_fw_cmd
,
2021 "no bgp graceful-restart preserve-fw-state",
2023 "BGP specific commands\n"
2024 "Graceful restart capability parameters\n"
2025 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2028 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2032 static void bgp_redistribute_redo(struct bgp
*bgp
)
2036 struct list
*red_list
;
2037 struct listnode
*node
;
2038 struct bgp_redist
*red
;
2040 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2041 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
2043 red_list
= bgp
->redist
[afi
][i
];
2047 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
2048 bgp_redistribute_resend(bgp
, afi
, i
,
2055 /* "bgp graceful-shutdown" configuration */
2056 DEFUN (bgp_graceful_shutdown
,
2057 bgp_graceful_shutdown_cmd
,
2058 "bgp graceful-shutdown",
2060 "Graceful shutdown parameters\n")
2062 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2064 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2065 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2066 bgp_static_redo_import_check(bgp
);
2067 bgp_redistribute_redo(bgp
);
2068 bgp_clear_star_soft_out(vty
, bgp
->name
);
2069 bgp_clear_star_soft_in(vty
, bgp
->name
);
2075 DEFUN (no_bgp_graceful_shutdown
,
2076 no_bgp_graceful_shutdown_cmd
,
2077 "no bgp graceful-shutdown",
2080 "Graceful shutdown parameters\n")
2082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2084 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2085 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2086 bgp_static_redo_import_check(bgp
);
2087 bgp_redistribute_redo(bgp
);
2088 bgp_clear_star_soft_out(vty
, bgp
->name
);
2089 bgp_clear_star_soft_in(vty
, bgp
->name
);
2095 /* "bgp fast-external-failover" configuration. */
2096 DEFUN (bgp_fast_external_failover
,
2097 bgp_fast_external_failover_cmd
,
2098 "bgp fast-external-failover",
2100 "Immediately reset session if a link to a directly connected external peer goes down\n")
2102 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2103 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2107 DEFUN (no_bgp_fast_external_failover
,
2108 no_bgp_fast_external_failover_cmd
,
2109 "no bgp fast-external-failover",
2112 "Immediately reset session if a link to a directly connected external peer goes down\n")
2114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2115 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2119 /* "bgp enforce-first-as" configuration. */
2120 #if CONFDATE > 20190517
2121 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2124 DEFUN_HIDDEN (bgp_enforce_first_as
,
2125 bgp_enforce_first_as_cmd
,
2126 "[no] bgp enforce-first-as",
2129 "Enforce the first AS for EBGP routes\n")
2131 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2133 if (strmatch(argv
[0]->text
, "no"))
2134 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2136 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2141 /* "bgp bestpath compare-routerid" configuration. */
2142 DEFUN (bgp_bestpath_compare_router_id
,
2143 bgp_bestpath_compare_router_id_cmd
,
2144 "bgp bestpath compare-routerid",
2145 "BGP specific commands\n"
2146 "Change the default bestpath selection\n"
2147 "Compare router-id for identical EBGP paths\n")
2149 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2150 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2151 bgp_recalculate_all_bestpaths(bgp
);
2156 DEFUN (no_bgp_bestpath_compare_router_id
,
2157 no_bgp_bestpath_compare_router_id_cmd
,
2158 "no bgp bestpath compare-routerid",
2160 "BGP specific commands\n"
2161 "Change the default bestpath selection\n"
2162 "Compare router-id for identical EBGP paths\n")
2164 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2165 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2166 bgp_recalculate_all_bestpaths(bgp
);
2171 /* "bgp bestpath as-path ignore" configuration. */
2172 DEFUN (bgp_bestpath_aspath_ignore
,
2173 bgp_bestpath_aspath_ignore_cmd
,
2174 "bgp bestpath as-path ignore",
2175 "BGP specific commands\n"
2176 "Change the default bestpath selection\n"
2177 "AS-path attribute\n"
2178 "Ignore as-path length in selecting a route\n")
2180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2181 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2182 bgp_recalculate_all_bestpaths(bgp
);
2187 DEFUN (no_bgp_bestpath_aspath_ignore
,
2188 no_bgp_bestpath_aspath_ignore_cmd
,
2189 "no bgp bestpath as-path ignore",
2191 "BGP specific commands\n"
2192 "Change the default bestpath selection\n"
2193 "AS-path attribute\n"
2194 "Ignore as-path length in selecting a route\n")
2196 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2197 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2198 bgp_recalculate_all_bestpaths(bgp
);
2203 /* "bgp bestpath as-path confed" configuration. */
2204 DEFUN (bgp_bestpath_aspath_confed
,
2205 bgp_bestpath_aspath_confed_cmd
,
2206 "bgp bestpath as-path confed",
2207 "BGP specific commands\n"
2208 "Change the default bestpath selection\n"
2209 "AS-path attribute\n"
2210 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2213 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2214 bgp_recalculate_all_bestpaths(bgp
);
2219 DEFUN (no_bgp_bestpath_aspath_confed
,
2220 no_bgp_bestpath_aspath_confed_cmd
,
2221 "no bgp bestpath as-path confed",
2223 "BGP specific commands\n"
2224 "Change the default bestpath selection\n"
2225 "AS-path attribute\n"
2226 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2229 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2230 bgp_recalculate_all_bestpaths(bgp
);
2235 /* "bgp bestpath as-path multipath-relax" configuration. */
2236 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2237 bgp_bestpath_aspath_multipath_relax_cmd
,
2238 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2239 "BGP specific commands\n"
2240 "Change the default bestpath selection\n"
2241 "AS-path attribute\n"
2242 "Allow load sharing across routes that have different AS paths (but same length)\n"
2243 "Generate an AS_SET\n"
2244 "Do not generate an AS_SET\n")
2246 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2248 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2250 /* no-as-set is now the default behavior so we can silently
2252 if (argv_find(argv
, argc
, "as-set", &idx
))
2253 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2255 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2257 bgp_recalculate_all_bestpaths(bgp
);
2262 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2263 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2264 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2266 "BGP specific commands\n"
2267 "Change the default bestpath selection\n"
2268 "AS-path attribute\n"
2269 "Allow load sharing across routes that have different AS paths (but same length)\n"
2270 "Generate an AS_SET\n"
2271 "Do not generate an AS_SET\n")
2273 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2274 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2275 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2276 bgp_recalculate_all_bestpaths(bgp
);
2281 /* "bgp log-neighbor-changes" configuration. */
2282 DEFUN (bgp_log_neighbor_changes
,
2283 bgp_log_neighbor_changes_cmd
,
2284 "bgp log-neighbor-changes",
2285 "BGP specific commands\n"
2286 "Log neighbor up/down and reset reason\n")
2288 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2289 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2293 DEFUN (no_bgp_log_neighbor_changes
,
2294 no_bgp_log_neighbor_changes_cmd
,
2295 "no bgp log-neighbor-changes",
2297 "BGP specific commands\n"
2298 "Log neighbor up/down and reset reason\n")
2300 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2301 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2305 /* "bgp bestpath med" configuration. */
2306 DEFUN (bgp_bestpath_med
,
2307 bgp_bestpath_med_cmd
,
2308 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2309 "BGP specific commands\n"
2310 "Change the default bestpath selection\n"
2312 "Compare MED among confederation paths\n"
2313 "Treat missing MED as the least preferred one\n"
2314 "Treat missing MED as the least preferred one\n"
2315 "Compare MED among confederation paths\n")
2317 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2320 if (argv_find(argv
, argc
, "confed", &idx
))
2321 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2323 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2324 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2326 bgp_recalculate_all_bestpaths(bgp
);
2331 DEFUN (no_bgp_bestpath_med
,
2332 no_bgp_bestpath_med_cmd
,
2333 "no 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_unset(bgp
, BGP_FLAG_MED_CONFED
);
2349 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2350 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2352 bgp_recalculate_all_bestpaths(bgp
);
2357 /* "no bgp default ipv4-unicast". */
2358 DEFUN (no_bgp_default_ipv4_unicast
,
2359 no_bgp_default_ipv4_unicast_cmd
,
2360 "no bgp default ipv4-unicast",
2362 "BGP specific commands\n"
2363 "Configure BGP defaults\n"
2364 "Activate ipv4-unicast for a peer by default\n")
2366 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2367 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2371 DEFUN (bgp_default_ipv4_unicast
,
2372 bgp_default_ipv4_unicast_cmd
,
2373 "bgp default ipv4-unicast",
2374 "BGP specific commands\n"
2375 "Configure BGP defaults\n"
2376 "Activate ipv4-unicast for a peer by default\n")
2378 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2379 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2383 /* Display hostname in certain command outputs */
2384 DEFUN (bgp_default_show_hostname
,
2385 bgp_default_show_hostname_cmd
,
2386 "bgp default show-hostname",
2387 "BGP specific commands\n"
2388 "Configure BGP defaults\n"
2389 "Show hostname in certain command outputs\n")
2391 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2392 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2396 DEFUN (no_bgp_default_show_hostname
,
2397 no_bgp_default_show_hostname_cmd
,
2398 "no bgp default show-hostname",
2400 "BGP specific commands\n"
2401 "Configure BGP defaults\n"
2402 "Show hostname in certain command outputs\n")
2404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2405 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2409 /* "bgp network import-check" configuration. */
2410 DEFUN (bgp_network_import_check
,
2411 bgp_network_import_check_cmd
,
2412 "bgp network import-check",
2413 "BGP specific commands\n"
2414 "BGP network command\n"
2415 "Check BGP network route exists in IGP\n")
2417 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2418 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2419 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2420 bgp_static_redo_import_check(bgp
);
2426 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2427 "bgp network import-check exact",
2428 "BGP specific commands\n"
2429 "BGP network command\n"
2430 "Check BGP network route exists in IGP\n"
2431 "Match route precisely\n")
2433 DEFUN (no_bgp_network_import_check
,
2434 no_bgp_network_import_check_cmd
,
2435 "no bgp network import-check",
2437 "BGP specific commands\n"
2438 "BGP network command\n"
2439 "Check BGP network route exists in IGP\n")
2441 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2442 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2443 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2444 bgp_static_redo_import_check(bgp
);
2450 DEFUN (bgp_default_local_preference
,
2451 bgp_default_local_preference_cmd
,
2452 "bgp default local-preference (0-4294967295)",
2453 "BGP specific commands\n"
2454 "Configure BGP defaults\n"
2455 "local preference (higher=more preferred)\n"
2456 "Configure default local preference value\n")
2458 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2460 uint32_t local_pref
;
2462 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2464 bgp_default_local_preference_set(bgp
, local_pref
);
2465 bgp_clear_star_soft_in(vty
, bgp
->name
);
2470 DEFUN (no_bgp_default_local_preference
,
2471 no_bgp_default_local_preference_cmd
,
2472 "no bgp default local-preference [(0-4294967295)]",
2474 "BGP specific commands\n"
2475 "Configure BGP defaults\n"
2476 "local preference (higher=more preferred)\n"
2477 "Configure default local preference value\n")
2479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2480 bgp_default_local_preference_unset(bgp
);
2481 bgp_clear_star_soft_in(vty
, bgp
->name
);
2487 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2488 bgp_default_subgroup_pkt_queue_max_cmd
,
2489 "bgp default subgroup-pkt-queue-max (20-100)",
2490 "BGP specific commands\n"
2491 "Configure BGP defaults\n"
2492 "subgroup-pkt-queue-max\n"
2493 "Configure subgroup packet queue max\n")
2495 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2499 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2501 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2506 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2507 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2508 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2510 "BGP specific commands\n"
2511 "Configure BGP defaults\n"
2512 "subgroup-pkt-queue-max\n"
2513 "Configure subgroup packet queue max\n")
2515 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2516 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2521 DEFUN (bgp_rr_allow_outbound_policy
,
2522 bgp_rr_allow_outbound_policy_cmd
,
2523 "bgp route-reflector allow-outbound-policy",
2524 "BGP specific commands\n"
2525 "Allow modifications made by out route-map\n"
2526 "on ibgp neighbors\n")
2528 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2530 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2531 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2532 update_group_announce_rrclients(bgp
);
2533 bgp_clear_star_soft_out(vty
, bgp
->name
);
2539 DEFUN (no_bgp_rr_allow_outbound_policy
,
2540 no_bgp_rr_allow_outbound_policy_cmd
,
2541 "no bgp route-reflector allow-outbound-policy",
2543 "BGP specific commands\n"
2544 "Allow modifications made by out route-map\n"
2545 "on ibgp neighbors\n")
2547 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2549 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2550 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2551 update_group_announce_rrclients(bgp
);
2552 bgp_clear_star_soft_out(vty
, bgp
->name
);
2558 DEFUN (bgp_listen_limit
,
2559 bgp_listen_limit_cmd
,
2560 "bgp listen limit (1-5000)",
2561 "BGP specific commands\n"
2562 "Configure BGP defaults\n"
2563 "maximum number of BGP Dynamic Neighbors that can be created\n"
2564 "Configure Dynamic Neighbors listen limit value\n")
2566 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2570 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2572 bgp_listen_limit_set(bgp
, listen_limit
);
2577 DEFUN (no_bgp_listen_limit
,
2578 no_bgp_listen_limit_cmd
,
2579 "no bgp listen limit [(1-5000)]",
2580 "BGP specific commands\n"
2581 "Configure BGP defaults\n"
2582 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2583 "Configure Dynamic Neighbors listen limit value to default\n"
2584 "Configure Dynamic Neighbors listen limit value\n")
2586 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2587 bgp_listen_limit_unset(bgp
);
2593 * Check if this listen range is already configured. Check for exact
2594 * match or overlap based on input.
2596 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2597 struct prefix
*range
, int exact
)
2599 struct listnode
*node
, *nnode
;
2600 struct listnode
*node1
, *nnode1
;
2601 struct peer_group
*group
;
2606 afi
= family2afi(range
->family
);
2607 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2608 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2611 match
= prefix_same(range
, lr
);
2613 match
= (prefix_match(range
, lr
)
2614 || prefix_match(lr
, range
));
2623 DEFUN (bgp_listen_range
,
2624 bgp_listen_range_cmd
,
2625 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2626 "BGP specific commands\n"
2627 "Configure BGP dynamic neighbors listen range\n"
2628 "Configure BGP dynamic neighbors listen range\n"
2630 "Member of the peer-group\n"
2631 "Peer-group name\n")
2633 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2634 struct prefix range
;
2635 struct peer_group
*group
, *existing_group
;
2640 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2641 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2642 char *prefix
= argv
[idx
]->arg
;
2643 argv_find(argv
, argc
, "WORD", &idx
);
2644 char *peergroup
= argv
[idx
]->arg
;
2646 /* Convert IP prefix string to struct prefix. */
2647 ret
= str2prefix(prefix
, &range
);
2649 vty_out(vty
, "%% Malformed listen range\n");
2650 return CMD_WARNING_CONFIG_FAILED
;
2653 afi
= family2afi(range
.family
);
2655 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2657 "%% Malformed listen range (link-local address)\n");
2658 return CMD_WARNING_CONFIG_FAILED
;
2663 /* Check if same listen range is already configured. */
2664 existing_group
= listen_range_exists(bgp
, &range
, 1);
2665 if (existing_group
) {
2666 if (strcmp(existing_group
->name
, peergroup
) == 0)
2670 "%% Same listen range is attached to peer-group %s\n",
2671 existing_group
->name
);
2672 return CMD_WARNING_CONFIG_FAILED
;
2676 /* Check if an overlapping listen range exists. */
2677 if (listen_range_exists(bgp
, &range
, 0)) {
2679 "%% Listen range overlaps with existing listen range\n");
2680 return CMD_WARNING_CONFIG_FAILED
;
2683 group
= peer_group_lookup(bgp
, peergroup
);
2685 vty_out(vty
, "%% Configure the peer-group first\n");
2686 return CMD_WARNING_CONFIG_FAILED
;
2689 ret
= peer_group_listen_range_add(group
, &range
);
2690 return bgp_vty_return(vty
, ret
);
2693 DEFUN (no_bgp_listen_range
,
2694 no_bgp_listen_range_cmd
,
2695 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2697 "BGP specific commands\n"
2698 "Unconfigure BGP dynamic neighbors listen range\n"
2699 "Unconfigure BGP dynamic neighbors listen range\n"
2701 "Member of the peer-group\n"
2702 "Peer-group name\n")
2704 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2705 struct prefix range
;
2706 struct peer_group
*group
;
2711 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2712 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2713 char *prefix
= argv
[idx
]->arg
;
2714 argv_find(argv
, argc
, "WORD", &idx
);
2715 char *peergroup
= argv
[idx
]->arg
;
2717 /* Convert IP prefix string to struct prefix. */
2718 ret
= str2prefix(prefix
, &range
);
2720 vty_out(vty
, "%% Malformed listen range\n");
2721 return CMD_WARNING_CONFIG_FAILED
;
2724 afi
= family2afi(range
.family
);
2726 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2728 "%% Malformed listen range (link-local address)\n");
2729 return CMD_WARNING_CONFIG_FAILED
;
2734 group
= peer_group_lookup(bgp
, peergroup
);
2736 vty_out(vty
, "%% Peer-group does not exist\n");
2737 return CMD_WARNING_CONFIG_FAILED
;
2740 ret
= peer_group_listen_range_del(group
, &range
);
2741 return bgp_vty_return(vty
, ret
);
2744 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2746 struct peer_group
*group
;
2747 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2748 struct prefix
*range
;
2750 char buf
[PREFIX2STR_BUFFER
];
2752 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2753 vty_out(vty
, " bgp listen limit %d\n",
2754 bgp
->dynamic_neighbors_limit
);
2756 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2757 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2758 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2760 prefix2str(range
, buf
, sizeof(buf
));
2762 " bgp listen range %s peer-group %s\n",
2770 DEFUN (bgp_disable_connected_route_check
,
2771 bgp_disable_connected_route_check_cmd
,
2772 "bgp disable-ebgp-connected-route-check",
2773 "BGP specific commands\n"
2774 "Disable checking if nexthop is connected on ebgp sessions\n")
2776 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2777 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2778 bgp_clear_star_soft_in(vty
, bgp
->name
);
2783 DEFUN (no_bgp_disable_connected_route_check
,
2784 no_bgp_disable_connected_route_check_cmd
,
2785 "no bgp disable-ebgp-connected-route-check",
2787 "BGP specific commands\n"
2788 "Disable checking if nexthop is connected on ebgp sessions\n")
2790 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2791 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2792 bgp_clear_star_soft_in(vty
, bgp
->name
);
2798 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2799 const char *as_str
, afi_t afi
, safi_t safi
)
2801 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2804 int as_type
= AS_SPECIFIED
;
2807 if (as_str
[0] == 'i') {
2809 as_type
= AS_INTERNAL
;
2810 } else if (as_str
[0] == 'e') {
2812 as_type
= AS_EXTERNAL
;
2814 /* Get AS number. */
2815 as
= strtoul(as_str
, NULL
, 10);
2818 /* If peer is peer group, call proper function. */
2819 ret
= str2sockunion(peer_str
, &su
);
2821 /* Check for peer by interface */
2822 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2825 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2828 "%% Create the peer-group or interface first or specify \"interface\" keyword\n");
2829 vty_out(vty
, "%% if using an unnumbered interface neighbor\n");
2830 return CMD_WARNING_CONFIG_FAILED
;
2835 if (peer_address_self_check(bgp
, &su
)) {
2837 "%% Can not configure the local system as neighbor\n");
2838 return CMD_WARNING_CONFIG_FAILED
;
2840 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2843 /* This peer belongs to peer group. */
2845 case BGP_ERR_PEER_GROUP_MEMBER
:
2847 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2849 return CMD_WARNING_CONFIG_FAILED
;
2850 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2852 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2854 return CMD_WARNING_CONFIG_FAILED
;
2856 return bgp_vty_return(vty
, ret
);
2859 DEFUN (bgp_default_shutdown
,
2860 bgp_default_shutdown_cmd
,
2861 "[no] bgp default shutdown",
2864 "Configure BGP defaults\n"
2865 "Apply administrative shutdown to newly configured peers\n")
2867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2868 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2872 DEFUN (neighbor_remote_as
,
2873 neighbor_remote_as_cmd
,
2874 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2877 "Specify a BGP neighbor\n"
2879 "Internal BGP peer\n"
2880 "External BGP peer\n")
2883 int idx_remote_as
= 3;
2884 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2885 argv
[idx_remote_as
]->arg
, AFI_IP
,
2889 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2890 afi_t afi
, safi_t safi
, int v6only
,
2891 const char *peer_group_name
,
2894 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2896 int as_type
= AS_UNSPECIFIED
;
2898 struct peer_group
*group
;
2902 group
= peer_group_lookup(bgp
, conf_if
);
2905 vty_out(vty
, "%% Name conflict with peer-group \n");
2906 return CMD_WARNING_CONFIG_FAILED
;
2910 if (as_str
[0] == 'i') {
2911 as_type
= AS_INTERNAL
;
2912 } else if (as_str
[0] == 'e') {
2913 as_type
= AS_EXTERNAL
;
2915 /* Get AS number. */
2916 as
= strtoul(as_str
, NULL
, 10);
2917 as_type
= AS_SPECIFIED
;
2921 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2924 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2927 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2928 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2929 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2930 as_type
, 0, 0, NULL
);
2932 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2933 as_type
, afi
, safi
, NULL
);
2936 vty_out(vty
, "%% BGP failed to create peer\n");
2937 return CMD_WARNING_CONFIG_FAILED
;
2941 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2943 /* Request zebra to initiate IPv6 RAs on this interface. We do
2945 * any unnumbered peer in order to not worry about run-time
2947 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2949 * gets deleted later etc.)
2952 bgp_zebra_initiate_radv(bgp
, peer
);
2955 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2956 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2958 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2960 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2962 /* v6only flag changed. Reset bgp seesion */
2963 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2964 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2965 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2966 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2968 bgp_session_reset(peer
);
2971 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2972 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2973 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2974 UNSET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2977 if (peer_group_name
) {
2978 group
= peer_group_lookup(bgp
, peer_group_name
);
2980 vty_out(vty
, "%% Configure the peer-group first\n");
2981 return CMD_WARNING_CONFIG_FAILED
;
2984 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2987 return bgp_vty_return(vty
, ret
);
2990 DEFUN (neighbor_interface_config
,
2991 neighbor_interface_config_cmd
,
2992 "neighbor WORD interface [peer-group WORD]",
2994 "Interface name or neighbor tag\n"
2995 "Enable BGP on interface\n"
2996 "Member of the peer-group\n"
2997 "Peer-group name\n")
3000 int idx_peer_group_word
= 4;
3002 if (argc
> idx_peer_group_word
)
3003 return peer_conf_interface_get(
3004 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3005 argv
[idx_peer_group_word
]->arg
, NULL
);
3007 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3008 SAFI_UNICAST
, 0, NULL
, NULL
);
3011 DEFUN (neighbor_interface_config_v6only
,
3012 neighbor_interface_config_v6only_cmd
,
3013 "neighbor WORD interface v6only [peer-group WORD]",
3015 "Interface name or neighbor tag\n"
3016 "Enable BGP on interface\n"
3017 "Enable BGP with v6 link-local only\n"
3018 "Member of the peer-group\n"
3019 "Peer-group name\n")
3022 int idx_peer_group_word
= 5;
3024 if (argc
> idx_peer_group_word
)
3025 return peer_conf_interface_get(
3026 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3027 argv
[idx_peer_group_word
]->arg
, NULL
);
3029 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3030 SAFI_UNICAST
, 1, NULL
, NULL
);
3034 DEFUN (neighbor_interface_config_remote_as
,
3035 neighbor_interface_config_remote_as_cmd
,
3036 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3038 "Interface name or neighbor tag\n"
3039 "Enable BGP on interface\n"
3040 "Specify a BGP neighbor\n"
3042 "Internal BGP peer\n"
3043 "External BGP peer\n")
3046 int idx_remote_as
= 4;
3047 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3048 SAFI_UNICAST
, 0, NULL
,
3049 argv
[idx_remote_as
]->arg
);
3052 DEFUN (neighbor_interface_v6only_config_remote_as
,
3053 neighbor_interface_v6only_config_remote_as_cmd
,
3054 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3056 "Interface name or neighbor tag\n"
3057 "Enable BGP with v6 link-local only\n"
3058 "Enable BGP on interface\n"
3059 "Specify a BGP neighbor\n"
3061 "Internal BGP peer\n"
3062 "External BGP peer\n")
3065 int idx_remote_as
= 5;
3066 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3067 SAFI_UNICAST
, 1, NULL
,
3068 argv
[idx_remote_as
]->arg
);
3071 DEFUN (neighbor_peer_group
,
3072 neighbor_peer_group_cmd
,
3073 "neighbor WORD peer-group",
3075 "Interface name or neighbor tag\n"
3076 "Configure peer-group\n")
3078 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3081 struct peer_group
*group
;
3083 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3085 vty_out(vty
, "%% Name conflict with interface: \n");
3086 return CMD_WARNING_CONFIG_FAILED
;
3089 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3091 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3092 return CMD_WARNING_CONFIG_FAILED
;
3100 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3104 "Specify a BGP neighbor\n"
3106 "Internal BGP peer\n"
3107 "External BGP peer\n")
3109 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3113 struct peer_group
*group
;
3117 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3119 /* look up for neighbor by interface name config. */
3120 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3122 /* Request zebra to terminate IPv6 RAs on this
3125 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3130 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3132 peer_group_delete(group
);
3134 vty_out(vty
, "%% Create the peer-group first\n");
3135 return CMD_WARNING_CONFIG_FAILED
;
3138 peer
= peer_lookup(bgp
, &su
);
3140 if (peer_dynamic_neighbor(peer
)) {
3142 "%% Operation not allowed on a dynamic neighbor\n");
3143 return CMD_WARNING_CONFIG_FAILED
;
3146 other
= peer
->doppelganger
;
3148 if (other
&& other
->status
!= Deleted
)
3156 DEFUN (no_neighbor_interface_config
,
3157 no_neighbor_interface_config_cmd
,
3158 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3162 "Configure BGP on interface\n"
3163 "Enable BGP with v6 link-local only\n"
3164 "Member of the peer-group\n"
3166 "Specify a BGP neighbor\n"
3168 "Internal BGP peer\n"
3169 "External BGP peer\n")
3171 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3175 /* look up for neighbor by interface name config. */
3176 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3178 /* Request zebra to terminate IPv6 RAs on this interface. */
3180 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3183 vty_out(vty
, "%% Create the bgp interface first\n");
3184 return CMD_WARNING_CONFIG_FAILED
;
3189 DEFUN (no_neighbor_peer_group
,
3190 no_neighbor_peer_group_cmd
,
3191 "no neighbor WORD peer-group",
3195 "Configure peer-group\n")
3197 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3199 struct peer_group
*group
;
3201 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3203 peer_group_delete(group
);
3205 vty_out(vty
, "%% Create the peer-group first\n");
3206 return CMD_WARNING_CONFIG_FAILED
;
3211 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3212 no_neighbor_interface_peer_group_remote_as_cmd
,
3213 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3216 "Interface name or neighbor tag\n"
3217 "Specify a BGP neighbor\n"
3219 "Internal BGP peer\n"
3220 "External BGP peer\n")
3222 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3224 struct peer_group
*group
;
3227 /* look up for neighbor by interface name config. */
3228 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3230 peer_as_change(peer
, 0, AS_SPECIFIED
);
3234 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3236 peer_group_remote_as_delete(group
);
3238 vty_out(vty
, "%% Create the peer-group or interface first\n");
3239 return CMD_WARNING_CONFIG_FAILED
;
3244 DEFUN (neighbor_local_as
,
3245 neighbor_local_as_cmd
,
3246 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3249 "Specify a local-as number\n"
3250 "AS number used as local AS\n")
3258 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3260 return CMD_WARNING_CONFIG_FAILED
;
3262 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3263 ret
= peer_local_as_set(peer
, as
, 0, 0);
3264 return bgp_vty_return(vty
, ret
);
3267 DEFUN (neighbor_local_as_no_prepend
,
3268 neighbor_local_as_no_prepend_cmd
,
3269 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3272 "Specify a local-as number\n"
3273 "AS number used as local AS\n"
3274 "Do not prepend local-as to updates from ebgp peers\n")
3282 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3284 return CMD_WARNING_CONFIG_FAILED
;
3286 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3287 ret
= peer_local_as_set(peer
, as
, 1, 0);
3288 return bgp_vty_return(vty
, ret
);
3291 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3292 neighbor_local_as_no_prepend_replace_as_cmd
,
3293 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3296 "Specify a local-as number\n"
3297 "AS number used as local AS\n"
3298 "Do not prepend local-as to updates from ebgp peers\n"
3299 "Do not prepend local-as to updates from ibgp peers\n")
3307 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3309 return CMD_WARNING_CONFIG_FAILED
;
3311 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3312 ret
= peer_local_as_set(peer
, as
, 1, 1);
3313 return bgp_vty_return(vty
, ret
);
3316 DEFUN (no_neighbor_local_as
,
3317 no_neighbor_local_as_cmd
,
3318 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3322 "Specify a local-as number\n"
3323 "AS number used as local AS\n"
3324 "Do not prepend local-as to updates from ebgp peers\n"
3325 "Do not prepend local-as to updates from ibgp peers\n")
3331 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3333 return CMD_WARNING_CONFIG_FAILED
;
3335 ret
= peer_local_as_unset(peer
);
3336 return bgp_vty_return(vty
, ret
);
3340 DEFUN (neighbor_solo
,
3342 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3345 "Solo peer - part of its own update group\n")
3351 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3353 return CMD_WARNING_CONFIG_FAILED
;
3355 ret
= update_group_adjust_soloness(peer
, 1);
3356 return bgp_vty_return(vty
, ret
);
3359 DEFUN (no_neighbor_solo
,
3360 no_neighbor_solo_cmd
,
3361 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3365 "Solo peer - part of its own update group\n")
3371 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3373 return CMD_WARNING_CONFIG_FAILED
;
3375 ret
= update_group_adjust_soloness(peer
, 0);
3376 return bgp_vty_return(vty
, ret
);
3379 DEFUN (neighbor_password
,
3380 neighbor_password_cmd
,
3381 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3392 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3394 return CMD_WARNING_CONFIG_FAILED
;
3396 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3397 return bgp_vty_return(vty
, ret
);
3400 DEFUN (no_neighbor_password
,
3401 no_neighbor_password_cmd
,
3402 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3413 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3415 return CMD_WARNING_CONFIG_FAILED
;
3417 ret
= peer_password_unset(peer
);
3418 return bgp_vty_return(vty
, ret
);
3421 DEFUN (neighbor_activate
,
3422 neighbor_activate_cmd
,
3423 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3426 "Enable the Address Family for this Neighbor\n")
3432 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3434 return CMD_WARNING_CONFIG_FAILED
;
3436 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3437 return bgp_vty_return(vty
, ret
);
3440 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3441 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3442 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3443 "Enable the Address Family for this Neighbor\n")
3445 DEFUN (no_neighbor_activate
,
3446 no_neighbor_activate_cmd
,
3447 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3451 "Enable the Address Family for this Neighbor\n")
3458 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3460 return CMD_WARNING_CONFIG_FAILED
;
3462 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3463 return bgp_vty_return(vty
, ret
);
3466 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3467 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3468 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3469 "Enable the Address Family for this Neighbor\n")
3471 DEFUN (neighbor_set_peer_group
,
3472 neighbor_set_peer_group_cmd
,
3473 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3476 "Member of the peer-group\n"
3477 "Peer-group name\n")
3479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3486 struct peer_group
*group
;
3488 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3490 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3492 vty_out(vty
, "%% Malformed address or name: %s\n",
3493 argv
[idx_peer
]->arg
);
3494 return CMD_WARNING_CONFIG_FAILED
;
3497 if (peer_address_self_check(bgp
, &su
)) {
3499 "%% Can not configure the local system as neighbor\n");
3500 return CMD_WARNING_CONFIG_FAILED
;
3503 /* Disallow for dynamic neighbor. */
3504 peer
= peer_lookup(bgp
, &su
);
3505 if (peer
&& peer_dynamic_neighbor(peer
)) {
3507 "%% Operation not allowed on a dynamic neighbor\n");
3508 return CMD_WARNING_CONFIG_FAILED
;
3512 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3514 vty_out(vty
, "%% Configure the peer-group first\n");
3515 return CMD_WARNING_CONFIG_FAILED
;
3518 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3520 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3522 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3524 return CMD_WARNING_CONFIG_FAILED
;
3527 return bgp_vty_return(vty
, ret
);
3530 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3531 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3532 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3533 "Member of the peer-group\n"
3534 "Peer-group name\n")
3536 DEFUN (no_neighbor_set_peer_group
,
3537 no_neighbor_set_peer_group_cmd
,
3538 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3542 "Member of the peer-group\n"
3543 "Peer-group name\n")
3545 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3550 struct peer_group
*group
;
3552 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3554 return CMD_WARNING_CONFIG_FAILED
;
3556 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3558 vty_out(vty
, "%% Configure the peer-group first\n");
3559 return CMD_WARNING_CONFIG_FAILED
;
3562 ret
= peer_delete(peer
);
3564 return bgp_vty_return(vty
, ret
);
3567 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3568 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3569 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3570 "Member of the peer-group\n"
3571 "Peer-group name\n")
3573 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3574 uint32_t flag
, int set
)
3579 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3581 return CMD_WARNING_CONFIG_FAILED
;
3584 * If 'neighbor <interface>', then this is for directly connected peers,
3585 * we should not accept disable-connected-check.
3587 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3589 "%s is directly connected peer, cannot accept disable-"
3590 "connected-check\n",
3592 return CMD_WARNING_CONFIG_FAILED
;
3595 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3596 peer_tx_shutdown_message_unset(peer
);
3599 ret
= peer_flag_set(peer
, flag
);
3601 ret
= peer_flag_unset(peer
, flag
);
3603 return bgp_vty_return(vty
, ret
);
3606 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3608 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3611 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3614 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3617 /* neighbor passive. */
3618 DEFUN (neighbor_passive
,
3619 neighbor_passive_cmd
,
3620 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3623 "Don't send open messages to this neighbor\n")
3626 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3629 DEFUN (no_neighbor_passive
,
3630 no_neighbor_passive_cmd
,
3631 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3635 "Don't send open messages to this neighbor\n")
3638 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3641 /* neighbor shutdown. */
3642 DEFUN (neighbor_shutdown_msg
,
3643 neighbor_shutdown_msg_cmd
,
3644 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3647 "Administratively shut down this neighbor\n"
3648 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3649 "Shutdown message\n")
3655 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3659 return CMD_WARNING_CONFIG_FAILED
;
3660 message
= argv_concat(argv
, argc
, 4);
3661 peer_tx_shutdown_message_set(peer
, message
);
3662 XFREE(MTYPE_TMP
, message
);
3665 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3668 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3669 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3670 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3671 "Administratively shut down this neighbor\n")
3673 DEFUN (no_neighbor_shutdown_msg
,
3674 no_neighbor_shutdown_msg_cmd
,
3675 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3679 "Administratively shut down this neighbor\n"
3680 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3681 "Shutdown message\n")
3685 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3686 PEER_FLAG_SHUTDOWN
);
3689 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3690 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3691 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3692 "Administratively shut down this neighbor\n")
3694 /* neighbor capability dynamic. */
3695 DEFUN (neighbor_capability_dynamic
,
3696 neighbor_capability_dynamic_cmd
,
3697 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3700 "Advertise capability to the peer\n"
3701 "Advertise dynamic capability to this neighbor\n")
3704 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3705 PEER_FLAG_DYNAMIC_CAPABILITY
);
3708 DEFUN (no_neighbor_capability_dynamic
,
3709 no_neighbor_capability_dynamic_cmd
,
3710 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3714 "Advertise capability to the peer\n"
3715 "Advertise dynamic capability to this neighbor\n")
3718 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3719 PEER_FLAG_DYNAMIC_CAPABILITY
);
3722 /* neighbor dont-capability-negotiate */
3723 DEFUN (neighbor_dont_capability_negotiate
,
3724 neighbor_dont_capability_negotiate_cmd
,
3725 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3728 "Do not perform capability negotiation\n")
3731 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3732 PEER_FLAG_DONT_CAPABILITY
);
3735 DEFUN (no_neighbor_dont_capability_negotiate
,
3736 no_neighbor_dont_capability_negotiate_cmd
,
3737 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3741 "Do not perform capability negotiation\n")
3744 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3745 PEER_FLAG_DONT_CAPABILITY
);
3748 /* neighbor capability extended next hop encoding */
3749 DEFUN (neighbor_capability_enhe
,
3750 neighbor_capability_enhe_cmd
,
3751 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3754 "Advertise capability to the peer\n"
3755 "Advertise extended next-hop capability to the peer\n")
3758 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3759 PEER_FLAG_CAPABILITY_ENHE
);
3762 DEFUN (no_neighbor_capability_enhe
,
3763 no_neighbor_capability_enhe_cmd
,
3764 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3768 "Advertise capability to the peer\n"
3769 "Advertise extended next-hop capability to the peer\n")
3772 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3773 PEER_FLAG_CAPABILITY_ENHE
);
3776 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3777 afi_t afi
, safi_t safi
, uint32_t flag
,
3783 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3785 return CMD_WARNING_CONFIG_FAILED
;
3788 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3790 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3792 return bgp_vty_return(vty
, ret
);
3795 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3796 afi_t afi
, safi_t safi
, uint32_t flag
)
3798 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3801 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3802 afi_t afi
, safi_t safi
, uint32_t flag
)
3804 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3807 /* neighbor capability orf prefix-list. */
3808 DEFUN (neighbor_capability_orf_prefix
,
3809 neighbor_capability_orf_prefix_cmd
,
3810 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3813 "Advertise capability to the peer\n"
3814 "Advertise ORF capability to the peer\n"
3815 "Advertise prefixlist ORF capability to this neighbor\n"
3816 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3817 "Capability to RECEIVE the ORF from this neighbor\n"
3818 "Capability to SEND the ORF to this neighbor\n")
3821 int idx_send_recv
= 5;
3824 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3825 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3826 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3827 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3828 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3829 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3831 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3832 return CMD_WARNING_CONFIG_FAILED
;
3835 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3836 bgp_node_safi(vty
), flag
);
3840 neighbor_capability_orf_prefix
,
3841 neighbor_capability_orf_prefix_hidden_cmd
,
3842 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3843 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3844 "Advertise capability to the peer\n"
3845 "Advertise ORF capability to the peer\n"
3846 "Advertise prefixlist ORF capability to this neighbor\n"
3847 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3848 "Capability to RECEIVE the ORF from this neighbor\n"
3849 "Capability to SEND the ORF to this neighbor\n")
3851 DEFUN (no_neighbor_capability_orf_prefix
,
3852 no_neighbor_capability_orf_prefix_cmd
,
3853 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3857 "Advertise capability to the peer\n"
3858 "Advertise ORF capability to the peer\n"
3859 "Advertise prefixlist ORF capability to this neighbor\n"
3860 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3861 "Capability to RECEIVE the ORF from this neighbor\n"
3862 "Capability to SEND the ORF to this neighbor\n")
3865 int idx_send_recv
= 6;
3868 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3869 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3870 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3871 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3872 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3873 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3875 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3876 return CMD_WARNING_CONFIG_FAILED
;
3879 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3880 bgp_node_afi(vty
), bgp_node_safi(vty
),
3885 no_neighbor_capability_orf_prefix
,
3886 no_neighbor_capability_orf_prefix_hidden_cmd
,
3887 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3888 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3889 "Advertise capability to the peer\n"
3890 "Advertise ORF capability to the peer\n"
3891 "Advertise prefixlist ORF capability to this neighbor\n"
3892 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3893 "Capability to RECEIVE the ORF from this neighbor\n"
3894 "Capability to SEND the ORF to this neighbor\n")
3896 /* neighbor next-hop-self. */
3897 DEFUN (neighbor_nexthop_self
,
3898 neighbor_nexthop_self_cmd
,
3899 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3902 "Disable the next hop calculation for this neighbor\n")
3905 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3906 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3909 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3910 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3911 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3912 "Disable the next hop calculation for this neighbor\n")
3914 /* neighbor next-hop-self. */
3915 DEFUN (neighbor_nexthop_self_force
,
3916 neighbor_nexthop_self_force_cmd
,
3917 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3920 "Disable the next hop calculation for this neighbor\n"
3921 "Set the next hop to self for reflected routes\n")
3924 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3926 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3929 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3930 neighbor_nexthop_self_force_hidden_cmd
,
3931 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3932 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3933 "Disable the next hop calculation for this neighbor\n"
3934 "Set the next hop to self for reflected routes\n")
3936 DEFUN (no_neighbor_nexthop_self
,
3937 no_neighbor_nexthop_self_cmd
,
3938 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3942 "Disable the next hop calculation for this neighbor\n")
3945 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3946 bgp_node_afi(vty
), bgp_node_safi(vty
),
3947 PEER_FLAG_NEXTHOP_SELF
);
3950 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3951 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3952 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3953 "Disable the next hop calculation for this neighbor\n")
3955 DEFUN (no_neighbor_nexthop_self_force
,
3956 no_neighbor_nexthop_self_force_cmd
,
3957 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3961 "Disable the next hop calculation for this neighbor\n"
3962 "Set the next hop to self for reflected routes\n")
3965 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3966 bgp_node_afi(vty
), bgp_node_safi(vty
),
3967 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3970 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3971 no_neighbor_nexthop_self_force_hidden_cmd
,
3972 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3973 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3974 "Disable the next hop calculation for this neighbor\n"
3975 "Set the next hop to self for reflected routes\n")
3977 /* neighbor as-override */
3978 DEFUN (neighbor_as_override
,
3979 neighbor_as_override_cmd
,
3980 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3983 "Override ASNs in outbound updates if aspath equals remote-as\n")
3986 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3987 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3990 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3991 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3992 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3993 "Override ASNs in outbound updates if aspath equals remote-as\n")
3995 DEFUN (no_neighbor_as_override
,
3996 no_neighbor_as_override_cmd
,
3997 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4001 "Override ASNs in outbound updates if aspath equals remote-as\n")
4004 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4005 bgp_node_afi(vty
), bgp_node_safi(vty
),
4006 PEER_FLAG_AS_OVERRIDE
);
4009 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4010 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4011 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4012 "Override ASNs in outbound updates if aspath equals remote-as\n")
4014 /* neighbor remove-private-AS. */
4015 DEFUN (neighbor_remove_private_as
,
4016 neighbor_remove_private_as_cmd
,
4017 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4020 "Remove private ASNs in outbound updates\n")
4023 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4025 PEER_FLAG_REMOVE_PRIVATE_AS
);
4028 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4029 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4030 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4031 "Remove private ASNs in outbound updates\n")
4033 DEFUN (neighbor_remove_private_as_all
,
4034 neighbor_remove_private_as_all_cmd
,
4035 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4038 "Remove private ASNs in outbound updates\n"
4039 "Apply to all AS numbers\n")
4042 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4044 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4047 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4048 neighbor_remove_private_as_all_hidden_cmd
,
4049 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4050 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4051 "Remove private ASNs in outbound updates\n"
4052 "Apply to all AS numbers")
4054 DEFUN (neighbor_remove_private_as_replace_as
,
4055 neighbor_remove_private_as_replace_as_cmd
,
4056 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4059 "Remove private ASNs in outbound updates\n"
4060 "Replace private ASNs with our ASN in outbound updates\n")
4063 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4065 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4068 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4069 neighbor_remove_private_as_replace_as_hidden_cmd
,
4070 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4071 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4072 "Remove private ASNs in outbound updates\n"
4073 "Replace private ASNs with our ASN in outbound updates\n")
4075 DEFUN (neighbor_remove_private_as_all_replace_as
,
4076 neighbor_remove_private_as_all_replace_as_cmd
,
4077 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4080 "Remove private ASNs in outbound updates\n"
4081 "Apply to all AS numbers\n"
4082 "Replace private ASNs with our ASN in outbound updates\n")
4085 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4087 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4091 neighbor_remove_private_as_all_replace_as
,
4092 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4093 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4094 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4095 "Remove private ASNs in outbound updates\n"
4096 "Apply to all AS numbers\n"
4097 "Replace private ASNs with our ASN in outbound updates\n")
4099 DEFUN (no_neighbor_remove_private_as
,
4100 no_neighbor_remove_private_as_cmd
,
4101 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4105 "Remove private ASNs in outbound updates\n")
4108 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4109 bgp_node_afi(vty
), bgp_node_safi(vty
),
4110 PEER_FLAG_REMOVE_PRIVATE_AS
);
4113 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4114 no_neighbor_remove_private_as_hidden_cmd
,
4115 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4116 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4117 "Remove private ASNs in outbound updates\n")
4119 DEFUN (no_neighbor_remove_private_as_all
,
4120 no_neighbor_remove_private_as_all_cmd
,
4121 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4125 "Remove private ASNs in outbound updates\n"
4126 "Apply to all AS numbers\n")
4129 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4130 bgp_node_afi(vty
), bgp_node_safi(vty
),
4131 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4134 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4135 no_neighbor_remove_private_as_all_hidden_cmd
,
4136 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4137 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4138 "Remove private ASNs in outbound updates\n"
4139 "Apply to all AS numbers\n")
4141 DEFUN (no_neighbor_remove_private_as_replace_as
,
4142 no_neighbor_remove_private_as_replace_as_cmd
,
4143 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4147 "Remove private ASNs in outbound updates\n"
4148 "Replace private ASNs with our ASN 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_REPLACE
);
4156 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4157 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4158 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4159 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4160 "Remove private ASNs in outbound updates\n"
4161 "Replace private ASNs with our ASN in outbound updates\n")
4163 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4164 no_neighbor_remove_private_as_all_replace_as_cmd
,
4165 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4169 "Remove private ASNs in outbound updates\n"
4170 "Apply to all AS numbers\n"
4171 "Replace private ASNs with our ASN in outbound updates\n")
4174 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4175 bgp_node_afi(vty
), bgp_node_safi(vty
),
4176 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4180 no_neighbor_remove_private_as_all_replace_as
,
4181 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4182 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4183 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4184 "Remove private ASNs in outbound updates\n"
4185 "Apply to all AS numbers\n"
4186 "Replace private ASNs with our ASN in outbound updates\n")
4189 /* neighbor send-community. */
4190 DEFUN (neighbor_send_community
,
4191 neighbor_send_community_cmd
,
4192 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4195 "Send Community attribute to this neighbor\n")
4199 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4201 PEER_FLAG_SEND_COMMUNITY
);
4204 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4205 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4206 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4207 "Send Community attribute to this neighbor\n")
4209 DEFUN (no_neighbor_send_community
,
4210 no_neighbor_send_community_cmd
,
4211 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4215 "Send Community attribute to this neighbor\n")
4219 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4220 bgp_node_afi(vty
), bgp_node_safi(vty
),
4221 PEER_FLAG_SEND_COMMUNITY
);
4224 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4225 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4226 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4227 "Send Community attribute to this neighbor\n")
4229 /* neighbor send-community extended. */
4230 DEFUN (neighbor_send_community_type
,
4231 neighbor_send_community_type_cmd
,
4232 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4235 "Send Community attribute to this neighbor\n"
4236 "Send Standard and Extended Community attributes\n"
4237 "Send Standard, Large and Extended Community attributes\n"
4238 "Send Extended Community attributes\n"
4239 "Send Standard Community attributes\n"
4240 "Send Large Community attributes\n")
4244 const char *type
= argv
[argc
- 1]->text
;
4246 if (strmatch(type
, "standard")) {
4247 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4248 } else if (strmatch(type
, "extended")) {
4249 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4250 } else if (strmatch(type
, "large")) {
4251 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4252 } else if (strmatch(type
, "both")) {
4253 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4254 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4255 } else { /* if (strmatch(type, "all")) */
4256 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4257 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4258 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4261 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4262 bgp_node_safi(vty
), flag
);
4266 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4267 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4268 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4269 "Send Community attribute to this neighbor\n"
4270 "Send Standard and Extended Community attributes\n"
4271 "Send Standard, Large and Extended Community attributes\n"
4272 "Send Extended Community attributes\n"
4273 "Send Standard Community attributes\n"
4274 "Send Large Community attributes\n")
4276 DEFUN (no_neighbor_send_community_type
,
4277 no_neighbor_send_community_type_cmd
,
4278 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4282 "Send Community attribute to this neighbor\n"
4283 "Send Standard and Extended Community attributes\n"
4284 "Send Standard, Large and Extended Community attributes\n"
4285 "Send Extended Community attributes\n"
4286 "Send Standard Community attributes\n"
4287 "Send Large Community attributes\n")
4291 const char *type
= argv
[argc
- 1]->text
;
4293 if (strmatch(type
, "standard")) {
4294 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4295 } else if (strmatch(type
, "extended")) {
4296 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4297 } else if (strmatch(type
, "large")) {
4298 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4299 } else if (strmatch(type
, "both")) {
4300 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4301 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4302 } else { /* if (strmatch(type, "all")) */
4303 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4304 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4305 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4308 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4309 bgp_node_afi(vty
), bgp_node_safi(vty
),
4314 no_neighbor_send_community_type
,
4315 no_neighbor_send_community_type_hidden_cmd
,
4316 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4317 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4318 "Send Community attribute to this neighbor\n"
4319 "Send Standard and Extended Community attributes\n"
4320 "Send Standard, Large and Extended Community attributes\n"
4321 "Send Extended Community attributes\n"
4322 "Send Standard Community attributes\n"
4323 "Send Large Community attributes\n")
4325 /* neighbor soft-reconfig. */
4326 DEFUN (neighbor_soft_reconfiguration
,
4327 neighbor_soft_reconfiguration_cmd
,
4328 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4331 "Per neighbor soft reconfiguration\n"
4332 "Allow inbound soft reconfiguration for this neighbor\n")
4335 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4337 PEER_FLAG_SOFT_RECONFIG
);
4340 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4341 neighbor_soft_reconfiguration_hidden_cmd
,
4342 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4343 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4344 "Per neighbor soft reconfiguration\n"
4345 "Allow inbound soft reconfiguration for this neighbor\n")
4347 DEFUN (no_neighbor_soft_reconfiguration
,
4348 no_neighbor_soft_reconfiguration_cmd
,
4349 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4353 "Per neighbor soft reconfiguration\n"
4354 "Allow inbound soft reconfiguration for this neighbor\n")
4357 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4358 bgp_node_afi(vty
), bgp_node_safi(vty
),
4359 PEER_FLAG_SOFT_RECONFIG
);
4362 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4363 no_neighbor_soft_reconfiguration_hidden_cmd
,
4364 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4365 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4366 "Per neighbor soft reconfiguration\n"
4367 "Allow inbound soft reconfiguration for this neighbor\n")
4369 DEFUN (neighbor_route_reflector_client
,
4370 neighbor_route_reflector_client_cmd
,
4371 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4374 "Configure a neighbor as Route Reflector client\n")
4380 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4382 return CMD_WARNING_CONFIG_FAILED
;
4384 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4386 PEER_FLAG_REFLECTOR_CLIENT
);
4389 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4390 neighbor_route_reflector_client_hidden_cmd
,
4391 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4392 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4393 "Configure a neighbor as Route Reflector client\n")
4395 DEFUN (no_neighbor_route_reflector_client
,
4396 no_neighbor_route_reflector_client_cmd
,
4397 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4401 "Configure a neighbor as Route Reflector client\n")
4404 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4405 bgp_node_afi(vty
), bgp_node_safi(vty
),
4406 PEER_FLAG_REFLECTOR_CLIENT
);
4409 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4410 no_neighbor_route_reflector_client_hidden_cmd
,
4411 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4412 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4413 "Configure a neighbor as Route Reflector client\n")
4415 /* neighbor route-server-client. */
4416 DEFUN (neighbor_route_server_client
,
4417 neighbor_route_server_client_cmd
,
4418 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4421 "Configure a neighbor as Route Server client\n")
4426 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4428 return CMD_WARNING_CONFIG_FAILED
;
4429 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4431 PEER_FLAG_RSERVER_CLIENT
);
4434 ALIAS_HIDDEN(neighbor_route_server_client
,
4435 neighbor_route_server_client_hidden_cmd
,
4436 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4437 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4438 "Configure a neighbor as Route Server client\n")
4440 DEFUN (no_neighbor_route_server_client
,
4441 no_neighbor_route_server_client_cmd
,
4442 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4446 "Configure a neighbor as Route Server client\n")
4449 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4450 bgp_node_afi(vty
), bgp_node_safi(vty
),
4451 PEER_FLAG_RSERVER_CLIENT
);
4454 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4455 no_neighbor_route_server_client_hidden_cmd
,
4456 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4457 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4458 "Configure a neighbor as Route Server client\n")
4460 DEFUN (neighbor_nexthop_local_unchanged
,
4461 neighbor_nexthop_local_unchanged_cmd
,
4462 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4465 "Configure treatment of outgoing link-local nexthop attribute\n"
4466 "Leave link-local nexthop unchanged for this peer\n")
4469 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4471 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4474 DEFUN (no_neighbor_nexthop_local_unchanged
,
4475 no_neighbor_nexthop_local_unchanged_cmd
,
4476 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4480 "Configure treatment of outgoing link-local-nexthop attribute\n"
4481 "Leave link-local nexthop unchanged for this peer\n")
4484 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4485 bgp_node_afi(vty
), bgp_node_safi(vty
),
4486 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4489 DEFUN (neighbor_attr_unchanged
,
4490 neighbor_attr_unchanged_cmd
,
4491 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4494 "BGP attribute is propagated unchanged to this neighbor\n"
4495 "As-path attribute\n"
4496 "Nexthop attribute\n"
4500 char *peer_str
= argv
[1]->arg
;
4503 afi_t afi
= bgp_node_afi(vty
);
4504 safi_t safi
= bgp_node_safi(vty
);
4506 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4508 return CMD_WARNING_CONFIG_FAILED
;
4510 if (argv_find(argv
, argc
, "as-path", &idx
))
4511 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4513 if (argv_find(argv
, argc
, "next-hop", &idx
))
4514 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4516 if (argv_find(argv
, argc
, "med", &idx
))
4517 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4519 /* no flags means all of them! */
4521 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4522 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4523 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4525 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4526 && peer_af_flag_check(peer
, afi
, safi
,
4527 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4528 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4529 PEER_FLAG_AS_PATH_UNCHANGED
);
4532 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4533 && peer_af_flag_check(peer
, afi
, safi
,
4534 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4535 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4536 PEER_FLAG_NEXTHOP_UNCHANGED
);
4539 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4540 && peer_af_flag_check(peer
, afi
, safi
,
4541 PEER_FLAG_MED_UNCHANGED
)) {
4542 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4543 PEER_FLAG_MED_UNCHANGED
);
4547 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4551 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4552 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4553 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4554 "BGP attribute is propagated unchanged to this neighbor\n"
4555 "As-path attribute\n"
4556 "Nexthop attribute\n"
4559 DEFUN (no_neighbor_attr_unchanged
,
4560 no_neighbor_attr_unchanged_cmd
,
4561 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4565 "BGP attribute is propagated unchanged to this neighbor\n"
4566 "As-path attribute\n"
4567 "Nexthop attribute\n"
4571 char *peer
= argv
[2]->arg
;
4574 if (argv_find(argv
, argc
, "as-path", &idx
))
4575 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4577 if (argv_find(argv
, argc
, "next-hop", &idx
))
4578 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4580 if (argv_find(argv
, argc
, "med", &idx
))
4581 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4583 if (!flags
) // no flags means all of them!
4585 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4586 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4587 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4590 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4591 bgp_node_safi(vty
), flags
);
4595 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4596 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4597 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4598 "BGP attribute is propagated unchanged to this neighbor\n"
4599 "As-path attribute\n"
4600 "Nexthop attribute\n"
4603 /* EBGP multihop configuration. */
4604 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4605 const char *ttl_str
)
4610 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4612 return CMD_WARNING_CONFIG_FAILED
;
4615 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4620 ttl
= strtoul(ttl_str
, NULL
, 10);
4622 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4625 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4629 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4631 return CMD_WARNING_CONFIG_FAILED
;
4633 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4636 /* neighbor ebgp-multihop. */
4637 DEFUN (neighbor_ebgp_multihop
,
4638 neighbor_ebgp_multihop_cmd
,
4639 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4642 "Allow EBGP neighbors not on directly connected networks\n")
4645 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4648 DEFUN (neighbor_ebgp_multihop_ttl
,
4649 neighbor_ebgp_multihop_ttl_cmd
,
4650 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4653 "Allow EBGP neighbors not on directly connected networks\n"
4654 "maximum hop count\n")
4658 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4659 argv
[idx_number
]->arg
);
4662 DEFUN (no_neighbor_ebgp_multihop
,
4663 no_neighbor_ebgp_multihop_cmd
,
4664 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4668 "Allow EBGP neighbors not on directly connected networks\n"
4669 "maximum hop count\n")
4672 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4676 /* disable-connected-check */
4677 DEFUN (neighbor_disable_connected_check
,
4678 neighbor_disable_connected_check_cmd
,
4679 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4682 "one-hop away EBGP peer using loopback address\n"
4683 "Enforce EBGP neighbors perform multihop\n")
4686 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4687 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4690 DEFUN (no_neighbor_disable_connected_check
,
4691 no_neighbor_disable_connected_check_cmd
,
4692 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4696 "one-hop away EBGP peer using loopback address\n"
4697 "Enforce EBGP neighbors perform multihop\n")
4700 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4701 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4705 /* enforce-first-as */
4706 DEFUN (neighbor_enforce_first_as
,
4707 neighbor_enforce_first_as_cmd
,
4708 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4711 "Enforce the first AS for EBGP routes\n")
4715 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4716 PEER_FLAG_ENFORCE_FIRST_AS
);
4719 DEFUN (no_neighbor_enforce_first_as
,
4720 no_neighbor_enforce_first_as_cmd
,
4721 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4725 "Enforce the first AS for EBGP routes\n")
4729 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4730 PEER_FLAG_ENFORCE_FIRST_AS
);
4734 DEFUN (neighbor_description
,
4735 neighbor_description_cmd
,
4736 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4739 "Neighbor specific description\n"
4740 "Up to 80 characters describing this neighbor\n")
4747 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4749 return CMD_WARNING_CONFIG_FAILED
;
4751 str
= argv_concat(argv
, argc
, idx_line
);
4753 peer_description_set(peer
, str
);
4755 XFREE(MTYPE_TMP
, str
);
4760 DEFUN (no_neighbor_description
,
4761 no_neighbor_description_cmd
,
4762 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4766 "Neighbor specific description\n")
4771 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4773 return CMD_WARNING_CONFIG_FAILED
;
4775 peer_description_unset(peer
);
4780 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4781 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4782 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4783 "Neighbor specific description\n"
4784 "Up to 80 characters describing this neighbor\n")
4786 /* Neighbor update-source. */
4787 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4788 const char *source_str
)
4794 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4796 return CMD_WARNING_CONFIG_FAILED
;
4802 if (str2sockunion(source_str
, &su
) == 0)
4803 peer_update_source_addr_set(peer
, &su
);
4805 if (str2prefix(source_str
, &p
)) {
4807 "%% Invalid update-source, remove prefix length \n");
4808 return CMD_WARNING_CONFIG_FAILED
;
4810 peer_update_source_if_set(peer
, source_str
);
4813 peer_update_source_unset(peer
);
4818 #define BGP_UPDATE_SOURCE_HELP_STR \
4821 "Interface name (requires zebra to be running)\n"
4823 DEFUN (neighbor_update_source
,
4824 neighbor_update_source_cmd
,
4825 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4828 "Source of routing updates\n"
4829 BGP_UPDATE_SOURCE_HELP_STR
)
4833 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4834 argv
[idx_peer_2
]->arg
);
4837 DEFUN (no_neighbor_update_source
,
4838 no_neighbor_update_source_cmd
,
4839 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4843 "Source of routing updates\n"
4844 BGP_UPDATE_SOURCE_HELP_STR
)
4847 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4850 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4851 afi_t afi
, safi_t safi
,
4852 const char *rmap
, int set
)
4856 struct route_map
*route_map
;
4858 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4860 return CMD_WARNING_CONFIG_FAILED
;
4863 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4864 ret
= peer_default_originate_set(peer
, afi
, safi
,
4867 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4869 return bgp_vty_return(vty
, ret
);
4872 /* neighbor default-originate. */
4873 DEFUN (neighbor_default_originate
,
4874 neighbor_default_originate_cmd
,
4875 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4878 "Originate default route to this neighbor\n")
4881 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4883 bgp_node_safi(vty
), NULL
, 1);
4886 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4887 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4888 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4889 "Originate default route to this neighbor\n")
4891 DEFUN (neighbor_default_originate_rmap
,
4892 neighbor_default_originate_rmap_cmd
,
4893 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4896 "Originate default route to this neighbor\n"
4897 "Route-map to specify criteria to originate default\n"
4902 return peer_default_originate_set_vty(
4903 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4904 argv
[idx_word
]->arg
, 1);
4908 neighbor_default_originate_rmap
,
4909 neighbor_default_originate_rmap_hidden_cmd
,
4910 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4911 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4912 "Originate default route to this neighbor\n"
4913 "Route-map to specify criteria to originate default\n"
4916 DEFUN (no_neighbor_default_originate
,
4917 no_neighbor_default_originate_cmd
,
4918 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4922 "Originate default route to this neighbor\n"
4923 "Route-map to specify criteria to originate default\n"
4927 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4929 bgp_node_safi(vty
), NULL
, 0);
4933 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4934 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4935 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4936 "Originate default route to this neighbor\n"
4937 "Route-map to specify criteria to originate default\n"
4941 /* Set neighbor's BGP port. */
4942 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4943 const char *port_str
)
4949 peer
= peer_lookup_vty(vty
, ip_str
);
4951 return CMD_WARNING_CONFIG_FAILED
;
4954 sp
= getservbyname("bgp", "tcp");
4955 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4957 port
= strtoul(port_str
, NULL
, 10);
4960 peer_port_set(peer
, port
);
4965 /* Set specified peer's BGP port. */
4966 DEFUN (neighbor_port
,
4968 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4971 "Neighbor's BGP port\n"
4972 "TCP port number\n")
4976 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4977 argv
[idx_number
]->arg
);
4980 DEFUN (no_neighbor_port
,
4981 no_neighbor_port_cmd
,
4982 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4986 "Neighbor's BGP port\n"
4987 "TCP port number\n")
4990 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4994 /* neighbor weight. */
4995 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4996 safi_t safi
, const char *weight_str
)
5000 unsigned long weight
;
5002 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5004 return CMD_WARNING_CONFIG_FAILED
;
5006 weight
= strtoul(weight_str
, NULL
, 10);
5008 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5009 return bgp_vty_return(vty
, ret
);
5012 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5018 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5020 return CMD_WARNING_CONFIG_FAILED
;
5022 ret
= peer_weight_unset(peer
, afi
, safi
);
5023 return bgp_vty_return(vty
, ret
);
5026 DEFUN (neighbor_weight
,
5027 neighbor_weight_cmd
,
5028 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5031 "Set default weight for routes from this neighbor\n"
5036 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5037 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5040 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5041 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5042 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5043 "Set default weight for routes from this neighbor\n"
5046 DEFUN (no_neighbor_weight
,
5047 no_neighbor_weight_cmd
,
5048 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5052 "Set default weight for routes from this neighbor\n"
5056 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5057 bgp_node_afi(vty
), bgp_node_safi(vty
));
5060 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5061 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5062 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5063 "Set default weight for routes from this neighbor\n"
5067 /* Override capability negotiation. */
5068 DEFUN (neighbor_override_capability
,
5069 neighbor_override_capability_cmd
,
5070 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5073 "Override capability negotiation result\n")
5076 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5077 PEER_FLAG_OVERRIDE_CAPABILITY
);
5080 DEFUN (no_neighbor_override_capability
,
5081 no_neighbor_override_capability_cmd
,
5082 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5086 "Override capability negotiation result\n")
5089 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5090 PEER_FLAG_OVERRIDE_CAPABILITY
);
5093 DEFUN (neighbor_strict_capability
,
5094 neighbor_strict_capability_cmd
,
5095 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5098 "Strict capability negotiation match\n")
5102 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5103 PEER_FLAG_STRICT_CAP_MATCH
);
5106 DEFUN (no_neighbor_strict_capability
,
5107 no_neighbor_strict_capability_cmd
,
5108 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5112 "Strict capability negotiation match\n")
5116 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5117 PEER_FLAG_STRICT_CAP_MATCH
);
5120 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5121 const char *keep_str
, const char *hold_str
)
5128 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5130 return CMD_WARNING_CONFIG_FAILED
;
5132 keepalive
= strtoul(keep_str
, NULL
, 10);
5133 holdtime
= strtoul(hold_str
, NULL
, 10);
5135 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5137 return bgp_vty_return(vty
, ret
);
5140 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5145 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5147 return CMD_WARNING_CONFIG_FAILED
;
5149 ret
= peer_timers_unset(peer
);
5151 return bgp_vty_return(vty
, ret
);
5154 DEFUN (neighbor_timers
,
5155 neighbor_timers_cmd
,
5156 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5159 "BGP per neighbor timers\n"
5160 "Keepalive interval\n"
5165 int idx_number_2
= 4;
5166 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5167 argv
[idx_number
]->arg
,
5168 argv
[idx_number_2
]->arg
);
5171 DEFUN (no_neighbor_timers
,
5172 no_neighbor_timers_cmd
,
5173 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5177 "BGP per neighbor timers\n"
5178 "Keepalive interval\n"
5182 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5186 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5187 const char *time_str
)
5193 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5195 return CMD_WARNING_CONFIG_FAILED
;
5197 connect
= strtoul(time_str
, NULL
, 10);
5199 ret
= peer_timers_connect_set(peer
, connect
);
5201 return bgp_vty_return(vty
, ret
);
5204 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5209 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5211 return CMD_WARNING_CONFIG_FAILED
;
5213 ret
= peer_timers_connect_unset(peer
);
5215 return bgp_vty_return(vty
, ret
);
5218 DEFUN (neighbor_timers_connect
,
5219 neighbor_timers_connect_cmd
,
5220 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5223 "BGP per neighbor timers\n"
5224 "BGP connect timer\n"
5229 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5230 argv
[idx_number
]->arg
);
5233 DEFUN (no_neighbor_timers_connect
,
5234 no_neighbor_timers_connect_cmd
,
5235 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5239 "BGP per neighbor timers\n"
5240 "BGP connect timer\n"
5244 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5248 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5249 const char *time_str
, int set
)
5253 uint32_t routeadv
= 0;
5255 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5257 return CMD_WARNING_CONFIG_FAILED
;
5260 routeadv
= strtoul(time_str
, NULL
, 10);
5263 ret
= peer_advertise_interval_set(peer
, routeadv
);
5265 ret
= peer_advertise_interval_unset(peer
);
5267 return bgp_vty_return(vty
, ret
);
5270 DEFUN (neighbor_advertise_interval
,
5271 neighbor_advertise_interval_cmd
,
5272 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5275 "Minimum interval between sending BGP routing updates\n"
5276 "time in seconds\n")
5280 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5281 argv
[idx_number
]->arg
, 1);
5284 DEFUN (no_neighbor_advertise_interval
,
5285 no_neighbor_advertise_interval_cmd
,
5286 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5290 "Minimum interval between sending BGP routing updates\n"
5291 "time in seconds\n")
5294 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5298 /* Time to wait before processing route-map updates */
5299 DEFUN (bgp_set_route_map_delay_timer
,
5300 bgp_set_route_map_delay_timer_cmd
,
5301 "bgp route-map delay-timer (0-600)",
5303 "BGP route-map delay timer\n"
5304 "Time in secs to wait before processing route-map changes\n"
5305 "0 disables the timer, no route updates happen when route-maps change\n")
5308 uint32_t rmap_delay_timer
;
5310 if (argv
[idx_number
]->arg
) {
5311 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5312 bm
->rmap_update_timer
= rmap_delay_timer
;
5314 /* if the dynamic update handling is being disabled, and a timer
5316 * running, stop the timer and act as if the timer has already
5319 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5320 BGP_TIMER_OFF(bm
->t_rmap_update
);
5321 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5326 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5327 return CMD_WARNING_CONFIG_FAILED
;
5331 DEFUN (no_bgp_set_route_map_delay_timer
,
5332 no_bgp_set_route_map_delay_timer_cmd
,
5333 "no bgp route-map delay-timer [(0-600)]",
5336 "Default BGP route-map delay timer\n"
5337 "Reset to default time to wait for processing route-map changes\n"
5338 "0 disables the timer, no route updates happen when route-maps change\n")
5341 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5347 /* neighbor interface */
5348 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5353 peer
= peer_lookup_vty(vty
, ip_str
);
5354 if (!peer
|| peer
->conf_if
) {
5355 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5356 return CMD_WARNING_CONFIG_FAILED
;
5360 peer_interface_set(peer
, str
);
5362 peer_interface_unset(peer
);
5367 DEFUN (neighbor_interface
,
5368 neighbor_interface_cmd
,
5369 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5377 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5380 DEFUN (no_neighbor_interface
,
5381 no_neighbor_interface_cmd
,
5382 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5390 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5393 DEFUN (neighbor_distribute_list
,
5394 neighbor_distribute_list_cmd
,
5395 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5398 "Filter updates to/from this neighbor\n"
5399 "IP access-list number\n"
5400 "IP access-list number (expanded range)\n"
5401 "IP Access-list name\n"
5402 "Filter incoming updates\n"
5403 "Filter outgoing updates\n")
5410 const char *pstr
= argv
[idx_peer
]->arg
;
5411 const char *acl
= argv
[idx_acl
]->arg
;
5412 const char *inout
= argv
[argc
- 1]->text
;
5414 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5416 return CMD_WARNING_CONFIG_FAILED
;
5418 /* Check filter direction. */
5419 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5420 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5423 return bgp_vty_return(vty
, ret
);
5427 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5428 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5429 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5430 "Filter updates to/from this neighbor\n"
5431 "IP access-list number\n"
5432 "IP access-list number (expanded range)\n"
5433 "IP Access-list name\n"
5434 "Filter incoming updates\n"
5435 "Filter outgoing updates\n")
5437 DEFUN (no_neighbor_distribute_list
,
5438 no_neighbor_distribute_list_cmd
,
5439 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5443 "Filter updates to/from this neighbor\n"
5444 "IP access-list number\n"
5445 "IP access-list number (expanded range)\n"
5446 "IP Access-list name\n"
5447 "Filter incoming updates\n"
5448 "Filter outgoing updates\n")
5454 const char *pstr
= argv
[idx_peer
]->arg
;
5455 const char *inout
= argv
[argc
- 1]->text
;
5457 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5459 return CMD_WARNING_CONFIG_FAILED
;
5461 /* Check filter direction. */
5462 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5463 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5466 return bgp_vty_return(vty
, ret
);
5470 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5471 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5472 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5473 "Filter updates to/from this neighbor\n"
5474 "IP access-list number\n"
5475 "IP access-list number (expanded range)\n"
5476 "IP Access-list name\n"
5477 "Filter incoming updates\n"
5478 "Filter outgoing updates\n")
5480 /* Set prefix list to the peer. */
5481 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5482 afi_t afi
, safi_t safi
,
5483 const char *name_str
,
5484 const char *direct_str
)
5487 int direct
= FILTER_IN
;
5490 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5492 return CMD_WARNING_CONFIG_FAILED
;
5494 /* Check filter direction. */
5495 if (strncmp(direct_str
, "i", 1) == 0)
5497 else if (strncmp(direct_str
, "o", 1) == 0)
5498 direct
= FILTER_OUT
;
5500 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5502 return bgp_vty_return(vty
, ret
);
5505 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5506 afi_t afi
, safi_t safi
,
5507 const char *direct_str
)
5511 int direct
= FILTER_IN
;
5513 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5515 return CMD_WARNING_CONFIG_FAILED
;
5517 /* Check filter direction. */
5518 if (strncmp(direct_str
, "i", 1) == 0)
5520 else if (strncmp(direct_str
, "o", 1) == 0)
5521 direct
= FILTER_OUT
;
5523 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5525 return bgp_vty_return(vty
, ret
);
5528 DEFUN (neighbor_prefix_list
,
5529 neighbor_prefix_list_cmd
,
5530 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5533 "Filter updates to/from this neighbor\n"
5534 "Name of a prefix list\n"
5535 "Filter incoming updates\n"
5536 "Filter outgoing updates\n")
5541 return peer_prefix_list_set_vty(
5542 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5543 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5546 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5547 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5548 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5549 "Filter updates to/from this neighbor\n"
5550 "Name of a prefix list\n"
5551 "Filter incoming updates\n"
5552 "Filter outgoing updates\n")
5554 DEFUN (no_neighbor_prefix_list
,
5555 no_neighbor_prefix_list_cmd
,
5556 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5560 "Filter updates to/from this neighbor\n"
5561 "Name of a prefix list\n"
5562 "Filter incoming updates\n"
5563 "Filter outgoing updates\n")
5567 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5568 bgp_node_afi(vty
), bgp_node_safi(vty
),
5569 argv
[idx_in_out
]->arg
);
5572 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5573 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5574 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5575 "Filter updates to/from this neighbor\n"
5576 "Name of a prefix list\n"
5577 "Filter incoming updates\n"
5578 "Filter outgoing updates\n")
5580 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5581 safi_t safi
, const char *name_str
,
5582 const char *direct_str
)
5586 int direct
= FILTER_IN
;
5588 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5590 return CMD_WARNING_CONFIG_FAILED
;
5592 /* Check filter direction. */
5593 if (strncmp(direct_str
, "i", 1) == 0)
5595 else if (strncmp(direct_str
, "o", 1) == 0)
5596 direct
= FILTER_OUT
;
5598 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5600 return bgp_vty_return(vty
, ret
);
5603 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5604 safi_t safi
, const char *direct_str
)
5608 int direct
= FILTER_IN
;
5610 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5612 return CMD_WARNING_CONFIG_FAILED
;
5614 /* Check filter direction. */
5615 if (strncmp(direct_str
, "i", 1) == 0)
5617 else if (strncmp(direct_str
, "o", 1) == 0)
5618 direct
= FILTER_OUT
;
5620 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5622 return bgp_vty_return(vty
, ret
);
5625 DEFUN (neighbor_filter_list
,
5626 neighbor_filter_list_cmd
,
5627 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5630 "Establish BGP filters\n"
5631 "AS path access-list name\n"
5632 "Filter incoming routes\n"
5633 "Filter outgoing routes\n")
5638 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5639 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5640 argv
[idx_in_out
]->arg
);
5643 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5644 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5645 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5646 "Establish BGP filters\n"
5647 "AS path access-list name\n"
5648 "Filter incoming routes\n"
5649 "Filter outgoing routes\n")
5651 DEFUN (no_neighbor_filter_list
,
5652 no_neighbor_filter_list_cmd
,
5653 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5657 "Establish BGP filters\n"
5658 "AS path access-list name\n"
5659 "Filter incoming routes\n"
5660 "Filter outgoing routes\n")
5664 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5665 bgp_node_afi(vty
), bgp_node_safi(vty
),
5666 argv
[idx_in_out
]->arg
);
5669 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5670 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5671 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5672 "Establish BGP filters\n"
5673 "AS path access-list name\n"
5674 "Filter incoming routes\n"
5675 "Filter outgoing routes\n")
5677 /* Set route-map to the peer. */
5678 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5679 afi_t afi
, safi_t safi
, const char *name_str
,
5680 const char *direct_str
)
5684 int direct
= RMAP_IN
;
5685 struct route_map
*route_map
;
5687 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5689 return CMD_WARNING_CONFIG_FAILED
;
5691 /* Check filter direction. */
5692 if (strncmp(direct_str
, "in", 2) == 0)
5694 else if (strncmp(direct_str
, "o", 1) == 0)
5697 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5698 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5700 return bgp_vty_return(vty
, ret
);
5703 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5704 afi_t afi
, safi_t safi
,
5705 const char *direct_str
)
5709 int direct
= RMAP_IN
;
5711 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5713 return CMD_WARNING_CONFIG_FAILED
;
5715 /* Check filter direction. */
5716 if (strncmp(direct_str
, "in", 2) == 0)
5718 else if (strncmp(direct_str
, "o", 1) == 0)
5721 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5723 return bgp_vty_return(vty
, ret
);
5726 DEFUN (neighbor_route_map
,
5727 neighbor_route_map_cmd
,
5728 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5731 "Apply route map to neighbor\n"
5732 "Name of route map\n"
5733 "Apply map to incoming routes\n"
5734 "Apply map to outbound routes\n")
5739 return peer_route_map_set_vty(
5740 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5741 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5744 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5745 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5746 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5747 "Apply route map to neighbor\n"
5748 "Name of route map\n"
5749 "Apply map to incoming routes\n"
5750 "Apply map to outbound routes\n")
5752 DEFUN (no_neighbor_route_map
,
5753 no_neighbor_route_map_cmd
,
5754 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5758 "Apply route map to neighbor\n"
5759 "Name of route map\n"
5760 "Apply map to incoming routes\n"
5761 "Apply map to outbound routes\n")
5765 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5766 bgp_node_afi(vty
), bgp_node_safi(vty
),
5767 argv
[idx_in_out
]->arg
);
5770 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5771 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5772 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5773 "Apply route map to neighbor\n"
5774 "Name of route map\n"
5775 "Apply map to incoming routes\n"
5776 "Apply map to outbound routes\n")
5778 /* Set unsuppress-map to the peer. */
5779 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5780 afi_t afi
, safi_t safi
,
5781 const char *name_str
)
5785 struct route_map
*route_map
;
5787 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5789 return CMD_WARNING_CONFIG_FAILED
;
5791 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5792 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5794 return bgp_vty_return(vty
, ret
);
5797 /* Unset route-map from the peer. */
5798 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5799 afi_t afi
, safi_t safi
)
5804 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5806 return CMD_WARNING_CONFIG_FAILED
;
5808 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5810 return bgp_vty_return(vty
, ret
);
5813 DEFUN (neighbor_unsuppress_map
,
5814 neighbor_unsuppress_map_cmd
,
5815 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5818 "Route-map to selectively unsuppress suppressed routes\n"
5819 "Name of route map\n")
5823 return peer_unsuppress_map_set_vty(
5824 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5825 argv
[idx_word
]->arg
);
5828 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5830 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5831 "Route-map to selectively unsuppress suppressed routes\n"
5832 "Name of route map\n")
5834 DEFUN (no_neighbor_unsuppress_map
,
5835 no_neighbor_unsuppress_map_cmd
,
5836 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5840 "Route-map to selectively unsuppress suppressed routes\n"
5841 "Name of route map\n")
5844 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5846 bgp_node_safi(vty
));
5849 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5850 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5851 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5852 "Route-map to selectively unsuppress suppressed routes\n"
5853 "Name of route map\n")
5855 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5856 afi_t afi
, safi_t safi
,
5857 const char *num_str
,
5858 const char *threshold_str
, int warning
,
5859 const char *restart_str
)
5867 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5869 return CMD_WARNING_CONFIG_FAILED
;
5871 max
= strtoul(num_str
, NULL
, 10);
5873 threshold
= atoi(threshold_str
);
5875 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5878 restart
= atoi(restart_str
);
5882 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5885 return bgp_vty_return(vty
, ret
);
5888 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5889 afi_t afi
, safi_t safi
)
5894 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5896 return CMD_WARNING_CONFIG_FAILED
;
5898 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5900 return bgp_vty_return(vty
, ret
);
5903 /* Maximum number of prefix configuration. prefix count is different
5904 for each peer configuration. So this configuration can be set for
5905 each peer configuration. */
5906 DEFUN (neighbor_maximum_prefix
,
5907 neighbor_maximum_prefix_cmd
,
5908 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5911 "Maximum number of prefix accept from this peer\n"
5912 "maximum no. of prefix limit\n")
5916 return peer_maximum_prefix_set_vty(
5917 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5918 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5921 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5922 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5923 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5924 "Maximum number of prefix accept from this peer\n"
5925 "maximum no. of prefix limit\n")
5927 DEFUN (neighbor_maximum_prefix_threshold
,
5928 neighbor_maximum_prefix_threshold_cmd
,
5929 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5932 "Maximum number of prefix accept from this peer\n"
5933 "maximum no. of prefix limit\n"
5934 "Threshold value (%) at which to generate a warning msg\n")
5938 int idx_number_2
= 4;
5939 return peer_maximum_prefix_set_vty(
5940 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5941 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5945 neighbor_maximum_prefix_threshold
,
5946 neighbor_maximum_prefix_threshold_hidden_cmd
,
5947 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5948 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5949 "Maximum number of prefix accept from this peer\n"
5950 "maximum no. of prefix limit\n"
5951 "Threshold value (%) at which to generate a warning msg\n")
5953 DEFUN (neighbor_maximum_prefix_warning
,
5954 neighbor_maximum_prefix_warning_cmd
,
5955 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5958 "Maximum number of prefix accept from this peer\n"
5959 "maximum no. of prefix limit\n"
5960 "Only give warning message when limit is exceeded\n")
5964 return peer_maximum_prefix_set_vty(
5965 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5966 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5970 neighbor_maximum_prefix_warning
,
5971 neighbor_maximum_prefix_warning_hidden_cmd
,
5972 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5973 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5974 "Maximum number of prefix accept from this peer\n"
5975 "maximum no. of prefix limit\n"
5976 "Only give warning message when limit is exceeded\n")
5978 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5979 neighbor_maximum_prefix_threshold_warning_cmd
,
5980 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5983 "Maximum number of prefix accept from this peer\n"
5984 "maximum no. of prefix limit\n"
5985 "Threshold value (%) at which to generate a warning msg\n"
5986 "Only give warning message when limit is exceeded\n")
5990 int idx_number_2
= 4;
5991 return peer_maximum_prefix_set_vty(
5992 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5993 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5997 neighbor_maximum_prefix_threshold_warning
,
5998 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5999 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6000 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6001 "Maximum number of prefix accept from this peer\n"
6002 "maximum no. of prefix limit\n"
6003 "Threshold value (%) at which to generate a warning msg\n"
6004 "Only give warning message when limit is exceeded\n")
6006 DEFUN (neighbor_maximum_prefix_restart
,
6007 neighbor_maximum_prefix_restart_cmd
,
6008 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6011 "Maximum number of prefix accept from this peer\n"
6012 "maximum no. of prefix limit\n"
6013 "Restart bgp connection after limit is exceeded\n"
6014 "Restart interval in minutes\n")
6018 int idx_number_2
= 5;
6019 return peer_maximum_prefix_set_vty(
6020 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6021 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6025 neighbor_maximum_prefix_restart
,
6026 neighbor_maximum_prefix_restart_hidden_cmd
,
6027 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6028 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6029 "Maximum number of prefix accept from this peer\n"
6030 "maximum no. of prefix limit\n"
6031 "Restart bgp connection after limit is exceeded\n"
6032 "Restart interval in minutes\n")
6034 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6035 neighbor_maximum_prefix_threshold_restart_cmd
,
6036 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6039 "Maximum number of prefixes to accept from this peer\n"
6040 "maximum no. of prefix limit\n"
6041 "Threshold value (%) at which to generate a warning msg\n"
6042 "Restart bgp connection after limit is exceeded\n"
6043 "Restart interval in minutes\n")
6047 int idx_number_2
= 4;
6048 int idx_number_3
= 6;
6049 return peer_maximum_prefix_set_vty(
6050 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6051 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6052 argv
[idx_number_3
]->arg
);
6056 neighbor_maximum_prefix_threshold_restart
,
6057 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6058 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6059 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6060 "Maximum number of prefixes to accept from this peer\n"
6061 "maximum no. of prefix limit\n"
6062 "Threshold value (%) at which to generate a warning msg\n"
6063 "Restart bgp connection after limit is exceeded\n"
6064 "Restart interval in minutes\n")
6066 DEFUN (no_neighbor_maximum_prefix
,
6067 no_neighbor_maximum_prefix_cmd
,
6068 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6072 "Maximum number of prefixes to accept from this peer\n"
6073 "maximum no. of prefix limit\n"
6074 "Threshold value (%) at which to generate a warning msg\n"
6075 "Restart bgp connection after limit is exceeded\n"
6076 "Restart interval in minutes\n"
6077 "Only give warning message when limit is exceeded\n")
6080 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6082 bgp_node_safi(vty
));
6086 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6087 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6088 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6089 "Maximum number of prefixes to accept from this peer\n"
6090 "maximum no. of prefix limit\n"
6091 "Threshold value (%) at which to generate a warning msg\n"
6092 "Restart bgp connection after limit is exceeded\n"
6093 "Restart interval in minutes\n"
6094 "Only give warning message when limit is exceeded\n")
6097 /* "neighbor allowas-in" */
6098 DEFUN (neighbor_allowas_in
,
6099 neighbor_allowas_in_cmd
,
6100 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6103 "Accept as-path with my AS present in it\n"
6104 "Number of occurences of AS number\n"
6105 "Only accept my AS in the as-path if the route was originated in my AS\n")
6108 int idx_number_origin
= 3;
6114 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6116 return CMD_WARNING_CONFIG_FAILED
;
6118 if (argc
<= idx_number_origin
)
6121 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6124 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6127 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6130 return bgp_vty_return(vty
, ret
);
6134 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6135 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6136 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6137 "Accept as-path with my AS present in it\n"
6138 "Number of occurences of AS number\n"
6139 "Only accept my AS in the as-path if the route was originated in my AS\n")
6141 DEFUN (no_neighbor_allowas_in
,
6142 no_neighbor_allowas_in_cmd
,
6143 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6147 "allow local ASN appears in aspath attribute\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")
6155 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6157 return CMD_WARNING_CONFIG_FAILED
;
6159 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6160 bgp_node_safi(vty
));
6162 return bgp_vty_return(vty
, ret
);
6166 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6167 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6168 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6169 "allow local ASN appears in aspath attribute\n"
6170 "Number of occurences of AS number\n"
6171 "Only accept my AS in the as-path if the route was originated in my AS\n")
6173 DEFUN (neighbor_ttl_security
,
6174 neighbor_ttl_security_cmd
,
6175 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6178 "BGP ttl-security parameters\n"
6179 "Specify the maximum number of hops to the BGP peer\n"
6180 "Number of hops to BGP peer\n")
6187 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6189 return CMD_WARNING_CONFIG_FAILED
;
6191 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6194 * If 'neighbor swpX', then this is for directly connected peers,
6195 * we should not accept a ttl-security hops value greater than 1.
6197 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6199 "%s is directly connected peer, hops cannot exceed 1\n",
6200 argv
[idx_peer
]->arg
);
6201 return CMD_WARNING_CONFIG_FAILED
;
6204 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6207 DEFUN (no_neighbor_ttl_security
,
6208 no_neighbor_ttl_security_cmd
,
6209 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6213 "BGP ttl-security parameters\n"
6214 "Specify the maximum number of hops to the BGP peer\n"
6215 "Number of hops to BGP peer\n")
6220 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6222 return CMD_WARNING_CONFIG_FAILED
;
6224 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6227 DEFUN (neighbor_addpath_tx_all_paths
,
6228 neighbor_addpath_tx_all_paths_cmd
,
6229 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6232 "Use addpath to advertise all paths to a neighbor\n")
6237 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6239 return CMD_WARNING_CONFIG_FAILED
;
6241 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6246 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6247 neighbor_addpath_tx_all_paths_hidden_cmd
,
6248 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6249 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6250 "Use addpath to advertise all paths to a neighbor\n")
6252 DEFUN (no_neighbor_addpath_tx_all_paths
,
6253 no_neighbor_addpath_tx_all_paths_cmd
,
6254 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6258 "Use addpath to advertise all paths to a neighbor\n")
6263 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6265 return CMD_WARNING_CONFIG_FAILED
;
6267 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6268 != BGP_ADDPATH_ALL
) {
6270 "%% Peer not currently configured to transmit all paths.");
6271 return CMD_WARNING_CONFIG_FAILED
;
6274 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6280 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6281 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6282 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6283 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6284 "Use addpath to advertise all paths to a neighbor\n")
6286 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6287 neighbor_addpath_tx_bestpath_per_as_cmd
,
6288 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6291 "Use addpath to advertise the bestpath per each neighboring AS\n")
6296 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6298 return CMD_WARNING_CONFIG_FAILED
;
6300 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6301 BGP_ADDPATH_BEST_PER_AS
);
6306 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6307 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6308 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6309 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6310 "Use addpath to advertise the bestpath per each neighboring AS\n")
6312 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6313 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6314 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6318 "Use addpath to advertise the bestpath per each neighboring AS\n")
6323 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6325 return CMD_WARNING_CONFIG_FAILED
;
6327 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6328 != BGP_ADDPATH_BEST_PER_AS
) {
6330 "%% Peer not currently configured to transmit all best path per as.");
6331 return CMD_WARNING_CONFIG_FAILED
;
6334 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6340 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6341 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6342 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6343 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6344 "Use addpath to advertise the bestpath per each neighboring AS\n")
6346 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6347 struct ecommunity
**list
)
6349 struct ecommunity
*ecom
= NULL
;
6350 struct ecommunity
*ecomadd
;
6352 for (; argc
; --argc
, ++argv
) {
6354 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6355 ECOMMUNITY_ROUTE_TARGET
, 0);
6357 vty_out(vty
, "Malformed community-list value\n");
6359 ecommunity_free(&ecom
);
6360 return CMD_WARNING_CONFIG_FAILED
;
6364 ecommunity_merge(ecom
, ecomadd
);
6365 ecommunity_free(&ecomadd
);
6372 ecommunity_free(&*list
);
6380 * v2vimport is true if we are handling a `import vrf ...` command
6382 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6386 switch (vty
->node
) {
6395 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6400 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6401 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6402 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6403 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6405 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6409 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6410 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6411 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6412 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6414 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6421 DEFPY (af_rd_vpn_export
,
6422 af_rd_vpn_export_cmd
,
6423 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6425 "Specify route distinguisher\n"
6426 "Between current address-family and vpn\n"
6427 "For routes leaked from current address-family to vpn\n"
6428 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6431 struct prefix_rd prd
;
6437 if (argv_find(argv
, argc
, "no", &idx
))
6441 ret
= str2prefix_rd(rd_str
, &prd
);
6443 vty_out(vty
, "%% Malformed rd\n");
6444 return CMD_WARNING_CONFIG_FAILED
;
6448 afi
= vpn_policy_getafi(vty
, bgp
, false);
6450 return CMD_WARNING_CONFIG_FAILED
;
6453 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6455 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6456 bgp_get_default(), bgp
);
6459 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6460 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6461 BGP_VPN_POLICY_TOVPN_RD_SET
);
6463 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6464 BGP_VPN_POLICY_TOVPN_RD_SET
);
6467 /* post-change: re-export vpn routes */
6468 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6469 bgp_get_default(), bgp
);
6474 ALIAS (af_rd_vpn_export
,
6475 af_no_rd_vpn_export_cmd
,
6478 "Specify route distinguisher\n"
6479 "Between current address-family and vpn\n"
6480 "For routes leaked from current address-family to vpn\n")
6482 DEFPY (af_label_vpn_export
,
6483 af_label_vpn_export_cmd
,
6484 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6486 "label value for VRF\n"
6487 "Between current address-family and vpn\n"
6488 "For routes leaked from current address-family to vpn\n"
6489 "Label Value <0-1048575>\n"
6490 "Automatically assign a label\n")
6492 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6493 mpls_label_t label
= MPLS_LABEL_NONE
;
6498 if (argv_find(argv
, argc
, "no", &idx
))
6501 /* If "no ...", squash trailing parameter */
6507 label
= label_val
; /* parser should force unsigned */
6510 afi
= vpn_policy_getafi(vty
, bgp
, false);
6512 return CMD_WARNING_CONFIG_FAILED
;
6515 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6516 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6521 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6523 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6524 bgp_get_default(), bgp
);
6526 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6527 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6529 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6532 * label has previously been automatically
6533 * assigned by labelpool: release it
6535 * NB if tovpn_label == MPLS_LABEL_NONE it
6536 * means the automatic assignment is in flight
6537 * and therefore the labelpool callback must
6538 * detect that the auto label is not needed.
6541 bgp_lp_release(LP_TYPE_VRF
,
6542 &bgp
->vpn_policy
[afi
],
6543 bgp
->vpn_policy
[afi
].tovpn_label
);
6545 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6546 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6549 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6551 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6552 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6553 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6554 vpn_leak_label_callback
);
6557 /* post-change: re-export vpn routes */
6558 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6559 bgp_get_default(), bgp
);
6564 ALIAS (af_label_vpn_export
,
6565 af_no_label_vpn_export_cmd
,
6566 "no label vpn export",
6568 "label value for VRF\n"
6569 "Between current address-family and vpn\n"
6570 "For routes leaked from current address-family to vpn\n")
6572 DEFPY (af_nexthop_vpn_export
,
6573 af_nexthop_vpn_export_cmd
,
6574 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6576 "Specify next hop to use for VRF advertised prefixes\n"
6577 "Between current address-family and vpn\n"
6578 "For routes leaked from current address-family to vpn\n"
6582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6588 if (argv_find(argv
, argc
, "no", &idx
))
6592 if (!sockunion2hostprefix(nexthop_str
, &p
))
6593 return CMD_WARNING_CONFIG_FAILED
;
6596 afi
= vpn_policy_getafi(vty
, bgp
, false);
6598 return CMD_WARNING_CONFIG_FAILED
;
6601 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6603 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6604 bgp_get_default(), bgp
);
6607 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6608 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6609 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6611 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6612 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6615 /* post-change: re-export vpn routes */
6616 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6617 bgp_get_default(), bgp
);
6622 ALIAS (af_nexthop_vpn_export
,
6623 af_no_nexthop_vpn_export_cmd
,
6624 "no nexthop vpn export",
6626 "Specify next hop to use for VRF advertised prefixes\n"
6627 "Between current address-family and vpn\n"
6628 "For routes leaked from current address-family to vpn\n")
6630 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6632 if (!strcmp(dstr
, "import")) {
6633 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6634 } else if (!strcmp(dstr
, "export")) {
6635 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6636 } else if (!strcmp(dstr
, "both")) {
6637 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6638 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6640 vty_out(vty
, "%% direction parse error\n");
6641 return CMD_WARNING_CONFIG_FAILED
;
6646 DEFPY (af_rt_vpn_imexport
,
6647 af_rt_vpn_imexport_cmd
,
6648 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6650 "Specify route target list\n"
6651 "Specify route target list\n"
6652 "Between current address-family and vpn\n"
6653 "For routes leaked from vpn to current address-family: match any\n"
6654 "For routes leaked from current address-family to vpn: set\n"
6655 "both import: match any and export: set\n"
6656 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6658 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6660 struct ecommunity
*ecom
= NULL
;
6661 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6662 vpn_policy_direction_t dir
;
6667 if (argv_find(argv
, argc
, "no", &idx
))
6670 afi
= vpn_policy_getafi(vty
, bgp
, false);
6672 return CMD_WARNING_CONFIG_FAILED
;
6674 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6675 if (ret
!= CMD_SUCCESS
)
6679 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6680 vty_out(vty
, "%% Missing RTLIST\n");
6681 return CMD_WARNING_CONFIG_FAILED
;
6683 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6684 if (ret
!= CMD_SUCCESS
) {
6689 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6693 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6696 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6698 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6699 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6700 ecommunity_dup(ecom
);
6702 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6704 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6705 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6708 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6712 ecommunity_free(&ecom
);
6717 ALIAS (af_rt_vpn_imexport
,
6718 af_no_rt_vpn_imexport_cmd
,
6719 "no <rt|route-target> vpn <import|export|both>$direction_str",
6721 "Specify route target list\n"
6722 "Specify route target list\n"
6723 "Between current address-family and vpn\n"
6724 "For routes leaked from vpn to current address-family\n"
6725 "For routes leaked from current address-family to vpn\n"
6726 "both import and export\n")
6728 DEFPY (af_route_map_vpn_imexport
,
6729 af_route_map_vpn_imexport_cmd
,
6730 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6731 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6733 "Specify route map\n"
6734 "Between current address-family and vpn\n"
6735 "For routes leaked from vpn to current address-family\n"
6736 "For routes leaked from current address-family to vpn\n"
6737 "name of route-map\n")
6739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6741 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6742 vpn_policy_direction_t dir
;
6747 if (argv_find(argv
, argc
, "no", &idx
))
6750 afi
= vpn_policy_getafi(vty
, bgp
, false);
6752 return CMD_WARNING_CONFIG_FAILED
;
6754 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6755 if (ret
!= CMD_SUCCESS
)
6758 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6762 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6765 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6766 XFREE(MTYPE_ROUTE_MAP_NAME
,
6767 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6768 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6769 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6770 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6771 route_map_lookup_warn_noexist(vty
, rmap_str
);
6772 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6775 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6776 XFREE(MTYPE_ROUTE_MAP_NAME
,
6777 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6778 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6779 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6782 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6788 ALIAS (af_route_map_vpn_imexport
,
6789 af_no_route_map_vpn_imexport_cmd
,
6790 "no route-map vpn <import|export>$direction_str",
6792 "Specify route map\n"
6793 "Between current address-family and vpn\n"
6794 "For routes leaked from vpn to current address-family\n"
6795 "For routes leaked from current address-family to vpn\n")
6797 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6798 "[no] import vrf route-map RMAP$rmap_str",
6800 "Import routes from another VRF\n"
6801 "Vrf routes being filtered\n"
6802 "Specify route map\n"
6803 "name of route-map\n")
6805 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6806 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6810 struct bgp
*bgp_default
;
6812 if (argv_find(argv
, argc
, "no", &idx
))
6815 afi
= vpn_policy_getafi(vty
, bgp
, true);
6817 return CMD_WARNING_CONFIG_FAILED
;
6819 bgp_default
= bgp_get_default();
6824 /* Auto-create assuming the same AS */
6825 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6826 BGP_INSTANCE_TYPE_DEFAULT
);
6830 "VRF default is not configured as a bgp instance\n");
6835 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6838 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6839 XFREE(MTYPE_ROUTE_MAP_NAME
,
6840 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6841 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6842 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6843 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6844 route_map_lookup_warn_noexist(vty
, rmap_str
);
6845 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6848 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6849 XFREE(MTYPE_ROUTE_MAP_NAME
,
6850 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6851 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6852 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6855 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6860 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6861 "no import vrf route-map",
6863 "Import routes from another VRF\n"
6864 "Vrf routes being filtered\n"
6865 "Specify route map\n")
6867 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6868 "[no] import vrf VIEWVRFNAME$import_name",
6870 "Import routes from another VRF\n"
6871 "VRF to import from\n"
6872 "The name of the VRF\n")
6874 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6875 struct listnode
*node
;
6876 struct bgp
*vrf_bgp
, *bgp_default
;
6879 bool remove
= false;
6882 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6886 if (import_name
== NULL
) {
6887 vty_out(vty
, "%% Missing import name\n");
6891 if (argv_find(argv
, argc
, "no", &idx
))
6894 afi
= vpn_policy_getafi(vty
, bgp
, true);
6896 return CMD_WARNING_CONFIG_FAILED
;
6898 safi
= bgp_node_safi(vty
);
6900 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6901 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6902 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6903 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6904 remove
? "unimport" : "import", import_name
);
6908 bgp_default
= bgp_get_default();
6910 /* Auto-create assuming the same AS */
6911 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6912 BGP_INSTANCE_TYPE_DEFAULT
);
6916 "VRF default is not configured as a bgp instance\n");
6921 vrf_bgp
= bgp_lookup_by_name(import_name
);
6923 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6924 vrf_bgp
= bgp_default
;
6926 /* Auto-create assuming the same AS */
6927 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6931 "VRF %s is not configured as a bgp instance\n",
6938 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6940 /* Already importing from "import_vrf"? */
6941 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6943 if (strcmp(vname
, import_name
) == 0)
6947 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6953 /* This command is valid only in a bgp vrf instance or the default instance */
6954 DEFPY (bgp_imexport_vpn
,
6955 bgp_imexport_vpn_cmd
,
6956 "[no] <import|export>$direction_str vpn",
6958 "Import routes to this address-family\n"
6959 "Export routes from this address-family\n"
6960 "to/from default instance VPN RIB\n")
6962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6969 vpn_policy_direction_t dir
;
6971 if (argv_find(argv
, argc
, "no", &idx
))
6974 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6975 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6977 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6978 return CMD_WARNING_CONFIG_FAILED
;
6981 afi
= bgp_node_afi(vty
);
6982 safi
= bgp_node_safi(vty
);
6983 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6984 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6985 return CMD_WARNING_CONFIG_FAILED
;
6988 if (!strcmp(direction_str
, "import")) {
6989 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6990 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6991 } else if (!strcmp(direction_str
, "export")) {
6992 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6993 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6995 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6996 return CMD_WARNING_CONFIG_FAILED
;
6999 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7002 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7003 if (!previous_state
) {
7004 /* trigger export current vrf */
7005 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7008 if (previous_state
) {
7009 /* trigger un-export current vrf */
7010 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7012 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7018 DEFPY (af_routetarget_import
,
7019 af_routetarget_import_cmd
,
7020 "[no] <rt|route-target> redirect import RTLIST...",
7022 "Specify route target list\n"
7023 "Specify route target list\n"
7024 "Flow-spec redirect type route target\n"
7025 "Import routes to this address-family\n"
7026 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7028 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7030 struct ecommunity
*ecom
= NULL
;
7035 if (argv_find(argv
, argc
, "no", &idx
))
7038 afi
= vpn_policy_getafi(vty
, bgp
, false);
7040 return CMD_WARNING_CONFIG_FAILED
;
7043 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7044 vty_out(vty
, "%% Missing RTLIST\n");
7045 return CMD_WARNING_CONFIG_FAILED
;
7047 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7048 if (ret
!= CMD_SUCCESS
)
7053 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7054 ecommunity_free(&bgp
->vpn_policy
[afi
]
7055 .import_redirect_rtlist
);
7056 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7057 ecommunity_dup(ecom
);
7059 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7060 ecommunity_free(&bgp
->vpn_policy
[afi
]
7061 .import_redirect_rtlist
);
7062 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7066 ecommunity_free(&ecom
);
7071 DEFUN_NOSH (address_family_ipv4_safi
,
7072 address_family_ipv4_safi_cmd
,
7073 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7074 "Enter Address Family command mode\n"
7076 BGP_SAFI_WITH_LABEL_HELP_STR
)
7080 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7081 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7082 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7083 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7084 && safi
!= SAFI_EVPN
) {
7086 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7087 return CMD_WARNING_CONFIG_FAILED
;
7089 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7091 vty
->node
= BGP_IPV4_NODE
;
7096 DEFUN_NOSH (address_family_ipv6_safi
,
7097 address_family_ipv6_safi_cmd
,
7098 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7099 "Enter Address Family command mode\n"
7101 BGP_SAFI_WITH_LABEL_HELP_STR
)
7104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7105 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7106 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7107 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7108 && safi
!= SAFI_EVPN
) {
7110 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7111 return CMD_WARNING_CONFIG_FAILED
;
7113 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7115 vty
->node
= BGP_IPV6_NODE
;
7120 #ifdef KEEP_OLD_VPN_COMMANDS
7121 DEFUN_NOSH (address_family_vpnv4
,
7122 address_family_vpnv4_cmd
,
7123 "address-family vpnv4 [unicast]",
7124 "Enter Address Family command mode\n"
7126 "Address Family modifier\n")
7128 vty
->node
= BGP_VPNV4_NODE
;
7132 DEFUN_NOSH (address_family_vpnv6
,
7133 address_family_vpnv6_cmd
,
7134 "address-family vpnv6 [unicast]",
7135 "Enter Address Family command mode\n"
7137 "Address Family modifier\n")
7139 vty
->node
= BGP_VPNV6_NODE
;
7144 DEFUN_NOSH (address_family_evpn
,
7145 address_family_evpn_cmd
,
7146 "address-family l2vpn evpn",
7147 "Enter Address Family command mode\n"
7149 "Address Family modifier\n")
7151 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7152 vty
->node
= BGP_EVPN_NODE
;
7156 DEFUN_NOSH (exit_address_family
,
7157 exit_address_family_cmd
,
7158 "exit-address-family",
7159 "Exit from Address Family configuration mode\n")
7161 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7162 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7163 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7164 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7165 || vty
->node
== BGP_EVPN_NODE
7166 || vty
->node
== BGP_FLOWSPECV4_NODE
7167 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7168 vty
->node
= BGP_NODE
;
7172 /* Recalculate bestpath and re-advertise a prefix */
7173 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7174 const char *ip_str
, afi_t afi
, safi_t safi
,
7175 struct prefix_rd
*prd
)
7178 struct prefix match
;
7179 struct bgp_node
*rn
;
7180 struct bgp_node
*rm
;
7182 struct bgp_table
*table
;
7183 struct bgp_table
*rib
;
7185 /* BGP structure lookup. */
7187 bgp
= bgp_lookup_by_name(view_name
);
7189 vty_out(vty
, "%% Can't find BGP instance %s\n",
7194 bgp
= bgp_get_default();
7196 vty_out(vty
, "%% No BGP process is configured\n");
7201 /* Check IP address argument. */
7202 ret
= str2prefix(ip_str
, &match
);
7204 vty_out(vty
, "%% address is malformed\n");
7208 match
.family
= afi2family(afi
);
7209 rib
= bgp
->rib
[afi
][safi
];
7211 if (safi
== SAFI_MPLS_VPN
) {
7212 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7213 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7216 if ((table
= rn
->info
) != NULL
) {
7217 if ((rm
= bgp_node_match(table
, &match
))
7220 == match
.prefixlen
) {
7222 BGP_NODE_USER_CLEAR
);
7223 bgp_process(bgp
, rm
, afi
, safi
);
7225 bgp_unlock_node(rm
);
7230 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7231 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7232 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7233 bgp_process(bgp
, rn
, afi
, safi
);
7235 bgp_unlock_node(rn
);
7242 /* one clear bgp command to rule them all */
7243 DEFUN (clear_ip_bgp_all
,
7244 clear_ip_bgp_all_cmd
,
7245 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]",
7249 BGP_INSTANCE_HELP_STR
7251 BGP_SAFI_WITH_LABEL_HELP_STR
7253 "BGP neighbor address to clear\n"
7254 "BGP IPv6 neighbor to clear\n"
7255 "BGP neighbor on interface to clear\n"
7256 "Clear peers with the AS number\n"
7257 "Clear all external peers\n"
7258 "Clear all members of peer-group\n"
7259 "BGP peer-group name\n"
7264 "Push out prefix-list ORF and do inbound soft reconfig\n"
7269 afi_t afi
= AFI_IP6
;
7270 safi_t safi
= SAFI_UNICAST
;
7271 enum clear_sort clr_sort
= clear_peer
;
7272 enum bgp_clear_type clr_type
;
7273 char *clr_arg
= NULL
;
7277 /* clear [ip] bgp */
7278 if (argv_find(argv
, argc
, "ip", &idx
))
7281 /* [<vrf> VIEWVRFNAME] */
7282 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7283 vrf
= argv
[idx
+ 1]->arg
;
7285 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7287 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7288 /* [<view> VIEWVRFNAME] */
7289 vrf
= argv
[idx
+ 1]->arg
;
7292 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7293 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7294 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7296 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7297 if (argv_find(argv
, argc
, "*", &idx
)) {
7298 clr_sort
= clear_all
;
7299 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7300 clr_sort
= clear_peer
;
7301 clr_arg
= argv
[idx
]->arg
;
7302 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7303 clr_sort
= clear_peer
;
7304 clr_arg
= argv
[idx
]->arg
;
7305 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7306 clr_sort
= clear_group
;
7308 clr_arg
= argv
[idx
]->arg
;
7309 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7310 clr_sort
= clear_peer
;
7311 clr_arg
= argv
[idx
]->arg
;
7312 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7313 clr_sort
= clear_as
;
7314 clr_arg
= argv
[idx
]->arg
;
7315 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7316 clr_sort
= clear_external
;
7319 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7320 if (argv_find(argv
, argc
, "soft", &idx
)) {
7321 if (argv_find(argv
, argc
, "in", &idx
)
7322 || argv_find(argv
, argc
, "out", &idx
))
7323 clr_type
= strmatch(argv
[idx
]->text
, "in")
7325 : BGP_CLEAR_SOFT_OUT
;
7327 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7328 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7329 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7330 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7331 : BGP_CLEAR_SOFT_IN
;
7332 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7333 clr_type
= BGP_CLEAR_SOFT_OUT
;
7335 clr_type
= BGP_CLEAR_SOFT_NONE
;
7337 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7340 DEFUN (clear_ip_bgp_prefix
,
7341 clear_ip_bgp_prefix_cmd
,
7342 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7346 BGP_INSTANCE_HELP_STR
7347 "Clear bestpath and re-advertise\n"
7351 char *prefix
= NULL
;
7355 /* [<view|vrf> VIEWVRFNAME] */
7356 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7357 vrf
= argv
[idx
+ 1]->arg
;
7359 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7361 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7362 /* [<view> VIEWVRFNAME] */
7363 vrf
= argv
[idx
+ 1]->arg
;
7367 prefix
= argv
[argc
- 1]->arg
;
7369 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7372 DEFUN (clear_bgp_ipv6_safi_prefix
,
7373 clear_bgp_ipv6_safi_prefix_cmd
,
7374 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7380 "Clear bestpath and re-advertise\n"
7384 int idx_ipv6_prefix
= 0;
7385 safi_t safi
= SAFI_UNICAST
;
7386 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7387 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7389 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7390 return bgp_clear_prefix(
7391 vty
, NULL
, prefix
, AFI_IP6
,
7395 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7396 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7397 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7401 BGP_INSTANCE_HELP_STR
7404 "Clear bestpath and re-advertise\n"
7408 int idx_vrfview
= 0;
7409 int idx_ipv6_prefix
= 0;
7410 safi_t safi
= SAFI_UNICAST
;
7411 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7412 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7413 char *vrfview
= NULL
;
7415 /* [<view|vrf> VIEWVRFNAME] */
7416 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7417 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7418 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7420 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7421 /* [<view> VIEWVRFNAME] */
7422 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7424 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7426 return bgp_clear_prefix(
7427 vty
, vrfview
, prefix
,
7428 AFI_IP6
, safi
, NULL
);
7431 DEFUN (show_bgp_views
,
7433 "show [ip] bgp views",
7437 "Show the defined BGP views\n")
7439 struct list
*inst
= bm
->bgp
;
7440 struct listnode
*node
;
7443 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7444 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7448 vty_out(vty
, "Defined BGP views:\n");
7449 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7451 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7453 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7460 DEFUN (show_bgp_vrfs
,
7462 "show [ip] bgp vrfs [json]",
7469 char buf
[ETHER_ADDR_STRLEN
];
7470 struct list
*inst
= bm
->bgp
;
7471 struct listnode
*node
;
7473 bool uj
= use_json(argc
, argv
);
7474 json_object
*json
= NULL
;
7475 json_object
*json_vrfs
= NULL
;
7478 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7479 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7484 json
= json_object_new_object();
7485 json_vrfs
= json_object_new_object();
7488 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7489 const char *name
, *type
;
7491 struct listnode
*node2
, *nnode2
;
7492 int peers_cfg
, peers_estb
;
7493 json_object
*json_vrf
= NULL
;
7496 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7500 if (!uj
&& count
== 1)
7502 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7503 "Type", "Id", "routerId", "#PeersVfg",
7504 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7506 peers_cfg
= peers_estb
= 0;
7508 json_vrf
= json_object_new_object();
7511 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7512 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7515 if (peer
->status
== Established
)
7519 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7520 name
= VRF_DEFAULT_NAME
;
7529 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7531 : (int64_t)bgp
->vrf_id
;
7532 json_object_string_add(json_vrf
, "type", type
);
7533 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7534 json_object_string_add(json_vrf
, "routerId",
7535 inet_ntoa(bgp
->router_id
));
7536 json_object_int_add(json_vrf
, "numConfiguredPeers",
7538 json_object_int_add(json_vrf
, "numEstablishedPeers",
7541 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7542 json_object_string_add(
7544 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7545 json_object_object_add(json_vrfs
, name
, json_vrf
);
7548 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7550 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7552 inet_ntoa(bgp
->router_id
), peers_cfg
,
7553 peers_estb
, name
, bgp
->l3vni
,
7554 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7558 json_object_object_add(json
, "vrfs", json_vrfs
);
7560 json_object_int_add(json
, "totalVrfs", count
);
7562 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7563 json
, JSON_C_TO_STRING_PRETTY
));
7564 json_object_free(json
);
7568 "\nTotal number of VRFs (including default): %d\n",
7576 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7578 struct vty
*vty
= (struct vty
*)args
;
7579 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7581 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7585 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7587 vty_out(vty
, "self nexthop database:\n");
7588 bgp_nexthop_show_address_hash(vty
, bgp
);
7590 vty_out(vty
, "Tunnel-ip database:\n");
7591 hash_iterate(bgp
->tip_hash
,
7592 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7596 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7597 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7598 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7599 "martian next-hops\n"
7600 "martian next-hop database\n")
7602 struct bgp
*bgp
= NULL
;
7606 /* [<vrf> VIEWVRFNAME] */
7607 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7608 name
= argv
[idx
+ 1]->arg
;
7609 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7611 } else if (argv_find(argv
, argc
, "view", &idx
))
7612 /* [<view> VIEWVRFNAME] */
7613 name
= argv
[idx
+ 1]->arg
;
7615 bgp
= bgp_lookup_by_name(name
);
7617 bgp
= bgp_get_default();
7620 vty_out(vty
, "%% No BGP process is configured\n");
7623 bgp_show_martian_nexthops(vty
, bgp
);
7628 DEFUN (show_bgp_memory
,
7629 show_bgp_memory_cmd
,
7630 "show [ip] bgp memory",
7634 "Global BGP memory statistics\n")
7636 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7637 unsigned long count
;
7639 /* RIB related usage stats */
7640 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7641 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7642 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7643 count
* sizeof(struct bgp_node
)));
7645 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7646 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7647 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7648 count
* sizeof(struct bgp_path_info
)));
7649 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7650 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7653 memstrbuf
, sizeof(memstrbuf
),
7654 count
* sizeof(struct bgp_path_info_extra
)));
7656 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7657 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7658 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7659 count
* sizeof(struct bgp_static
)));
7661 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7662 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7663 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7664 count
* sizeof(struct bpacket
)));
7667 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7668 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7669 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7670 count
* sizeof(struct bgp_adj_in
)));
7671 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7672 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7673 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7674 count
* sizeof(struct bgp_adj_out
)));
7676 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7677 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7679 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7680 count
* sizeof(struct bgp_nexthop_cache
)));
7682 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7683 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7685 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7686 count
* sizeof(struct bgp_damp_info
)));
7689 count
= attr_count();
7690 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7691 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7692 count
* sizeof(struct attr
)));
7694 if ((count
= attr_unknown_count()))
7695 vty_out(vty
, "%ld unknown attributes\n", count
);
7697 /* AS_PATH attributes */
7698 count
= aspath_count();
7699 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7700 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7701 count
* sizeof(struct aspath
)));
7703 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7704 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7705 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7706 count
* sizeof(struct assegment
)));
7708 /* Other attributes */
7709 if ((count
= community_count()))
7710 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7711 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7712 count
* sizeof(struct community
)));
7713 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7714 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7715 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7716 count
* sizeof(struct ecommunity
)));
7717 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7719 "%ld BGP large-community entries, using %s of memory\n",
7720 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7721 count
* sizeof(struct lcommunity
)));
7723 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7724 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7725 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7726 count
* sizeof(struct cluster_list
)));
7728 /* Peer related usage */
7729 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7730 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7731 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7732 count
* sizeof(struct peer
)));
7734 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7735 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7736 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7737 count
* sizeof(struct peer_group
)));
7740 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7741 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7742 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7743 count
* sizeof(struct hash
)));
7744 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7745 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7746 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7747 count
* sizeof(struct hash_backet
)));
7748 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7749 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7750 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7751 count
* sizeof(regex_t
)));
7755 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7757 json_object
*bestpath
= json_object_new_object();
7759 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7760 json_object_string_add(bestpath
, "asPath", "ignore");
7762 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7763 json_object_string_add(bestpath
, "asPath", "confed");
7765 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7766 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7767 json_object_string_add(bestpath
, "multiPathRelax",
7770 json_object_string_add(bestpath
, "multiPathRelax",
7773 json_object_string_add(bestpath
, "multiPathRelax", "false");
7775 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7776 json_object_string_add(bestpath
, "compareRouterId", "true");
7777 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7778 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7779 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7780 json_object_string_add(bestpath
, "med", "confed");
7781 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7782 json_object_string_add(bestpath
, "med",
7783 "missing-as-worst");
7785 json_object_string_add(bestpath
, "med", "true");
7788 json_object_object_add(json
, "bestPath", bestpath
);
7791 /* Show BGP peer's summary information. */
7792 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7793 bool use_json
, json_object
*json
)
7796 struct listnode
*node
, *nnode
;
7797 unsigned int count
= 0, dn_count
= 0;
7798 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7799 char neighbor_buf
[VTY_BUFSIZ
];
7800 int neighbor_col_default_width
= 16;
7802 int max_neighbor_width
= 0;
7804 json_object
*json_peer
= NULL
;
7805 json_object
*json_peers
= NULL
;
7806 struct peer_af
*paf
;
7808 /* labeled-unicast routes are installed in the unicast table so in order
7810 * display the correct PfxRcd value we must look at SAFI_UNICAST
7812 if (safi
== SAFI_LABELED_UNICAST
)
7813 pfx_rcd_safi
= SAFI_UNICAST
;
7815 pfx_rcd_safi
= safi
;
7819 json
= json_object_new_object();
7821 json_peers
= json_object_new_object();
7823 /* Loop over all neighbors that will be displayed to determine
7825 * characters are needed for the Neighbor column
7827 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7828 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7831 if (peer
->afc
[afi
][safi
]) {
7832 memset(dn_flag
, '\0', sizeof(dn_flag
));
7833 if (peer_dynamic_neighbor(peer
))
7837 && bgp_flag_check(bgp
,
7838 BGP_FLAG_SHOW_HOSTNAME
))
7839 sprintf(neighbor_buf
, "%s%s(%s) ",
7840 dn_flag
, peer
->hostname
,
7843 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7846 len
= strlen(neighbor_buf
);
7848 if (len
> max_neighbor_width
)
7849 max_neighbor_width
= len
;
7853 /* Originally we displayed the Neighbor column as 16
7854 * characters wide so make that the default
7856 if (max_neighbor_width
< neighbor_col_default_width
)
7857 max_neighbor_width
= neighbor_col_default_width
;
7860 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7861 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7864 if (!peer
->afc
[afi
][safi
])
7869 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7872 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7874 : (int64_t)bgp
->vrf_id
;
7876 /* Usage summary and header */
7878 json_object_string_add(
7880 inet_ntoa(bgp
->router_id
));
7881 json_object_int_add(json
, "as", bgp
->as
);
7882 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7883 json_object_string_add(
7886 == BGP_INSTANCE_TYPE_DEFAULT
)
7891 "BGP router identifier %s, local AS number %u vrf-id %d",
7892 inet_ntoa(bgp
->router_id
), bgp
->as
,
7893 bgp
->vrf_id
== VRF_UNKNOWN
7895 : (int)bgp
->vrf_id
);
7899 if (bgp_update_delay_configured(bgp
)) {
7901 json_object_int_add(
7902 json
, "updateDelayLimit",
7903 bgp
->v_update_delay
);
7905 if (bgp
->v_update_delay
7906 != bgp
->v_establish_wait
)
7907 json_object_int_add(
7909 "updateDelayEstablishWait",
7910 bgp
->v_establish_wait
);
7912 if (bgp_update_delay_active(bgp
)) {
7913 json_object_string_add(
7915 "updateDelayFirstNeighbor",
7916 bgp
->update_delay_begin_time
);
7917 json_object_boolean_true_add(
7919 "updateDelayInProgress");
7921 if (bgp
->update_delay_over
) {
7922 json_object_string_add(
7924 "updateDelayFirstNeighbor",
7925 bgp
->update_delay_begin_time
);
7926 json_object_string_add(
7928 "updateDelayBestpathResumed",
7929 bgp
->update_delay_end_time
);
7930 json_object_string_add(
7932 "updateDelayZebraUpdateResume",
7933 bgp
->update_delay_zebra_resume_time
);
7934 json_object_string_add(
7936 "updateDelayPeerUpdateResume",
7937 bgp
->update_delay_peers_resume_time
);
7942 "Read-only mode update-delay limit: %d seconds\n",
7943 bgp
->v_update_delay
);
7944 if (bgp
->v_update_delay
7945 != bgp
->v_establish_wait
)
7947 " Establish wait: %d seconds\n",
7948 bgp
->v_establish_wait
);
7950 if (bgp_update_delay_active(bgp
)) {
7952 " First neighbor established: %s\n",
7953 bgp
->update_delay_begin_time
);
7955 " Delay in progress\n");
7957 if (bgp
->update_delay_over
) {
7959 " First neighbor established: %s\n",
7960 bgp
->update_delay_begin_time
);
7962 " Best-paths resumed: %s\n",
7963 bgp
->update_delay_end_time
);
7965 " zebra update resumed: %s\n",
7966 bgp
->update_delay_zebra_resume_time
);
7968 " peers update resumed: %s\n",
7969 bgp
->update_delay_peers_resume_time
);
7976 if (bgp_maxmed_onstartup_configured(bgp
)
7977 && bgp
->maxmed_active
)
7978 json_object_boolean_true_add(
7979 json
, "maxMedOnStartup");
7980 if (bgp
->v_maxmed_admin
)
7981 json_object_boolean_true_add(
7982 json
, "maxMedAdministrative");
7984 json_object_int_add(
7985 json
, "tableVersion",
7986 bgp_table_version(bgp
->rib
[afi
][safi
]));
7988 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7989 json_object_int_add(json
, "ribCount", ents
);
7990 json_object_int_add(
7992 ents
* sizeof(struct bgp_node
));
7994 ents
= listcount(bgp
->peer
);
7995 json_object_int_add(json
, "peerCount", ents
);
7996 json_object_int_add(json
, "peerMemory",
7997 ents
* sizeof(struct peer
));
7999 if ((ents
= listcount(bgp
->group
))) {
8000 json_object_int_add(
8001 json
, "peerGroupCount", ents
);
8002 json_object_int_add(
8003 json
, "peerGroupMemory",
8004 ents
* sizeof(struct
8008 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8009 BGP_CONFIG_DAMPENING
))
8010 json_object_boolean_true_add(
8011 json
, "dampeningEnabled");
8013 if (bgp_maxmed_onstartup_configured(bgp
)
8014 && bgp
->maxmed_active
)
8016 "Max-med on-startup active\n");
8017 if (bgp
->v_maxmed_admin
)
8019 "Max-med administrative active\n");
8021 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8022 bgp_table_version(bgp
->rib
[afi
][safi
]));
8024 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8026 "RIB entries %ld, using %s of memory\n",
8028 mtype_memstr(memstrbuf
,
8030 ents
* sizeof(struct
8033 /* Peer related usage */
8034 ents
= listcount(bgp
->peer
);
8035 vty_out(vty
, "Peers %ld, using %s of memory\n",
8038 memstrbuf
, sizeof(memstrbuf
),
8039 ents
* sizeof(struct peer
)));
8041 if ((ents
= listcount(bgp
->group
)))
8043 "Peer groups %ld, using %s of memory\n",
8048 ents
* sizeof(struct
8051 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8052 BGP_CONFIG_DAMPENING
))
8053 vty_out(vty
, "Dampening enabled.\n");
8056 /* Subtract 8 here because 'Neighbor' is
8058 vty_out(vty
, "Neighbor");
8059 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8062 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8069 json_peer
= json_object_new_object();
8071 if (peer_dynamic_neighbor(peer
)) {
8073 json_object_boolean_true_add(json_peer
,
8078 json_object_string_add(json_peer
, "hostname",
8081 if (peer
->domainname
)
8082 json_object_string_add(json_peer
, "domainname",
8085 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8086 json_object_int_add(json_peer
, "version", 4);
8087 json_object_int_add(json_peer
, "msgRcvd",
8088 PEER_TOTAL_RX(peer
));
8089 json_object_int_add(json_peer
, "msgSent",
8090 PEER_TOTAL_TX(peer
));
8092 json_object_int_add(json_peer
, "tableVersion",
8093 peer
->version
[afi
][safi
]);
8094 json_object_int_add(json_peer
, "outq",
8096 json_object_int_add(json_peer
, "inq", 0);
8097 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8098 use_json
, json_peer
);
8101 * Adding "pfxRcd" field to match with the corresponding
8102 * CLI. "prefixReceivedCount" will be deprecated in
8105 json_object_int_add(json_peer
, "prefixReceivedCount",
8106 peer
->pcount
[afi
][pfx_rcd_safi
]);
8107 json_object_int_add(json_peer
, "pfxRcd",
8108 peer
->pcount
[afi
][pfx_rcd_safi
]);
8110 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8111 if (paf
&& PAF_SUBGRP(paf
))
8112 json_object_int_add(json_peer
,
8114 (PAF_SUBGRP(paf
))->scount
);
8116 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8117 json_object_string_add(json_peer
, "state",
8119 else if (peer
->afc_recv
[afi
][safi
])
8120 json_object_string_add(
8122 lookup_msg(bgp_status_msg
, peer
->status
,
8124 else if (CHECK_FLAG(peer
->sflags
,
8125 PEER_STATUS_PREFIX_OVERFLOW
))
8126 json_object_string_add(json_peer
, "state",
8129 json_object_string_add(
8131 lookup_msg(bgp_status_msg
, peer
->status
,
8135 json_object_string_add(json_peer
, "idType",
8137 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8138 json_object_string_add(json_peer
, "idType",
8140 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8141 json_object_string_add(json_peer
, "idType",
8144 json_object_object_add(json_peers
, peer
->host
,
8147 memset(dn_flag
, '\0', sizeof(dn_flag
));
8148 if (peer_dynamic_neighbor(peer
)) {
8154 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8155 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8156 peer
->hostname
, peer
->host
);
8158 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8160 /* pad the neighbor column with spaces */
8161 if (len
< max_neighbor_width
)
8162 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8165 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8166 peer
->as
, PEER_TOTAL_RX(peer
),
8167 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8168 0, peer
->obuf
->count
,
8169 peer_uptime(peer
->uptime
, timebuf
,
8170 BGP_UPTIME_LEN
, 0, NULL
));
8172 if (peer
->status
== Established
)
8173 if (peer
->afc_recv
[afi
][safi
])
8174 vty_out(vty
, " %12ld",
8178 vty_out(vty
, " NoNeg");
8180 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8181 vty_out(vty
, " Idle (Admin)");
8182 else if (CHECK_FLAG(
8184 PEER_STATUS_PREFIX_OVERFLOW
))
8185 vty_out(vty
, " Idle (PfxCt)");
8187 vty_out(vty
, " %12s",
8188 lookup_msg(bgp_status_msg
,
8189 peer
->status
, NULL
));
8196 json_object_object_add(json
, "peers", json_peers
);
8198 json_object_int_add(json
, "totalPeers", count
);
8199 json_object_int_add(json
, "dynamicPeers", dn_count
);
8201 bgp_show_bestpath_json(bgp
, json
);
8203 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8204 json
, JSON_C_TO_STRING_PRETTY
));
8205 json_object_free(json
);
8208 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8210 vty_out(vty
, "No %s neighbor is configured\n",
8211 afi_safi_print(afi
, safi
));
8215 vty_out(vty
, "* - dynamic neighbor\n");
8216 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8217 dn_count
, bgp
->dynamic_neighbors_limit
);
8224 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8225 int safi
, bool use_json
,
8229 int afi_wildcard
= (afi
== AFI_MAX
);
8230 int safi_wildcard
= (safi
== SAFI_MAX
);
8231 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8232 bool nbr_output
= false;
8234 if (use_json
&& is_wildcard
)
8235 vty_out(vty
, "{\n");
8237 afi
= 1; /* AFI_IP */
8238 while (afi
< AFI_MAX
) {
8240 safi
= 1; /* SAFI_UNICAST */
8241 while (safi
< SAFI_MAX
) {
8242 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8246 * So limit output to those afi/safi
8248 * actualy have something interesting in
8252 json
= json_object_new_object();
8255 vty_out(vty
, ",\n");
8259 vty_out(vty
, "\"%s\":",
8263 vty_out(vty
, "\n%s Summary:\n",
8268 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8280 if (use_json
&& is_wildcard
)
8281 vty_out(vty
, "}\n");
8282 else if (!nbr_output
) {
8284 vty_out(vty
, "{}\n");
8286 vty_out(vty
, "%% No BGP neighbors found\n");
8290 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8291 safi_t safi
, bool use_json
)
8293 struct listnode
*node
, *nnode
;
8295 json_object
*json
= NULL
;
8297 bool nbr_output
= false;
8300 vty_out(vty
, "{\n");
8302 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8305 json
= json_object_new_object();
8308 vty_out(vty
, ",\n");
8312 vty_out(vty
, "\"%s\":",
8313 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8317 vty_out(vty
, "\nInstance %s:\n",
8318 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8322 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8326 vty_out(vty
, "}\n");
8327 else if (!nbr_output
)
8328 vty_out(vty
, "%% BGP instance not found\n");
8331 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8332 safi_t safi
, bool use_json
)
8337 if (strmatch(name
, "all")) {
8338 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8342 bgp
= bgp_lookup_by_name(name
);
8346 vty_out(vty
, "{}\n");
8349 "%% BGP instance not found\n");
8353 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8359 bgp
= bgp_get_default();
8362 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8365 vty_out(vty
, "{}\n");
8367 vty_out(vty
, "%% BGP instance not found\n");
8374 /* `show [ip] bgp summary' commands. */
8375 DEFUN (show_ip_bgp_summary
,
8376 show_ip_bgp_summary_cmd
,
8377 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8381 BGP_INSTANCE_HELP_STR
8383 BGP_SAFI_WITH_LABEL_HELP_STR
8384 "Summary of BGP neighbor status\n"
8388 afi_t afi
= AFI_MAX
;
8389 safi_t safi
= SAFI_MAX
;
8394 if (argv_find(argv
, argc
, "ip", &idx
))
8396 /* [<vrf> VIEWVRFNAME] */
8397 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8398 vrf
= argv
[idx
+ 1]->arg
;
8399 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8401 } else if (argv_find(argv
, argc
, "view", &idx
))
8402 /* [<view> VIEWVRFNAME] */
8403 vrf
= argv
[idx
+ 1]->arg
;
8404 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8405 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8406 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8409 bool uj
= use_json(argc
, argv
);
8411 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8414 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8416 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8417 return "IPv4 Unicast";
8418 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8419 return "IPv4 Multicast";
8420 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8421 return "IPv4 Labeled Unicast";
8422 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8424 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8425 return "IPv4 Encap";
8426 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8427 return "IPv4 Flowspec";
8428 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8429 return "IPv6 Unicast";
8430 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8431 return "IPv6 Multicast";
8432 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8433 return "IPv6 Labeled Unicast";
8434 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8436 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8437 return "IPv6 Encap";
8438 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8439 return "IPv6 Flowspec";
8440 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8441 return "L2VPN EVPN";
8447 * Please note that we have intentionally camelCased
8448 * the return strings here. So if you want
8449 * to use this function, please ensure you
8450 * are doing this within json output
8452 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8454 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8455 return "ipv4Unicast";
8456 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8457 return "ipv4Multicast";
8458 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8459 return "ipv4LabeledUnicast";
8460 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8462 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8464 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8465 return "ipv4Flowspec";
8466 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8467 return "ipv6Unicast";
8468 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8469 return "ipv6Multicast";
8470 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8471 return "ipv6LabeledUnicast";
8472 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8474 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8476 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8477 return "ipv6Flowspec";
8478 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8484 /* Show BGP peer's information. */
8485 enum show_type
{ show_all
, show_peer
};
8487 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8488 afi_t afi
, safi_t safi
,
8489 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8490 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8491 bool use_json
, json_object
*json_pref
)
8494 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8495 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8497 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8498 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8499 json_object_string_add(json_pref
, "sendMode",
8500 "advertisedAndReceived");
8501 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8502 json_object_string_add(json_pref
, "sendMode",
8504 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8505 json_object_string_add(json_pref
, "sendMode",
8508 vty_out(vty
, " Send-mode: ");
8509 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8510 vty_out(vty
, "advertised");
8511 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8512 vty_out(vty
, "%sreceived",
8513 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8522 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8523 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8525 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8526 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8527 json_object_string_add(json_pref
, "recvMode",
8528 "advertisedAndReceived");
8529 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8530 json_object_string_add(json_pref
, "recvMode",
8532 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8533 json_object_string_add(json_pref
, "recvMode",
8536 vty_out(vty
, " Receive-mode: ");
8537 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8538 vty_out(vty
, "advertised");
8539 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8540 vty_out(vty
, "%sreceived",
8541 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8550 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8551 safi_t safi
, bool use_json
,
8552 json_object
*json_neigh
)
8554 struct bgp_filter
*filter
;
8555 struct peer_af
*paf
;
8556 char orf_pfx_name
[BUFSIZ
];
8558 json_object
*json_af
= NULL
;
8559 json_object
*json_prefA
= NULL
;
8560 json_object
*json_prefB
= NULL
;
8561 json_object
*json_addr
= NULL
;
8564 json_addr
= json_object_new_object();
8565 json_af
= json_object_new_object();
8566 filter
= &p
->filter
[afi
][safi
];
8568 if (peer_group_active(p
))
8569 json_object_string_add(json_addr
, "peerGroupMember",
8572 paf
= peer_af_find(p
, afi
, safi
);
8573 if (paf
&& PAF_SUBGRP(paf
)) {
8574 json_object_int_add(json_addr
, "updateGroupId",
8575 PAF_UPDGRP(paf
)->id
);
8576 json_object_int_add(json_addr
, "subGroupId",
8577 PAF_SUBGRP(paf
)->id
);
8578 json_object_int_add(json_addr
, "packetQueueLength",
8579 bpacket_queue_virtual_length(paf
));
8582 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8583 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8584 PEER_CAP_ORF_PREFIX_SM_RCV
)
8585 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8586 PEER_CAP_ORF_PREFIX_RM_ADV
)
8587 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8588 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8589 json_object_int_add(json_af
, "orfType",
8591 json_prefA
= json_object_new_object();
8592 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8593 PEER_CAP_ORF_PREFIX_SM_ADV
,
8594 PEER_CAP_ORF_PREFIX_RM_ADV
,
8595 PEER_CAP_ORF_PREFIX_SM_RCV
,
8596 PEER_CAP_ORF_PREFIX_RM_RCV
,
8597 use_json
, json_prefA
);
8598 json_object_object_add(json_af
, "orfPrefixList",
8602 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8603 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8604 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8605 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8606 PEER_CAP_ORF_PREFIX_RM_ADV
)
8607 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8608 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8609 json_object_int_add(json_af
, "orfOldType",
8610 ORF_TYPE_PREFIX_OLD
);
8611 json_prefB
= json_object_new_object();
8612 bgp_show_peer_afi_orf_cap(
8613 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8614 PEER_CAP_ORF_PREFIX_RM_ADV
,
8615 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8616 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8618 json_object_object_add(json_af
, "orfOldPrefixList",
8622 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8623 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8624 PEER_CAP_ORF_PREFIX_SM_RCV
)
8625 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8626 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8627 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8628 PEER_CAP_ORF_PREFIX_RM_ADV
)
8629 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8630 PEER_CAP_ORF_PREFIX_RM_RCV
)
8631 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8632 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8633 json_object_object_add(json_addr
, "afDependentCap",
8636 json_object_free(json_af
);
8638 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8639 orf_pfx_count
= prefix_bgp_show_prefix_list(
8640 NULL
, afi
, orf_pfx_name
, use_json
);
8642 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8643 PEER_STATUS_ORF_PREFIX_SEND
)
8645 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8646 PEER_STATUS_ORF_PREFIX_SEND
))
8647 json_object_boolean_true_add(json_neigh
,
8650 json_object_int_add(json_addr
, "orfRecvCounter",
8653 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8654 PEER_STATUS_ORF_WAIT_REFRESH
))
8655 json_object_string_add(
8656 json_addr
, "orfFirstUpdate",
8657 "deferredUntilORFOrRouteRefreshRecvd");
8659 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8660 PEER_FLAG_REFLECTOR_CLIENT
))
8661 json_object_boolean_true_add(json_addr
,
8662 "routeReflectorClient");
8663 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8664 PEER_FLAG_RSERVER_CLIENT
))
8665 json_object_boolean_true_add(json_addr
,
8666 "routeServerClient");
8667 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8668 json_object_boolean_true_add(json_addr
,
8669 "inboundSoftConfigPermit");
8671 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8672 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8673 json_object_boolean_true_add(
8675 "privateAsNumsAllReplacedInUpdatesToNbr");
8676 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8677 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8678 json_object_boolean_true_add(
8680 "privateAsNumsReplacedInUpdatesToNbr");
8681 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8682 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8683 json_object_boolean_true_add(
8685 "privateAsNumsAllRemovedInUpdatesToNbr");
8686 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8687 PEER_FLAG_REMOVE_PRIVATE_AS
))
8688 json_object_boolean_true_add(
8690 "privateAsNumsRemovedInUpdatesToNbr");
8692 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8693 json_object_boolean_true_add(
8695 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8698 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8699 json_object_string_add(json_addr
,
8700 "overrideASNsInOutboundUpdates",
8701 "ifAspathEqualRemoteAs");
8703 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8704 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8705 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8706 json_object_boolean_true_add(json_addr
,
8707 "routerAlwaysNextHop");
8708 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8709 PEER_FLAG_AS_PATH_UNCHANGED
))
8710 json_object_boolean_true_add(
8711 json_addr
, "unchangedAsPathPropogatedToNbr");
8712 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8713 PEER_FLAG_NEXTHOP_UNCHANGED
))
8714 json_object_boolean_true_add(
8715 json_addr
, "unchangedNextHopPropogatedToNbr");
8716 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8717 json_object_boolean_true_add(
8718 json_addr
, "unchangedMedPropogatedToNbr");
8719 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8720 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8721 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8722 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8723 PEER_FLAG_SEND_COMMUNITY
)
8724 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8725 PEER_FLAG_SEND_EXT_COMMUNITY
))
8726 json_object_string_add(json_addr
,
8727 "commAttriSentToNbr",
8728 "extendedAndStandard");
8729 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8730 PEER_FLAG_SEND_EXT_COMMUNITY
))
8731 json_object_string_add(json_addr
,
8732 "commAttriSentToNbr",
8735 json_object_string_add(json_addr
,
8736 "commAttriSentToNbr",
8739 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8740 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8741 if (p
->default_rmap
[afi
][safi
].name
)
8742 json_object_string_add(
8743 json_addr
, "defaultRouteMap",
8744 p
->default_rmap
[afi
][safi
].name
);
8746 if (paf
&& PAF_SUBGRP(paf
)
8747 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8748 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8749 json_object_boolean_true_add(json_addr
,
8752 json_object_boolean_true_add(json_addr
,
8756 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8757 if (is_evpn_enabled())
8758 json_object_boolean_true_add(
8759 json_addr
, "advertiseAllVnis");
8762 if (filter
->plist
[FILTER_IN
].name
8763 || filter
->dlist
[FILTER_IN
].name
8764 || filter
->aslist
[FILTER_IN
].name
8765 || filter
->map
[RMAP_IN
].name
)
8766 json_object_boolean_true_add(json_addr
,
8767 "inboundPathPolicyConfig");
8768 if (filter
->plist
[FILTER_OUT
].name
8769 || filter
->dlist
[FILTER_OUT
].name
8770 || filter
->aslist
[FILTER_OUT
].name
8771 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8772 json_object_boolean_true_add(
8773 json_addr
, "outboundPathPolicyConfig");
8776 if (filter
->plist
[FILTER_IN
].name
)
8777 json_object_string_add(json_addr
,
8778 "incomingUpdatePrefixFilterList",
8779 filter
->plist
[FILTER_IN
].name
);
8780 if (filter
->plist
[FILTER_OUT
].name
)
8781 json_object_string_add(json_addr
,
8782 "outgoingUpdatePrefixFilterList",
8783 filter
->plist
[FILTER_OUT
].name
);
8785 /* distribute-list */
8786 if (filter
->dlist
[FILTER_IN
].name
)
8787 json_object_string_add(
8788 json_addr
, "incomingUpdateNetworkFilterList",
8789 filter
->dlist
[FILTER_IN
].name
);
8790 if (filter
->dlist
[FILTER_OUT
].name
)
8791 json_object_string_add(
8792 json_addr
, "outgoingUpdateNetworkFilterList",
8793 filter
->dlist
[FILTER_OUT
].name
);
8796 if (filter
->aslist
[FILTER_IN
].name
)
8797 json_object_string_add(json_addr
,
8798 "incomingUpdateAsPathFilterList",
8799 filter
->aslist
[FILTER_IN
].name
);
8800 if (filter
->aslist
[FILTER_OUT
].name
)
8801 json_object_string_add(json_addr
,
8802 "outgoingUpdateAsPathFilterList",
8803 filter
->aslist
[FILTER_OUT
].name
);
8806 if (filter
->map
[RMAP_IN
].name
)
8807 json_object_string_add(
8808 json_addr
, "routeMapForIncomingAdvertisements",
8809 filter
->map
[RMAP_IN
].name
);
8810 if (filter
->map
[RMAP_OUT
].name
)
8811 json_object_string_add(
8812 json_addr
, "routeMapForOutgoingAdvertisements",
8813 filter
->map
[RMAP_OUT
].name
);
8815 /* unsuppress-map */
8816 if (filter
->usmap
.name
)
8817 json_object_string_add(json_addr
,
8818 "selectiveUnsuppressRouteMap",
8819 filter
->usmap
.name
);
8821 /* Receive prefix count */
8822 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8823 p
->pcount
[afi
][safi
]);
8824 if (paf
&& PAF_SUBGRP(paf
))
8825 json_object_int_add(json_addr
, "sentPrefixCounter",
8826 (PAF_SUBGRP(paf
))->scount
);
8828 /* Maximum prefix */
8829 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8830 json_object_int_add(json_addr
, "prefixAllowedMax",
8831 p
->pmax
[afi
][safi
]);
8832 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8833 PEER_FLAG_MAX_PREFIX_WARNING
))
8834 json_object_boolean_true_add(
8835 json_addr
, "prefixAllowedMaxWarning");
8836 json_object_int_add(json_addr
,
8837 "prefixAllowedWarningThresh",
8838 p
->pmax_threshold
[afi
][safi
]);
8839 if (p
->pmax_restart
[afi
][safi
])
8840 json_object_int_add(
8842 "prefixAllowedRestartIntervalMsecs",
8843 p
->pmax_restart
[afi
][safi
] * 60000);
8845 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8849 filter
= &p
->filter
[afi
][safi
];
8851 vty_out(vty
, " For address family: %s\n",
8852 afi_safi_print(afi
, safi
));
8854 if (peer_group_active(p
))
8855 vty_out(vty
, " %s peer-group member\n",
8858 paf
= peer_af_find(p
, afi
, safi
);
8859 if (paf
&& PAF_SUBGRP(paf
)) {
8860 vty_out(vty
, " Update group %" PRIu64
8861 ", subgroup %" PRIu64
"\n",
8862 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8863 vty_out(vty
, " Packet Queue length %d\n",
8864 bpacket_queue_virtual_length(paf
));
8866 vty_out(vty
, " Not part of any update group\n");
8868 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8869 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8870 PEER_CAP_ORF_PREFIX_SM_RCV
)
8871 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8872 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8873 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8874 PEER_CAP_ORF_PREFIX_RM_ADV
)
8875 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8876 PEER_CAP_ORF_PREFIX_RM_RCV
)
8877 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8878 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8879 vty_out(vty
, " AF-dependant capabilities:\n");
8881 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8882 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8883 PEER_CAP_ORF_PREFIX_SM_RCV
)
8884 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8885 PEER_CAP_ORF_PREFIX_RM_ADV
)
8886 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8887 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8889 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8891 bgp_show_peer_afi_orf_cap(
8892 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8893 PEER_CAP_ORF_PREFIX_RM_ADV
,
8894 PEER_CAP_ORF_PREFIX_SM_RCV
,
8895 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8897 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8898 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8899 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8900 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8901 PEER_CAP_ORF_PREFIX_RM_ADV
)
8902 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8903 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8905 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8906 ORF_TYPE_PREFIX_OLD
);
8907 bgp_show_peer_afi_orf_cap(
8908 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8909 PEER_CAP_ORF_PREFIX_RM_ADV
,
8910 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8911 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8914 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8915 orf_pfx_count
= prefix_bgp_show_prefix_list(
8916 NULL
, afi
, orf_pfx_name
, use_json
);
8918 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8919 PEER_STATUS_ORF_PREFIX_SEND
)
8921 vty_out(vty
, " Outbound Route Filter (ORF):");
8922 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8923 PEER_STATUS_ORF_PREFIX_SEND
))
8924 vty_out(vty
, " sent;");
8926 vty_out(vty
, " received (%d entries)",
8930 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8931 PEER_STATUS_ORF_WAIT_REFRESH
))
8933 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8935 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8936 PEER_FLAG_REFLECTOR_CLIENT
))
8937 vty_out(vty
, " Route-Reflector Client\n");
8938 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8939 PEER_FLAG_RSERVER_CLIENT
))
8940 vty_out(vty
, " Route-Server Client\n");
8941 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8943 " Inbound soft reconfiguration allowed\n");
8945 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8946 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8948 " Private AS numbers (all) replaced in updates to this neighbor\n");
8949 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8950 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8952 " Private AS numbers replaced in updates to this neighbor\n");
8953 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8954 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8956 " Private AS numbers (all) removed in updates to this neighbor\n");
8957 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8958 PEER_FLAG_REMOVE_PRIVATE_AS
))
8960 " Private AS numbers removed in updates to this neighbor\n");
8962 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8963 vty_out(vty
, " %s\n",
8964 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8965 ->human_description
);
8967 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8969 " Override ASNs in outbound updates if aspath equals remote-as\n");
8971 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8972 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8973 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8974 vty_out(vty
, " NEXT_HOP is always this router\n");
8975 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8976 PEER_FLAG_AS_PATH_UNCHANGED
))
8978 " AS_PATH is propagated unchanged to this neighbor\n");
8979 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8980 PEER_FLAG_NEXTHOP_UNCHANGED
))
8982 " NEXT_HOP is propagated unchanged to this neighbor\n");
8983 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8985 " MED is propagated unchanged to this neighbor\n");
8986 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8987 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8988 PEER_FLAG_SEND_EXT_COMMUNITY
)
8989 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8990 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8992 " Community attribute sent to this neighbor");
8993 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8994 PEER_FLAG_SEND_COMMUNITY
)
8995 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8996 PEER_FLAG_SEND_EXT_COMMUNITY
)
8997 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8998 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8999 vty_out(vty
, "(all)\n");
9000 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9001 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9002 vty_out(vty
, "(large)\n");
9003 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9004 PEER_FLAG_SEND_EXT_COMMUNITY
))
9005 vty_out(vty
, "(extended)\n");
9007 vty_out(vty
, "(standard)\n");
9009 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9010 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9011 vty_out(vty
, " Default information originate,");
9013 if (p
->default_rmap
[afi
][safi
].name
)
9014 vty_out(vty
, " default route-map %s%s,",
9015 p
->default_rmap
[afi
][safi
].map
? "*"
9017 p
->default_rmap
[afi
][safi
].name
);
9018 if (paf
&& PAF_SUBGRP(paf
)
9019 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9020 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9021 vty_out(vty
, " default sent\n");
9023 vty_out(vty
, " default not sent\n");
9026 /* advertise-vni-all */
9027 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9028 if (is_evpn_enabled())
9029 vty_out(vty
, " advertise-all-vni\n");
9032 if (filter
->plist
[FILTER_IN
].name
9033 || filter
->dlist
[FILTER_IN
].name
9034 || filter
->aslist
[FILTER_IN
].name
9035 || filter
->map
[RMAP_IN
].name
)
9036 vty_out(vty
, " Inbound path policy configured\n");
9037 if (filter
->plist
[FILTER_OUT
].name
9038 || filter
->dlist
[FILTER_OUT
].name
9039 || filter
->aslist
[FILTER_OUT
].name
9040 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9041 vty_out(vty
, " Outbound path policy configured\n");
9044 if (filter
->plist
[FILTER_IN
].name
)
9046 " Incoming update prefix filter list is %s%s\n",
9047 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9048 filter
->plist
[FILTER_IN
].name
);
9049 if (filter
->plist
[FILTER_OUT
].name
)
9051 " Outgoing update prefix filter list is %s%s\n",
9052 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9053 filter
->plist
[FILTER_OUT
].name
);
9055 /* distribute-list */
9056 if (filter
->dlist
[FILTER_IN
].name
)
9058 " Incoming update network filter list is %s%s\n",
9059 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9060 filter
->dlist
[FILTER_IN
].name
);
9061 if (filter
->dlist
[FILTER_OUT
].name
)
9063 " Outgoing update network filter list is %s%s\n",
9064 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9065 filter
->dlist
[FILTER_OUT
].name
);
9068 if (filter
->aslist
[FILTER_IN
].name
)
9070 " Incoming update AS path filter list is %s%s\n",
9071 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9072 filter
->aslist
[FILTER_IN
].name
);
9073 if (filter
->aslist
[FILTER_OUT
].name
)
9075 " Outgoing update AS path filter list is %s%s\n",
9076 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9077 filter
->aslist
[FILTER_OUT
].name
);
9080 if (filter
->map
[RMAP_IN
].name
)
9082 " Route map for incoming advertisements is %s%s\n",
9083 filter
->map
[RMAP_IN
].map
? "*" : "",
9084 filter
->map
[RMAP_IN
].name
);
9085 if (filter
->map
[RMAP_OUT
].name
)
9087 " Route map for outgoing advertisements is %s%s\n",
9088 filter
->map
[RMAP_OUT
].map
? "*" : "",
9089 filter
->map
[RMAP_OUT
].name
);
9091 /* unsuppress-map */
9092 if (filter
->usmap
.name
)
9094 " Route map for selective unsuppress is %s%s\n",
9095 filter
->usmap
.map
? "*" : "",
9096 filter
->usmap
.name
);
9098 /* Receive prefix count */
9099 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9101 /* Maximum prefix */
9102 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9103 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9105 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9106 PEER_FLAG_MAX_PREFIX_WARNING
)
9109 vty_out(vty
, " Threshold for warning message %d%%",
9110 p
->pmax_threshold
[afi
][safi
]);
9111 if (p
->pmax_restart
[afi
][safi
])
9112 vty_out(vty
, ", restart interval %d min",
9113 p
->pmax_restart
[afi
][safi
]);
9121 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9125 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9126 char timebuf
[BGP_UPTIME_LEN
];
9128 const char *subcode_str
;
9129 const char *code_str
;
9134 json_object
*json_neigh
= NULL
;
9140 json_neigh
= json_object_new_object();
9142 memset(dn_flag
, '\0', sizeof(dn_flag
));
9143 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9147 if (p
->conf_if
) /* Configured interface name. */
9148 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9149 BGP_PEER_SU_UNSPEC(p
)
9151 : sockunion2str(&p
->su
, buf
,
9153 else /* Configured IP address. */
9154 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9159 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9160 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9162 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9163 json_object_string_add(
9164 json_neigh
, "bgpNeighborAddr",
9165 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9167 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9169 if (p
->change_local_as
)
9170 json_object_int_add(json_neigh
, "localAs",
9171 p
->change_local_as
);
9173 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9175 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9176 json_object_boolean_true_add(json_neigh
,
9177 "localAsNoPrepend");
9179 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9180 json_object_boolean_true_add(json_neigh
,
9181 "localAsReplaceAs");
9183 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9184 || (p
->as_type
== AS_INTERNAL
))
9185 vty_out(vty
, "remote AS %u, ", p
->as
);
9187 vty_out(vty
, "remote AS Unspecified, ");
9188 vty_out(vty
, "local AS %u%s%s, ",
9189 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9190 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9193 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9197 /* peer type internal, external, confed-internal or confed-external */
9198 if (p
->as
== p
->local_as
) {
9200 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9201 json_object_boolean_true_add(
9202 json_neigh
, "nbrConfedInternalLink");
9204 json_object_boolean_true_add(json_neigh
,
9207 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9208 vty_out(vty
, "confed-internal link\n");
9210 vty_out(vty
, "internal link\n");
9214 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9215 json_object_boolean_true_add(
9216 json_neigh
, "nbrConfedExternalLink");
9218 json_object_boolean_true_add(json_neigh
,
9221 if (bgp_confederation_peers_check(bgp
, p
->as
))
9222 vty_out(vty
, "confed-external link\n");
9224 vty_out(vty
, "external link\n");
9231 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9233 vty_out(vty
, " Description: %s\n", p
->desc
);
9239 json_object_string_add(json_neigh
, "hostname",
9243 json_object_string_add(json_neigh
, "domainname",
9246 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9247 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9250 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9257 json_object_string_add(json_neigh
, "peerGroup",
9261 struct prefix prefix
, *range
= NULL
;
9263 sockunion2hostprefix(&(p
->su
), &prefix
);
9264 range
= peer_group_lookup_dynamic_neighbor_range(
9268 prefix2str(range
, buf1
, sizeof(buf1
));
9269 json_object_string_add(
9271 "peerSubnetRangeGroup", buf1
);
9276 " Member of peer-group %s for session parameters\n",
9280 struct prefix prefix
, *range
= NULL
;
9282 sockunion2hostprefix(&(p
->su
), &prefix
);
9283 range
= peer_group_lookup_dynamic_neighbor_range(
9287 prefix2str(range
, buf1
, sizeof(buf1
));
9289 " Belongs to the subnet range group: %s\n",
9297 /* Administrative shutdown. */
9298 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9299 json_object_boolean_true_add(json_neigh
,
9303 json_object_int_add(json_neigh
, "bgpVersion", 4);
9304 json_object_string_add(
9305 json_neigh
, "remoteRouterId",
9306 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9307 json_object_string_add(
9308 json_neigh
, "localRouterId",
9309 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9313 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9314 && bgp_confederation_peers_check(bgp
, p
->as
))
9315 json_object_boolean_true_add(json_neigh
,
9319 json_object_string_add(
9320 json_neigh
, "bgpState",
9321 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9323 if (p
->status
== Established
) {
9326 uptime
= bgp_clock();
9327 uptime
-= p
->uptime
;
9328 epoch_tbuf
= time(NULL
) - uptime
;
9330 #if CONFDATE > 20200101
9332 "bgpTimerUp should be deprecated and can be removed now");
9335 * bgpTimerUp was miliseconds that was accurate
9336 * up to 1 day, then the value returned
9337 * became garbage. So in order to provide
9338 * some level of backwards compatability,
9339 * we still provde the data, but now
9340 * we are returning the correct value
9341 * and also adding a new bgpTimerUpMsec
9342 * which will allow us to deprecate
9345 json_object_int_add(json_neigh
, "bgpTimerUp",
9347 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9349 json_object_string_add(json_neigh
, "bgpTimerUpString",
9350 peer_uptime(p
->uptime
, timebuf
,
9353 json_object_int_add(json_neigh
,
9354 "bgpTimerUpEstablishedEpoch",
9358 else if (p
->status
== Active
) {
9359 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9360 json_object_string_add(json_neigh
, "bgpStateIs",
9362 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9363 json_object_string_add(json_neigh
, "bgpStateIs",
9371 uptime
= bgp_clock();
9372 uptime
-= p
->readtime
;
9373 tm
= gmtime(&uptime
);
9374 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9375 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9376 + (tm
->tm_hour
* 3600000));
9378 uptime
= bgp_clock();
9379 uptime
-= p
->last_write
;
9380 tm
= gmtime(&uptime
);
9381 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9382 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9383 + (tm
->tm_hour
* 3600000));
9385 uptime
= bgp_clock();
9386 uptime
-= p
->update_time
;
9387 tm
= gmtime(&uptime
);
9388 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9389 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9390 + (tm
->tm_hour
* 3600000));
9392 /* Configured timer values. */
9393 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9394 p
->v_holdtime
* 1000);
9395 json_object_int_add(json_neigh
,
9396 "bgpTimerKeepAliveIntervalMsecs",
9397 p
->v_keepalive
* 1000);
9398 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9399 json_object_int_add(json_neigh
,
9400 "bgpTimerConfiguredHoldTimeMsecs",
9401 p
->holdtime
* 1000);
9402 json_object_int_add(
9404 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9405 p
->keepalive
* 1000);
9406 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9407 || (bgp
->default_keepalive
9408 != BGP_DEFAULT_KEEPALIVE
)) {
9409 json_object_int_add(json_neigh
,
9410 "bgpTimerConfiguredHoldTimeMsecs",
9411 bgp
->default_holdtime
);
9412 json_object_int_add(
9414 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9415 bgp
->default_keepalive
);
9418 /* Administrative shutdown. */
9419 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9420 vty_out(vty
, " Administratively shut down\n");
9423 vty_out(vty
, " BGP version 4");
9424 vty_out(vty
, ", remote router ID %s",
9425 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9426 vty_out(vty
, ", local router ID %s\n",
9427 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9431 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9432 && bgp_confederation_peers_check(bgp
, p
->as
))
9434 " Neighbor under common administration\n");
9437 vty_out(vty
, " BGP state = %s",
9438 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9440 if (p
->status
== Established
)
9441 vty_out(vty
, ", up for %8s",
9442 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9445 else if (p
->status
== Active
) {
9446 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9447 vty_out(vty
, " (passive)");
9448 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9449 vty_out(vty
, " (NSF passive)");
9454 vty_out(vty
, " Last read %s",
9455 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9457 vty_out(vty
, ", Last write %s\n",
9458 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9461 /* Configured timer values. */
9463 " Hold time is %d, keepalive interval is %d seconds\n",
9464 p
->v_holdtime
, p
->v_keepalive
);
9465 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9466 vty_out(vty
, " Configured hold time is %d",
9468 vty_out(vty
, ", keepalive interval is %d seconds\n",
9470 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9471 || (bgp
->default_keepalive
9472 != BGP_DEFAULT_KEEPALIVE
)) {
9473 vty_out(vty
, " Configured hold time is %d",
9474 bgp
->default_holdtime
);
9475 vty_out(vty
, ", keepalive interval is %d seconds\n",
9476 bgp
->default_keepalive
);
9480 if (p
->status
== Established
) {
9481 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9482 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9483 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9484 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9485 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9486 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9487 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9488 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9489 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9490 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9491 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9492 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9493 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9494 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9495 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9496 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9497 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9498 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9499 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9500 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9502 json_object
*json_cap
= NULL
;
9504 json_cap
= json_object_new_object();
9507 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9508 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9509 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9510 && CHECK_FLAG(p
->cap
,
9512 json_object_string_add(
9513 json_cap
, "4byteAs",
9514 "advertisedAndReceived");
9515 else if (CHECK_FLAG(p
->cap
,
9517 json_object_string_add(
9518 json_cap
, "4byteAs",
9520 else if (CHECK_FLAG(p
->cap
,
9522 json_object_string_add(
9523 json_cap
, "4byteAs",
9528 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9529 || CHECK_FLAG(p
->cap
,
9530 PEER_CAP_ADDPATH_ADV
)) {
9531 json_object
*json_add
= NULL
;
9532 const char *print_store
;
9534 json_add
= json_object_new_object();
9536 FOREACH_AFI_SAFI (afi
, safi
) {
9537 json_object
*json_sub
= NULL
;
9539 json_object_new_object();
9540 print_store
= afi_safi_print(
9546 PEER_CAP_ADDPATH_AF_TX_ADV
)
9550 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9555 PEER_CAP_ADDPATH_AF_TX_ADV
)
9560 PEER_CAP_ADDPATH_AF_TX_RCV
))
9561 json_object_boolean_true_add(
9563 "txAdvertisedAndReceived");
9569 PEER_CAP_ADDPATH_AF_TX_ADV
))
9570 json_object_boolean_true_add(
9578 PEER_CAP_ADDPATH_AF_TX_RCV
))
9579 json_object_boolean_true_add(
9587 PEER_CAP_ADDPATH_AF_RX_ADV
)
9591 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9596 PEER_CAP_ADDPATH_AF_RX_ADV
)
9601 PEER_CAP_ADDPATH_AF_RX_RCV
))
9602 json_object_boolean_true_add(
9604 "rxAdvertisedAndReceived");
9610 PEER_CAP_ADDPATH_AF_RX_ADV
))
9611 json_object_boolean_true_add(
9619 PEER_CAP_ADDPATH_AF_RX_RCV
))
9620 json_object_boolean_true_add(
9628 PEER_CAP_ADDPATH_AF_TX_ADV
)
9632 PEER_CAP_ADDPATH_AF_TX_RCV
)
9636 PEER_CAP_ADDPATH_AF_RX_ADV
)
9640 PEER_CAP_ADDPATH_AF_RX_RCV
))
9641 json_object_object_add(
9650 json_object_object_add(
9651 json_cap
, "addPath", json_add
);
9655 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9656 || CHECK_FLAG(p
->cap
,
9657 PEER_CAP_DYNAMIC_ADV
)) {
9658 if (CHECK_FLAG(p
->cap
,
9659 PEER_CAP_DYNAMIC_ADV
)
9660 && CHECK_FLAG(p
->cap
,
9661 PEER_CAP_DYNAMIC_RCV
))
9662 json_object_string_add(
9663 json_cap
, "dynamic",
9664 "advertisedAndReceived");
9665 else if (CHECK_FLAG(
9667 PEER_CAP_DYNAMIC_ADV
))
9668 json_object_string_add(
9669 json_cap
, "dynamic",
9671 else if (CHECK_FLAG(
9673 PEER_CAP_DYNAMIC_RCV
))
9674 json_object_string_add(
9675 json_cap
, "dynamic",
9679 /* Extended nexthop */
9680 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9681 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9682 json_object
*json_nxt
= NULL
;
9683 const char *print_store
;
9686 if (CHECK_FLAG(p
->cap
,
9688 && CHECK_FLAG(p
->cap
,
9690 json_object_string_add(
9693 "advertisedAndReceived");
9694 else if (CHECK_FLAG(p
->cap
,
9696 json_object_string_add(
9700 else if (CHECK_FLAG(p
->cap
,
9702 json_object_string_add(
9707 if (CHECK_FLAG(p
->cap
,
9708 PEER_CAP_ENHE_RCV
)) {
9710 json_object_new_object();
9712 for (safi
= SAFI_UNICAST
;
9713 safi
< SAFI_MAX
; safi
++) {
9718 PEER_CAP_ENHE_AF_RCV
)) {
9719 print_store
= afi_safi_print(
9722 json_object_string_add(
9728 json_object_object_add(
9730 "extendedNexthopFamililesByPeer",
9736 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9737 || CHECK_FLAG(p
->cap
,
9738 PEER_CAP_REFRESH_NEW_RCV
)
9739 || CHECK_FLAG(p
->cap
,
9740 PEER_CAP_REFRESH_OLD_RCV
)) {
9741 if (CHECK_FLAG(p
->cap
,
9742 PEER_CAP_REFRESH_ADV
)
9745 PEER_CAP_REFRESH_NEW_RCV
)
9748 PEER_CAP_REFRESH_OLD_RCV
))) {
9751 PEER_CAP_REFRESH_OLD_RCV
)
9754 PEER_CAP_REFRESH_NEW_RCV
))
9755 json_object_string_add(
9758 "advertisedAndReceivedOldNew");
9762 PEER_CAP_REFRESH_OLD_RCV
))
9763 json_object_string_add(
9766 "advertisedAndReceivedOld");
9768 json_object_string_add(
9771 "advertisedAndReceivedNew");
9776 PEER_CAP_REFRESH_ADV
))
9777 json_object_string_add(
9784 PEER_CAP_REFRESH_NEW_RCV
)
9787 PEER_CAP_REFRESH_OLD_RCV
))
9788 json_object_string_add(
9794 /* Multiprotocol Extensions */
9795 json_object
*json_multi
= NULL
;
9796 json_multi
= json_object_new_object();
9798 FOREACH_AFI_SAFI (afi
, safi
) {
9799 if (p
->afc_adv
[afi
][safi
]
9800 || p
->afc_recv
[afi
][safi
]) {
9801 json_object
*json_exten
= NULL
;
9803 json_object_new_object();
9805 if (p
->afc_adv
[afi
][safi
]
9806 && p
->afc_recv
[afi
][safi
])
9807 json_object_boolean_true_add(
9809 "advertisedAndReceived");
9810 else if (p
->afc_adv
[afi
][safi
])
9811 json_object_boolean_true_add(
9814 else if (p
->afc_recv
[afi
][safi
])
9815 json_object_boolean_true_add(
9819 json_object_object_add(
9826 json_object_object_add(
9827 json_cap
, "multiprotocolExtensions",
9830 /* Hostname capabilities */
9831 json_object
*json_hname
= NULL
;
9833 json_hname
= json_object_new_object();
9835 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9836 json_object_string_add(
9837 json_hname
, "advHostName",
9838 bgp
->peer_self
->hostname
9842 json_object_string_add(
9843 json_hname
, "advDomainName",
9844 bgp
->peer_self
->domainname
9851 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9852 json_object_string_add(
9853 json_hname
, "rcvHostName",
9854 p
->hostname
? p
->hostname
9856 json_object_string_add(
9857 json_hname
, "rcvDomainName",
9858 p
->domainname
? p
->domainname
9862 json_object_object_add(json_cap
, "hostName",
9865 /* Gracefull Restart */
9866 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9867 || CHECK_FLAG(p
->cap
,
9868 PEER_CAP_RESTART_ADV
)) {
9869 if (CHECK_FLAG(p
->cap
,
9870 PEER_CAP_RESTART_ADV
)
9871 && CHECK_FLAG(p
->cap
,
9872 PEER_CAP_RESTART_RCV
))
9873 json_object_string_add(
9876 "advertisedAndReceived");
9877 else if (CHECK_FLAG(
9879 PEER_CAP_RESTART_ADV
))
9880 json_object_string_add(
9882 "gracefulRestartCapability",
9884 else if (CHECK_FLAG(
9886 PEER_CAP_RESTART_RCV
))
9887 json_object_string_add(
9889 "gracefulRestartCapability",
9892 if (CHECK_FLAG(p
->cap
,
9893 PEER_CAP_RESTART_RCV
)) {
9894 int restart_af_count
= 0;
9895 json_object
*json_restart
=
9898 json_object_new_object();
9900 json_object_int_add(
9902 "gracefulRestartRemoteTimerMsecs",
9903 p
->v_gr_restart
* 1000);
9905 FOREACH_AFI_SAFI (afi
, safi
) {
9910 PEER_CAP_RESTART_AF_RCV
)) {
9915 json_object_new_object();
9921 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9922 json_object_boolean_true_add(
9926 json_object_object_add(
9934 if (!restart_af_count
) {
9935 json_object_string_add(
9937 "addressFamiliesByPeer",
9942 json_object_object_add(
9944 "addressFamiliesByPeer",
9948 json_object_object_add(json_neigh
,
9949 "neighborCapabilities",
9952 vty_out(vty
, " Neighbor capabilities:\n");
9955 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9956 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9957 vty_out(vty
, " 4 Byte AS:");
9958 if (CHECK_FLAG(p
->cap
,
9960 vty_out(vty
, " advertised");
9961 if (CHECK_FLAG(p
->cap
,
9963 vty_out(vty
, " %sreceived",
9973 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9974 || CHECK_FLAG(p
->cap
,
9975 PEER_CAP_ADDPATH_ADV
)) {
9976 vty_out(vty
, " AddPath:\n");
9978 FOREACH_AFI_SAFI (afi
, safi
) {
9982 PEER_CAP_ADDPATH_AF_TX_ADV
)
9986 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9997 PEER_CAP_ADDPATH_AF_TX_ADV
))
10008 PEER_CAP_ADDPATH_AF_TX_RCV
))
10015 PEER_CAP_ADDPATH_AF_TX_ADV
)
10019 vty_out(vty
, "\n");
10025 PEER_CAP_ADDPATH_AF_RX_ADV
)
10029 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10040 PEER_CAP_ADDPATH_AF_RX_ADV
))
10051 PEER_CAP_ADDPATH_AF_RX_RCV
))
10058 PEER_CAP_ADDPATH_AF_RX_ADV
)
10062 vty_out(vty
, "\n");
10068 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10069 || CHECK_FLAG(p
->cap
,
10070 PEER_CAP_DYNAMIC_ADV
)) {
10071 vty_out(vty
, " Dynamic:");
10072 if (CHECK_FLAG(p
->cap
,
10073 PEER_CAP_DYNAMIC_ADV
))
10074 vty_out(vty
, " advertised");
10075 if (CHECK_FLAG(p
->cap
,
10076 PEER_CAP_DYNAMIC_RCV
))
10077 vty_out(vty
, " %sreceived",
10080 PEER_CAP_DYNAMIC_ADV
)
10083 vty_out(vty
, "\n");
10086 /* Extended nexthop */
10087 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10088 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10089 vty_out(vty
, " Extended nexthop:");
10090 if (CHECK_FLAG(p
->cap
,
10091 PEER_CAP_ENHE_ADV
))
10092 vty_out(vty
, " advertised");
10093 if (CHECK_FLAG(p
->cap
,
10094 PEER_CAP_ENHE_RCV
))
10095 vty_out(vty
, " %sreceived",
10101 vty_out(vty
, "\n");
10103 if (CHECK_FLAG(p
->cap
,
10104 PEER_CAP_ENHE_RCV
)) {
10106 " Address families by peer:\n ");
10107 for (safi
= SAFI_UNICAST
;
10108 safi
< SAFI_MAX
; safi
++)
10113 PEER_CAP_ENHE_AF_RCV
))
10122 /* Route Refresh */
10123 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10124 || CHECK_FLAG(p
->cap
,
10125 PEER_CAP_REFRESH_NEW_RCV
)
10126 || CHECK_FLAG(p
->cap
,
10127 PEER_CAP_REFRESH_OLD_RCV
)) {
10128 vty_out(vty
, " Route refresh:");
10129 if (CHECK_FLAG(p
->cap
,
10130 PEER_CAP_REFRESH_ADV
))
10131 vty_out(vty
, " advertised");
10132 if (CHECK_FLAG(p
->cap
,
10133 PEER_CAP_REFRESH_NEW_RCV
)
10136 PEER_CAP_REFRESH_OLD_RCV
))
10137 vty_out(vty
, " %sreceived(%s)",
10140 PEER_CAP_REFRESH_ADV
)
10145 PEER_CAP_REFRESH_OLD_RCV
)
10148 PEER_CAP_REFRESH_NEW_RCV
))
10152 PEER_CAP_REFRESH_OLD_RCV
)
10156 vty_out(vty
, "\n");
10159 /* Multiprotocol Extensions */
10160 FOREACH_AFI_SAFI (afi
, safi
)
10161 if (p
->afc_adv
[afi
][safi
]
10162 || p
->afc_recv
[afi
][safi
]) {
10164 " Address Family %s:",
10165 afi_safi_print(afi
,
10167 if (p
->afc_adv
[afi
][safi
])
10170 if (p
->afc_recv
[afi
][safi
])
10177 vty_out(vty
, "\n");
10180 /* Hostname capability */
10181 vty_out(vty
, " Hostname Capability:");
10183 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10185 " advertised (name: %s,domain name: %s)",
10186 bgp
->peer_self
->hostname
10190 bgp
->peer_self
->domainname
10195 vty_out(vty
, " not advertised");
10198 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10200 " received (name: %s,domain name: %s)",
10201 p
->hostname
? p
->hostname
10203 p
->domainname
? p
->domainname
10206 vty_out(vty
, " not received");
10209 vty_out(vty
, "\n");
10211 /* Gracefull Restart */
10212 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10213 || CHECK_FLAG(p
->cap
,
10214 PEER_CAP_RESTART_ADV
)) {
10216 " Graceful Restart Capabilty:");
10217 if (CHECK_FLAG(p
->cap
,
10218 PEER_CAP_RESTART_ADV
))
10219 vty_out(vty
, " advertised");
10220 if (CHECK_FLAG(p
->cap
,
10221 PEER_CAP_RESTART_RCV
))
10222 vty_out(vty
, " %sreceived",
10225 PEER_CAP_RESTART_ADV
)
10228 vty_out(vty
, "\n");
10230 if (CHECK_FLAG(p
->cap
,
10231 PEER_CAP_RESTART_RCV
)) {
10232 int restart_af_count
= 0;
10235 " Remote Restart timer is %d seconds\n",
10238 " Address families by peer:\n ");
10240 FOREACH_AFI_SAFI (afi
, safi
)
10245 PEER_CAP_RESTART_AF_RCV
)) {
10258 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10260 : "not preserved");
10261 restart_af_count
++;
10263 if (!restart_af_count
)
10264 vty_out(vty
, "none");
10265 vty_out(vty
, "\n");
10272 /* graceful restart information */
10273 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10274 || p
->t_gr_stale
) {
10275 json_object
*json_grace
= NULL
;
10276 json_object
*json_grace_send
= NULL
;
10277 json_object
*json_grace_recv
= NULL
;
10278 int eor_send_af_count
= 0;
10279 int eor_receive_af_count
= 0;
10282 json_grace
= json_object_new_object();
10283 json_grace_send
= json_object_new_object();
10284 json_grace_recv
= json_object_new_object();
10286 if (p
->status
== Established
) {
10287 FOREACH_AFI_SAFI (afi
, safi
) {
10288 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10289 PEER_STATUS_EOR_SEND
)) {
10290 json_object_boolean_true_add(
10292 afi_safi_print(afi
,
10294 eor_send_af_count
++;
10297 FOREACH_AFI_SAFI (afi
, safi
) {
10299 p
->af_sflags
[afi
][safi
],
10300 PEER_STATUS_EOR_RECEIVED
)) {
10301 json_object_boolean_true_add(
10303 afi_safi_print(afi
,
10305 eor_receive_af_count
++;
10310 json_object_object_add(json_grace
, "endOfRibSend",
10312 json_object_object_add(json_grace
, "endOfRibRecv",
10315 if (p
->t_gr_restart
)
10316 json_object_int_add(json_grace
,
10317 "gracefulRestartTimerMsecs",
10318 thread_timer_remain_second(
10323 json_object_int_add(
10325 "gracefulStalepathTimerMsecs",
10326 thread_timer_remain_second(
10330 json_object_object_add(
10331 json_neigh
, "gracefulRestartInfo", json_grace
);
10333 vty_out(vty
, " Graceful restart information:\n");
10334 if (p
->status
== Established
) {
10335 vty_out(vty
, " End-of-RIB send: ");
10336 FOREACH_AFI_SAFI (afi
, safi
) {
10337 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10338 PEER_STATUS_EOR_SEND
)) {
10339 vty_out(vty
, "%s%s",
10340 eor_send_af_count
? ", "
10342 afi_safi_print(afi
,
10344 eor_send_af_count
++;
10347 vty_out(vty
, "\n");
10348 vty_out(vty
, " End-of-RIB received: ");
10349 FOREACH_AFI_SAFI (afi
, safi
) {
10351 p
->af_sflags
[afi
][safi
],
10352 PEER_STATUS_EOR_RECEIVED
)) {
10353 vty_out(vty
, "%s%s",
10354 eor_receive_af_count
10357 afi_safi_print(afi
,
10359 eor_receive_af_count
++;
10362 vty_out(vty
, "\n");
10365 if (p
->t_gr_restart
)
10367 " The remaining time of restart timer is %ld\n",
10368 thread_timer_remain_second(
10373 " The remaining time of stalepath timer is %ld\n",
10374 thread_timer_remain_second(
10379 json_object
*json_stat
= NULL
;
10380 json_stat
= json_object_new_object();
10381 /* Packet counts. */
10382 json_object_int_add(json_stat
, "depthInq", 0);
10383 json_object_int_add(json_stat
, "depthOutq",
10384 (unsigned long)p
->obuf
->count
);
10385 json_object_int_add(json_stat
, "opensSent",
10386 atomic_load_explicit(&p
->open_out
,
10387 memory_order_relaxed
));
10388 json_object_int_add(json_stat
, "opensRecv",
10389 atomic_load_explicit(&p
->open_in
,
10390 memory_order_relaxed
));
10391 json_object_int_add(json_stat
, "notificationsSent",
10392 atomic_load_explicit(&p
->notify_out
,
10393 memory_order_relaxed
));
10394 json_object_int_add(json_stat
, "notificationsRecv",
10395 atomic_load_explicit(&p
->notify_in
,
10396 memory_order_relaxed
));
10397 json_object_int_add(json_stat
, "updatesSent",
10398 atomic_load_explicit(&p
->update_out
,
10399 memory_order_relaxed
));
10400 json_object_int_add(json_stat
, "updatesRecv",
10401 atomic_load_explicit(&p
->update_in
,
10402 memory_order_relaxed
));
10403 json_object_int_add(json_stat
, "keepalivesSent",
10404 atomic_load_explicit(&p
->keepalive_out
,
10405 memory_order_relaxed
));
10406 json_object_int_add(json_stat
, "keepalivesRecv",
10407 atomic_load_explicit(&p
->keepalive_in
,
10408 memory_order_relaxed
));
10409 json_object_int_add(json_stat
, "routeRefreshSent",
10410 atomic_load_explicit(&p
->refresh_out
,
10411 memory_order_relaxed
));
10412 json_object_int_add(json_stat
, "routeRefreshRecv",
10413 atomic_load_explicit(&p
->refresh_in
,
10414 memory_order_relaxed
));
10415 json_object_int_add(json_stat
, "capabilitySent",
10416 atomic_load_explicit(&p
->dynamic_cap_out
,
10417 memory_order_relaxed
));
10418 json_object_int_add(json_stat
, "capabilityRecv",
10419 atomic_load_explicit(&p
->dynamic_cap_in
,
10420 memory_order_relaxed
));
10421 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10422 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10423 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10425 /* Packet counts. */
10426 vty_out(vty
, " Message statistics:\n");
10427 vty_out(vty
, " Inq depth is 0\n");
10428 vty_out(vty
, " Outq depth is %lu\n",
10429 (unsigned long)p
->obuf
->count
);
10430 vty_out(vty
, " Sent Rcvd\n");
10431 vty_out(vty
, " Opens: %10d %10d\n",
10432 atomic_load_explicit(&p
->open_out
,
10433 memory_order_relaxed
),
10434 atomic_load_explicit(&p
->open_in
,
10435 memory_order_relaxed
));
10436 vty_out(vty
, " Notifications: %10d %10d\n",
10437 atomic_load_explicit(&p
->notify_out
,
10438 memory_order_relaxed
),
10439 atomic_load_explicit(&p
->notify_in
,
10440 memory_order_relaxed
));
10441 vty_out(vty
, " Updates: %10d %10d\n",
10442 atomic_load_explicit(&p
->update_out
,
10443 memory_order_relaxed
),
10444 atomic_load_explicit(&p
->update_in
,
10445 memory_order_relaxed
));
10446 vty_out(vty
, " Keepalives: %10d %10d\n",
10447 atomic_load_explicit(&p
->keepalive_out
,
10448 memory_order_relaxed
),
10449 atomic_load_explicit(&p
->keepalive_in
,
10450 memory_order_relaxed
));
10451 vty_out(vty
, " Route Refresh: %10d %10d\n",
10452 atomic_load_explicit(&p
->refresh_out
,
10453 memory_order_relaxed
),
10454 atomic_load_explicit(&p
->refresh_in
,
10455 memory_order_relaxed
));
10456 vty_out(vty
, " Capability: %10d %10d\n",
10457 atomic_load_explicit(&p
->dynamic_cap_out
,
10458 memory_order_relaxed
),
10459 atomic_load_explicit(&p
->dynamic_cap_in
,
10460 memory_order_relaxed
));
10461 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10466 /* advertisement-interval */
10467 json_object_int_add(json_neigh
,
10468 "minBtwnAdvertisementRunsTimerMsecs",
10469 p
->v_routeadv
* 1000);
10471 /* Update-source. */
10472 if (p
->update_if
|| p
->update_source
) {
10474 json_object_string_add(json_neigh
,
10477 else if (p
->update_source
)
10478 json_object_string_add(
10479 json_neigh
, "updateSource",
10480 sockunion2str(p
->update_source
, buf1
,
10484 /* advertisement-interval */
10486 " Minimum time between advertisement runs is %d seconds\n",
10489 /* Update-source. */
10490 if (p
->update_if
|| p
->update_source
) {
10491 vty_out(vty
, " Update source is ");
10493 vty_out(vty
, "%s", p
->update_if
);
10494 else if (p
->update_source
)
10496 sockunion2str(p
->update_source
, buf1
,
10498 vty_out(vty
, "\n");
10501 vty_out(vty
, "\n");
10504 /* Address Family Information */
10505 json_object
*json_hold
= NULL
;
10508 json_hold
= json_object_new_object();
10510 FOREACH_AFI_SAFI (afi
, safi
)
10511 if (p
->afc
[afi
][safi
])
10512 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10516 json_object_object_add(json_neigh
, "addressFamilyInfo",
10518 json_object_int_add(json_neigh
, "connectionsEstablished",
10520 json_object_int_add(json_neigh
, "connectionsDropped",
10523 vty_out(vty
, " Connections established %d; dropped %d\n",
10524 p
->established
, p
->dropped
);
10526 if (!p
->last_reset
) {
10528 json_object_string_add(json_neigh
, "lastReset",
10531 vty_out(vty
, " Last reset never\n");
10537 uptime
= bgp_clock();
10538 uptime
-= p
->resettime
;
10539 tm
= gmtime(&uptime
);
10540 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10541 (tm
->tm_sec
* 1000)
10542 + (tm
->tm_min
* 60000)
10543 + (tm
->tm_hour
* 3600000));
10544 json_object_string_add(
10545 json_neigh
, "lastResetDueTo",
10546 peer_down_str
[(int)p
->last_reset
]);
10547 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10548 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10549 char errorcodesubcode_hexstr
[5];
10550 char errorcodesubcode_str
[256];
10552 code_str
= bgp_notify_code_str(p
->notify
.code
);
10553 subcode_str
= bgp_notify_subcode_str(
10554 p
->notify
.code
, p
->notify
.subcode
);
10556 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10557 p
->notify
.code
, p
->notify
.subcode
);
10558 json_object_string_add(json_neigh
,
10559 "lastErrorCodeSubcode",
10560 errorcodesubcode_hexstr
);
10561 snprintf(errorcodesubcode_str
, 255, "%s%s",
10562 code_str
, subcode_str
);
10563 json_object_string_add(json_neigh
,
10564 "lastNotificationReason",
10565 errorcodesubcode_str
);
10566 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10567 && p
->notify
.code
== BGP_NOTIFY_CEASE
10568 && (p
->notify
.subcode
10569 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10570 || p
->notify
.subcode
10571 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10572 && p
->notify
.length
) {
10574 const char *msg_str
;
10576 msg_str
= bgp_notify_admin_message(
10577 msgbuf
, sizeof(msgbuf
),
10578 (uint8_t *)p
->notify
.data
,
10581 json_object_string_add(
10583 "lastShutdownDescription",
10588 vty_out(vty
, " Last reset %s, ",
10589 peer_uptime(p
->resettime
, timebuf
,
10590 BGP_UPTIME_LEN
, 0, NULL
));
10592 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10593 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10594 code_str
= bgp_notify_code_str(p
->notify
.code
);
10595 subcode_str
= bgp_notify_subcode_str(
10596 p
->notify
.code
, p
->notify
.subcode
);
10597 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10598 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10601 code_str
, subcode_str
);
10602 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10603 && p
->notify
.code
== BGP_NOTIFY_CEASE
10604 && (p
->notify
.subcode
10605 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10606 || p
->notify
.subcode
10607 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10608 && p
->notify
.length
) {
10610 const char *msg_str
;
10612 msg_str
= bgp_notify_admin_message(
10613 msgbuf
, sizeof(msgbuf
),
10614 (uint8_t *)p
->notify
.data
,
10618 " Message: \"%s\"\n",
10622 vty_out(vty
, "due to %s\n",
10623 peer_down_str
[(int)p
->last_reset
]);
10626 if (p
->last_reset_cause_size
) {
10627 msg
= p
->last_reset_cause
;
10629 " Message received that caused BGP to send a NOTIFICATION:\n ");
10630 for (i
= 1; i
<= p
->last_reset_cause_size
;
10632 vty_out(vty
, "%02X", *msg
++);
10634 if (i
!= p
->last_reset_cause_size
) {
10636 vty_out(vty
, "\n ");
10637 } else if (i
% 4 == 0) {
10642 vty_out(vty
, "\n");
10647 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10649 json_object_boolean_true_add(json_neigh
,
10650 "prefixesConfigExceedMax");
10653 " Peer had exceeded the max. no. of prefixes configured.\n");
10655 if (p
->t_pmax_restart
) {
10657 json_object_boolean_true_add(
10658 json_neigh
, "reducePrefixNumFrom");
10659 json_object_int_add(json_neigh
,
10660 "restartInTimerMsec",
10661 thread_timer_remain_second(
10666 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10667 p
->host
, thread_timer_remain_second(
10668 p
->t_pmax_restart
));
10671 json_object_boolean_true_add(
10673 "reducePrefixNumAndClearIpBgp");
10676 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10681 /* EBGP Multihop and GTSM */
10682 if (p
->sort
!= BGP_PEER_IBGP
) {
10684 if (p
->gtsm_hops
> 0)
10685 json_object_int_add(json_neigh
,
10686 "externalBgpNbrMaxHopsAway",
10688 else if (p
->ttl
> 1)
10689 json_object_int_add(json_neigh
,
10690 "externalBgpNbrMaxHopsAway",
10693 if (p
->gtsm_hops
> 0)
10695 " External BGP neighbor may be up to %d hops away.\n",
10697 else if (p
->ttl
> 1)
10699 " External BGP neighbor may be up to %d hops away.\n",
10703 if (p
->gtsm_hops
> 0) {
10705 json_object_int_add(json_neigh
,
10706 "internalBgpNbrMaxHopsAway",
10710 " Internal BGP neighbor may be up to %d hops away.\n",
10715 /* Local address. */
10718 json_object_string_add(json_neigh
, "hostLocal",
10719 sockunion2str(p
->su_local
, buf1
,
10721 json_object_int_add(json_neigh
, "portLocal",
10722 ntohs(p
->su_local
->sin
.sin_port
));
10724 vty_out(vty
, "Local host: %s, Local port: %d\n",
10725 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10726 ntohs(p
->su_local
->sin
.sin_port
));
10729 /* Remote address. */
10730 if (p
->su_remote
) {
10732 json_object_string_add(json_neigh
, "hostForeign",
10733 sockunion2str(p
->su_remote
, buf1
,
10735 json_object_int_add(json_neigh
, "portForeign",
10736 ntohs(p
->su_remote
->sin
.sin_port
));
10738 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10739 sockunion2str(p
->su_remote
, buf1
,
10741 ntohs(p
->su_remote
->sin
.sin_port
));
10744 /* Nexthop display. */
10747 json_object_string_add(json_neigh
, "nexthop",
10749 &p
->nexthop
.v4
, buf1
,
10751 json_object_string_add(json_neigh
, "nexthopGlobal",
10752 inet_ntop(AF_INET6
,
10753 &p
->nexthop
.v6_global
,
10754 buf1
, sizeof(buf1
)));
10755 json_object_string_add(json_neigh
, "nexthopLocal",
10756 inet_ntop(AF_INET6
,
10757 &p
->nexthop
.v6_local
,
10758 buf1
, sizeof(buf1
)));
10759 if (p
->shared_network
)
10760 json_object_string_add(json_neigh
,
10764 json_object_string_add(json_neigh
,
10766 "nonSharedNetwork");
10768 vty_out(vty
, "Nexthop: %s\n",
10769 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10771 vty_out(vty
, "Nexthop global: %s\n",
10772 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10774 vty_out(vty
, "Nexthop local: %s\n",
10775 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10777 vty_out(vty
, "BGP connection: %s\n",
10778 p
->shared_network
? "shared network"
10779 : "non shared network");
10783 /* Timer information. */
10785 json_object_int_add(json_neigh
, "connectRetryTimer",
10787 if (p
->status
== Established
&& p
->rtt
)
10788 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10791 json_object_int_add(
10792 json_neigh
, "nextStartTimerDueInMsecs",
10793 thread_timer_remain_second(p
->t_start
) * 1000);
10795 json_object_int_add(
10796 json_neigh
, "nextConnectTimerDueInMsecs",
10797 thread_timer_remain_second(p
->t_connect
)
10799 if (p
->t_routeadv
) {
10800 json_object_int_add(json_neigh
, "mraiInterval",
10802 json_object_int_add(
10803 json_neigh
, "mraiTimerExpireInMsecs",
10804 thread_timer_remain_second(p
->t_routeadv
)
10808 json_object_int_add(json_neigh
, "authenticationEnabled",
10812 json_object_string_add(json_neigh
, "readThread", "on");
10814 json_object_string_add(json_neigh
, "readThread", "off");
10816 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10817 json_object_string_add(json_neigh
, "writeThread", "on");
10819 json_object_string_add(json_neigh
, "writeThread",
10822 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10824 if (p
->status
== Established
&& p
->rtt
)
10825 vty_out(vty
, "Estimated round trip time: %d ms\n",
10828 vty_out(vty
, "Next start timer due in %ld seconds\n",
10829 thread_timer_remain_second(p
->t_start
));
10831 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10832 thread_timer_remain_second(p
->t_connect
));
10835 "MRAI (interval %u) timer expires in %ld seconds\n",
10837 thread_timer_remain_second(p
->t_routeadv
));
10839 vty_out(vty
, "Peer Authentication Enabled\n");
10841 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10842 p
->t_read
? "on" : "off",
10843 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10848 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10849 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10850 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10853 vty_out(vty
, "\n");
10855 /* BFD information. */
10856 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10859 if (p
->conf_if
) /* Configured interface name. */
10860 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10861 else /* Configured IP address. */
10862 json_object_object_add(json
, p
->host
, json_neigh
);
10866 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10867 enum show_type type
, union sockunion
*su
,
10868 const char *conf_if
, bool use_json
,
10871 struct listnode
*node
, *nnode
;
10874 bool nbr_output
= false;
10876 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10877 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10882 bgp_show_peer(vty
, peer
, use_json
, json
);
10888 && !strcmp(peer
->conf_if
, conf_if
))
10890 && !strcmp(peer
->hostname
, conf_if
))) {
10892 bgp_show_peer(vty
, peer
, use_json
,
10896 if (sockunion_same(&peer
->su
, su
)) {
10898 bgp_show_peer(vty
, peer
, use_json
,
10906 if (type
== show_peer
&& !find
) {
10908 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10910 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10913 if (type
!= show_peer
&& !nbr_output
&& !use_json
)
10914 vty_out(vty
, "%% No BGP neighbors found\n");
10917 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10918 json
, JSON_C_TO_STRING_PRETTY
));
10919 json_object_free(json
);
10921 vty_out(vty
, "\n");
10924 return CMD_SUCCESS
;
10927 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10928 enum show_type type
,
10929 const char *ip_str
,
10932 struct listnode
*node
, *nnode
;
10934 union sockunion su
;
10935 json_object
*json
= NULL
;
10936 int ret
, is_first
= 1;
10937 bool nbr_output
= false;
10940 vty_out(vty
, "{\n");
10942 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10945 if (!(json
= json_object_new_object())) {
10947 EC_BGP_JSON_MEM_ERROR
,
10948 "Unable to allocate memory for JSON object");
10950 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10954 json_object_int_add(json
, "vrfId",
10955 (bgp
->vrf_id
== VRF_UNKNOWN
)
10957 : (int64_t)bgp
->vrf_id
);
10958 json_object_string_add(
10960 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10965 vty_out(vty
, ",\n");
10969 vty_out(vty
, "\"%s\":",
10970 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10974 vty_out(vty
, "\nInstance %s:\n",
10975 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10980 if (type
== show_peer
) {
10981 ret
= str2sockunion(ip_str
, &su
);
10983 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10986 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10989 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10995 vty_out(vty
, "}\n");
10996 else if (!nbr_output
)
10997 vty_out(vty
, "%% BGP instance not found\n");
11000 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11001 enum show_type type
, const char *ip_str
,
11006 union sockunion su
;
11007 json_object
*json
= NULL
;
11010 if (strmatch(name
, "all")) {
11011 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11013 return CMD_SUCCESS
;
11015 bgp
= bgp_lookup_by_name(name
);
11018 json
= json_object_new_object();
11019 vty_out(vty
, "%s\n",
11020 json_object_to_json_string_ext(
11022 JSON_C_TO_STRING_PRETTY
));
11023 json_object_free(json
);
11026 "%% BGP instance not found\n");
11028 return CMD_WARNING
;
11032 bgp
= bgp_get_default();
11036 json
= json_object_new_object();
11038 ret
= str2sockunion(ip_str
, &su
);
11040 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11043 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11046 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11049 json_object_free(json
);
11052 vty_out(vty
, "{}\n");
11054 vty_out(vty
, "%% BGP instance not found\n");
11057 return CMD_SUCCESS
;
11060 /* "show [ip] bgp neighbors" commands. */
11061 DEFUN (show_ip_bgp_neighbors
,
11062 show_ip_bgp_neighbors_cmd
,
11063 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11067 BGP_INSTANCE_HELP_STR
11070 "Detailed information on TCP and BGP neighbor connections\n"
11071 "Neighbor to display information about\n"
11072 "Neighbor to display information about\n"
11073 "Neighbor on BGP configured interface\n"
11077 char *sh_arg
= NULL
;
11078 enum show_type sh_type
;
11080 bool uj
= use_json(argc
, argv
);
11084 /* [<vrf> VIEWVRFNAME] */
11085 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11086 vrf
= argv
[idx
+ 1]->arg
;
11087 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11089 } else if (argv_find(argv
, argc
, "view", &idx
))
11090 /* [<view> VIEWVRFNAME] */
11091 vrf
= argv
[idx
+ 1]->arg
;
11094 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11095 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11096 || argv_find(argv
, argc
, "WORD", &idx
)) {
11097 sh_type
= show_peer
;
11098 sh_arg
= argv
[idx
]->arg
;
11100 sh_type
= show_all
;
11102 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11105 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11106 paths' and `show ip mbgp paths'. Those functions results are the
11108 DEFUN (show_ip_bgp_paths
,
11109 show_ip_bgp_paths_cmd
,
11110 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11115 "Path information\n")
11117 vty_out(vty
, "Address Refcnt Path\n");
11118 aspath_print_all_vty(vty
);
11119 return CMD_SUCCESS
;
11124 static void community_show_all_iterator(struct hash_backet
*backet
,
11127 struct community
*com
;
11129 com
= (struct community
*)backet
->data
;
11130 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11131 community_str(com
, false));
11134 /* Show BGP's community internal data. */
11135 DEFUN (show_ip_bgp_community_info
,
11136 show_ip_bgp_community_info_cmd
,
11137 "show [ip] bgp community-info",
11141 "List all bgp community information\n")
11143 vty_out(vty
, "Address Refcnt Community\n");
11145 hash_iterate(community_hash(),
11146 (void (*)(struct hash_backet
*,
11147 void *))community_show_all_iterator
,
11150 return CMD_SUCCESS
;
11153 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
11156 struct lcommunity
*lcom
;
11158 lcom
= (struct lcommunity
*)backet
->data
;
11159 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11160 lcommunity_str(lcom
, false));
11163 /* Show BGP's community internal data. */
11164 DEFUN (show_ip_bgp_lcommunity_info
,
11165 show_ip_bgp_lcommunity_info_cmd
,
11166 "show ip bgp large-community-info",
11170 "List all bgp large-community information\n")
11172 vty_out(vty
, "Address Refcnt Large-community\n");
11174 hash_iterate(lcommunity_hash(),
11175 (void (*)(struct hash_backet
*,
11176 void *))lcommunity_show_all_iterator
,
11179 return CMD_SUCCESS
;
11183 DEFUN (show_ip_bgp_attr_info
,
11184 show_ip_bgp_attr_info_cmd
,
11185 "show [ip] bgp attribute-info",
11189 "List all bgp attribute information\n")
11191 attr_show_all(vty
);
11192 return CMD_SUCCESS
;
11195 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11196 safi_t safi
, bool use_json
)
11199 struct listnode
*node
;
11201 char buf1
[INET6_ADDRSTRLEN
];
11203 vpn_policy_direction_t dir
;
11206 json_object
*json
= NULL
;
11207 json_object
*json_import_vrfs
= NULL
;
11208 json_object
*json_export_vrfs
= NULL
;
11210 json
= json_object_new_object();
11212 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11215 vty_out(vty
, "%s\n",
11216 json_object_to_json_string_ext(
11218 JSON_C_TO_STRING_PRETTY
));
11219 json_object_free(json
);
11221 return CMD_WARNING
;
11224 /* Provide context for the block */
11225 json_object_string_add(json
, "vrf", name
? name
: "default");
11226 json_object_string_add(json
, "afiSafi",
11227 afi_safi_print(afi
, safi
));
11229 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11230 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11231 json_object_string_add(json
, "importFromVrfs", "none");
11232 json_object_string_add(json
, "importRts", "none");
11234 json_import_vrfs
= json_object_new_array();
11236 for (ALL_LIST_ELEMENTS_RO(
11237 bgp
->vpn_policy
[afi
].import_vrf
,
11239 json_object_array_add(json_import_vrfs
,
11240 json_object_new_string(vname
));
11242 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11243 ecom_str
= ecommunity_ecom2str(
11244 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11245 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11246 json_object_object_add(json
, "importFromVrfs",
11248 json_object_string_add(json
, "importRts", ecom_str
);
11250 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11253 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11254 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11255 json_object_string_add(json
, "exportToVrfs", "none");
11256 json_object_string_add(json
, "routeDistinguisher",
11258 json_object_string_add(json
, "exportRts", "none");
11260 json_export_vrfs
= json_object_new_array();
11262 for (ALL_LIST_ELEMENTS_RO(
11263 bgp
->vpn_policy
[afi
].export_vrf
,
11265 json_object_array_add(json_export_vrfs
,
11266 json_object_new_string(vname
));
11267 json_object_object_add(json
, "exportToVrfs",
11269 json_object_string_add(json
, "routeDistinguisher",
11270 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11271 buf1
, RD_ADDRSTRLEN
));
11273 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11274 ecom_str
= ecommunity_ecom2str(
11275 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11276 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11277 json_object_string_add(json
, "exportRts", ecom_str
);
11279 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11282 vty_out(vty
, "%s\n",
11283 json_object_to_json_string_ext(json
,
11284 JSON_C_TO_STRING_PRETTY
));
11285 json_object_free(json
);
11288 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11291 vty_out(vty
, "%% No such BGP instance exist\n");
11292 return CMD_WARNING
;
11295 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11296 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11298 "This VRF is not importing %s routes from any other VRF\n",
11299 afi_safi_print(afi
, safi
));
11302 "This VRF is importing %s routes from the following VRFs:\n",
11303 afi_safi_print(afi
, safi
));
11305 for (ALL_LIST_ELEMENTS_RO(
11306 bgp
->vpn_policy
[afi
].import_vrf
,
11308 vty_out(vty
, " %s\n", vname
);
11310 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11311 ecom_str
= ecommunity_ecom2str(
11312 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11313 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11314 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11316 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11319 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11320 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11322 "This VRF is not exporting %s routes to any other VRF\n",
11323 afi_safi_print(afi
, safi
));
11326 "This VRF is exporting %s routes to the following VRFs:\n",
11327 afi_safi_print(afi
, safi
));
11329 for (ALL_LIST_ELEMENTS_RO(
11330 bgp
->vpn_policy
[afi
].export_vrf
,
11332 vty_out(vty
, " %s\n", vname
);
11334 vty_out(vty
, "RD: %s\n",
11335 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11336 buf1
, RD_ADDRSTRLEN
));
11338 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11339 ecom_str
= ecommunity_ecom2str(
11340 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11341 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11342 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11343 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11347 return CMD_SUCCESS
;
11350 /* "show [ip] bgp route-leak" command. */
11351 DEFUN (show_ip_bgp_route_leak
,
11352 show_ip_bgp_route_leak_cmd
,
11353 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11357 BGP_INSTANCE_HELP_STR
11360 "Route leaking information\n"
11364 afi_t afi
= AFI_MAX
;
11365 safi_t safi
= SAFI_MAX
;
11367 bool uj
= use_json(argc
, argv
);
11370 /* show [ip] bgp */
11371 if (argv_find(argv
, argc
, "ip", &idx
)) {
11373 safi
= SAFI_UNICAST
;
11375 /* [vrf VIEWVRFNAME] */
11376 if (argv_find(argv
, argc
, "view", &idx
)) {
11378 "%% This command is not applicable to BGP views\n");
11379 return CMD_WARNING
;
11382 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11383 vrf
= argv
[idx
+ 1]->arg
;
11384 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11387 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11388 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11389 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11392 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11394 "%% This command is applicable only for unicast ipv4|ipv6\n");
11395 return CMD_WARNING
;
11398 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
);
11401 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11404 struct listnode
*node
, *nnode
;
11407 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11408 vty_out(vty
, "\nInstance %s:\n",
11409 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11412 update_group_show(bgp
, afi
, safi
, vty
, 0);
11416 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11417 int safi
, uint64_t subgrp_id
)
11422 if (strmatch(name
, "all")) {
11423 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11424 return CMD_SUCCESS
;
11426 bgp
= bgp_lookup_by_name(name
);
11429 bgp
= bgp_get_default();
11433 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11434 return CMD_SUCCESS
;
11437 DEFUN (show_ip_bgp_updgrps
,
11438 show_ip_bgp_updgrps_cmd
,
11439 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11443 BGP_INSTANCE_HELP_STR
11445 BGP_SAFI_WITH_LABEL_HELP_STR
11446 "Detailed info about dynamic update groups\n"
11447 "Specific subgroup to display detailed info for\n")
11450 afi_t afi
= AFI_IP6
;
11451 safi_t safi
= SAFI_UNICAST
;
11452 uint64_t subgrp_id
= 0;
11456 /* show [ip] bgp */
11457 if (argv_find(argv
, argc
, "ip", &idx
))
11459 /* [<vrf> VIEWVRFNAME] */
11460 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11461 vrf
= argv
[idx
+ 1]->arg
;
11462 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11464 } else if (argv_find(argv
, argc
, "view", &idx
))
11465 /* [<view> VIEWVRFNAME] */
11466 vrf
= argv
[idx
+ 1]->arg
;
11467 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11468 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11469 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11472 /* get subgroup id, if provided */
11474 if (argv
[idx
]->type
== VARIABLE_TKN
)
11475 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11477 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11480 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11481 show_bgp_instance_all_ipv6_updgrps_cmd
,
11482 "show [ip] bgp <view|vrf> all update-groups",
11486 BGP_INSTANCE_ALL_HELP_STR
11487 "Detailed info about dynamic update groups\n")
11489 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11490 return CMD_SUCCESS
;
11493 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11494 show_bgp_l2vpn_evpn_updgrps_cmd
,
11495 "show [ip] bgp l2vpn evpn update-groups",
11499 "l2vpn address family\n"
11500 "evpn sub-address family\n"
11501 "Detailed info about dynamic update groups\n")
11504 uint64_t subgrp_id
= 0;
11506 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11507 return CMD_SUCCESS
;
11510 DEFUN (show_bgp_updgrps_stats
,
11511 show_bgp_updgrps_stats_cmd
,
11512 "show [ip] bgp update-groups statistics",
11516 "Detailed info about dynamic update groups\n"
11521 bgp
= bgp_get_default();
11523 update_group_show_stats(bgp
, vty
);
11525 return CMD_SUCCESS
;
11528 DEFUN (show_bgp_instance_updgrps_stats
,
11529 show_bgp_instance_updgrps_stats_cmd
,
11530 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11534 BGP_INSTANCE_HELP_STR
11535 "Detailed info about dynamic update groups\n"
11541 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11543 update_group_show_stats(bgp
, vty
);
11545 return CMD_SUCCESS
;
11548 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11549 afi_t afi
, safi_t safi
,
11550 const char *what
, uint64_t subgrp_id
)
11555 bgp
= bgp_lookup_by_name(name
);
11557 bgp
= bgp_get_default();
11560 if (!strcmp(what
, "advertise-queue"))
11561 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11563 else if (!strcmp(what
, "advertised-routes"))
11564 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11566 else if (!strcmp(what
, "packet-queue"))
11567 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11572 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11573 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11574 "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",
11575 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11577 "Detailed info about dynamic update groups\n"
11578 "Specific subgroup to display info for\n"
11579 "Advertisement queue\n"
11580 "Announced routes\n"
11583 uint64_t subgrp_id
= 0;
11587 subgrp_id
= strtoull(sgid
, NULL
, 10);
11592 afiz
= bgp_vty_afi_from_str(afi
);
11596 afiz
= bgp_vty_afi_from_str(afi
);
11597 if (afiz
!= AFI_IP
)
11599 "%% Cannot specify both 'ip' and 'ipv6'\n");
11600 return CMD_WARNING
;
11603 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11605 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11606 return CMD_SUCCESS
;
11609 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11611 struct listnode
*node
, *nnode
;
11612 struct prefix
*range
;
11615 char buf
[PREFIX2STR_BUFFER
];
11618 const char *peer_status
;
11619 const char *af_str
;
11624 conf
= group
->conf
;
11626 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11627 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11629 } else if (conf
->as_type
== AS_INTERNAL
) {
11630 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11633 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11636 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11637 vty_out(vty
, " Peer-group type is internal\n");
11639 vty_out(vty
, " Peer-group type is external\n");
11641 /* Display AFs configured. */
11642 vty_out(vty
, " Configured address-families:");
11643 FOREACH_AFI_SAFI (afi
, safi
) {
11644 if (conf
->afc
[afi
][safi
]) {
11646 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11650 vty_out(vty
, " none\n");
11652 vty_out(vty
, "\n");
11654 /* Display listen ranges (for dynamic neighbors), if any */
11655 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11658 else if (afi
== AFI_IP6
)
11662 lr_count
= listcount(group
->listen_range
[afi
]);
11664 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11668 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11670 prefix2str(range
, buf
, sizeof(buf
));
11671 vty_out(vty
, " %s\n", buf
);
11676 /* Display group members and their status */
11677 if (listcount(group
->peer
)) {
11678 vty_out(vty
, " Peer-group members:\n");
11679 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11680 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11681 peer_status
= "Idle (Admin)";
11682 else if (CHECK_FLAG(peer
->sflags
,
11683 PEER_STATUS_PREFIX_OVERFLOW
))
11684 peer_status
= "Idle (PfxCt)";
11686 peer_status
= lookup_msg(bgp_status_msg
,
11687 peer
->status
, NULL
);
11689 dynamic
= peer_dynamic_neighbor(peer
);
11690 vty_out(vty
, " %s %s %s \n", peer
->host
,
11691 dynamic
? "(dynamic)" : "", peer_status
);
11695 return CMD_SUCCESS
;
11698 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11699 const char *group_name
)
11702 struct listnode
*node
, *nnode
;
11703 struct peer_group
*group
;
11704 bool found
= false;
11706 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11709 vty_out(vty
, "%% BGP instance not found\n");
11710 return CMD_WARNING
;
11713 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11715 if (strmatch(group
->name
, group_name
)) {
11716 bgp_show_one_peer_group(vty
, group
);
11721 bgp_show_one_peer_group(vty
, group
);
11725 if (group_name
&& !found
)
11726 vty_out(vty
, "%% No such peer-group\n");
11728 return CMD_SUCCESS
;
11731 DEFUN (show_ip_bgp_peer_groups
,
11732 show_ip_bgp_peer_groups_cmd
,
11733 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11737 BGP_INSTANCE_HELP_STR
11738 "Detailed information on BGP peer groups\n"
11739 "Peer group name\n")
11744 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11746 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11748 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11752 /* Redistribute VTY commands. */
11754 DEFUN (bgp_redistribute_ipv4
,
11755 bgp_redistribute_ipv4_cmd
,
11756 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11757 "Redistribute information from another routing protocol\n"
11758 FRR_IP_REDIST_HELP_STR_BGPD
)
11760 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11761 int idx_protocol
= 1;
11764 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11766 vty_out(vty
, "%% Invalid route type\n");
11767 return CMD_WARNING_CONFIG_FAILED
;
11770 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11771 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11775 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11776 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11777 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11779 DEFUN (bgp_redistribute_ipv4_rmap
,
11780 bgp_redistribute_ipv4_rmap_cmd
,
11781 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11782 "Redistribute information from another routing protocol\n"
11783 FRR_IP_REDIST_HELP_STR_BGPD
11784 "Route map reference\n"
11785 "Pointer to route-map entries\n")
11787 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11788 int idx_protocol
= 1;
11791 struct bgp_redist
*red
;
11793 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11794 vty
, argv
[idx_word
]->arg
);
11796 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11798 vty_out(vty
, "%% Invalid route type\n");
11799 return CMD_WARNING_CONFIG_FAILED
;
11802 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11804 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11805 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11809 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11810 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11811 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11812 "Route map reference\n"
11813 "Pointer to route-map entries\n")
11815 DEFUN (bgp_redistribute_ipv4_metric
,
11816 bgp_redistribute_ipv4_metric_cmd
,
11817 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11818 "Redistribute information from another routing protocol\n"
11819 FRR_IP_REDIST_HELP_STR_BGPD
11820 "Metric for redistributed routes\n"
11821 "Default metric\n")
11823 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11824 int idx_protocol
= 1;
11825 int idx_number
= 3;
11828 struct bgp_redist
*red
;
11831 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11833 vty_out(vty
, "%% Invalid route type\n");
11834 return CMD_WARNING_CONFIG_FAILED
;
11836 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11838 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11839 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11840 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11844 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11845 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11846 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11847 "Metric for redistributed routes\n"
11848 "Default metric\n")
11850 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11851 bgp_redistribute_ipv4_rmap_metric_cmd
,
11852 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11853 "Redistribute information from another routing protocol\n"
11854 FRR_IP_REDIST_HELP_STR_BGPD
11855 "Route map reference\n"
11856 "Pointer to route-map entries\n"
11857 "Metric for redistributed routes\n"
11858 "Default metric\n")
11860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11861 int idx_protocol
= 1;
11863 int idx_number
= 5;
11866 struct bgp_redist
*red
;
11868 struct route_map
*route_map
=
11869 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11871 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11873 vty_out(vty
, "%% Invalid route type\n");
11874 return CMD_WARNING_CONFIG_FAILED
;
11876 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11878 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11880 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11881 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11882 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11886 bgp_redistribute_ipv4_rmap_metric
,
11887 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11888 "redistribute " FRR_IP_REDIST_STR_BGPD
11889 " route-map WORD metric (0-4294967295)",
11890 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11891 "Route map reference\n"
11892 "Pointer to route-map entries\n"
11893 "Metric for redistributed routes\n"
11894 "Default metric\n")
11896 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11897 bgp_redistribute_ipv4_metric_rmap_cmd
,
11898 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11899 "Redistribute information from another routing protocol\n"
11900 FRR_IP_REDIST_HELP_STR_BGPD
11901 "Metric for redistributed routes\n"
11903 "Route map reference\n"
11904 "Pointer to route-map entries\n")
11906 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11907 int idx_protocol
= 1;
11908 int idx_number
= 3;
11912 struct bgp_redist
*red
;
11914 struct route_map
*route_map
=
11915 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11917 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11919 vty_out(vty
, "%% Invalid route type\n");
11920 return CMD_WARNING_CONFIG_FAILED
;
11922 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11924 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11925 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11927 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11928 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11932 bgp_redistribute_ipv4_metric_rmap
,
11933 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11934 "redistribute " FRR_IP_REDIST_STR_BGPD
11935 " metric (0-4294967295) route-map WORD",
11936 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11937 "Metric for redistributed routes\n"
11939 "Route map reference\n"
11940 "Pointer to route-map entries\n")
11942 DEFUN (bgp_redistribute_ipv4_ospf
,
11943 bgp_redistribute_ipv4_ospf_cmd
,
11944 "redistribute <ospf|table> (1-65535)",
11945 "Redistribute information from another routing protocol\n"
11946 "Open Shortest Path First (OSPFv2)\n"
11947 "Non-main Kernel Routing Table\n"
11948 "Instance ID/Table ID\n")
11950 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11951 int idx_ospf_table
= 1;
11952 int idx_number
= 2;
11953 unsigned short instance
;
11954 unsigned short protocol
;
11956 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11958 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11959 protocol
= ZEBRA_ROUTE_OSPF
;
11961 protocol
= ZEBRA_ROUTE_TABLE
;
11963 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11964 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
11967 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11968 "redistribute <ospf|table> (1-65535)",
11969 "Redistribute information from another routing protocol\n"
11970 "Open Shortest Path First (OSPFv2)\n"
11971 "Non-main Kernel Routing Table\n"
11972 "Instance ID/Table ID\n")
11974 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11975 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11976 "redistribute <ospf|table> (1-65535) route-map WORD",
11977 "Redistribute information from another routing protocol\n"
11978 "Open Shortest Path First (OSPFv2)\n"
11979 "Non-main Kernel Routing Table\n"
11980 "Instance ID/Table ID\n"
11981 "Route map reference\n"
11982 "Pointer to route-map entries\n")
11984 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11985 int idx_ospf_table
= 1;
11986 int idx_number
= 2;
11988 struct bgp_redist
*red
;
11989 unsigned short instance
;
11992 struct route_map
*route_map
=
11993 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
11995 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11996 protocol
= ZEBRA_ROUTE_OSPF
;
11998 protocol
= ZEBRA_ROUTE_TABLE
;
12000 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12001 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12003 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12004 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12007 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12008 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12009 "redistribute <ospf|table> (1-65535) route-map WORD",
12010 "Redistribute information from another routing protocol\n"
12011 "Open Shortest Path First (OSPFv2)\n"
12012 "Non-main Kernel Routing Table\n"
12013 "Instance ID/Table ID\n"
12014 "Route map reference\n"
12015 "Pointer to route-map entries\n")
12017 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12018 bgp_redistribute_ipv4_ospf_metric_cmd
,
12019 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12020 "Redistribute information from another routing protocol\n"
12021 "Open Shortest Path First (OSPFv2)\n"
12022 "Non-main Kernel Routing Table\n"
12023 "Instance ID/Table ID\n"
12024 "Metric for redistributed routes\n"
12025 "Default metric\n")
12027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12028 int idx_ospf_table
= 1;
12029 int idx_number
= 2;
12030 int idx_number_2
= 4;
12032 struct bgp_redist
*red
;
12033 unsigned short instance
;
12037 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12038 protocol
= ZEBRA_ROUTE_OSPF
;
12040 protocol
= ZEBRA_ROUTE_TABLE
;
12042 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12043 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12045 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12046 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12048 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12051 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12052 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12053 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12054 "Redistribute information from another routing protocol\n"
12055 "Open Shortest Path First (OSPFv2)\n"
12056 "Non-main Kernel Routing Table\n"
12057 "Instance ID/Table ID\n"
12058 "Metric for redistributed routes\n"
12059 "Default metric\n")
12061 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12062 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12063 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12064 "Redistribute information from another routing protocol\n"
12065 "Open Shortest Path First (OSPFv2)\n"
12066 "Non-main Kernel Routing Table\n"
12067 "Instance ID/Table ID\n"
12068 "Route map reference\n"
12069 "Pointer to route-map entries\n"
12070 "Metric for redistributed routes\n"
12071 "Default metric\n")
12073 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12074 int idx_ospf_table
= 1;
12075 int idx_number
= 2;
12077 int idx_number_2
= 6;
12079 struct bgp_redist
*red
;
12080 unsigned short instance
;
12083 struct route_map
*route_map
=
12084 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12086 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12087 protocol
= ZEBRA_ROUTE_OSPF
;
12089 protocol
= ZEBRA_ROUTE_TABLE
;
12091 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12092 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12094 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12096 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12097 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12099 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12103 bgp_redistribute_ipv4_ospf_rmap_metric
,
12104 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12105 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12106 "Redistribute information from another routing protocol\n"
12107 "Open Shortest Path First (OSPFv2)\n"
12108 "Non-main Kernel Routing Table\n"
12109 "Instance ID/Table ID\n"
12110 "Route map reference\n"
12111 "Pointer to route-map entries\n"
12112 "Metric for redistributed routes\n"
12113 "Default metric\n")
12115 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12116 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12117 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12118 "Redistribute information from another routing protocol\n"
12119 "Open Shortest Path First (OSPFv2)\n"
12120 "Non-main Kernel Routing Table\n"
12121 "Instance ID/Table ID\n"
12122 "Metric for redistributed routes\n"
12124 "Route map reference\n"
12125 "Pointer to route-map entries\n")
12127 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12128 int idx_ospf_table
= 1;
12129 int idx_number
= 2;
12130 int idx_number_2
= 4;
12133 struct bgp_redist
*red
;
12134 unsigned short instance
;
12137 struct route_map
*route_map
=
12138 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12140 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12141 protocol
= ZEBRA_ROUTE_OSPF
;
12143 protocol
= ZEBRA_ROUTE_TABLE
;
12145 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12146 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12148 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12149 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12152 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12153 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12157 bgp_redistribute_ipv4_ospf_metric_rmap
,
12158 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12159 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12160 "Redistribute information from another routing protocol\n"
12161 "Open Shortest Path First (OSPFv2)\n"
12162 "Non-main Kernel Routing Table\n"
12163 "Instance ID/Table ID\n"
12164 "Metric for redistributed routes\n"
12166 "Route map reference\n"
12167 "Pointer to route-map entries\n")
12169 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12170 no_bgp_redistribute_ipv4_ospf_cmd
,
12171 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12173 "Redistribute information from another routing protocol\n"
12174 "Open Shortest Path First (OSPFv2)\n"
12175 "Non-main Kernel Routing Table\n"
12176 "Instance ID/Table ID\n"
12177 "Metric for redistributed routes\n"
12179 "Route map reference\n"
12180 "Pointer to route-map entries\n")
12182 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12183 int idx_ospf_table
= 2;
12184 int idx_number
= 3;
12185 unsigned short instance
;
12188 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12189 protocol
= ZEBRA_ROUTE_OSPF
;
12191 protocol
= ZEBRA_ROUTE_TABLE
;
12193 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12194 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12198 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12199 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12201 "Redistribute information from another routing protocol\n"
12202 "Open Shortest Path First (OSPFv2)\n"
12203 "Non-main Kernel Routing Table\n"
12204 "Instance ID/Table ID\n"
12205 "Metric for redistributed routes\n"
12207 "Route map reference\n"
12208 "Pointer to route-map entries\n")
12210 DEFUN (no_bgp_redistribute_ipv4
,
12211 no_bgp_redistribute_ipv4_cmd
,
12212 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12214 "Redistribute information from another routing protocol\n"
12215 FRR_IP_REDIST_HELP_STR_BGPD
12216 "Metric for redistributed routes\n"
12218 "Route map reference\n"
12219 "Pointer to route-map entries\n")
12221 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12222 int idx_protocol
= 2;
12225 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12227 vty_out(vty
, "%% Invalid route type\n");
12228 return CMD_WARNING_CONFIG_FAILED
;
12230 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12234 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12235 "no redistribute " FRR_IP_REDIST_STR_BGPD
12236 " [metric (0-4294967295)] [route-map WORD]",
12238 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12239 "Metric for redistributed routes\n"
12241 "Route map reference\n"
12242 "Pointer to route-map entries\n")
12244 DEFUN (bgp_redistribute_ipv6
,
12245 bgp_redistribute_ipv6_cmd
,
12246 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12247 "Redistribute information from another routing protocol\n"
12248 FRR_IP6_REDIST_HELP_STR_BGPD
)
12250 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12251 int idx_protocol
= 1;
12254 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12256 vty_out(vty
, "%% Invalid route type\n");
12257 return CMD_WARNING_CONFIG_FAILED
;
12260 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12261 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12264 DEFUN (bgp_redistribute_ipv6_rmap
,
12265 bgp_redistribute_ipv6_rmap_cmd
,
12266 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12267 "Redistribute information from another routing protocol\n"
12268 FRR_IP6_REDIST_HELP_STR_BGPD
12269 "Route map reference\n"
12270 "Pointer to route-map entries\n")
12272 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12273 int idx_protocol
= 1;
12276 struct bgp_redist
*red
;
12278 struct route_map
*route_map
=
12279 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12281 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12283 vty_out(vty
, "%% Invalid route type\n");
12284 return CMD_WARNING_CONFIG_FAILED
;
12287 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12289 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12290 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12293 DEFUN (bgp_redistribute_ipv6_metric
,
12294 bgp_redistribute_ipv6_metric_cmd
,
12295 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12296 "Redistribute information from another routing protocol\n"
12297 FRR_IP6_REDIST_HELP_STR_BGPD
12298 "Metric for redistributed routes\n"
12299 "Default metric\n")
12301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12302 int idx_protocol
= 1;
12303 int idx_number
= 3;
12306 struct bgp_redist
*red
;
12309 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12311 vty_out(vty
, "%% Invalid route type\n");
12312 return CMD_WARNING_CONFIG_FAILED
;
12314 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12316 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12317 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12318 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12321 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12322 bgp_redistribute_ipv6_rmap_metric_cmd
,
12323 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12324 "Redistribute information from another routing protocol\n"
12325 FRR_IP6_REDIST_HELP_STR_BGPD
12326 "Route map reference\n"
12327 "Pointer to route-map entries\n"
12328 "Metric for redistributed routes\n"
12329 "Default metric\n")
12331 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12332 int idx_protocol
= 1;
12334 int idx_number
= 5;
12337 struct bgp_redist
*red
;
12339 struct route_map
*route_map
=
12340 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12342 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12344 vty_out(vty
, "%% Invalid route type\n");
12345 return CMD_WARNING_CONFIG_FAILED
;
12347 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12349 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12351 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12352 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12354 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12357 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12358 bgp_redistribute_ipv6_metric_rmap_cmd
,
12359 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12360 "Redistribute information from another routing protocol\n"
12361 FRR_IP6_REDIST_HELP_STR_BGPD
12362 "Metric for redistributed routes\n"
12364 "Route map reference\n"
12365 "Pointer to route-map entries\n")
12367 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12368 int idx_protocol
= 1;
12369 int idx_number
= 3;
12373 struct bgp_redist
*red
;
12375 struct route_map
*route_map
=
12376 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12378 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12380 vty_out(vty
, "%% Invalid route type\n");
12381 return CMD_WARNING_CONFIG_FAILED
;
12383 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12385 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12386 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12389 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12390 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12393 DEFUN (no_bgp_redistribute_ipv6
,
12394 no_bgp_redistribute_ipv6_cmd
,
12395 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12397 "Redistribute information from another routing protocol\n"
12398 FRR_IP6_REDIST_HELP_STR_BGPD
12399 "Metric for redistributed routes\n"
12401 "Route map reference\n"
12402 "Pointer to route-map entries\n")
12404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12405 int idx_protocol
= 2;
12408 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12410 vty_out(vty
, "%% Invalid route type\n");
12411 return CMD_WARNING_CONFIG_FAILED
;
12414 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12417 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12422 /* Unicast redistribution only. */
12423 if (safi
!= SAFI_UNICAST
)
12426 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12427 /* Redistribute BGP does not make sense. */
12428 if (i
!= ZEBRA_ROUTE_BGP
) {
12429 struct list
*red_list
;
12430 struct listnode
*node
;
12431 struct bgp_redist
*red
;
12433 red_list
= bgp
->redist
[afi
][i
];
12437 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12438 /* "redistribute" configuration. */
12439 vty_out(vty
, " redistribute %s",
12440 zebra_route_string(i
));
12442 vty_out(vty
, " %d", red
->instance
);
12443 if (red
->redist_metric_flag
)
12444 vty_out(vty
, " metric %u",
12445 red
->redist_metric
);
12446 if (red
->rmap
.name
)
12447 vty_out(vty
, " route-map %s",
12449 vty_out(vty
, "\n");
12455 /* This is part of the address-family block (unicast only) */
12456 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12461 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12462 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12463 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12464 bgp
->vpn_policy
[afi
]
12465 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12467 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12468 bgp
->vpn_policy
[afi
]
12469 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12471 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12472 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12473 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12474 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12477 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12478 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12480 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12483 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12484 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12485 bgp
->vpn_policy
[afi
].tovpn_label
);
12488 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12489 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12490 char buf
[RD_ADDRSTRLEN
];
12491 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12492 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12495 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12496 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12498 char buf
[PREFIX_STRLEN
];
12499 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12500 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12503 vty_out(vty
, "%*snexthop vpn export %s\n",
12507 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12508 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12510 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12511 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12513 char *b
= ecommunity_ecom2str(
12514 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12515 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12516 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12517 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12519 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12520 char *b
= ecommunity_ecom2str(
12521 bgp
->vpn_policy
[afi
]
12522 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12523 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12524 ECOMMUNITY_ROUTE_TARGET
);
12525 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12526 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12528 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12529 char *b
= ecommunity_ecom2str(
12530 bgp
->vpn_policy
[afi
]
12531 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12532 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12533 ECOMMUNITY_ROUTE_TARGET
);
12534 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12535 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12539 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12540 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12541 bgp
->vpn_policy
[afi
]
12542 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12544 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12545 char *b
= ecommunity_ecom2str(
12546 bgp
->vpn_policy
[afi
]
12547 .import_redirect_rtlist
,
12548 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12549 ECOMMUNITY_ROUTE_TARGET
);
12551 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12552 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12557 /* BGP node structure. */
12558 static struct cmd_node bgp_node
= {
12559 BGP_NODE
, "%s(config-router)# ", 1,
12562 static struct cmd_node bgp_ipv4_unicast_node
= {
12563 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12566 static struct cmd_node bgp_ipv4_multicast_node
= {
12567 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12570 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12571 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12574 static struct cmd_node bgp_ipv6_unicast_node
= {
12575 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12578 static struct cmd_node bgp_ipv6_multicast_node
= {
12579 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12582 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12583 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12586 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12587 "%s(config-router-af)# ", 1};
12589 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12590 "%s(config-router-af-vpnv6)# ", 1};
12592 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12593 "%s(config-router-evpn)# ", 1};
12595 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12596 "%s(config-router-af-vni)# ", 1};
12598 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12599 "%s(config-router-af)# ", 1};
12601 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12602 "%s(config-router-af-vpnv6)# ", 1};
12604 static void community_list_vty(void);
12606 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12610 struct listnode
*lnbgp
, *lnpeer
;
12612 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12613 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12614 /* only provide suggestions on the appropriate input
12616 * they'll otherwise show up multiple times */
12617 enum cmd_token_type match_type
;
12618 char *name
= peer
->host
;
12620 if (peer
->conf_if
) {
12621 match_type
= VARIABLE_TKN
;
12622 name
= peer
->conf_if
;
12623 } else if (strchr(peer
->host
, ':'))
12624 match_type
= IPV6_TKN
;
12626 match_type
= IPV4_TKN
;
12628 if (token
->type
!= match_type
)
12631 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12636 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12637 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12638 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12639 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12640 {.completions
= NULL
}};
12642 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12645 struct peer_group
*group
;
12646 struct listnode
*lnbgp
, *lnpeer
;
12648 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12649 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12650 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12655 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12656 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12657 {.completions
= NULL
} };
12659 void bgp_vty_init(void)
12661 cmd_variable_handler_register(bgp_var_neighbor
);
12662 cmd_variable_handler_register(bgp_var_peergroup
);
12664 /* Install bgp top node. */
12665 install_node(&bgp_node
, bgp_config_write
);
12666 install_node(&bgp_ipv4_unicast_node
, NULL
);
12667 install_node(&bgp_ipv4_multicast_node
, NULL
);
12668 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12669 install_node(&bgp_ipv6_unicast_node
, NULL
);
12670 install_node(&bgp_ipv6_multicast_node
, NULL
);
12671 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12672 install_node(&bgp_vpnv4_node
, NULL
);
12673 install_node(&bgp_vpnv6_node
, NULL
);
12674 install_node(&bgp_evpn_node
, NULL
);
12675 install_node(&bgp_evpn_vni_node
, NULL
);
12676 install_node(&bgp_flowspecv4_node
, NULL
);
12677 install_node(&bgp_flowspecv6_node
, NULL
);
12679 /* Install default VTY commands to new nodes. */
12680 install_default(BGP_NODE
);
12681 install_default(BGP_IPV4_NODE
);
12682 install_default(BGP_IPV4M_NODE
);
12683 install_default(BGP_IPV4L_NODE
);
12684 install_default(BGP_IPV6_NODE
);
12685 install_default(BGP_IPV6M_NODE
);
12686 install_default(BGP_IPV6L_NODE
);
12687 install_default(BGP_VPNV4_NODE
);
12688 install_default(BGP_VPNV6_NODE
);
12689 install_default(BGP_FLOWSPECV4_NODE
);
12690 install_default(BGP_FLOWSPECV6_NODE
);
12691 install_default(BGP_EVPN_NODE
);
12692 install_default(BGP_EVPN_VNI_NODE
);
12694 /* "bgp multiple-instance" commands. */
12695 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12696 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12698 /* "bgp config-type" commands. */
12699 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12700 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12702 /* "bgp local-mac" hidden commands. */
12703 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12704 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12706 /* bgp route-map delay-timer commands. */
12707 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12708 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12710 /* Dummy commands (Currently not supported) */
12711 install_element(BGP_NODE
, &no_synchronization_cmd
);
12712 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12714 /* "router bgp" commands. */
12715 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12717 /* "no router bgp" commands. */
12718 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12720 /* "bgp router-id" commands. */
12721 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12722 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12724 /* "bgp cluster-id" commands. */
12725 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12726 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12728 /* "bgp confederation" commands. */
12729 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12730 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12732 /* "bgp confederation peers" commands. */
12733 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12734 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12736 /* bgp max-med command */
12737 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12738 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12739 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12740 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12741 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12743 /* bgp disable-ebgp-connected-nh-check */
12744 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12745 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12747 /* bgp update-delay command */
12748 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12749 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12750 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12752 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12753 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12754 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12755 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12757 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12758 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12760 /* "maximum-paths" commands. */
12761 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12762 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12763 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12764 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12765 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12766 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12767 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12768 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12769 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12770 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12771 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12772 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12773 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12774 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12775 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12777 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12778 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12779 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12780 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12781 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12783 /* "timers bgp" commands. */
12784 install_element(BGP_NODE
, &bgp_timers_cmd
);
12785 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12787 /* route-map delay-timer commands - per instance for backwards compat.
12789 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12790 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12792 /* "bgp client-to-client reflection" commands */
12793 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12794 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12796 /* "bgp always-compare-med" commands */
12797 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12798 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12800 /* "bgp deterministic-med" commands */
12801 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12802 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12804 /* "bgp graceful-restart" commands */
12805 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12806 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12807 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12808 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12809 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12810 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12812 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12813 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12815 /* "bgp graceful-shutdown" commands */
12816 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12817 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12819 /* "bgp fast-external-failover" commands */
12820 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12821 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12823 /* "bgp enforce-first-as" commands */
12824 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12826 /* "bgp bestpath compare-routerid" commands */
12827 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12828 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12830 /* "bgp bestpath as-path ignore" commands */
12831 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12832 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12834 /* "bgp bestpath as-path confed" commands */
12835 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12836 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12838 /* "bgp bestpath as-path multipath-relax" commands */
12839 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12840 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12842 /* "bgp log-neighbor-changes" commands */
12843 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12844 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12846 /* "bgp bestpath med" commands */
12847 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12848 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12850 /* "no bgp default ipv4-unicast" commands. */
12851 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12852 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12854 /* "bgp network import-check" commands. */
12855 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12856 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12857 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12859 /* "bgp default local-preference" commands. */
12860 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12861 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12863 /* bgp default show-hostname */
12864 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12865 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12867 /* "bgp default subgroup-pkt-queue-max" commands. */
12868 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12869 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12871 /* bgp ibgp-allow-policy-mods command */
12872 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12873 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12875 /* "bgp listen limit" commands. */
12876 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12877 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12879 /* "bgp listen range" commands. */
12880 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12881 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12883 /* "bgp default shutdown" command */
12884 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12886 /* "neighbor remote-as" commands. */
12887 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12888 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12889 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12890 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12891 install_element(BGP_NODE
,
12892 &neighbor_interface_v6only_config_remote_as_cmd
);
12893 install_element(BGP_NODE
, &no_neighbor_cmd
);
12894 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12896 /* "neighbor peer-group" commands. */
12897 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12898 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12899 install_element(BGP_NODE
,
12900 &no_neighbor_interface_peer_group_remote_as_cmd
);
12902 /* "neighbor local-as" commands. */
12903 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12904 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12905 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12906 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12908 /* "neighbor solo" commands. */
12909 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12910 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12912 /* "neighbor password" commands. */
12913 install_element(BGP_NODE
, &neighbor_password_cmd
);
12914 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12916 /* "neighbor activate" commands. */
12917 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12918 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12919 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12920 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12921 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12922 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12923 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12924 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12925 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12926 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12927 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12928 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12930 /* "no neighbor activate" commands. */
12931 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12932 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12933 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12934 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12935 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12936 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12937 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12938 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12939 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12940 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12941 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12942 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12944 /* "neighbor peer-group" set commands. */
12945 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12946 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12947 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12948 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12949 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12950 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12951 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12952 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12953 install_element(BGP_FLOWSPECV4_NODE
,
12954 &neighbor_set_peer_group_hidden_cmd
);
12955 install_element(BGP_FLOWSPECV6_NODE
,
12956 &neighbor_set_peer_group_hidden_cmd
);
12958 /* "no neighbor peer-group unset" commands. */
12959 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12960 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12961 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12962 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12963 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12964 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12965 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12966 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12967 install_element(BGP_FLOWSPECV4_NODE
,
12968 &no_neighbor_set_peer_group_hidden_cmd
);
12969 install_element(BGP_FLOWSPECV6_NODE
,
12970 &no_neighbor_set_peer_group_hidden_cmd
);
12972 /* "neighbor softreconfiguration inbound" commands.*/
12973 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12974 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12975 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12976 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12977 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12978 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12979 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12980 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12981 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12982 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12983 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12984 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12985 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12986 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12987 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12988 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12989 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12990 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12991 install_element(BGP_FLOWSPECV4_NODE
,
12992 &neighbor_soft_reconfiguration_cmd
);
12993 install_element(BGP_FLOWSPECV4_NODE
,
12994 &no_neighbor_soft_reconfiguration_cmd
);
12995 install_element(BGP_FLOWSPECV6_NODE
,
12996 &neighbor_soft_reconfiguration_cmd
);
12997 install_element(BGP_FLOWSPECV6_NODE
,
12998 &no_neighbor_soft_reconfiguration_cmd
);
13000 /* "neighbor attribute-unchanged" commands. */
13001 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13002 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13003 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13004 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13005 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13006 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13007 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13008 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13009 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13010 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13011 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13012 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13013 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13014 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13015 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13016 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13017 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13018 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13020 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13021 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13023 /* "nexthop-local unchanged" commands */
13024 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13025 install_element(BGP_IPV6_NODE
,
13026 &no_neighbor_nexthop_local_unchanged_cmd
);
13028 /* "neighbor next-hop-self" commands. */
13029 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13030 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13031 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13032 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13033 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13034 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13035 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13036 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13037 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13038 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13039 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13040 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13041 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13042 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13043 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13044 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13045 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13046 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13047 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13048 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13050 /* "neighbor next-hop-self force" commands. */
13051 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13052 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13053 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13054 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13055 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13056 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13057 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13058 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13059 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13060 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13061 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13062 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13063 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13064 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13065 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13066 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13067 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13068 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13070 /* "neighbor as-override" commands. */
13071 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13072 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13073 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13074 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13075 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13076 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13077 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13078 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13079 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13080 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13081 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13082 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13083 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13084 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13085 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13086 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13087 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13088 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13090 /* "neighbor remove-private-AS" commands. */
13091 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13092 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13093 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13094 install_element(BGP_NODE
,
13095 &no_neighbor_remove_private_as_all_hidden_cmd
);
13096 install_element(BGP_NODE
,
13097 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13098 install_element(BGP_NODE
,
13099 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13100 install_element(BGP_NODE
,
13101 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13104 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13105 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13106 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13107 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13108 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13109 install_element(BGP_IPV4_NODE
,
13110 &neighbor_remove_private_as_replace_as_cmd
);
13111 install_element(BGP_IPV4_NODE
,
13112 &no_neighbor_remove_private_as_replace_as_cmd
);
13113 install_element(BGP_IPV4_NODE
,
13114 &neighbor_remove_private_as_all_replace_as_cmd
);
13115 install_element(BGP_IPV4_NODE
,
13116 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13117 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13118 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13119 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13120 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13121 install_element(BGP_IPV4M_NODE
,
13122 &neighbor_remove_private_as_replace_as_cmd
);
13123 install_element(BGP_IPV4M_NODE
,
13124 &no_neighbor_remove_private_as_replace_as_cmd
);
13125 install_element(BGP_IPV4M_NODE
,
13126 &neighbor_remove_private_as_all_replace_as_cmd
);
13127 install_element(BGP_IPV4M_NODE
,
13128 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13129 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13130 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13131 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13132 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13133 install_element(BGP_IPV4L_NODE
,
13134 &neighbor_remove_private_as_replace_as_cmd
);
13135 install_element(BGP_IPV4L_NODE
,
13136 &no_neighbor_remove_private_as_replace_as_cmd
);
13137 install_element(BGP_IPV4L_NODE
,
13138 &neighbor_remove_private_as_all_replace_as_cmd
);
13139 install_element(BGP_IPV4L_NODE
,
13140 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13141 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13142 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13143 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13144 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13145 install_element(BGP_IPV6_NODE
,
13146 &neighbor_remove_private_as_replace_as_cmd
);
13147 install_element(BGP_IPV6_NODE
,
13148 &no_neighbor_remove_private_as_replace_as_cmd
);
13149 install_element(BGP_IPV6_NODE
,
13150 &neighbor_remove_private_as_all_replace_as_cmd
);
13151 install_element(BGP_IPV6_NODE
,
13152 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13153 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13154 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13155 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13156 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13157 install_element(BGP_IPV6M_NODE
,
13158 &neighbor_remove_private_as_replace_as_cmd
);
13159 install_element(BGP_IPV6M_NODE
,
13160 &no_neighbor_remove_private_as_replace_as_cmd
);
13161 install_element(BGP_IPV6M_NODE
,
13162 &neighbor_remove_private_as_all_replace_as_cmd
);
13163 install_element(BGP_IPV6M_NODE
,
13164 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13165 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13166 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13167 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13168 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13169 install_element(BGP_IPV6L_NODE
,
13170 &neighbor_remove_private_as_replace_as_cmd
);
13171 install_element(BGP_IPV6L_NODE
,
13172 &no_neighbor_remove_private_as_replace_as_cmd
);
13173 install_element(BGP_IPV6L_NODE
,
13174 &neighbor_remove_private_as_all_replace_as_cmd
);
13175 install_element(BGP_IPV6L_NODE
,
13176 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13177 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13178 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13179 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13180 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13181 install_element(BGP_VPNV4_NODE
,
13182 &neighbor_remove_private_as_replace_as_cmd
);
13183 install_element(BGP_VPNV4_NODE
,
13184 &no_neighbor_remove_private_as_replace_as_cmd
);
13185 install_element(BGP_VPNV4_NODE
,
13186 &neighbor_remove_private_as_all_replace_as_cmd
);
13187 install_element(BGP_VPNV4_NODE
,
13188 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13189 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13190 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13191 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13192 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13193 install_element(BGP_VPNV6_NODE
,
13194 &neighbor_remove_private_as_replace_as_cmd
);
13195 install_element(BGP_VPNV6_NODE
,
13196 &no_neighbor_remove_private_as_replace_as_cmd
);
13197 install_element(BGP_VPNV6_NODE
,
13198 &neighbor_remove_private_as_all_replace_as_cmd
);
13199 install_element(BGP_VPNV6_NODE
,
13200 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13202 /* "neighbor send-community" commands.*/
13203 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13204 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13205 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13206 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13207 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13208 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13209 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13210 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13211 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13212 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13213 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13214 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13215 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13216 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13217 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13218 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13219 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13220 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13221 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13222 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13223 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13224 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13225 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13226 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13227 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13228 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13229 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13230 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13231 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13232 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13233 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13234 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13235 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13236 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13237 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13238 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13240 /* "neighbor route-reflector" commands.*/
13241 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13242 install_element(BGP_NODE
,
13243 &no_neighbor_route_reflector_client_hidden_cmd
);
13244 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13245 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13246 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13247 install_element(BGP_IPV4M_NODE
,
13248 &no_neighbor_route_reflector_client_cmd
);
13249 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13250 install_element(BGP_IPV4L_NODE
,
13251 &no_neighbor_route_reflector_client_cmd
);
13252 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13253 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13254 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13255 install_element(BGP_IPV6M_NODE
,
13256 &no_neighbor_route_reflector_client_cmd
);
13257 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13258 install_element(BGP_IPV6L_NODE
,
13259 &no_neighbor_route_reflector_client_cmd
);
13260 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13261 install_element(BGP_VPNV4_NODE
,
13262 &no_neighbor_route_reflector_client_cmd
);
13263 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13264 install_element(BGP_VPNV6_NODE
,
13265 &no_neighbor_route_reflector_client_cmd
);
13266 install_element(BGP_FLOWSPECV4_NODE
,
13267 &neighbor_route_reflector_client_cmd
);
13268 install_element(BGP_FLOWSPECV4_NODE
,
13269 &no_neighbor_route_reflector_client_cmd
);
13270 install_element(BGP_FLOWSPECV6_NODE
,
13271 &neighbor_route_reflector_client_cmd
);
13272 install_element(BGP_FLOWSPECV6_NODE
,
13273 &no_neighbor_route_reflector_client_cmd
);
13274 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13275 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13277 /* "neighbor route-server" commands.*/
13278 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13279 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13280 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13281 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13282 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13283 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13284 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13285 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13286 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13287 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13288 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13289 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13290 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13291 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13292 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13293 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13294 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13295 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13296 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13297 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13298 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13299 install_element(BGP_FLOWSPECV4_NODE
,
13300 &no_neighbor_route_server_client_cmd
);
13301 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13302 install_element(BGP_FLOWSPECV6_NODE
,
13303 &no_neighbor_route_server_client_cmd
);
13305 /* "neighbor addpath-tx-all-paths" commands.*/
13306 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13307 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13308 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13309 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13310 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13311 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13312 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13313 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13314 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13315 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13316 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13317 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13318 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13319 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13320 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13321 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13322 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13323 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13325 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13326 install_element(BGP_NODE
,
13327 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13328 install_element(BGP_NODE
,
13329 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13330 install_element(BGP_IPV4_NODE
,
13331 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13332 install_element(BGP_IPV4_NODE
,
13333 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13334 install_element(BGP_IPV4M_NODE
,
13335 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13336 install_element(BGP_IPV4M_NODE
,
13337 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13338 install_element(BGP_IPV4L_NODE
,
13339 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13340 install_element(BGP_IPV4L_NODE
,
13341 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13342 install_element(BGP_IPV6_NODE
,
13343 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13344 install_element(BGP_IPV6_NODE
,
13345 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13346 install_element(BGP_IPV6M_NODE
,
13347 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13348 install_element(BGP_IPV6M_NODE
,
13349 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13350 install_element(BGP_IPV6L_NODE
,
13351 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13352 install_element(BGP_IPV6L_NODE
,
13353 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13354 install_element(BGP_VPNV4_NODE
,
13355 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13356 install_element(BGP_VPNV4_NODE
,
13357 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13358 install_element(BGP_VPNV6_NODE
,
13359 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13360 install_element(BGP_VPNV6_NODE
,
13361 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13363 /* "neighbor passive" commands. */
13364 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13365 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13368 /* "neighbor shutdown" commands. */
13369 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13370 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13371 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13372 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13374 /* "neighbor capability extended-nexthop" commands.*/
13375 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13376 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13378 /* "neighbor capability orf prefix-list" commands.*/
13379 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13380 install_element(BGP_NODE
,
13381 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13382 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13383 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13384 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13385 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13386 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13387 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13388 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13389 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13390 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13391 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13392 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13393 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13395 /* "neighbor capability dynamic" commands.*/
13396 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13397 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13399 /* "neighbor dont-capability-negotiate" commands. */
13400 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13401 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13403 /* "neighbor ebgp-multihop" commands. */
13404 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13405 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13406 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13408 /* "neighbor disable-connected-check" commands. */
13409 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13410 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13412 /* "neighbor enforce-first-as" commands. */
13413 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13414 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13416 /* "neighbor description" commands. */
13417 install_element(BGP_NODE
, &neighbor_description_cmd
);
13418 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13419 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13421 /* "neighbor update-source" commands. "*/
13422 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13423 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13425 /* "neighbor default-originate" commands. */
13426 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13427 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13428 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13429 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13430 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13431 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13432 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13433 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13434 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13435 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13436 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13437 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13438 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13439 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13440 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13441 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13442 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13443 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13444 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13445 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13446 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13448 /* "neighbor port" commands. */
13449 install_element(BGP_NODE
, &neighbor_port_cmd
);
13450 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13452 /* "neighbor weight" commands. */
13453 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13454 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13456 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13457 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13458 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13459 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13460 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13461 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13462 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13463 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13464 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13465 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13466 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13467 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13468 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13469 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13470 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13471 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13473 /* "neighbor override-capability" commands. */
13474 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13475 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13477 /* "neighbor strict-capability-match" commands. */
13478 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13479 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13481 /* "neighbor timers" commands. */
13482 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13483 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13485 /* "neighbor timers connect" commands. */
13486 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13487 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13489 /* "neighbor advertisement-interval" commands. */
13490 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13491 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13493 /* "neighbor interface" commands. */
13494 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13495 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13497 /* "neighbor distribute" commands. */
13498 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13499 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13500 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13501 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13502 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13503 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13504 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13505 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13506 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13507 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13508 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13509 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13510 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13511 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13512 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13513 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13514 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13515 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13517 /* "neighbor prefix-list" commands. */
13518 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13519 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13520 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13521 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13522 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13523 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13524 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13525 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13526 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13527 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13528 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13529 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13530 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13531 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13532 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13533 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13534 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13535 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13536 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13537 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13538 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13539 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13541 /* "neighbor filter-list" commands. */
13542 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13543 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13544 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13545 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13546 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13547 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13548 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13549 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13550 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13551 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13552 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13553 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13554 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13555 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13556 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13557 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13558 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13559 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13560 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13561 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13562 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13563 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13565 /* "neighbor route-map" commands. */
13566 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13567 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13568 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13569 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13570 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13571 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13572 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13573 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13574 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13575 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13576 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13577 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13578 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13579 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13580 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13581 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13582 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13583 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13584 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13585 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13586 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13587 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13588 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13589 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13591 /* "neighbor unsuppress-map" commands. */
13592 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13593 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13594 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13595 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13596 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13597 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13598 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13599 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13600 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13601 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13602 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13603 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13604 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13605 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13606 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13607 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13608 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13609 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13611 /* "neighbor maximum-prefix" commands. */
13612 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13613 install_element(BGP_NODE
,
13614 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13615 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13616 install_element(BGP_NODE
,
13617 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13618 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13619 install_element(BGP_NODE
,
13620 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13621 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13622 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13623 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13624 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13625 install_element(BGP_IPV4_NODE
,
13626 &neighbor_maximum_prefix_threshold_warning_cmd
);
13627 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13628 install_element(BGP_IPV4_NODE
,
13629 &neighbor_maximum_prefix_threshold_restart_cmd
);
13630 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13631 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13632 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13633 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13634 install_element(BGP_IPV4M_NODE
,
13635 &neighbor_maximum_prefix_threshold_warning_cmd
);
13636 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13637 install_element(BGP_IPV4M_NODE
,
13638 &neighbor_maximum_prefix_threshold_restart_cmd
);
13639 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13640 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13641 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13642 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13643 install_element(BGP_IPV4L_NODE
,
13644 &neighbor_maximum_prefix_threshold_warning_cmd
);
13645 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13646 install_element(BGP_IPV4L_NODE
,
13647 &neighbor_maximum_prefix_threshold_restart_cmd
);
13648 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13649 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13650 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13651 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13652 install_element(BGP_IPV6_NODE
,
13653 &neighbor_maximum_prefix_threshold_warning_cmd
);
13654 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13655 install_element(BGP_IPV6_NODE
,
13656 &neighbor_maximum_prefix_threshold_restart_cmd
);
13657 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13658 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13659 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13660 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13661 install_element(BGP_IPV6M_NODE
,
13662 &neighbor_maximum_prefix_threshold_warning_cmd
);
13663 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13664 install_element(BGP_IPV6M_NODE
,
13665 &neighbor_maximum_prefix_threshold_restart_cmd
);
13666 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13667 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13668 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13669 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13670 install_element(BGP_IPV6L_NODE
,
13671 &neighbor_maximum_prefix_threshold_warning_cmd
);
13672 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13673 install_element(BGP_IPV6L_NODE
,
13674 &neighbor_maximum_prefix_threshold_restart_cmd
);
13675 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13676 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13677 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13678 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13679 install_element(BGP_VPNV4_NODE
,
13680 &neighbor_maximum_prefix_threshold_warning_cmd
);
13681 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13682 install_element(BGP_VPNV4_NODE
,
13683 &neighbor_maximum_prefix_threshold_restart_cmd
);
13684 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13685 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13686 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13687 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13688 install_element(BGP_VPNV6_NODE
,
13689 &neighbor_maximum_prefix_threshold_warning_cmd
);
13690 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13691 install_element(BGP_VPNV6_NODE
,
13692 &neighbor_maximum_prefix_threshold_restart_cmd
);
13693 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13695 /* "neighbor allowas-in" */
13696 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13697 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13698 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13699 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13700 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13701 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13702 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13703 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13704 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13705 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13706 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13707 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13708 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13709 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13710 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13711 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13712 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13713 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13714 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13715 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13717 /* address-family commands. */
13718 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13719 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13720 #ifdef KEEP_OLD_VPN_COMMANDS
13721 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13722 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13723 #endif /* KEEP_OLD_VPN_COMMANDS */
13725 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13727 /* "exit-address-family" command. */
13728 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13729 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13730 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13731 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13732 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13733 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13734 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13735 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13736 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13737 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13738 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13740 /* "clear ip bgp commands" */
13741 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13743 /* clear ip bgp prefix */
13744 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13745 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13746 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13748 /* "show [ip] bgp summary" commands. */
13749 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13750 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13751 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13752 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13753 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13754 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13755 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13757 /* "show [ip] bgp neighbors" commands. */
13758 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13760 /* "show [ip] bgp peer-group" commands. */
13761 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13763 /* "show [ip] bgp paths" commands. */
13764 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13766 /* "show [ip] bgp community" commands. */
13767 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13769 /* "show ip bgp large-community" commands. */
13770 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13771 /* "show [ip] bgp attribute-info" commands. */
13772 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13773 /* "show [ip] bgp route-leak" command */
13774 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13776 /* "redistribute" commands. */
13777 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13778 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13779 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13780 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13781 install_element(BGP_NODE
,
13782 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13783 install_element(BGP_NODE
,
13784 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13785 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13786 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13787 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13788 install_element(BGP_NODE
,
13789 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13790 install_element(BGP_NODE
,
13791 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13792 install_element(BGP_NODE
,
13793 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13794 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13795 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13796 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13797 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13798 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13799 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13800 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13801 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13802 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13803 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13804 install_element(BGP_IPV4_NODE
,
13805 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13806 install_element(BGP_IPV4_NODE
,
13807 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13808 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13809 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13810 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13811 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13812 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13813 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13815 /* import|export vpn [route-map WORD] */
13816 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13817 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13819 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13820 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13822 /* ttl_security commands */
13823 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13824 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13826 /* "show [ip] bgp memory" commands. */
13827 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13829 /* "show bgp martian next-hop" */
13830 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13832 /* "show [ip] bgp views" commands. */
13833 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13835 /* "show [ip] bgp vrfs" commands. */
13836 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13838 /* Community-list. */
13839 community_list_vty();
13841 /* vpn-policy commands */
13842 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13843 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13844 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13845 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13846 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13847 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13848 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13849 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13850 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13851 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13852 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13853 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13855 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13856 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13858 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13859 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13860 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13861 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13862 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13863 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13864 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13865 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13866 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13867 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13868 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13869 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13872 #include "memory.h"
13873 #include "bgp_regex.h"
13874 #include "bgp_clist.h"
13875 #include "bgp_ecommunity.h"
13877 /* VTY functions. */
13879 /* Direction value to string conversion. */
13880 static const char *community_direct_str(int direct
)
13883 case COMMUNITY_DENY
:
13885 case COMMUNITY_PERMIT
:
13892 /* Display error string. */
13893 static void community_list_perror(struct vty
*vty
, int ret
)
13896 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13897 vty_out(vty
, "%% Can't find community-list\n");
13899 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13900 vty_out(vty
, "%% Malformed community-list value\n");
13902 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13904 "%% Community name conflict, previously defined as standard community\n");
13906 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13908 "%% Community name conflict, previously defined as expanded community\n");
13913 /* "community-list" keyword help string. */
13914 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13916 /*community-list standard */
13917 DEFUN (community_list_standard
,
13918 bgp_community_list_standard_cmd
,
13919 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13922 "Community list number (standard)\n"
13923 "Add an standard community-list entry\n"
13924 "Community list name\n"
13925 "Specify community to reject\n"
13926 "Specify community to accept\n"
13929 char *cl_name_or_number
= NULL
;
13931 int style
= COMMUNITY_LIST_STANDARD
;
13935 if (argv_find(argv
, argc
, "ip", &idx
)) {
13936 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
13937 vty_out(vty
, "if you are using this please migrate to the below command.\n");
13938 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
13939 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
13942 argv_find(argv
, argc
, "(1-99)", &idx
);
13943 argv_find(argv
, argc
, "WORD", &idx
);
13944 cl_name_or_number
= argv
[idx
]->arg
;
13945 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13947 argv_find(argv
, argc
, "AA:NN", &idx
);
13948 char *str
= argv_concat(argv
, argc
, idx
);
13950 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13953 XFREE(MTYPE_TMP
, str
);
13956 /* Display error string. */
13957 community_list_perror(vty
, ret
);
13958 return CMD_WARNING_CONFIG_FAILED
;
13961 return CMD_SUCCESS
;
13964 #if CONFDATE > 20191005
13965 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
13967 ALIAS (community_list_standard
,
13968 ip_community_list_standard_cmd
,
13969 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13972 "Community list number (standard)\n"
13973 "Add an standard community-list entry\n"
13974 "Community list name\n"
13975 "Specify community to reject\n"
13976 "Specify community to accept\n"
13979 DEFUN (no_community_list_standard_all
,
13980 no_bgp_community_list_standard_all_cmd
,
13981 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13985 "Community list number (standard)\n"
13986 "Add an standard community-list entry\n"
13987 "Community list name\n"
13988 "Specify community to reject\n"
13989 "Specify community to accept\n"
13992 char *cl_name_or_number
= NULL
;
13994 int style
= COMMUNITY_LIST_STANDARD
;
13998 if (argv_find(argv
, argc
, "ip", &idx
)) {
13999 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14000 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14001 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14002 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14005 argv_find(argv
, argc
, "(1-99)", &idx
);
14006 argv_find(argv
, argc
, "WORD", &idx
);
14007 cl_name_or_number
= argv
[idx
]->arg
;
14008 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14010 argv_find(argv
, argc
, "AA:NN", &idx
);
14011 char *str
= argv_concat(argv
, argc
, idx
);
14013 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14016 XFREE(MTYPE_TMP
, str
);
14019 community_list_perror(vty
, ret
);
14020 return CMD_WARNING_CONFIG_FAILED
;
14023 return CMD_SUCCESS
;
14025 ALIAS (no_community_list_standard_all
,
14026 no_ip_community_list_standard_all_cmd
,
14027 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14031 "Community list number (standard)\n"
14032 "Add an standard community-list entry\n"
14033 "Community list name\n"
14034 "Specify community to reject\n"
14035 "Specify community to accept\n"
14038 /*community-list expanded */
14039 DEFUN (community_list_expanded_all
,
14040 bgp_community_list_expanded_all_cmd
,
14041 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14044 "Community list number (expanded)\n"
14045 "Add an expanded community-list entry\n"
14046 "Community list name\n"
14047 "Specify community to reject\n"
14048 "Specify community to accept\n"
14051 char *cl_name_or_number
= NULL
;
14053 int style
= COMMUNITY_LIST_EXPANDED
;
14056 if (argv_find(argv
, argc
, "ip", &idx
)) {
14057 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14058 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14059 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14060 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14062 argv_find(argv
, argc
, "(100-500)", &idx
);
14063 argv_find(argv
, argc
, "WORD", &idx
);
14064 cl_name_or_number
= argv
[idx
]->arg
;
14065 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14067 argv_find(argv
, argc
, "AA:NN", &idx
);
14068 char *str
= argv_concat(argv
, argc
, idx
);
14070 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14073 XFREE(MTYPE_TMP
, str
);
14076 /* Display error string. */
14077 community_list_perror(vty
, ret
);
14078 return CMD_WARNING_CONFIG_FAILED
;
14081 return CMD_SUCCESS
;
14084 ALIAS (community_list_expanded_all
,
14085 ip_community_list_expanded_all_cmd
,
14086 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14089 "Community list number (expanded)\n"
14090 "Add an expanded community-list entry\n"
14091 "Community list name\n"
14092 "Specify community to reject\n"
14093 "Specify community to accept\n"
14096 DEFUN (no_community_list_expanded_all
,
14097 no_bgp_community_list_expanded_all_cmd
,
14098 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14102 "Community list number (expanded)\n"
14103 "Add an expanded community-list entry\n"
14104 "Community list name\n"
14105 "Specify community to reject\n"
14106 "Specify community to accept\n"
14109 char *cl_name_or_number
= NULL
;
14111 int style
= COMMUNITY_LIST_EXPANDED
;
14114 if (argv_find(argv
, argc
, "ip", &idx
)) {
14115 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14116 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14117 vty_out(vty
, "'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14118 zlog_warn("Deprecated option: 'no community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14120 argv_find(argv
, argc
, "(100-500)", &idx
);
14121 argv_find(argv
, argc
, "WORD", &idx
);
14122 cl_name_or_number
= argv
[idx
]->arg
;
14123 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14125 argv_find(argv
, argc
, "AA:NN", &idx
);
14126 char *str
= argv_concat(argv
, argc
, idx
);
14128 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14131 XFREE(MTYPE_TMP
, str
);
14134 community_list_perror(vty
, ret
);
14135 return CMD_WARNING_CONFIG_FAILED
;
14138 return CMD_SUCCESS
;
14141 ALIAS (no_community_list_expanded_all
,
14142 no_ip_community_list_expanded_all_cmd
,
14143 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14147 "Community list number (expanded)\n"
14148 "Add an expanded community-list entry\n"
14149 "Community list name\n"
14150 "Specify community to reject\n"
14151 "Specify community to accept\n"
14154 /* Return configuration string of community-list entry. */
14155 static const char *community_list_config_str(struct community_entry
*entry
)
14162 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14163 str
= community_str(entry
->u
.com
, false);
14164 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14165 str
= lcommunity_str(entry
->u
.lcom
, false);
14167 str
= entry
->config
;
14172 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14174 struct community_entry
*entry
;
14176 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14177 if (entry
== list
->head
) {
14178 if (all_digit(list
->name
))
14179 vty_out(vty
, "Community %s list %s\n",
14180 entry
->style
== COMMUNITY_LIST_STANDARD
14182 : "(expanded) access",
14185 vty_out(vty
, "Named Community %s list %s\n",
14186 entry
->style
== COMMUNITY_LIST_STANDARD
14192 vty_out(vty
, " %s\n",
14193 community_direct_str(entry
->direct
));
14195 vty_out(vty
, " %s %s\n",
14196 community_direct_str(entry
->direct
),
14197 community_list_config_str(entry
));
14201 DEFUN (show_community_list
,
14202 show_bgp_community_list_cmd
,
14203 "show bgp community-list",
14206 "List community-list\n")
14208 struct community_list
*list
;
14209 struct community_list_master
*cm
;
14212 if (argv_find(argv
, argc
, "ip", &idx
)) {
14213 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14214 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14215 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14216 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14218 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14220 return CMD_SUCCESS
;
14222 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14223 community_list_show(vty
, list
);
14225 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14226 community_list_show(vty
, list
);
14228 return CMD_SUCCESS
;
14231 ALIAS (show_community_list
,
14232 show_ip_community_list_cmd
,
14233 "show ip community-list",
14236 "List community-list\n")
14238 DEFUN (show_community_list_arg
,
14239 show_bgp_community_list_arg_cmd
,
14240 "show bgp community-list <(1-500)|WORD>",
14243 "List community-list\n"
14244 "Community-list number\n"
14245 "Community-list name\n")
14247 int idx_comm_list
= 3;
14248 struct community_list
*list
;
14251 if (argv_find(argv
, argc
, "ip", &idx
)) {
14252 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14253 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14254 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14255 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14257 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14258 COMMUNITY_LIST_MASTER
);
14260 vty_out(vty
, "%% Can't find community-list\n");
14261 return CMD_WARNING
;
14264 community_list_show(vty
, list
);
14266 return CMD_SUCCESS
;
14269 ALIAS (show_community_list_arg
,
14270 show_ip_community_list_arg_cmd
,
14271 "show ip community-list <(1-500)|WORD>",
14274 "List community-list\n"
14275 "Community-list number\n"
14276 "Community-list name\n")
14279 * Large Community code.
14281 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14282 struct cmd_token
**argv
, int style
,
14283 int reject_all_digit_name
)
14291 if (argv_find(argv
, argc
, "ip", &idx
)) {
14292 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14293 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14294 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14295 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14297 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14300 /* All digit name check. */
14302 argv_find(argv
, argc
, "WORD", &idx
);
14303 argv_find(argv
, argc
, "(1-99)", &idx
);
14304 argv_find(argv
, argc
, "(100-500)", &idx
);
14305 cl_name
= argv
[idx
]->arg
;
14306 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14307 vty_out(vty
, "%% Community name cannot have all digits\n");
14308 return CMD_WARNING_CONFIG_FAILED
;
14312 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14313 argv_find(argv
, argc
, "LINE", &idx
);
14314 /* Concat community string argument. */
14316 str
= argv_concat(argv
, argc
, idx
);
14320 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14322 /* Free temporary community list string allocated by
14325 XFREE(MTYPE_TMP
, str
);
14328 community_list_perror(vty
, ret
);
14329 return CMD_WARNING_CONFIG_FAILED
;
14331 return CMD_SUCCESS
;
14334 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14335 struct cmd_token
**argv
, int style
)
14342 if (argv_find(argv
, argc
, "ip", &idx
)) {
14343 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14344 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14345 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14346 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14348 argv_find(argv
, argc
, "permit", &idx
);
14349 argv_find(argv
, argc
, "deny", &idx
);
14352 /* Check the list direct. */
14353 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14354 direct
= COMMUNITY_PERMIT
;
14356 direct
= COMMUNITY_DENY
;
14359 argv_find(argv
, argc
, "LINE", &idx
);
14360 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14361 /* Concat community string argument. */
14362 str
= argv_concat(argv
, argc
, idx
);
14366 argv_find(argv
, argc
, "(1-99)", &idx
);
14367 argv_find(argv
, argc
, "(100-500)", &idx
);
14368 argv_find(argv
, argc
, "WORD", &idx
);
14370 /* Unset community list. */
14371 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14374 /* Free temporary community list string allocated by
14377 XFREE(MTYPE_TMP
, str
);
14380 community_list_perror(vty
, ret
);
14381 return CMD_WARNING_CONFIG_FAILED
;
14384 return CMD_SUCCESS
;
14387 /* "large-community-list" keyword help string. */
14388 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14389 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14391 #if CONFDATE > 20191005
14392 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14394 DEFUN (lcommunity_list_standard
,
14395 bgp_lcommunity_list_standard_cmd
,
14396 "bgp large-community-list (1-99) <deny|permit>",
14398 LCOMMUNITY_LIST_STR
14399 "Large Community list number (standard)\n"
14400 "Specify large community to reject\n"
14401 "Specify large community to accept\n")
14403 return lcommunity_list_set_vty(vty
, argc
, argv
,
14404 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14407 ALIAS (lcommunity_list_standard
,
14408 ip_lcommunity_list_standard_cmd
,
14409 "ip large-community-list (1-99) <deny|permit>",
14411 LCOMMUNITY_LIST_STR
14412 "Large Community list number (standard)\n"
14413 "Specify large community to reject\n"
14414 "Specify large community to accept\n")
14416 DEFUN (lcommunity_list_standard1
,
14417 bgp_lcommunity_list_standard1_cmd
,
14418 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14420 LCOMMUNITY_LIST_STR
14421 "Large Community list number (standard)\n"
14422 "Specify large community to reject\n"
14423 "Specify large community to accept\n"
14424 LCOMMUNITY_VAL_STR
)
14426 return lcommunity_list_set_vty(vty
, argc
, argv
,
14427 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14430 ALIAS (lcommunity_list_standard1
,
14431 ip_lcommunity_list_standard1_cmd
,
14432 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14434 LCOMMUNITY_LIST_STR
14435 "Large Community list number (standard)\n"
14436 "Specify large community to reject\n"
14437 "Specify large community to accept\n"
14438 LCOMMUNITY_VAL_STR
)
14440 DEFUN (lcommunity_list_expanded
,
14441 bgp_lcommunity_list_expanded_cmd
,
14442 "bgp large-community-list (100-500) <deny|permit> LINE...",
14444 LCOMMUNITY_LIST_STR
14445 "Large Community list number (expanded)\n"
14446 "Specify large community to reject\n"
14447 "Specify large community to accept\n"
14448 "An ordered list as a regular-expression\n")
14450 return lcommunity_list_set_vty(vty
, argc
, argv
,
14451 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14454 ALIAS (lcommunity_list_expanded
,
14455 ip_lcommunity_list_expanded_cmd
,
14456 "ip large-community-list (100-500) <deny|permit> LINE...",
14458 LCOMMUNITY_LIST_STR
14459 "Large Community list number (expanded)\n"
14460 "Specify large community to reject\n"
14461 "Specify large community to accept\n"
14462 "An ordered list as a regular-expression\n")
14464 DEFUN (lcommunity_list_name_standard
,
14465 bgp_lcommunity_list_name_standard_cmd
,
14466 "bgp large-community-list standard WORD <deny|permit>",
14468 LCOMMUNITY_LIST_STR
14469 "Specify standard large-community-list\n"
14470 "Large Community list name\n"
14471 "Specify large community to reject\n"
14472 "Specify large community to accept\n")
14474 return lcommunity_list_set_vty(vty
, argc
, argv
,
14475 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14478 ALIAS (lcommunity_list_name_standard
,
14479 ip_lcommunity_list_name_standard_cmd
,
14480 "ip large-community-list standard WORD <deny|permit>",
14482 LCOMMUNITY_LIST_STR
14483 "Specify standard large-community-list\n"
14484 "Large Community list name\n"
14485 "Specify large community to reject\n"
14486 "Specify large community to accept\n")
14488 DEFUN (lcommunity_list_name_standard1
,
14489 bgp_lcommunity_list_name_standard1_cmd
,
14490 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14492 LCOMMUNITY_LIST_STR
14493 "Specify standard large-community-list\n"
14494 "Large Community list name\n"
14495 "Specify large community to reject\n"
14496 "Specify large community to accept\n"
14497 LCOMMUNITY_VAL_STR
)
14499 return lcommunity_list_set_vty(vty
, argc
, argv
,
14500 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14503 ALIAS (lcommunity_list_name_standard1
,
14504 ip_lcommunity_list_name_standard1_cmd
,
14505 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14507 LCOMMUNITY_LIST_STR
14508 "Specify standard large-community-list\n"
14509 "Large Community list name\n"
14510 "Specify large community to reject\n"
14511 "Specify large community to accept\n"
14512 LCOMMUNITY_VAL_STR
)
14514 DEFUN (lcommunity_list_name_expanded
,
14515 bgp_lcommunity_list_name_expanded_cmd
,
14516 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14518 LCOMMUNITY_LIST_STR
14519 "Specify expanded large-community-list\n"
14520 "Large Community list name\n"
14521 "Specify large community to reject\n"
14522 "Specify large community to accept\n"
14523 "An ordered list as a regular-expression\n")
14525 return lcommunity_list_set_vty(vty
, argc
, argv
,
14526 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14529 ALIAS (lcommunity_list_name_expanded
,
14530 ip_lcommunity_list_name_expanded_cmd
,
14531 "ip large-community-list expanded WORD <deny|permit> LINE...",
14533 LCOMMUNITY_LIST_STR
14534 "Specify expanded large-community-list\n"
14535 "Large Community list name\n"
14536 "Specify large community to reject\n"
14537 "Specify large community to accept\n"
14538 "An ordered list as a regular-expression\n")
14540 DEFUN (no_lcommunity_list_standard_all
,
14541 no_bgp_lcommunity_list_standard_all_cmd
,
14542 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14545 LCOMMUNITY_LIST_STR
14546 "Large Community list number (standard)\n"
14547 "Large Community list number (expanded)\n"
14548 "Large Community list name\n")
14550 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14551 LARGE_COMMUNITY_LIST_STANDARD
);
14554 ALIAS (no_lcommunity_list_standard_all
,
14555 no_ip_lcommunity_list_standard_all_cmd
,
14556 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14559 LCOMMUNITY_LIST_STR
14560 "Large Community list number (standard)\n"
14561 "Large Community list number (expanded)\n"
14562 "Large Community list name\n")
14564 DEFUN (no_lcommunity_list_name_expanded_all
,
14565 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14566 "no bgp large-community-list expanded WORD",
14569 LCOMMUNITY_LIST_STR
14570 "Specify expanded large-community-list\n"
14571 "Large Community list name\n")
14573 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14574 LARGE_COMMUNITY_LIST_EXPANDED
);
14577 ALIAS (no_lcommunity_list_name_expanded_all
,
14578 no_ip_lcommunity_list_name_expanded_all_cmd
,
14579 "no ip large-community-list expanded WORD",
14582 LCOMMUNITY_LIST_STR
14583 "Specify expanded large-community-list\n"
14584 "Large Community list name\n")
14586 DEFUN (no_lcommunity_list_standard
,
14587 no_bgp_lcommunity_list_standard_cmd
,
14588 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14591 LCOMMUNITY_LIST_STR
14592 "Large Community list number (standard)\n"
14593 "Specify large community to reject\n"
14594 "Specify large community to accept\n"
14595 LCOMMUNITY_VAL_STR
)
14597 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14598 LARGE_COMMUNITY_LIST_STANDARD
);
14601 ALIAS (no_lcommunity_list_standard
,
14602 no_ip_lcommunity_list_standard_cmd
,
14603 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14606 LCOMMUNITY_LIST_STR
14607 "Large Community list number (standard)\n"
14608 "Specify large community to reject\n"
14609 "Specify large community to accept\n"
14610 LCOMMUNITY_VAL_STR
)
14612 DEFUN (no_lcommunity_list_expanded
,
14613 no_bgp_lcommunity_list_expanded_cmd
,
14614 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14617 LCOMMUNITY_LIST_STR
14618 "Large Community list number (expanded)\n"
14619 "Specify large community to reject\n"
14620 "Specify large community to accept\n"
14621 "An ordered list as a regular-expression\n")
14623 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14624 LARGE_COMMUNITY_LIST_EXPANDED
);
14627 ALIAS (no_lcommunity_list_expanded
,
14628 no_ip_lcommunity_list_expanded_cmd
,
14629 "no ip large-community-list (100-500) <deny|permit> LINE...",
14632 LCOMMUNITY_LIST_STR
14633 "Large Community list number (expanded)\n"
14634 "Specify large community to reject\n"
14635 "Specify large community to accept\n"
14636 "An ordered list as a regular-expression\n")
14638 DEFUN (no_lcommunity_list_name_standard
,
14639 no_bgp_lcommunity_list_name_standard_cmd
,
14640 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14643 LCOMMUNITY_LIST_STR
14644 "Specify standard large-community-list\n"
14645 "Large Community list name\n"
14646 "Specify large community to reject\n"
14647 "Specify large community to accept\n"
14648 LCOMMUNITY_VAL_STR
)
14650 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14651 LARGE_COMMUNITY_LIST_STANDARD
);
14654 ALIAS (no_lcommunity_list_name_standard
,
14655 no_ip_lcommunity_list_name_standard_cmd
,
14656 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14659 LCOMMUNITY_LIST_STR
14660 "Specify standard large-community-list\n"
14661 "Large Community list name\n"
14662 "Specify large community to reject\n"
14663 "Specify large community to accept\n"
14664 LCOMMUNITY_VAL_STR
)
14666 DEFUN (no_lcommunity_list_name_expanded
,
14667 no_bgp_lcommunity_list_name_expanded_cmd
,
14668 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14671 LCOMMUNITY_LIST_STR
14672 "Specify expanded large-community-list\n"
14673 "Large community list name\n"
14674 "Specify large community to reject\n"
14675 "Specify large community to accept\n"
14676 "An ordered list as a regular-expression\n")
14678 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14679 LARGE_COMMUNITY_LIST_EXPANDED
);
14682 ALIAS (no_lcommunity_list_name_expanded
,
14683 no_ip_lcommunity_list_name_expanded_cmd
,
14684 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14687 LCOMMUNITY_LIST_STR
14688 "Specify expanded large-community-list\n"
14689 "Large community list name\n"
14690 "Specify large community to reject\n"
14691 "Specify large community to accept\n"
14692 "An ordered list as a regular-expression\n")
14694 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14696 struct community_entry
*entry
;
14698 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14699 if (entry
== list
->head
) {
14700 if (all_digit(list
->name
))
14701 vty_out(vty
, "Large community %s list %s\n",
14702 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14704 : "(expanded) access",
14708 "Named large community %s list %s\n",
14709 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14715 vty_out(vty
, " %s\n",
14716 community_direct_str(entry
->direct
));
14718 vty_out(vty
, " %s %s\n",
14719 community_direct_str(entry
->direct
),
14720 community_list_config_str(entry
));
14724 DEFUN (show_lcommunity_list
,
14725 show_bgp_lcommunity_list_cmd
,
14726 "show bgp large-community-list",
14729 "List large-community list\n")
14731 struct community_list
*list
;
14732 struct community_list_master
*cm
;
14735 if (argv_find(argv
, argc
, "ip", &idx
)) {
14736 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14737 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14738 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14739 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14742 cm
= community_list_master_lookup(bgp_clist
,
14743 LARGE_COMMUNITY_LIST_MASTER
);
14745 return CMD_SUCCESS
;
14747 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14748 lcommunity_list_show(vty
, list
);
14750 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14751 lcommunity_list_show(vty
, list
);
14753 return CMD_SUCCESS
;
14756 ALIAS (show_lcommunity_list
,
14757 show_ip_lcommunity_list_cmd
,
14758 "show ip large-community-list",
14761 "List large-community list\n")
14763 DEFUN (show_lcommunity_list_arg
,
14764 show_bgp_lcommunity_list_arg_cmd
,
14765 "show bgp large-community-list <(1-500)|WORD>",
14768 "List large-community list\n"
14769 "large-community-list number\n"
14770 "large-community-list name\n")
14772 struct community_list
*list
;
14775 if (argv_find(argv
, argc
, "ip", &idx
)) {
14776 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14777 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14778 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14779 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14782 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14783 LARGE_COMMUNITY_LIST_MASTER
);
14785 vty_out(vty
, "%% Can't find extcommunity-list\n");
14786 return CMD_WARNING
;
14789 lcommunity_list_show(vty
, list
);
14791 return CMD_SUCCESS
;
14794 ALIAS (show_lcommunity_list_arg
,
14795 show_ip_lcommunity_list_arg_cmd
,
14796 "show ip large-community-list <(1-500)|WORD>",
14799 "List large-community list\n"
14800 "large-community-list number\n"
14801 "large-community-list name\n")
14803 /* "extcommunity-list" keyword help string. */
14804 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14805 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14807 DEFUN (extcommunity_list_standard
,
14808 bgp_extcommunity_list_standard_cmd
,
14809 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14811 EXTCOMMUNITY_LIST_STR
14812 "Extended Community list number (standard)\n"
14813 "Specify standard extcommunity-list\n"
14814 "Community list name\n"
14815 "Specify community to reject\n"
14816 "Specify community to accept\n"
14817 EXTCOMMUNITY_VAL_STR
)
14819 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14821 char *cl_number_or_name
= NULL
;
14824 if (argv_find(argv
, argc
, "ip", &idx
)) {
14825 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14826 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14827 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14828 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14830 argv_find(argv
, argc
, "(1-99)", &idx
);
14831 argv_find(argv
, argc
, "WORD", &idx
);
14832 cl_number_or_name
= argv
[idx
]->arg
;
14833 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14835 argv_find(argv
, argc
, "AA:NN", &idx
);
14836 char *str
= argv_concat(argv
, argc
, idx
);
14838 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14841 XFREE(MTYPE_TMP
, str
);
14844 community_list_perror(vty
, ret
);
14845 return CMD_WARNING_CONFIG_FAILED
;
14848 return CMD_SUCCESS
;
14851 #if CONFDATE > 20191005
14852 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
14854 ALIAS (extcommunity_list_standard
,
14855 ip_extcommunity_list_standard_cmd
,
14856 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14858 EXTCOMMUNITY_LIST_STR
14859 "Extended Community list number (standard)\n"
14860 "Specify standard extcommunity-list\n"
14861 "Community list name\n"
14862 "Specify community to reject\n"
14863 "Specify community to accept\n"
14864 EXTCOMMUNITY_VAL_STR
)
14866 DEFUN (extcommunity_list_name_expanded
,
14867 bgp_extcommunity_list_name_expanded_cmd
,
14868 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14870 EXTCOMMUNITY_LIST_STR
14871 "Extended Community list number (expanded)\n"
14872 "Specify expanded extcommunity-list\n"
14873 "Extended Community list name\n"
14874 "Specify community to reject\n"
14875 "Specify community to accept\n"
14876 "An ordered list as a regular-expression\n")
14878 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14880 char *cl_number_or_name
= NULL
;
14883 if (argv_find(argv
, argc
, "ip", &idx
)) {
14884 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14885 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14886 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14887 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14890 argv_find(argv
, argc
, "(100-500)", &idx
);
14891 argv_find(argv
, argc
, "WORD", &idx
);
14892 cl_number_or_name
= argv
[idx
]->arg
;
14893 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14895 argv_find(argv
, argc
, "LINE", &idx
);
14896 char *str
= argv_concat(argv
, argc
, idx
);
14898 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14901 XFREE(MTYPE_TMP
, str
);
14904 community_list_perror(vty
, ret
);
14905 return CMD_WARNING_CONFIG_FAILED
;
14908 return CMD_SUCCESS
;
14911 ALIAS (extcommunity_list_name_expanded
,
14912 ip_extcommunity_list_name_expanded_cmd
,
14913 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14915 EXTCOMMUNITY_LIST_STR
14916 "Extended Community list number (expanded)\n"
14917 "Specify expanded extcommunity-list\n"
14918 "Extended Community list name\n"
14919 "Specify community to reject\n"
14920 "Specify community to accept\n"
14921 "An ordered list as a regular-expression\n")
14923 DEFUN (no_extcommunity_list_standard_all
,
14924 no_bgp_extcommunity_list_standard_all_cmd
,
14925 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14928 EXTCOMMUNITY_LIST_STR
14929 "Extended Community list number (standard)\n"
14930 "Specify standard extcommunity-list\n"
14931 "Community list name\n"
14932 "Specify community to reject\n"
14933 "Specify community to accept\n"
14934 EXTCOMMUNITY_VAL_STR
)
14936 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14938 char *cl_number_or_name
= NULL
;
14941 if (argv_find(argv
, argc
, "ip", &idx
)) {
14942 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14943 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14944 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
14945 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
14947 argv_find(argv
, argc
, "(1-99)", &idx
);
14948 argv_find(argv
, argc
, "WORD", &idx
);
14949 cl_number_or_name
= argv
[idx
]->arg
;
14950 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14952 argv_find(argv
, argc
, "AA:NN", &idx
);
14953 char *str
= argv_concat(argv
, argc
, idx
);
14955 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14958 XFREE(MTYPE_TMP
, str
);
14961 community_list_perror(vty
, ret
);
14962 return CMD_WARNING_CONFIG_FAILED
;
14965 return CMD_SUCCESS
;
14968 ALIAS (no_extcommunity_list_standard_all
,
14969 no_ip_extcommunity_list_standard_all_cmd
,
14970 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14973 EXTCOMMUNITY_LIST_STR
14974 "Extended Community list number (standard)\n"
14975 "Specify standard extcommunity-list\n"
14976 "Community list name\n"
14977 "Specify community to reject\n"
14978 "Specify community to accept\n"
14979 EXTCOMMUNITY_VAL_STR
)
14981 DEFUN (no_extcommunity_list_expanded_all
,
14982 no_bgp_extcommunity_list_expanded_all_cmd
,
14983 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14986 EXTCOMMUNITY_LIST_STR
14987 "Extended Community list number (expanded)\n"
14988 "Specify expanded extcommunity-list\n"
14989 "Extended Community list name\n"
14990 "Specify community to reject\n"
14991 "Specify community to accept\n"
14992 "An ordered list as a regular-expression\n")
14994 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14996 char *cl_number_or_name
= NULL
;
14999 if (argv_find(argv
, argc
, "ip", &idx
)) {
15000 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15001 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15002 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15003 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15005 argv_find(argv
, argc
, "(100-500)", &idx
);
15006 argv_find(argv
, argc
, "WORD", &idx
);
15007 cl_number_or_name
= argv
[idx
]->arg
;
15008 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15010 argv_find(argv
, argc
, "LINE", &idx
);
15011 char *str
= argv_concat(argv
, argc
, idx
);
15013 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15016 XFREE(MTYPE_TMP
, str
);
15019 community_list_perror(vty
, ret
);
15020 return CMD_WARNING_CONFIG_FAILED
;
15023 return CMD_SUCCESS
;
15026 ALIAS (no_extcommunity_list_expanded_all
,
15027 no_ip_extcommunity_list_expanded_all_cmd
,
15028 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15031 EXTCOMMUNITY_LIST_STR
15032 "Extended Community list number (expanded)\n"
15033 "Specify expanded extcommunity-list\n"
15034 "Extended Community list name\n"
15035 "Specify community to reject\n"
15036 "Specify community to accept\n"
15037 "An ordered list as a regular-expression\n")
15039 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15041 struct community_entry
*entry
;
15043 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15044 if (entry
== list
->head
) {
15045 if (all_digit(list
->name
))
15046 vty_out(vty
, "Extended community %s list %s\n",
15047 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15049 : "(expanded) access",
15053 "Named extended community %s list %s\n",
15054 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15060 vty_out(vty
, " %s\n",
15061 community_direct_str(entry
->direct
));
15063 vty_out(vty
, " %s %s\n",
15064 community_direct_str(entry
->direct
),
15065 community_list_config_str(entry
));
15069 DEFUN (show_extcommunity_list
,
15070 show_bgp_extcommunity_list_cmd
,
15071 "show bgp extcommunity-list",
15074 "List extended-community list\n")
15076 struct community_list
*list
;
15077 struct community_list_master
*cm
;
15080 if (argv_find(argv
, argc
, "ip", &idx
)) {
15081 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15082 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15083 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15084 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15086 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15088 return CMD_SUCCESS
;
15090 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15091 extcommunity_list_show(vty
, list
);
15093 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15094 extcommunity_list_show(vty
, list
);
15096 return CMD_SUCCESS
;
15099 ALIAS (show_extcommunity_list
,
15100 show_ip_extcommunity_list_cmd
,
15101 "show ip extcommunity-list",
15104 "List extended-community list\n")
15106 DEFUN (show_extcommunity_list_arg
,
15107 show_bgp_extcommunity_list_arg_cmd
,
15108 "show bgp extcommunity-list <(1-500)|WORD>",
15111 "List extended-community list\n"
15112 "Extcommunity-list number\n"
15113 "Extcommunity-list name\n")
15115 int idx_comm_list
= 3;
15116 struct community_list
*list
;
15119 if (argv_find(argv
, argc
, "ip", &idx
)) {
15120 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15121 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15122 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15123 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15125 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
15126 EXTCOMMUNITY_LIST_MASTER
);
15128 vty_out(vty
, "%% Can't find extcommunity-list\n");
15129 return CMD_WARNING
;
15132 extcommunity_list_show(vty
, list
);
15134 return CMD_SUCCESS
;
15137 ALIAS (show_extcommunity_list_arg
,
15138 show_ip_extcommunity_list_arg_cmd
,
15139 "show ip extcommunity-list <(1-500)|WORD>",
15142 "List extended-community list\n"
15143 "Extcommunity-list number\n"
15144 "Extcommunity-list name\n")
15146 /* Display community-list and extcommunity-list configuration. */
15147 static int community_list_config_write(struct vty
*vty
)
15149 struct community_list
*list
;
15150 struct community_entry
*entry
;
15151 struct community_list_master
*cm
;
15154 /* Community-list. */
15155 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15157 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15158 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15159 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15160 community_direct_str(entry
->direct
),
15161 community_list_config_str(entry
));
15164 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15165 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15166 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15167 entry
->style
== COMMUNITY_LIST_STANDARD
15170 list
->name
, community_direct_str(entry
->direct
),
15171 community_list_config_str(entry
));
15175 /* Extcommunity-list. */
15176 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15178 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15179 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15180 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15181 list
->name
, community_direct_str(entry
->direct
),
15182 community_list_config_str(entry
));
15185 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15186 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15187 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15188 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15191 list
->name
, community_direct_str(entry
->direct
),
15192 community_list_config_str(entry
));
15197 /* lcommunity-list. */
15198 cm
= community_list_master_lookup(bgp_clist
,
15199 LARGE_COMMUNITY_LIST_MASTER
);
15201 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15202 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15203 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15204 list
->name
, community_direct_str(entry
->direct
),
15205 community_list_config_str(entry
));
15208 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15209 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15210 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15211 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15214 list
->name
, community_direct_str(entry
->direct
),
15215 community_list_config_str(entry
));
15222 static struct cmd_node community_list_node
= {
15223 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15226 static void community_list_vty(void)
15228 install_node(&community_list_node
, community_list_config_write
);
15230 /* Community-list. */
15231 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15232 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15233 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15234 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15235 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15236 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15237 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15238 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15239 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15240 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15241 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15242 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15244 /* Extcommunity-list. */
15245 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15246 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15247 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15248 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15249 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15250 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15251 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15252 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15253 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15254 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15255 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15256 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15258 /* Large Community List */
15259 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15260 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15261 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15262 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15263 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15264 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15265 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15266 install_element(CONFIG_NODE
,
15267 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15268 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15269 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15270 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15271 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15272 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15273 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15274 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15275 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15276 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15277 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15278 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15279 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15280 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15281 install_element(CONFIG_NODE
,
15282 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15283 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15284 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15285 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15286 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15287 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15288 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);