2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib/zclient.h"
34 #include "memory_vty.h"
40 #include "bgpd/bgpd.h"
41 #include "bgpd/bgp_attr_evpn.h"
42 #include "bgpd/bgp_advertise.h"
43 #include "bgpd/bgp_attr.h"
44 #include "bgpd/bgp_aspath.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_lcommunity.h"
48 #include "bgpd/bgp_damp.h"
49 #include "bgpd/bgp_debug.h"
50 #include "bgpd/bgp_errors.h"
51 #include "bgpd/bgp_fsm.h"
52 #include "bgpd/bgp_nexthop.h"
53 #include "bgpd/bgp_open.h"
54 #include "bgpd/bgp_regex.h"
55 #include "bgpd/bgp_route.h"
56 #include "bgpd/bgp_mplsvpn.h"
57 #include "bgpd/bgp_zebra.h"
58 #include "bgpd/bgp_table.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_packet.h"
62 #include "bgpd/bgp_updgrp.h"
63 #include "bgpd/bgp_bfd.h"
64 #include "bgpd/bgp_io.h"
65 #include "bgpd/bgp_evpn.h"
66 #include "bgpd/bgp_addpath.h"
67 #include "bgpd/bgp_mac.h"
69 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
70 struct prefix
*range
, int exact
);
72 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
81 return BGP_IPV4M_NODE
;
83 case SAFI_LABELED_UNICAST
:
84 return BGP_IPV4L_NODE
;
87 return BGP_VPNV4_NODE
;
90 return BGP_FLOWSPECV4_NODE
;
100 return BGP_IPV6_NODE
;
103 return BGP_IPV6M_NODE
;
105 case SAFI_LABELED_UNICAST
:
106 return BGP_IPV6L_NODE
;
109 return BGP_VPNV6_NODE
;
112 return BGP_FLOWSPECV6_NODE
;
115 return BGP_IPV4_NODE
;
120 return BGP_EVPN_NODE
;
123 // We should never be here but to clarify the switch statement..
124 return BGP_IPV4_NODE
;
128 // Impossible to happen
129 return BGP_IPV4_NODE
;
132 /* Utility function to get address family from current node. */
133 afi_t
bgp_node_afi(struct vty
*vty
)
141 case BGP_FLOWSPECV6_NODE
:
154 /* Utility function to get subsequent address family from current
156 safi_t
bgp_node_safi(struct vty
*vty
)
162 safi
= SAFI_MPLS_VPN
;
166 safi
= SAFI_MULTICAST
;
173 safi
= SAFI_LABELED_UNICAST
;
175 case BGP_FLOWSPECV4_NODE
:
176 case BGP_FLOWSPECV6_NODE
:
177 safi
= SAFI_FLOWSPEC
;
187 * Converts an AFI in string form to afi_t
189 * @param afi string, one of
193 * @return the corresponding afi_t
195 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
197 afi_t afi
= AFI_MAX
; /* unknown */
198 if (strmatch(afi_str
, "ipv4"))
200 else if (strmatch(afi_str
, "ipv6"))
202 else if (strmatch(afi_str
, "l2vpn"))
207 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
211 if (argv_find(argv
, argc
, "ipv4", index
)) {
215 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
223 /* supports <unicast|multicast|vpn|labeled-unicast> */
224 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
226 safi_t safi
= SAFI_MAX
; /* unknown */
227 if (strmatch(safi_str
, "multicast"))
228 safi
= SAFI_MULTICAST
;
229 else if (strmatch(safi_str
, "unicast"))
231 else if (strmatch(safi_str
, "vpn"))
232 safi
= SAFI_MPLS_VPN
;
233 else if (strmatch(safi_str
, "evpn"))
235 else if (strmatch(safi_str
, "labeled-unicast"))
236 safi
= SAFI_LABELED_UNICAST
;
237 else if (strmatch(safi_str
, "flowspec"))
238 safi
= SAFI_FLOWSPEC
;
242 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
246 if (argv_find(argv
, argc
, "unicast", index
)) {
249 *safi
= SAFI_UNICAST
;
250 } else if (argv_find(argv
, argc
, "multicast", index
)) {
253 *safi
= SAFI_MULTICAST
;
254 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
257 *safi
= SAFI_LABELED_UNICAST
;
258 } else if (argv_find(argv
, argc
, "vpn", index
)) {
261 *safi
= SAFI_MPLS_VPN
;
262 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
265 *safi
= SAFI_FLOWSPEC
;
271 * bgp_vty_find_and_parse_afi_safi_bgp
273 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
274 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
275 * to appropriate values for the calling function. This is to allow the
276 * calling function to make decisions appropriate for the show command
277 * that is being parsed.
279 * The show commands are generally of the form:
280 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
281 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
283 * Since we use argv_find if the show command in particular doesn't have:
285 * [<view|vrf> VIEWVRFNAME]
286 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
287 * The command parsing should still be ok.
289 * vty -> The vty for the command so we can output some useful data in
290 * the event of a parse error in the vrf.
291 * argv -> The command tokens
292 * argc -> How many command tokens we have
293 * idx -> The current place in the command, generally should be 0 for this
295 * afi -> The parsed afi if it was included in the show command, returned here
296 * safi -> The parsed safi if it was included in the show command, returned here
297 * bgp -> Pointer to the bgp data structure we need to fill in.
299 * The function returns the correct location in the parse tree for the
302 * Returns 0 for failure to parse correctly, else the idx position of where
303 * it found the last token.
305 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
306 struct cmd_token
**argv
, int argc
,
307 int *idx
, afi_t
*afi
, safi_t
*safi
,
308 struct bgp
**bgp
, bool use_json
)
310 char *vrf_name
= NULL
;
316 if (argv_find(argv
, argc
, "ip", idx
))
319 if (argv_find(argv
, argc
, "view", idx
))
320 vrf_name
= argv
[*idx
+ 1]->arg
;
321 else if (argv_find(argv
, argc
, "vrf", idx
)) {
322 vrf_name
= argv
[*idx
+ 1]->arg
;
323 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
327 if (strmatch(vrf_name
, "all"))
330 *bgp
= bgp_lookup_by_name(vrf_name
);
333 vty_out(vty
, "{}\n");
335 vty_out(vty
, "View/Vrf %s is unknown\n",
342 *bgp
= bgp_get_default();
345 vty_out(vty
, "{}\n");
348 "Default BGP instance not found\n");
354 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
355 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
361 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
363 struct interface
*ifp
= NULL
;
365 if (su
->sa
.sa_family
== AF_INET
)
366 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
367 else if (su
->sa
.sa_family
== AF_INET6
)
368 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
369 su
->sin6
.sin6_scope_id
,
378 /* Utility function for looking up peer from VTY. */
379 /* This is used only for configuration, so disallow if attempted on
380 * a dynamic neighbor.
382 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
384 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
393 ret
= str2sockunion(ip_str
, &su
);
395 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
397 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
400 "%% Malformed address or name: %s\n",
406 peer
= peer_lookup(bgp
, &su
);
409 "%% Specify remote-as or peer-group commands first\n");
412 if (peer_dynamic_neighbor(peer
)) {
414 "%% Operation not allowed on a dynamic neighbor\n");
421 /* Utility function for looking up peer or peer group. */
422 /* This is used only for configuration, so disallow if attempted on
423 * a dynamic neighbor.
425 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
427 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
430 struct peer
*peer
= NULL
;
431 struct peer_group
*group
= NULL
;
437 ret
= str2sockunion(peer_str
, &su
);
439 /* IP address, locate peer. */
440 peer
= peer_lookup(bgp
, &su
);
442 /* Not IP, could match either peer configured on interface or a
444 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
446 group
= peer_group_lookup(bgp
, peer_str
);
450 if (peer_dynamic_neighbor(peer
)) {
452 "%% Operation not allowed on a dynamic neighbor\n");
462 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
467 int bgp_vty_return(struct vty
*vty
, int ret
)
469 const char *str
= NULL
;
472 case BGP_ERR_INVALID_VALUE
:
473 str
= "Invalid value";
475 case BGP_ERR_INVALID_FLAG
:
476 str
= "Invalid flag";
478 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
479 str
= "Peer-group has been shutdown. Activate the peer-group first";
481 case BGP_ERR_PEER_FLAG_CONFLICT
:
482 str
= "Can't set override-capability and strict-capability-match at the same time";
484 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
485 str
= "Specify remote-as or peer-group remote AS first";
487 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
488 str
= "Cannot change the peer-group. Deconfigure first";
490 case BGP_ERR_PEER_GROUP_MISMATCH
:
491 str
= "Peer is not a member of this peer-group";
493 case BGP_ERR_PEER_FILTER_CONFLICT
:
494 str
= "Prefix/distribute list can not co-exist";
496 case BGP_ERR_NOT_INTERNAL_PEER
:
497 str
= "Invalid command. Not an internal neighbor";
499 case BGP_ERR_REMOVE_PRIVATE_AS
:
500 str
= "remove-private-AS cannot be configured for IBGP peers";
502 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
503 str
= "Local-AS allowed only for EBGP peers";
505 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
506 str
= "Cannot have local-as same as BGP AS number";
508 case BGP_ERR_TCPSIG_FAILED
:
509 str
= "Error while applying TCP-Sig to session(s)";
511 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
512 str
= "ebgp-multihop and ttl-security cannot be configured together";
514 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
515 str
= "ttl-security only allowed for EBGP peers";
517 case BGP_ERR_AS_OVERRIDE
:
518 str
= "as-override cannot be configured for IBGP peers";
520 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
521 str
= "Invalid limit for number of dynamic neighbors";
523 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
524 str
= "Dynamic neighbor listen range already exists";
526 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
527 str
= "Operation not allowed on a dynamic neighbor";
529 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
530 str
= "Operation not allowed on a directly connected neighbor";
532 case BGP_ERR_PEER_SAFI_CONFLICT
:
533 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
537 vty_out(vty
, "%% %s\n", str
);
538 return CMD_WARNING_CONFIG_FAILED
;
543 /* BGP clear sort. */
552 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
553 safi_t safi
, int error
)
556 case BGP_ERR_AF_UNCONFIGURED
:
558 "%%BGP: Enable %s address family for the neighbor %s\n",
559 afi_safi_print(afi
, safi
), peer
->host
);
561 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
563 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
571 /* `clear ip bgp' functions. */
572 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
573 enum clear_sort sort
, enum bgp_clear_type stype
,
579 struct listnode
*node
, *nnode
;
581 /* Clear all neighbors. */
583 * Pass along pointer to next node to peer_clear() when walking all
584 * nodes on the BGP instance as that may get freed if it is a
587 if (sort
== clear_all
) {
588 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
589 if (!peer
->afc
[afi
][safi
])
592 if (stype
== BGP_CLEAR_SOFT_NONE
)
593 ret
= peer_clear(peer
, &nnode
);
595 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
598 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
603 /* This is to apply read-only mode on this clear. */
604 if (stype
== BGP_CLEAR_SOFT_NONE
)
605 bgp
->update_delay_over
= 0;
608 vty_out(vty
, "%%BGP: No %s peer configured\n",
609 afi_safi_print(afi
, safi
));
614 /* Clear specified neighbor. */
615 if (sort
== clear_peer
) {
618 /* Make sockunion for lookup. */
619 ret
= str2sockunion(arg
, &su
);
621 peer
= peer_lookup_by_conf_if(bgp
, arg
);
623 peer
= peer_lookup_by_hostname(bgp
, arg
);
626 "Malformed address or name: %s\n",
632 peer
= peer_lookup(bgp
, &su
);
635 "%%BGP: Unknown neighbor - \"%s\"\n",
641 if (!peer
->afc
[afi
][safi
])
642 ret
= BGP_ERR_AF_UNCONFIGURED
;
643 else if (stype
== BGP_CLEAR_SOFT_NONE
)
644 ret
= peer_clear(peer
, NULL
);
646 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
649 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
654 /* Clear all neighbors belonging to a specific peer-group. */
655 if (sort
== clear_group
) {
656 struct peer_group
*group
;
658 group
= peer_group_lookup(bgp
, arg
);
660 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
664 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
665 if (!peer
->afc
[afi
][safi
])
668 if (stype
== BGP_CLEAR_SOFT_NONE
)
669 ret
= peer_clear(peer
, NULL
);
671 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
674 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
681 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
682 afi_safi_print(afi
, safi
), arg
);
687 /* Clear all external (eBGP) neighbors. */
688 if (sort
== clear_external
) {
689 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
690 if (peer
->sort
== BGP_PEER_IBGP
)
693 if (!peer
->afc
[afi
][safi
])
696 if (stype
== BGP_CLEAR_SOFT_NONE
)
697 ret
= peer_clear(peer
, &nnode
);
699 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
702 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
709 "%%BGP: No external %s peer is configured\n",
710 afi_safi_print(afi
, safi
));
715 /* Clear all neighbors belonging to a specific AS. */
716 if (sort
== clear_as
) {
717 as_t as
= strtoul(arg
, NULL
, 10);
719 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
723 if (!peer
->afc
[afi
][safi
])
724 ret
= BGP_ERR_AF_UNCONFIGURED
;
725 else if (stype
== BGP_CLEAR_SOFT_NONE
)
726 ret
= peer_clear(peer
, &nnode
);
728 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
731 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
738 "%%BGP: No %s peer is configured with AS %s\n",
739 afi_safi_print(afi
, safi
), arg
);
747 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
748 safi_t safi
, enum clear_sort sort
,
749 enum bgp_clear_type stype
, const char *arg
)
753 /* BGP structure lookup. */
755 bgp
= bgp_lookup_by_name(name
);
757 vty_out(vty
, "Can't find BGP instance %s\n", name
);
761 bgp
= bgp_get_default();
763 vty_out(vty
, "No BGP process is configured\n");
768 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
771 /* clear soft inbound */
772 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
777 FOREACH_AFI_SAFI (afi
, safi
)
778 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
779 BGP_CLEAR_SOFT_IN
, NULL
);
782 /* clear soft outbound */
783 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
788 FOREACH_AFI_SAFI (afi
, safi
)
789 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
790 BGP_CLEAR_SOFT_OUT
, NULL
);
794 #ifndef VTYSH_EXTRACT_PL
795 #include "bgpd/bgp_vty_clippy.c"
798 /* BGP global configuration. */
799 #if (CONFDATE > 20190601)
800 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
801 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
803 DEFUN_HIDDEN (bgp_multiple_instance_func
,
804 bgp_multiple_instance_cmd
,
805 "bgp multiple-instance",
807 "Enable bgp multiple instance\n")
809 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
813 DEFUN_HIDDEN (no_bgp_multiple_instance
,
814 no_bgp_multiple_instance_cmd
,
815 "no bgp multiple-instance",
818 "BGP multiple instance\n")
822 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
823 vty_out(vty
, "if you are using this please let the developers know\n");
824 zlog_info("Deprecated option: `bgp multiple-instance` being used");
825 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
827 vty_out(vty
, "%% There are more than two BGP instances\n");
828 return CMD_WARNING_CONFIG_FAILED
;
833 DEFUN_HIDDEN (bgp_local_mac
,
835 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
838 "VxLAN Network Identifier\n"
842 "mac-mobility sequence\n"
852 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
853 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
854 vty_out(vty
, "%% Malformed MAC address\n");
857 memset(&ip
, 0, sizeof(ip
));
858 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
860 bgp
= bgp_get_default();
862 vty_out(vty
, "Default BGP instance is not there\n");
866 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
868 vty_out(vty
, "Internal error\n");
875 DEFUN_HIDDEN (no_bgp_local_mac
,
876 no_bgp_local_mac_cmd
,
877 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
881 "VxLAN Network Identifier\n"
892 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
893 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
894 vty_out(vty
, "%% Malformed MAC address\n");
897 memset(&ip
, 0, sizeof(ip
));
899 bgp
= bgp_get_default();
901 vty_out(vty
, "Default BGP instance is not there\n");
905 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
907 vty_out(vty
, "Internal error\n");
914 #if (CONFDATE > 20190601)
915 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
916 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
918 DEFUN_HIDDEN (bgp_config_type
,
920 "bgp config-type <cisco|zebra>",
922 "Configuration type\n"
927 if (argv_find(argv
, argc
, "cisco", &idx
)) {
928 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
929 vty_out(vty
, "if you are using this please let the developers know!\n");
930 zlog_info("Deprecated option: `bgp config-type cisco` being used");
931 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
933 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
938 DEFUN_HIDDEN (no_bgp_config_type
,
939 no_bgp_config_type_cmd
,
940 "no bgp config-type [<cisco|zebra>]",
943 "Display configuration type\n"
947 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
952 DEFUN (no_synchronization
,
953 no_synchronization_cmd
,
954 "no synchronization",
956 "Perform IGP synchronization\n")
961 DEFUN (no_auto_summary
,
965 "Enable automatic network number summarization\n")
970 /* "router bgp" commands. */
971 DEFUN_NOSH (router_bgp
,
973 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
977 BGP_INSTANCE_HELP_STR
)
980 int idx_view_vrf
= 3;
986 const char *name
= NULL
;
987 enum bgp_instance_type inst_type
;
989 // "router bgp" without an ASN
991 // Pending: Make VRF option available for ASN less config
992 bgp
= bgp_get_default();
995 vty_out(vty
, "%% No BGP process is configured\n");
996 return CMD_WARNING_CONFIG_FAILED
;
999 if (listcount(bm
->bgp
) > 1) {
1000 vty_out(vty
, "%% Please specify ASN and VRF\n");
1001 return CMD_WARNING_CONFIG_FAILED
;
1007 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1009 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1011 name
= argv
[idx_vrf
]->arg
;
1013 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1014 if (strmatch(name
, VRF_DEFAULT_NAME
))
1017 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1018 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1019 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1022 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1023 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1025 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
1027 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
1029 "Please specify 'bgp multiple-instance' first\n");
1030 return CMD_WARNING_CONFIG_FAILED
;
1031 case BGP_ERR_AS_MISMATCH
:
1032 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1033 return CMD_WARNING_CONFIG_FAILED
;
1034 case BGP_ERR_INSTANCE_MISMATCH
:
1036 "BGP instance name and AS number mismatch\n");
1038 "BGP instance is already running; AS is %u\n",
1040 return CMD_WARNING_CONFIG_FAILED
;
1044 * If we just instantiated the default instance, complete
1045 * any pending VRF-VPN leaking that was configured via
1046 * earlier "router bgp X vrf FOO" blocks.
1048 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1049 vpn_leak_postchange_all();
1051 /* Pending: handle when user tries to change a view to vrf n vv.
1055 /* unset the auto created flag as the user config is now present */
1056 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1057 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1062 /* "no router bgp" commands. */
1063 DEFUN (no_router_bgp
,
1065 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
1070 BGP_INSTANCE_HELP_STR
)
1076 const char *name
= NULL
;
1078 // "no router bgp" without an ASN
1080 // Pending: Make VRF option available for ASN less config
1081 bgp
= bgp_get_default();
1084 vty_out(vty
, "%% No BGP process is configured\n");
1085 return CMD_WARNING_CONFIG_FAILED
;
1088 if (listcount(bm
->bgp
) > 1) {
1089 vty_out(vty
, "%% Please specify ASN and VRF\n");
1090 return CMD_WARNING_CONFIG_FAILED
;
1094 vty_out(vty
, "%% Please unconfigure l3vni %u",
1096 return CMD_WARNING_CONFIG_FAILED
;
1099 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1102 name
= argv
[idx_vrf
]->arg
;
1104 /* Lookup bgp structure. */
1105 bgp
= bgp_lookup(as
, name
);
1107 vty_out(vty
, "%% Can't find BGP instance\n");
1108 return CMD_WARNING_CONFIG_FAILED
;
1112 vty_out(vty
, "%% Please unconfigure l3vni %u",
1114 return CMD_WARNING_CONFIG_FAILED
;
1124 /* BGP router-id. */
1126 DEFPY (bgp_router_id
,
1128 "bgp router-id A.B.C.D",
1130 "Override configured router identifier\n"
1131 "Manually configured router identifier\n")
1133 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1134 bgp_router_id_static_set(bgp
, router_id
);
1138 DEFPY (no_bgp_router_id
,
1139 no_bgp_router_id_cmd
,
1140 "no bgp router-id [A.B.C.D]",
1143 "Override configured router identifier\n"
1144 "Manually configured router identifier\n")
1146 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1148 if (router_id_str
) {
1149 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1150 vty_out(vty
, "%% BGP router-id doesn't match\n");
1151 return CMD_WARNING_CONFIG_FAILED
;
1155 router_id
.s_addr
= 0;
1156 bgp_router_id_static_set(bgp
, router_id
);
1162 /* BGP Cluster ID. */
1163 DEFUN (bgp_cluster_id
,
1165 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1167 "Configure Route-Reflector Cluster-id\n"
1168 "Route-Reflector Cluster-id in IP address format\n"
1169 "Route-Reflector Cluster-id as 32 bit quantity\n")
1171 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1174 struct in_addr cluster
;
1176 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1178 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1179 return CMD_WARNING_CONFIG_FAILED
;
1182 bgp_cluster_id_set(bgp
, &cluster
);
1183 bgp_clear_star_soft_out(vty
, bgp
->name
);
1188 DEFUN (no_bgp_cluster_id
,
1189 no_bgp_cluster_id_cmd
,
1190 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1193 "Configure Route-Reflector Cluster-id\n"
1194 "Route-Reflector Cluster-id in IP address format\n"
1195 "Route-Reflector Cluster-id as 32 bit quantity\n")
1197 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1198 bgp_cluster_id_unset(bgp
);
1199 bgp_clear_star_soft_out(vty
, bgp
->name
);
1204 DEFUN (bgp_confederation_identifier
,
1205 bgp_confederation_identifier_cmd
,
1206 "bgp confederation identifier (1-4294967295)",
1207 "BGP specific commands\n"
1208 "AS confederation parameters\n"
1210 "Set routing domain confederation AS\n")
1212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1216 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1218 bgp_confederation_id_set(bgp
, as
);
1223 DEFUN (no_bgp_confederation_identifier
,
1224 no_bgp_confederation_identifier_cmd
,
1225 "no bgp confederation identifier [(1-4294967295)]",
1227 "BGP specific commands\n"
1228 "AS confederation parameters\n"
1230 "Set routing domain confederation AS\n")
1232 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1233 bgp_confederation_id_unset(bgp
);
1238 DEFUN (bgp_confederation_peers
,
1239 bgp_confederation_peers_cmd
,
1240 "bgp confederation peers (1-4294967295)...",
1241 "BGP specific commands\n"
1242 "AS confederation parameters\n"
1243 "Peer ASs in BGP confederation\n"
1246 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1251 for (i
= idx_asn
; i
< argc
; i
++) {
1252 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1254 if (bgp
->as
== as
) {
1256 "%% Local member-AS not allowed in confed peer list\n");
1260 bgp_confederation_peers_add(bgp
, as
);
1265 DEFUN (no_bgp_confederation_peers
,
1266 no_bgp_confederation_peers_cmd
,
1267 "no bgp confederation peers (1-4294967295)...",
1269 "BGP specific commands\n"
1270 "AS confederation parameters\n"
1271 "Peer ASs in BGP confederation\n"
1274 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1279 for (i
= idx_asn
; i
< argc
; i
++) {
1280 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1282 bgp_confederation_peers_remove(bgp
, as
);
1288 * Central routine for maximum-paths configuration.
1289 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1290 * @set: 1 for setting values, 0 for removing the max-paths config.
1292 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1293 const char *mpaths
, uint16_t options
,
1296 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1297 uint16_t maxpaths
= 0;
1302 afi
= bgp_node_afi(vty
);
1303 safi
= bgp_node_safi(vty
);
1306 maxpaths
= strtol(mpaths
, NULL
, 10);
1307 if (maxpaths
> multipath_num
) {
1309 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1310 maxpaths
, multipath_num
);
1311 return CMD_WARNING_CONFIG_FAILED
;
1313 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1316 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1320 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1321 (set
== 1) ? "" : "un",
1322 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1323 maxpaths
, afi
, safi
);
1324 return CMD_WARNING_CONFIG_FAILED
;
1327 bgp_recalculate_all_bestpaths(bgp
);
1332 DEFUN (bgp_maxmed_admin
,
1333 bgp_maxmed_admin_cmd
,
1334 "bgp max-med administrative ",
1336 "Advertise routes with max-med\n"
1337 "Administratively applied, for an indefinite period\n")
1339 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1341 bgp
->v_maxmed_admin
= 1;
1342 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1344 bgp_maxmed_update(bgp
);
1349 DEFUN (bgp_maxmed_admin_medv
,
1350 bgp_maxmed_admin_medv_cmd
,
1351 "bgp max-med administrative (0-4294967295)",
1353 "Advertise routes with max-med\n"
1354 "Administratively applied, for an indefinite period\n"
1355 "Max MED value to be used\n")
1357 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1360 bgp
->v_maxmed_admin
= 1;
1361 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1363 bgp_maxmed_update(bgp
);
1368 DEFUN (no_bgp_maxmed_admin
,
1369 no_bgp_maxmed_admin_cmd
,
1370 "no bgp max-med administrative [(0-4294967295)]",
1373 "Advertise routes with max-med\n"
1374 "Administratively applied, for an indefinite period\n"
1375 "Max MED value to be used\n")
1377 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1378 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1379 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1380 bgp_maxmed_update(bgp
);
1385 DEFUN (bgp_maxmed_onstartup
,
1386 bgp_maxmed_onstartup_cmd
,
1387 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1389 "Advertise routes with max-med\n"
1390 "Effective on a startup\n"
1391 "Time (seconds) period for max-med\n"
1392 "Max MED value to be used\n")
1394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1397 argv_find(argv
, argc
, "(5-86400)", &idx
);
1398 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1399 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1400 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1402 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1404 bgp_maxmed_update(bgp
);
1409 DEFUN (no_bgp_maxmed_onstartup
,
1410 no_bgp_maxmed_onstartup_cmd
,
1411 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1414 "Advertise routes with max-med\n"
1415 "Effective on a startup\n"
1416 "Time (seconds) period for max-med\n"
1417 "Max MED value to be used\n")
1419 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1421 /* Cancel max-med onstartup if its on */
1422 if (bgp
->t_maxmed_onstartup
) {
1423 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1424 bgp
->maxmed_onstartup_over
= 1;
1427 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1428 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1430 bgp_maxmed_update(bgp
);
1435 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1438 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1439 uint16_t update_delay
;
1440 uint16_t establish_wait
;
1442 update_delay
= strtoul(delay
, NULL
, 10);
1444 if (!wait
) /* update-delay <delay> */
1446 bgp
->v_update_delay
= update_delay
;
1447 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1451 /* update-delay <delay> <establish-wait> */
1452 establish_wait
= atoi(wait
);
1453 if (update_delay
< establish_wait
) {
1455 "%%Failed: update-delay less than the establish-wait!\n");
1456 return CMD_WARNING_CONFIG_FAILED
;
1459 bgp
->v_update_delay
= update_delay
;
1460 bgp
->v_establish_wait
= establish_wait
;
1465 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1469 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1470 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1475 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1477 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1478 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1479 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1480 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1486 /* Update-delay configuration */
1487 DEFUN (bgp_update_delay
,
1488 bgp_update_delay_cmd
,
1489 "update-delay (0-3600)",
1490 "Force initial delay for best-path and updates\n"
1494 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1497 DEFUN (bgp_update_delay_establish_wait
,
1498 bgp_update_delay_establish_wait_cmd
,
1499 "update-delay (0-3600) (1-3600)",
1500 "Force initial delay for best-path and updates\n"
1505 int idx_number_2
= 2;
1506 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1507 argv
[idx_number_2
]->arg
);
1510 /* Update-delay deconfiguration */
1511 DEFUN (no_bgp_update_delay
,
1512 no_bgp_update_delay_cmd
,
1513 "no update-delay [(0-3600) [(1-3600)]]",
1515 "Force initial delay for best-path and updates\n"
1519 return bgp_update_delay_deconfig_vty(vty
);
1523 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1526 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1529 uint32_t quanta
= strtoul(num
, NULL
, 10);
1530 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1531 memory_order_relaxed
);
1533 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1534 memory_order_relaxed
);
1540 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1543 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1546 uint32_t quanta
= strtoul(num
, NULL
, 10);
1547 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1548 memory_order_relaxed
);
1550 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1551 memory_order_relaxed
);
1557 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1560 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1561 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1562 vty_out(vty
, " write-quanta %d\n", quanta
);
1565 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1568 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1569 if (quanta
!= BGP_READ_PACKET_MAX
)
1570 vty_out(vty
, " read-quanta %d\n", quanta
);
1573 /* Packet quanta configuration */
1574 DEFUN (bgp_wpkt_quanta
,
1575 bgp_wpkt_quanta_cmd
,
1576 "write-quanta (1-10)",
1577 "How many packets to write to peer socket per run\n"
1578 "Number of packets\n")
1581 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1584 DEFUN (no_bgp_wpkt_quanta
,
1585 no_bgp_wpkt_quanta_cmd
,
1586 "no write-quanta (1-10)",
1588 "How many packets to write to peer socket per I/O cycle\n"
1589 "Number of packets\n")
1592 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1595 DEFUN (bgp_rpkt_quanta
,
1596 bgp_rpkt_quanta_cmd
,
1597 "read-quanta (1-10)",
1598 "How many packets to read from peer socket per I/O cycle\n"
1599 "Number of packets\n")
1602 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1605 DEFUN (no_bgp_rpkt_quanta
,
1606 no_bgp_rpkt_quanta_cmd
,
1607 "no read-quanta (1-10)",
1609 "How many packets to read from peer socket per I/O cycle\n"
1610 "Number of packets\n")
1613 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1616 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1618 if (!bgp
->heuristic_coalesce
)
1619 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1623 DEFUN (bgp_coalesce_time
,
1624 bgp_coalesce_time_cmd
,
1625 "coalesce-time (0-4294967295)",
1626 "Subgroup coalesce timer\n"
1627 "Subgroup coalesce timer value (in ms)\n")
1629 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1632 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1633 bgp
->heuristic_coalesce
= false;
1634 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1638 DEFUN (no_bgp_coalesce_time
,
1639 no_bgp_coalesce_time_cmd
,
1640 "no coalesce-time (0-4294967295)",
1642 "Subgroup coalesce timer\n"
1643 "Subgroup coalesce timer value (in ms)\n")
1645 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1647 bgp
->heuristic_coalesce
= true;
1648 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1652 /* Maximum-paths configuration */
1653 DEFUN (bgp_maxpaths
,
1655 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1656 "Forward packets over multiple paths\n"
1657 "Number of paths\n")
1660 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1661 argv
[idx_number
]->arg
, 0, 1);
1664 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1665 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1666 "Forward packets over multiple paths\n"
1667 "Number of paths\n")
1669 DEFUN (bgp_maxpaths_ibgp
,
1670 bgp_maxpaths_ibgp_cmd
,
1671 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1672 "Forward packets over multiple paths\n"
1674 "Number of paths\n")
1677 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1678 argv
[idx_number
]->arg
, 0, 1);
1681 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1682 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1683 "Forward packets over multiple paths\n"
1685 "Number of paths\n")
1687 DEFUN (bgp_maxpaths_ibgp_cluster
,
1688 bgp_maxpaths_ibgp_cluster_cmd
,
1689 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1690 "Forward packets over multiple paths\n"
1693 "Match the cluster length\n")
1696 return bgp_maxpaths_config_vty(
1697 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1698 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1701 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1702 "maximum-paths ibgp " CMD_RANGE_STR(
1703 1, MULTIPATH_NUM
) " equal-cluster-length",
1704 "Forward packets over multiple paths\n"
1707 "Match the cluster length\n")
1709 DEFUN (no_bgp_maxpaths
,
1710 no_bgp_maxpaths_cmd
,
1711 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1713 "Forward packets over multiple paths\n"
1714 "Number of paths\n")
1716 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1719 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1720 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1721 "Forward packets over multiple paths\n"
1722 "Number of paths\n")
1724 DEFUN (no_bgp_maxpaths_ibgp
,
1725 no_bgp_maxpaths_ibgp_cmd
,
1726 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1728 "Forward packets over multiple paths\n"
1731 "Match the cluster length\n")
1733 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1736 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1737 "no maximum-paths ibgp [" CMD_RANGE_STR(
1738 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1740 "Forward packets over multiple paths\n"
1743 "Match the cluster length\n")
1745 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1748 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1749 vty_out(vty
, " maximum-paths %d\n",
1750 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1753 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1754 vty_out(vty
, " maximum-paths ibgp %d",
1755 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1756 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1757 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1758 vty_out(vty
, " equal-cluster-length");
1767 "timers bgp (0-65535) (0-65535)",
1768 "Adjust routing timers\n"
1770 "Keepalive interval\n"
1773 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1775 int idx_number_2
= 3;
1776 unsigned long keepalive
= 0;
1777 unsigned long holdtime
= 0;
1779 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1780 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1782 /* Holdtime value check. */
1783 if (holdtime
< 3 && holdtime
!= 0) {
1785 "%% hold time value must be either 0 or greater than 3\n");
1786 return CMD_WARNING_CONFIG_FAILED
;
1789 bgp_timers_set(bgp
, keepalive
, holdtime
);
1794 DEFUN (no_bgp_timers
,
1796 "no timers bgp [(0-65535) (0-65535)]",
1798 "Adjust routing timers\n"
1800 "Keepalive interval\n"
1803 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1804 bgp_timers_unset(bgp
);
1810 DEFUN (bgp_client_to_client_reflection
,
1811 bgp_client_to_client_reflection_cmd
,
1812 "bgp client-to-client reflection",
1813 "BGP specific commands\n"
1814 "Configure client to client route reflection\n"
1815 "reflection of routes allowed\n")
1817 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1818 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1819 bgp_clear_star_soft_out(vty
, bgp
->name
);
1824 DEFUN (no_bgp_client_to_client_reflection
,
1825 no_bgp_client_to_client_reflection_cmd
,
1826 "no bgp client-to-client reflection",
1828 "BGP specific commands\n"
1829 "Configure client to client route reflection\n"
1830 "reflection of routes allowed\n")
1832 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1833 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1834 bgp_clear_star_soft_out(vty
, bgp
->name
);
1839 /* "bgp always-compare-med" configuration. */
1840 DEFUN (bgp_always_compare_med
,
1841 bgp_always_compare_med_cmd
,
1842 "bgp always-compare-med",
1843 "BGP specific commands\n"
1844 "Allow comparing MED from different neighbors\n")
1846 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1847 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1848 bgp_recalculate_all_bestpaths(bgp
);
1853 DEFUN (no_bgp_always_compare_med
,
1854 no_bgp_always_compare_med_cmd
,
1855 "no bgp always-compare-med",
1857 "BGP specific commands\n"
1858 "Allow comparing MED from different neighbors\n")
1860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1861 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1862 bgp_recalculate_all_bestpaths(bgp
);
1868 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1869 "bgp ebgp-requires-policy",
1870 "BGP specific commands\n"
1871 "Require in and out policy for eBGP peers (RFC8212)\n")
1873 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1874 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1878 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1879 "no bgp ebgp-requires-policy",
1881 "BGP specific commands\n"
1882 "Require in and out policy for eBGP peers (RFC8212)\n")
1884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1885 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1890 /* "bgp deterministic-med" configuration. */
1891 DEFUN (bgp_deterministic_med
,
1892 bgp_deterministic_med_cmd
,
1893 "bgp deterministic-med",
1894 "BGP specific commands\n"
1895 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1897 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1899 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1900 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1901 bgp_recalculate_all_bestpaths(bgp
);
1907 DEFUN (no_bgp_deterministic_med
,
1908 no_bgp_deterministic_med_cmd
,
1909 "no bgp deterministic-med",
1911 "BGP specific commands\n"
1912 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1914 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1915 int bestpath_per_as_used
;
1919 struct listnode
*node
, *nnode
;
1921 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1922 bestpath_per_as_used
= 0;
1924 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1925 FOREACH_AFI_SAFI (afi
, safi
)
1926 if (bgp_addpath_dmed_required(
1927 peer
->addpath_type
[afi
][safi
])) {
1928 bestpath_per_as_used
= 1;
1932 if (bestpath_per_as_used
)
1936 if (bestpath_per_as_used
) {
1938 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1939 return CMD_WARNING_CONFIG_FAILED
;
1941 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1942 bgp_recalculate_all_bestpaths(bgp
);
1949 /* "bgp graceful-restart" configuration. */
1950 DEFUN (bgp_graceful_restart
,
1951 bgp_graceful_restart_cmd
,
1952 "bgp graceful-restart",
1953 "BGP specific commands\n"
1954 "Graceful restart capability parameters\n")
1956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1957 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1961 DEFUN (no_bgp_graceful_restart
,
1962 no_bgp_graceful_restart_cmd
,
1963 "no bgp graceful-restart",
1965 "BGP specific commands\n"
1966 "Graceful restart capability parameters\n")
1968 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1969 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1973 DEFUN (bgp_graceful_restart_stalepath_time
,
1974 bgp_graceful_restart_stalepath_time_cmd
,
1975 "bgp graceful-restart stalepath-time (1-4095)",
1976 "BGP specific commands\n"
1977 "Graceful restart capability parameters\n"
1978 "Set the max time to hold onto restarting peer's stale paths\n"
1979 "Delay value (seconds)\n")
1981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1985 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1986 bgp
->stalepath_time
= stalepath
;
1990 DEFUN (bgp_graceful_restart_restart_time
,
1991 bgp_graceful_restart_restart_time_cmd
,
1992 "bgp graceful-restart restart-time (1-4095)",
1993 "BGP specific commands\n"
1994 "Graceful restart capability parameters\n"
1995 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1996 "Delay value (seconds)\n")
1998 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2002 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2003 bgp
->restart_time
= restart
;
2007 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2008 no_bgp_graceful_restart_stalepath_time_cmd
,
2009 "no bgp graceful-restart stalepath-time [(1-4095)]",
2011 "BGP specific commands\n"
2012 "Graceful restart capability parameters\n"
2013 "Set the max time to hold onto restarting peer's stale paths\n"
2014 "Delay value (seconds)\n")
2016 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2018 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2022 DEFUN (no_bgp_graceful_restart_restart_time
,
2023 no_bgp_graceful_restart_restart_time_cmd
,
2024 "no bgp graceful-restart restart-time [(1-4095)]",
2026 "BGP specific commands\n"
2027 "Graceful restart capability parameters\n"
2028 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2029 "Delay value (seconds)\n")
2031 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2033 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2037 DEFUN (bgp_graceful_restart_preserve_fw
,
2038 bgp_graceful_restart_preserve_fw_cmd
,
2039 "bgp graceful-restart preserve-fw-state",
2040 "BGP specific commands\n"
2041 "Graceful restart capability parameters\n"
2042 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2045 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2049 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2050 no_bgp_graceful_restart_preserve_fw_cmd
,
2051 "no bgp graceful-restart preserve-fw-state",
2053 "BGP specific commands\n"
2054 "Graceful restart capability parameters\n"
2055 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2058 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2062 /* "bgp graceful-shutdown" configuration */
2063 DEFUN (bgp_graceful_shutdown
,
2064 bgp_graceful_shutdown_cmd
,
2065 "bgp graceful-shutdown",
2067 "Graceful shutdown parameters\n")
2069 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2071 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2072 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2073 bgp_static_redo_import_check(bgp
);
2074 bgp_redistribute_redo(bgp
);
2075 bgp_clear_star_soft_out(vty
, bgp
->name
);
2076 bgp_clear_star_soft_in(vty
, bgp
->name
);
2082 DEFUN (no_bgp_graceful_shutdown
,
2083 no_bgp_graceful_shutdown_cmd
,
2084 "no bgp graceful-shutdown",
2087 "Graceful shutdown parameters\n")
2089 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2091 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2092 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2093 bgp_static_redo_import_check(bgp
);
2094 bgp_redistribute_redo(bgp
);
2095 bgp_clear_star_soft_out(vty
, bgp
->name
);
2096 bgp_clear_star_soft_in(vty
, bgp
->name
);
2102 /* "bgp fast-external-failover" configuration. */
2103 DEFUN (bgp_fast_external_failover
,
2104 bgp_fast_external_failover_cmd
,
2105 "bgp fast-external-failover",
2107 "Immediately reset session if a link to a directly connected external peer goes down\n")
2109 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2110 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2114 DEFUN (no_bgp_fast_external_failover
,
2115 no_bgp_fast_external_failover_cmd
,
2116 "no bgp fast-external-failover",
2119 "Immediately reset session if a link to a directly connected external peer goes down\n")
2121 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2122 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2126 /* "bgp enforce-first-as" configuration. */
2127 #if CONFDATE > 20190517
2128 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2131 DEFUN_HIDDEN (bgp_enforce_first_as
,
2132 bgp_enforce_first_as_cmd
,
2133 "[no] bgp enforce-first-as",
2136 "Enforce the first AS for EBGP routes\n")
2138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2140 if (strmatch(argv
[0]->text
, "no"))
2141 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2143 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2148 /* "bgp bestpath compare-routerid" configuration. */
2149 DEFUN (bgp_bestpath_compare_router_id
,
2150 bgp_bestpath_compare_router_id_cmd
,
2151 "bgp bestpath compare-routerid",
2152 "BGP specific commands\n"
2153 "Change the default bestpath selection\n"
2154 "Compare router-id for identical EBGP paths\n")
2156 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2157 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2158 bgp_recalculate_all_bestpaths(bgp
);
2163 DEFUN (no_bgp_bestpath_compare_router_id
,
2164 no_bgp_bestpath_compare_router_id_cmd
,
2165 "no bgp bestpath compare-routerid",
2167 "BGP specific commands\n"
2168 "Change the default bestpath selection\n"
2169 "Compare router-id for identical EBGP paths\n")
2171 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2172 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2173 bgp_recalculate_all_bestpaths(bgp
);
2178 /* "bgp bestpath as-path ignore" configuration. */
2179 DEFUN (bgp_bestpath_aspath_ignore
,
2180 bgp_bestpath_aspath_ignore_cmd
,
2181 "bgp bestpath as-path ignore",
2182 "BGP specific commands\n"
2183 "Change the default bestpath selection\n"
2184 "AS-path attribute\n"
2185 "Ignore as-path length in selecting a route\n")
2187 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2188 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2189 bgp_recalculate_all_bestpaths(bgp
);
2194 DEFUN (no_bgp_bestpath_aspath_ignore
,
2195 no_bgp_bestpath_aspath_ignore_cmd
,
2196 "no bgp bestpath as-path ignore",
2198 "BGP specific commands\n"
2199 "Change the default bestpath selection\n"
2200 "AS-path attribute\n"
2201 "Ignore as-path length in selecting a route\n")
2203 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2204 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2205 bgp_recalculate_all_bestpaths(bgp
);
2210 /* "bgp bestpath as-path confed" configuration. */
2211 DEFUN (bgp_bestpath_aspath_confed
,
2212 bgp_bestpath_aspath_confed_cmd
,
2213 "bgp bestpath as-path confed",
2214 "BGP specific commands\n"
2215 "Change the default bestpath selection\n"
2216 "AS-path attribute\n"
2217 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2219 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2220 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2221 bgp_recalculate_all_bestpaths(bgp
);
2226 DEFUN (no_bgp_bestpath_aspath_confed
,
2227 no_bgp_bestpath_aspath_confed_cmd
,
2228 "no bgp bestpath as-path confed",
2230 "BGP specific commands\n"
2231 "Change the default bestpath selection\n"
2232 "AS-path attribute\n"
2233 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2235 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2236 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2237 bgp_recalculate_all_bestpaths(bgp
);
2242 /* "bgp bestpath as-path multipath-relax" configuration. */
2243 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2244 bgp_bestpath_aspath_multipath_relax_cmd
,
2245 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2246 "BGP specific commands\n"
2247 "Change the default bestpath selection\n"
2248 "AS-path attribute\n"
2249 "Allow load sharing across routes that have different AS paths (but same length)\n"
2250 "Generate an AS_SET\n"
2251 "Do not generate an AS_SET\n")
2253 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2255 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2257 /* no-as-set is now the default behavior so we can silently
2259 if (argv_find(argv
, argc
, "as-set", &idx
))
2260 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2262 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2264 bgp_recalculate_all_bestpaths(bgp
);
2269 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2270 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2271 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2273 "BGP specific commands\n"
2274 "Change the default bestpath selection\n"
2275 "AS-path attribute\n"
2276 "Allow load sharing across routes that have different AS paths (but same length)\n"
2277 "Generate an AS_SET\n"
2278 "Do not generate an AS_SET\n")
2280 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2281 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2282 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2283 bgp_recalculate_all_bestpaths(bgp
);
2288 /* "bgp log-neighbor-changes" configuration. */
2289 DEFUN (bgp_log_neighbor_changes
,
2290 bgp_log_neighbor_changes_cmd
,
2291 "bgp log-neighbor-changes",
2292 "BGP specific commands\n"
2293 "Log neighbor up/down and reset reason\n")
2295 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2296 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2300 DEFUN (no_bgp_log_neighbor_changes
,
2301 no_bgp_log_neighbor_changes_cmd
,
2302 "no bgp log-neighbor-changes",
2304 "BGP specific commands\n"
2305 "Log neighbor up/down and reset reason\n")
2307 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2308 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2312 /* "bgp bestpath med" configuration. */
2313 DEFUN (bgp_bestpath_med
,
2314 bgp_bestpath_med_cmd
,
2315 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2316 "BGP specific commands\n"
2317 "Change the default bestpath selection\n"
2319 "Compare MED among confederation paths\n"
2320 "Treat missing MED as the least preferred one\n"
2321 "Treat missing MED as the least preferred one\n"
2322 "Compare MED among confederation paths\n")
2324 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2327 if (argv_find(argv
, argc
, "confed", &idx
))
2328 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2330 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2331 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2333 bgp_recalculate_all_bestpaths(bgp
);
2338 DEFUN (no_bgp_bestpath_med
,
2339 no_bgp_bestpath_med_cmd
,
2340 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2342 "BGP specific commands\n"
2343 "Change the default bestpath selection\n"
2345 "Compare MED among confederation paths\n"
2346 "Treat missing MED as the least preferred one\n"
2347 "Treat missing MED as the least preferred one\n"
2348 "Compare MED among confederation paths\n")
2350 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2353 if (argv_find(argv
, argc
, "confed", &idx
))
2354 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2356 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2357 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2359 bgp_recalculate_all_bestpaths(bgp
);
2364 /* "no bgp default ipv4-unicast". */
2365 DEFUN (no_bgp_default_ipv4_unicast
,
2366 no_bgp_default_ipv4_unicast_cmd
,
2367 "no bgp default ipv4-unicast",
2369 "BGP specific commands\n"
2370 "Configure BGP defaults\n"
2371 "Activate ipv4-unicast for a peer by default\n")
2373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2374 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2378 DEFUN (bgp_default_ipv4_unicast
,
2379 bgp_default_ipv4_unicast_cmd
,
2380 "bgp default ipv4-unicast",
2381 "BGP specific commands\n"
2382 "Configure BGP defaults\n"
2383 "Activate ipv4-unicast for a peer by default\n")
2385 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2386 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2390 /* Display hostname in certain command outputs */
2391 DEFUN (bgp_default_show_hostname
,
2392 bgp_default_show_hostname_cmd
,
2393 "bgp default show-hostname",
2394 "BGP specific commands\n"
2395 "Configure BGP defaults\n"
2396 "Show hostname in certain command outputs\n")
2398 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2399 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2403 DEFUN (no_bgp_default_show_hostname
,
2404 no_bgp_default_show_hostname_cmd
,
2405 "no bgp default show-hostname",
2407 "BGP specific commands\n"
2408 "Configure BGP defaults\n"
2409 "Show hostname in certain command outputs\n")
2411 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2412 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2416 /* "bgp network import-check" configuration. */
2417 DEFUN (bgp_network_import_check
,
2418 bgp_network_import_check_cmd
,
2419 "bgp network import-check",
2420 "BGP specific commands\n"
2421 "BGP network command\n"
2422 "Check BGP network route exists in IGP\n")
2424 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2425 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2426 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2427 bgp_static_redo_import_check(bgp
);
2433 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2434 "bgp network import-check exact",
2435 "BGP specific commands\n"
2436 "BGP network command\n"
2437 "Check BGP network route exists in IGP\n"
2438 "Match route precisely\n")
2440 DEFUN (no_bgp_network_import_check
,
2441 no_bgp_network_import_check_cmd
,
2442 "no bgp network import-check",
2444 "BGP specific commands\n"
2445 "BGP network command\n"
2446 "Check BGP network route exists in IGP\n")
2448 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2449 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2450 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2451 bgp_static_redo_import_check(bgp
);
2457 DEFUN (bgp_default_local_preference
,
2458 bgp_default_local_preference_cmd
,
2459 "bgp default local-preference (0-4294967295)",
2460 "BGP specific commands\n"
2461 "Configure BGP defaults\n"
2462 "local preference (higher=more preferred)\n"
2463 "Configure default local preference value\n")
2465 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2467 uint32_t local_pref
;
2469 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2471 bgp_default_local_preference_set(bgp
, local_pref
);
2472 bgp_clear_star_soft_in(vty
, bgp
->name
);
2477 DEFUN (no_bgp_default_local_preference
,
2478 no_bgp_default_local_preference_cmd
,
2479 "no bgp default local-preference [(0-4294967295)]",
2481 "BGP specific commands\n"
2482 "Configure BGP defaults\n"
2483 "local preference (higher=more preferred)\n"
2484 "Configure default local preference value\n")
2486 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2487 bgp_default_local_preference_unset(bgp
);
2488 bgp_clear_star_soft_in(vty
, bgp
->name
);
2494 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2495 bgp_default_subgroup_pkt_queue_max_cmd
,
2496 "bgp default subgroup-pkt-queue-max (20-100)",
2497 "BGP specific commands\n"
2498 "Configure BGP defaults\n"
2499 "subgroup-pkt-queue-max\n"
2500 "Configure subgroup packet queue max\n")
2502 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2506 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2508 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2513 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2514 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2515 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2517 "BGP specific commands\n"
2518 "Configure BGP defaults\n"
2519 "subgroup-pkt-queue-max\n"
2520 "Configure subgroup packet queue max\n")
2522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2523 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2528 DEFUN (bgp_rr_allow_outbound_policy
,
2529 bgp_rr_allow_outbound_policy_cmd
,
2530 "bgp route-reflector allow-outbound-policy",
2531 "BGP specific commands\n"
2532 "Allow modifications made by out route-map\n"
2533 "on ibgp neighbors\n")
2535 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2537 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2538 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2539 update_group_announce_rrclients(bgp
);
2540 bgp_clear_star_soft_out(vty
, bgp
->name
);
2546 DEFUN (no_bgp_rr_allow_outbound_policy
,
2547 no_bgp_rr_allow_outbound_policy_cmd
,
2548 "no bgp route-reflector allow-outbound-policy",
2550 "BGP specific commands\n"
2551 "Allow modifications made by out route-map\n"
2552 "on ibgp neighbors\n")
2554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2556 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2557 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2558 update_group_announce_rrclients(bgp
);
2559 bgp_clear_star_soft_out(vty
, bgp
->name
);
2565 DEFUN (bgp_listen_limit
,
2566 bgp_listen_limit_cmd
,
2567 "bgp listen limit (1-5000)",
2568 "BGP specific commands\n"
2569 "Configure BGP defaults\n"
2570 "maximum number of BGP Dynamic Neighbors that can be created\n"
2571 "Configure Dynamic Neighbors listen limit value\n")
2573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2577 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2579 bgp_listen_limit_set(bgp
, listen_limit
);
2584 DEFUN (no_bgp_listen_limit
,
2585 no_bgp_listen_limit_cmd
,
2586 "no bgp listen limit [(1-5000)]",
2587 "BGP specific commands\n"
2588 "Configure BGP defaults\n"
2589 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2590 "Configure Dynamic Neighbors listen limit value to default\n"
2591 "Configure Dynamic Neighbors listen limit value\n")
2593 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2594 bgp_listen_limit_unset(bgp
);
2600 * Check if this listen range is already configured. Check for exact
2601 * match or overlap based on input.
2603 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2604 struct prefix
*range
, int exact
)
2606 struct listnode
*node
, *nnode
;
2607 struct listnode
*node1
, *nnode1
;
2608 struct peer_group
*group
;
2613 afi
= family2afi(range
->family
);
2614 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2615 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2618 match
= prefix_same(range
, lr
);
2620 match
= (prefix_match(range
, lr
)
2621 || prefix_match(lr
, range
));
2630 DEFUN (bgp_listen_range
,
2631 bgp_listen_range_cmd
,
2632 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2633 "BGP specific commands\n"
2634 "Configure BGP dynamic neighbors listen range\n"
2635 "Configure BGP dynamic neighbors listen range\n"
2637 "Member of the peer-group\n"
2638 "Peer-group name\n")
2640 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2641 struct prefix range
;
2642 struct peer_group
*group
, *existing_group
;
2647 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2648 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2649 char *prefix
= argv
[idx
]->arg
;
2650 argv_find(argv
, argc
, "WORD", &idx
);
2651 char *peergroup
= argv
[idx
]->arg
;
2653 /* Convert IP prefix string to struct prefix. */
2654 ret
= str2prefix(prefix
, &range
);
2656 vty_out(vty
, "%% Malformed listen range\n");
2657 return CMD_WARNING_CONFIG_FAILED
;
2660 afi
= family2afi(range
.family
);
2662 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2664 "%% Malformed listen range (link-local address)\n");
2665 return CMD_WARNING_CONFIG_FAILED
;
2670 /* Check if same listen range is already configured. */
2671 existing_group
= listen_range_exists(bgp
, &range
, 1);
2672 if (existing_group
) {
2673 if (strcmp(existing_group
->name
, peergroup
) == 0)
2677 "%% Same listen range is attached to peer-group %s\n",
2678 existing_group
->name
);
2679 return CMD_WARNING_CONFIG_FAILED
;
2683 /* Check if an overlapping listen range exists. */
2684 if (listen_range_exists(bgp
, &range
, 0)) {
2686 "%% Listen range overlaps with existing listen range\n");
2687 return CMD_WARNING_CONFIG_FAILED
;
2690 group
= peer_group_lookup(bgp
, peergroup
);
2692 vty_out(vty
, "%% Configure the peer-group first\n");
2693 return CMD_WARNING_CONFIG_FAILED
;
2696 ret
= peer_group_listen_range_add(group
, &range
);
2697 return bgp_vty_return(vty
, ret
);
2700 DEFUN (no_bgp_listen_range
,
2701 no_bgp_listen_range_cmd
,
2702 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2704 "BGP specific commands\n"
2705 "Unconfigure BGP dynamic neighbors listen range\n"
2706 "Unconfigure BGP dynamic neighbors listen range\n"
2708 "Member of the peer-group\n"
2709 "Peer-group name\n")
2711 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2712 struct prefix range
;
2713 struct peer_group
*group
;
2718 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2719 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2720 char *prefix
= argv
[idx
]->arg
;
2721 argv_find(argv
, argc
, "WORD", &idx
);
2722 char *peergroup
= argv
[idx
]->arg
;
2724 /* Convert IP prefix string to struct prefix. */
2725 ret
= str2prefix(prefix
, &range
);
2727 vty_out(vty
, "%% Malformed listen range\n");
2728 return CMD_WARNING_CONFIG_FAILED
;
2731 afi
= family2afi(range
.family
);
2733 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2735 "%% Malformed listen range (link-local address)\n");
2736 return CMD_WARNING_CONFIG_FAILED
;
2741 group
= peer_group_lookup(bgp
, peergroup
);
2743 vty_out(vty
, "%% Peer-group does not exist\n");
2744 return CMD_WARNING_CONFIG_FAILED
;
2747 ret
= peer_group_listen_range_del(group
, &range
);
2748 return bgp_vty_return(vty
, ret
);
2751 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2753 struct peer_group
*group
;
2754 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2755 struct prefix
*range
;
2757 char buf
[PREFIX2STR_BUFFER
];
2759 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2760 vty_out(vty
, " bgp listen limit %d\n",
2761 bgp
->dynamic_neighbors_limit
);
2763 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2764 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2765 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2767 prefix2str(range
, buf
, sizeof(buf
));
2769 " bgp listen range %s peer-group %s\n",
2777 DEFUN (bgp_disable_connected_route_check
,
2778 bgp_disable_connected_route_check_cmd
,
2779 "bgp disable-ebgp-connected-route-check",
2780 "BGP specific commands\n"
2781 "Disable checking if nexthop is connected on ebgp sessions\n")
2783 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2784 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2785 bgp_clear_star_soft_in(vty
, bgp
->name
);
2790 DEFUN (no_bgp_disable_connected_route_check
,
2791 no_bgp_disable_connected_route_check_cmd
,
2792 "no bgp disable-ebgp-connected-route-check",
2794 "BGP specific commands\n"
2795 "Disable checking if nexthop is connected on ebgp sessions\n")
2797 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2798 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2799 bgp_clear_star_soft_in(vty
, bgp
->name
);
2805 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2806 const char *as_str
, afi_t afi
, safi_t safi
)
2808 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2811 int as_type
= AS_SPECIFIED
;
2814 if (as_str
[0] == 'i') {
2816 as_type
= AS_INTERNAL
;
2817 } else if (as_str
[0] == 'e') {
2819 as_type
= AS_EXTERNAL
;
2821 /* Get AS number. */
2822 as
= strtoul(as_str
, NULL
, 10);
2825 /* If peer is peer group or interface peer, call proper function. */
2826 ret
= str2sockunion(peer_str
, &su
);
2830 /* Check if existing interface peer */
2831 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2833 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2836 /* if not interface peer, check peer-group settings */
2837 if (ret
< 0 && !peer
) {
2838 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2841 "%% Create the peer-group or interface first\n");
2842 return CMD_WARNING_CONFIG_FAILED
;
2847 if (peer_address_self_check(bgp
, &su
)) {
2849 "%% Can not configure the local system as neighbor\n");
2850 return CMD_WARNING_CONFIG_FAILED
;
2852 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2855 /* This peer belongs to peer group. */
2857 case BGP_ERR_PEER_GROUP_MEMBER
:
2859 "%% Peer-group member cannot override remote-as of peer-group\n");
2860 return CMD_WARNING_CONFIG_FAILED
;
2861 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2863 "%% Peer-group members must be all internal or all external\n");
2864 return CMD_WARNING_CONFIG_FAILED
;
2866 return bgp_vty_return(vty
, ret
);
2869 DEFUN (bgp_default_shutdown
,
2870 bgp_default_shutdown_cmd
,
2871 "[no] bgp default shutdown",
2874 "Configure BGP defaults\n"
2875 "Apply administrative shutdown to newly configured peers\n")
2877 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2878 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2882 DEFUN (neighbor_remote_as
,
2883 neighbor_remote_as_cmd
,
2884 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2887 "Specify a BGP neighbor\n"
2889 "Internal BGP peer\n"
2890 "External BGP peer\n")
2893 int idx_remote_as
= 3;
2894 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2895 argv
[idx_remote_as
]->arg
, AFI_IP
,
2899 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2900 afi_t afi
, safi_t safi
, int v6only
,
2901 const char *peer_group_name
,
2904 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2906 int as_type
= AS_UNSPECIFIED
;
2908 struct peer_group
*group
;
2912 group
= peer_group_lookup(bgp
, conf_if
);
2915 vty_out(vty
, "%% Name conflict with peer-group \n");
2916 return CMD_WARNING_CONFIG_FAILED
;
2920 if (as_str
[0] == 'i') {
2921 as_type
= AS_INTERNAL
;
2922 } else if (as_str
[0] == 'e') {
2923 as_type
= AS_EXTERNAL
;
2925 /* Get AS number. */
2926 as
= strtoul(as_str
, NULL
, 10);
2927 as_type
= AS_SPECIFIED
;
2931 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2934 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2937 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2938 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2939 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2940 as_type
, 0, 0, NULL
);
2942 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2943 as_type
, afi
, safi
, NULL
);
2946 vty_out(vty
, "%% BGP failed to create peer\n");
2947 return CMD_WARNING_CONFIG_FAILED
;
2951 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2953 /* Request zebra to initiate IPv6 RAs on this interface. We do
2955 * any unnumbered peer in order to not worry about run-time
2957 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2959 * gets deleted later etc.)
2962 bgp_zebra_initiate_radv(bgp
, peer
);
2965 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2966 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2968 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2970 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2972 /* v6only flag changed. Reset bgp seesion */
2973 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2974 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2975 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2976 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2978 bgp_session_reset(peer
);
2981 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2982 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2983 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2984 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2987 if (peer_group_name
) {
2988 group
= peer_group_lookup(bgp
, peer_group_name
);
2990 vty_out(vty
, "%% Configure the peer-group first\n");
2991 return CMD_WARNING_CONFIG_FAILED
;
2994 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2997 return bgp_vty_return(vty
, ret
);
3000 DEFUN (neighbor_interface_config
,
3001 neighbor_interface_config_cmd
,
3002 "neighbor WORD interface [peer-group WORD]",
3004 "Interface name or neighbor tag\n"
3005 "Enable BGP on interface\n"
3006 "Member of the peer-group\n"
3007 "Peer-group name\n")
3010 int idx_peer_group_word
= 4;
3012 if (argc
> idx_peer_group_word
)
3013 return peer_conf_interface_get(
3014 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3015 argv
[idx_peer_group_word
]->arg
, NULL
);
3017 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3018 SAFI_UNICAST
, 0, NULL
, NULL
);
3021 DEFUN (neighbor_interface_config_v6only
,
3022 neighbor_interface_config_v6only_cmd
,
3023 "neighbor WORD interface v6only [peer-group WORD]",
3025 "Interface name or neighbor tag\n"
3026 "Enable BGP on interface\n"
3027 "Enable BGP with v6 link-local only\n"
3028 "Member of the peer-group\n"
3029 "Peer-group name\n")
3032 int idx_peer_group_word
= 5;
3034 if (argc
> idx_peer_group_word
)
3035 return peer_conf_interface_get(
3036 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3037 argv
[idx_peer_group_word
]->arg
, NULL
);
3039 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3040 SAFI_UNICAST
, 1, NULL
, NULL
);
3044 DEFUN (neighbor_interface_config_remote_as
,
3045 neighbor_interface_config_remote_as_cmd
,
3046 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3048 "Interface name or neighbor tag\n"
3049 "Enable BGP on interface\n"
3050 "Specify a BGP neighbor\n"
3052 "Internal BGP peer\n"
3053 "External BGP peer\n")
3056 int idx_remote_as
= 4;
3057 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3058 SAFI_UNICAST
, 0, NULL
,
3059 argv
[idx_remote_as
]->arg
);
3062 DEFUN (neighbor_interface_v6only_config_remote_as
,
3063 neighbor_interface_v6only_config_remote_as_cmd
,
3064 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3066 "Interface name or neighbor tag\n"
3067 "Enable BGP with v6 link-local only\n"
3068 "Enable BGP on interface\n"
3069 "Specify a BGP neighbor\n"
3071 "Internal BGP peer\n"
3072 "External BGP peer\n")
3075 int idx_remote_as
= 5;
3076 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3077 SAFI_UNICAST
, 1, NULL
,
3078 argv
[idx_remote_as
]->arg
);
3081 DEFUN (neighbor_peer_group
,
3082 neighbor_peer_group_cmd
,
3083 "neighbor WORD peer-group",
3085 "Interface name or neighbor tag\n"
3086 "Configure peer-group\n")
3088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3091 struct peer_group
*group
;
3093 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3095 vty_out(vty
, "%% Name conflict with interface: \n");
3096 return CMD_WARNING_CONFIG_FAILED
;
3099 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3101 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3102 return CMD_WARNING_CONFIG_FAILED
;
3110 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3114 "Specify a BGP neighbor\n"
3116 "Internal BGP peer\n"
3117 "External BGP peer\n")
3119 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3123 struct peer_group
*group
;
3127 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3129 /* look up for neighbor by interface name config. */
3130 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3132 /* Request zebra to terminate IPv6 RAs on this
3135 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3140 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3142 peer_group_delete(group
);
3144 vty_out(vty
, "%% Create the peer-group first\n");
3145 return CMD_WARNING_CONFIG_FAILED
;
3148 peer
= peer_lookup(bgp
, &su
);
3150 if (peer_dynamic_neighbor(peer
)) {
3152 "%% Operation not allowed on a dynamic neighbor\n");
3153 return CMD_WARNING_CONFIG_FAILED
;
3156 other
= peer
->doppelganger
;
3158 if (other
&& other
->status
!= Deleted
)
3166 DEFUN (no_neighbor_interface_config
,
3167 no_neighbor_interface_config_cmd
,
3168 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3172 "Configure BGP on interface\n"
3173 "Enable BGP with v6 link-local only\n"
3174 "Member of the peer-group\n"
3176 "Specify a BGP neighbor\n"
3178 "Internal BGP peer\n"
3179 "External BGP peer\n")
3181 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3185 /* look up for neighbor by interface name config. */
3186 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3188 /* Request zebra to terminate IPv6 RAs on this interface. */
3190 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3193 vty_out(vty
, "%% Create the bgp interface first\n");
3194 return CMD_WARNING_CONFIG_FAILED
;
3199 DEFUN (no_neighbor_peer_group
,
3200 no_neighbor_peer_group_cmd
,
3201 "no neighbor WORD peer-group",
3205 "Configure peer-group\n")
3207 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3209 struct peer_group
*group
;
3211 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3213 peer_group_delete(group
);
3215 vty_out(vty
, "%% Create the peer-group first\n");
3216 return CMD_WARNING_CONFIG_FAILED
;
3221 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3222 no_neighbor_interface_peer_group_remote_as_cmd
,
3223 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3226 "Interface name or neighbor tag\n"
3227 "Specify a BGP neighbor\n"
3229 "Internal BGP peer\n"
3230 "External BGP peer\n")
3232 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3234 struct peer_group
*group
;
3237 /* look up for neighbor by interface name config. */
3238 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3240 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3244 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3246 peer_group_remote_as_delete(group
);
3248 vty_out(vty
, "%% Create the peer-group or interface first\n");
3249 return CMD_WARNING_CONFIG_FAILED
;
3254 DEFUN (neighbor_local_as
,
3255 neighbor_local_as_cmd
,
3256 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3259 "Specify a local-as number\n"
3260 "AS number used as local AS\n")
3268 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3270 return CMD_WARNING_CONFIG_FAILED
;
3272 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3273 ret
= peer_local_as_set(peer
, as
, 0, 0);
3274 return bgp_vty_return(vty
, ret
);
3277 DEFUN (neighbor_local_as_no_prepend
,
3278 neighbor_local_as_no_prepend_cmd
,
3279 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3282 "Specify a local-as number\n"
3283 "AS number used as local AS\n"
3284 "Do not prepend local-as to updates from ebgp peers\n")
3292 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3294 return CMD_WARNING_CONFIG_FAILED
;
3296 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3297 ret
= peer_local_as_set(peer
, as
, 1, 0);
3298 return bgp_vty_return(vty
, ret
);
3301 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3302 neighbor_local_as_no_prepend_replace_as_cmd
,
3303 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3306 "Specify a local-as number\n"
3307 "AS number used as local AS\n"
3308 "Do not prepend local-as to updates from ebgp peers\n"
3309 "Do not prepend local-as to updates from ibgp peers\n")
3317 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3319 return CMD_WARNING_CONFIG_FAILED
;
3321 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3322 ret
= peer_local_as_set(peer
, as
, 1, 1);
3323 return bgp_vty_return(vty
, ret
);
3326 DEFUN (no_neighbor_local_as
,
3327 no_neighbor_local_as_cmd
,
3328 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3332 "Specify a local-as number\n"
3333 "AS number used as local AS\n"
3334 "Do not prepend local-as to updates from ebgp peers\n"
3335 "Do not prepend local-as to updates from ibgp peers\n")
3341 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3343 return CMD_WARNING_CONFIG_FAILED
;
3345 ret
= peer_local_as_unset(peer
);
3346 return bgp_vty_return(vty
, ret
);
3350 DEFUN (neighbor_solo
,
3352 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3355 "Solo peer - part of its own update group\n")
3361 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3363 return CMD_WARNING_CONFIG_FAILED
;
3365 ret
= update_group_adjust_soloness(peer
, 1);
3366 return bgp_vty_return(vty
, ret
);
3369 DEFUN (no_neighbor_solo
,
3370 no_neighbor_solo_cmd
,
3371 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3375 "Solo peer - part of its own update group\n")
3381 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3383 return CMD_WARNING_CONFIG_FAILED
;
3385 ret
= update_group_adjust_soloness(peer
, 0);
3386 return bgp_vty_return(vty
, ret
);
3389 DEFUN (neighbor_password
,
3390 neighbor_password_cmd
,
3391 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3402 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3404 return CMD_WARNING_CONFIG_FAILED
;
3406 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3407 return bgp_vty_return(vty
, ret
);
3410 DEFUN (no_neighbor_password
,
3411 no_neighbor_password_cmd
,
3412 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3423 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3425 return CMD_WARNING_CONFIG_FAILED
;
3427 ret
= peer_password_unset(peer
);
3428 return bgp_vty_return(vty
, ret
);
3431 DEFUN (neighbor_activate
,
3432 neighbor_activate_cmd
,
3433 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3436 "Enable the Address Family for this Neighbor\n")
3442 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3444 return CMD_WARNING_CONFIG_FAILED
;
3446 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3447 return bgp_vty_return(vty
, ret
);
3450 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3451 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3452 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3453 "Enable the Address Family for this Neighbor\n")
3455 DEFUN (no_neighbor_activate
,
3456 no_neighbor_activate_cmd
,
3457 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3461 "Enable the Address Family for this Neighbor\n")
3468 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3470 return CMD_WARNING_CONFIG_FAILED
;
3472 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3473 return bgp_vty_return(vty
, ret
);
3476 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3477 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3478 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3479 "Enable the Address Family for this Neighbor\n")
3481 DEFUN (neighbor_set_peer_group
,
3482 neighbor_set_peer_group_cmd
,
3483 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3486 "Member of the peer-group\n"
3487 "Peer-group name\n")
3489 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3496 struct peer_group
*group
;
3498 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3500 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3502 vty_out(vty
, "%% Malformed address or name: %s\n",
3503 argv
[idx_peer
]->arg
);
3504 return CMD_WARNING_CONFIG_FAILED
;
3507 if (peer_address_self_check(bgp
, &su
)) {
3509 "%% Can not configure the local system as neighbor\n");
3510 return CMD_WARNING_CONFIG_FAILED
;
3513 /* Disallow for dynamic neighbor. */
3514 peer
= peer_lookup(bgp
, &su
);
3515 if (peer
&& peer_dynamic_neighbor(peer
)) {
3517 "%% Operation not allowed on a dynamic neighbor\n");
3518 return CMD_WARNING_CONFIG_FAILED
;
3522 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3524 vty_out(vty
, "%% Configure the peer-group first\n");
3525 return CMD_WARNING_CONFIG_FAILED
;
3528 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3530 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3532 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3534 return CMD_WARNING_CONFIG_FAILED
;
3537 return bgp_vty_return(vty
, ret
);
3540 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3541 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3542 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3543 "Member of the peer-group\n"
3544 "Peer-group name\n")
3546 DEFUN (no_neighbor_set_peer_group
,
3547 no_neighbor_set_peer_group_cmd
,
3548 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3552 "Member of the peer-group\n"
3553 "Peer-group name\n")
3555 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3560 struct peer_group
*group
;
3562 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3564 return CMD_WARNING_CONFIG_FAILED
;
3566 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3568 vty_out(vty
, "%% Configure the peer-group first\n");
3569 return CMD_WARNING_CONFIG_FAILED
;
3572 ret
= peer_delete(peer
);
3574 return bgp_vty_return(vty
, ret
);
3577 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3578 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3579 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3580 "Member of the peer-group\n"
3581 "Peer-group name\n")
3583 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3584 uint32_t flag
, int set
)
3589 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3591 return CMD_WARNING_CONFIG_FAILED
;
3594 * If 'neighbor <interface>', then this is for directly connected peers,
3595 * we should not accept disable-connected-check.
3597 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3599 "%s is directly connected peer, cannot accept disable-"
3600 "connected-check\n",
3602 return CMD_WARNING_CONFIG_FAILED
;
3605 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3606 peer_tx_shutdown_message_unset(peer
);
3609 ret
= peer_flag_set(peer
, flag
);
3611 ret
= peer_flag_unset(peer
, flag
);
3613 return bgp_vty_return(vty
, ret
);
3616 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3618 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3621 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3624 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3627 /* neighbor passive. */
3628 DEFUN (neighbor_passive
,
3629 neighbor_passive_cmd
,
3630 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3633 "Don't send open messages to this neighbor\n")
3636 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3639 DEFUN (no_neighbor_passive
,
3640 no_neighbor_passive_cmd
,
3641 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3645 "Don't send open messages to this neighbor\n")
3648 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3651 /* neighbor shutdown. */
3652 DEFUN (neighbor_shutdown_msg
,
3653 neighbor_shutdown_msg_cmd
,
3654 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3657 "Administratively shut down this neighbor\n"
3658 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3659 "Shutdown message\n")
3665 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3669 return CMD_WARNING_CONFIG_FAILED
;
3670 message
= argv_concat(argv
, argc
, 4);
3671 peer_tx_shutdown_message_set(peer
, message
);
3672 XFREE(MTYPE_TMP
, message
);
3675 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3678 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3679 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3680 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3681 "Administratively shut down this neighbor\n")
3683 DEFUN (no_neighbor_shutdown_msg
,
3684 no_neighbor_shutdown_msg_cmd
,
3685 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3689 "Administratively shut down this neighbor\n"
3690 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3691 "Shutdown message\n")
3695 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3696 PEER_FLAG_SHUTDOWN
);
3699 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3700 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3701 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3702 "Administratively shut down this neighbor\n")
3704 /* neighbor capability dynamic. */
3705 DEFUN (neighbor_capability_dynamic
,
3706 neighbor_capability_dynamic_cmd
,
3707 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3710 "Advertise capability to the peer\n"
3711 "Advertise dynamic capability to this neighbor\n")
3714 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3715 PEER_FLAG_DYNAMIC_CAPABILITY
);
3718 DEFUN (no_neighbor_capability_dynamic
,
3719 no_neighbor_capability_dynamic_cmd
,
3720 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3724 "Advertise capability to the peer\n"
3725 "Advertise dynamic capability to this neighbor\n")
3728 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3729 PEER_FLAG_DYNAMIC_CAPABILITY
);
3732 /* neighbor dont-capability-negotiate */
3733 DEFUN (neighbor_dont_capability_negotiate
,
3734 neighbor_dont_capability_negotiate_cmd
,
3735 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3738 "Do not perform capability negotiation\n")
3741 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3742 PEER_FLAG_DONT_CAPABILITY
);
3745 DEFUN (no_neighbor_dont_capability_negotiate
,
3746 no_neighbor_dont_capability_negotiate_cmd
,
3747 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3751 "Do not perform capability negotiation\n")
3754 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3755 PEER_FLAG_DONT_CAPABILITY
);
3758 /* neighbor capability extended next hop encoding */
3759 DEFUN (neighbor_capability_enhe
,
3760 neighbor_capability_enhe_cmd
,
3761 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3764 "Advertise capability to the peer\n"
3765 "Advertise extended next-hop capability to the peer\n")
3768 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3769 PEER_FLAG_CAPABILITY_ENHE
);
3772 DEFUN (no_neighbor_capability_enhe
,
3773 no_neighbor_capability_enhe_cmd
,
3774 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3778 "Advertise capability to the peer\n"
3779 "Advertise extended next-hop capability to the peer\n")
3782 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3783 PEER_FLAG_CAPABILITY_ENHE
);
3786 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3787 afi_t afi
, safi_t safi
, uint32_t flag
,
3793 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3795 return CMD_WARNING_CONFIG_FAILED
;
3798 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3800 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3802 return bgp_vty_return(vty
, ret
);
3805 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3806 afi_t afi
, safi_t safi
, uint32_t flag
)
3808 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3811 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3812 afi_t afi
, safi_t safi
, uint32_t flag
)
3814 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3817 /* neighbor capability orf prefix-list. */
3818 DEFUN (neighbor_capability_orf_prefix
,
3819 neighbor_capability_orf_prefix_cmd
,
3820 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3823 "Advertise capability to the peer\n"
3824 "Advertise ORF capability to the peer\n"
3825 "Advertise prefixlist ORF capability to this neighbor\n"
3826 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3827 "Capability to RECEIVE the ORF from this neighbor\n"
3828 "Capability to SEND the ORF to this neighbor\n")
3831 int idx_send_recv
= 5;
3834 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3835 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3836 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3837 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3838 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3839 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3841 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3842 return CMD_WARNING_CONFIG_FAILED
;
3845 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3846 bgp_node_safi(vty
), flag
);
3850 neighbor_capability_orf_prefix
,
3851 neighbor_capability_orf_prefix_hidden_cmd
,
3852 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3853 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3854 "Advertise capability to the peer\n"
3855 "Advertise ORF capability to the peer\n"
3856 "Advertise prefixlist ORF capability to this neighbor\n"
3857 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3858 "Capability to RECEIVE the ORF from this neighbor\n"
3859 "Capability to SEND the ORF to this neighbor\n")
3861 DEFUN (no_neighbor_capability_orf_prefix
,
3862 no_neighbor_capability_orf_prefix_cmd
,
3863 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3867 "Advertise capability to the peer\n"
3868 "Advertise ORF capability to the peer\n"
3869 "Advertise prefixlist ORF capability to this neighbor\n"
3870 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3871 "Capability to RECEIVE the ORF from this neighbor\n"
3872 "Capability to SEND the ORF to this neighbor\n")
3875 int idx_send_recv
= 6;
3878 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3879 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3880 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3881 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3882 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3883 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3885 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3886 return CMD_WARNING_CONFIG_FAILED
;
3889 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3890 bgp_node_afi(vty
), bgp_node_safi(vty
),
3895 no_neighbor_capability_orf_prefix
,
3896 no_neighbor_capability_orf_prefix_hidden_cmd
,
3897 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3898 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3899 "Advertise capability to the peer\n"
3900 "Advertise ORF capability to the peer\n"
3901 "Advertise prefixlist ORF capability to this neighbor\n"
3902 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3903 "Capability to RECEIVE the ORF from this neighbor\n"
3904 "Capability to SEND the ORF to this neighbor\n")
3906 /* neighbor next-hop-self. */
3907 DEFUN (neighbor_nexthop_self
,
3908 neighbor_nexthop_self_cmd
,
3909 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3912 "Disable the next hop calculation for this neighbor\n")
3915 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3916 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3919 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3920 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3921 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3922 "Disable the next hop calculation for this neighbor\n")
3924 /* neighbor next-hop-self. */
3925 DEFUN (neighbor_nexthop_self_force
,
3926 neighbor_nexthop_self_force_cmd
,
3927 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3930 "Disable the next hop calculation for this neighbor\n"
3931 "Set the next hop to self for reflected routes\n")
3934 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3936 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3939 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3940 neighbor_nexthop_self_force_hidden_cmd
,
3941 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3942 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3943 "Disable the next hop calculation for this neighbor\n"
3944 "Set the next hop to self for reflected routes\n")
3946 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3947 neighbor_nexthop_self_all_hidden_cmd
,
3948 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3949 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3950 "Disable the next hop calculation for this neighbor\n"
3951 "Set the next hop to self for reflected routes\n")
3953 DEFUN (no_neighbor_nexthop_self
,
3954 no_neighbor_nexthop_self_cmd
,
3955 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3959 "Disable the next hop calculation for this neighbor\n")
3962 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3963 bgp_node_afi(vty
), bgp_node_safi(vty
),
3964 PEER_FLAG_NEXTHOP_SELF
);
3967 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3968 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3969 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3970 "Disable the next hop calculation for this neighbor\n")
3972 DEFUN (no_neighbor_nexthop_self_force
,
3973 no_neighbor_nexthop_self_force_cmd
,
3974 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3978 "Disable the next hop calculation for this neighbor\n"
3979 "Set the next hop to self for reflected routes\n")
3982 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3983 bgp_node_afi(vty
), bgp_node_safi(vty
),
3984 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3987 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3988 no_neighbor_nexthop_self_force_hidden_cmd
,
3989 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3990 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3991 "Disable the next hop calculation for this neighbor\n"
3992 "Set the next hop to self for reflected routes\n")
3994 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3995 no_neighbor_nexthop_self_all_hidden_cmd
,
3996 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3997 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3998 "Disable the next hop calculation for this neighbor\n"
3999 "Set the next hop to self for reflected routes\n")
4001 /* neighbor as-override */
4002 DEFUN (neighbor_as_override
,
4003 neighbor_as_override_cmd
,
4004 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4007 "Override ASNs in outbound updates if aspath equals remote-as\n")
4010 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4011 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4014 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4015 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4017 "Override ASNs in outbound updates if aspath equals remote-as\n")
4019 DEFUN (no_neighbor_as_override
,
4020 no_neighbor_as_override_cmd
,
4021 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4025 "Override ASNs in outbound updates if aspath equals remote-as\n")
4028 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4029 bgp_node_afi(vty
), bgp_node_safi(vty
),
4030 PEER_FLAG_AS_OVERRIDE
);
4033 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4034 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4035 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4036 "Override ASNs in outbound updates if aspath equals remote-as\n")
4038 /* neighbor remove-private-AS. */
4039 DEFUN (neighbor_remove_private_as
,
4040 neighbor_remove_private_as_cmd
,
4041 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4044 "Remove private ASNs in outbound updates\n")
4047 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4049 PEER_FLAG_REMOVE_PRIVATE_AS
);
4052 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4053 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4054 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4055 "Remove private ASNs in outbound updates\n")
4057 DEFUN (neighbor_remove_private_as_all
,
4058 neighbor_remove_private_as_all_cmd
,
4059 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4062 "Remove private ASNs in outbound updates\n"
4063 "Apply to all AS numbers\n")
4066 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4068 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4071 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4072 neighbor_remove_private_as_all_hidden_cmd
,
4073 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4074 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4075 "Remove private ASNs in outbound updates\n"
4076 "Apply to all AS numbers")
4078 DEFUN (neighbor_remove_private_as_replace_as
,
4079 neighbor_remove_private_as_replace_as_cmd
,
4080 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4083 "Remove private ASNs in outbound updates\n"
4084 "Replace private ASNs with our ASN in outbound updates\n")
4087 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4089 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4092 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4093 neighbor_remove_private_as_replace_as_hidden_cmd
,
4094 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4095 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4096 "Remove private ASNs in outbound updates\n"
4097 "Replace private ASNs with our ASN in outbound updates\n")
4099 DEFUN (neighbor_remove_private_as_all_replace_as
,
4100 neighbor_remove_private_as_all_replace_as_cmd
,
4101 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4104 "Remove private ASNs in outbound updates\n"
4105 "Apply to all AS numbers\n"
4106 "Replace private ASNs with our ASN in outbound updates\n")
4109 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4111 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4115 neighbor_remove_private_as_all_replace_as
,
4116 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4117 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4118 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4119 "Remove private ASNs in outbound updates\n"
4120 "Apply to all AS numbers\n"
4121 "Replace private ASNs with our ASN in outbound updates\n")
4123 DEFUN (no_neighbor_remove_private_as
,
4124 no_neighbor_remove_private_as_cmd
,
4125 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4129 "Remove private ASNs in outbound updates\n")
4132 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4133 bgp_node_afi(vty
), bgp_node_safi(vty
),
4134 PEER_FLAG_REMOVE_PRIVATE_AS
);
4137 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4138 no_neighbor_remove_private_as_hidden_cmd
,
4139 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4140 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4141 "Remove private ASNs in outbound updates\n")
4143 DEFUN (no_neighbor_remove_private_as_all
,
4144 no_neighbor_remove_private_as_all_cmd
,
4145 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4149 "Remove private ASNs in outbound updates\n"
4150 "Apply to all AS numbers\n")
4153 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4154 bgp_node_afi(vty
), bgp_node_safi(vty
),
4155 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4158 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4159 no_neighbor_remove_private_as_all_hidden_cmd
,
4160 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4161 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4162 "Remove private ASNs in outbound updates\n"
4163 "Apply to all AS numbers\n")
4165 DEFUN (no_neighbor_remove_private_as_replace_as
,
4166 no_neighbor_remove_private_as_replace_as_cmd
,
4167 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4171 "Remove private ASNs in outbound updates\n"
4172 "Replace private ASNs with our ASN in outbound updates\n")
4175 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4176 bgp_node_afi(vty
), bgp_node_safi(vty
),
4177 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4180 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4181 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4182 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4183 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4184 "Remove private ASNs in outbound updates\n"
4185 "Replace private ASNs with our ASN in outbound updates\n")
4187 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4188 no_neighbor_remove_private_as_all_replace_as_cmd
,
4189 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4193 "Remove private ASNs in outbound updates\n"
4194 "Apply to all AS numbers\n"
4195 "Replace private ASNs with our ASN in outbound updates\n")
4198 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4199 bgp_node_afi(vty
), bgp_node_safi(vty
),
4200 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4204 no_neighbor_remove_private_as_all_replace_as
,
4205 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4206 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4207 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4208 "Remove private ASNs in outbound updates\n"
4209 "Apply to all AS numbers\n"
4210 "Replace private ASNs with our ASN in outbound updates\n")
4213 /* neighbor send-community. */
4214 DEFUN (neighbor_send_community
,
4215 neighbor_send_community_cmd
,
4216 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4219 "Send Community attribute to this neighbor\n")
4223 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4225 PEER_FLAG_SEND_COMMUNITY
);
4228 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4229 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4230 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4231 "Send Community attribute to this neighbor\n")
4233 DEFUN (no_neighbor_send_community
,
4234 no_neighbor_send_community_cmd
,
4235 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4239 "Send Community attribute to this neighbor\n")
4243 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4244 bgp_node_afi(vty
), bgp_node_safi(vty
),
4245 PEER_FLAG_SEND_COMMUNITY
);
4248 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4249 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4250 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4251 "Send Community attribute to this neighbor\n")
4253 /* neighbor send-community extended. */
4254 DEFUN (neighbor_send_community_type
,
4255 neighbor_send_community_type_cmd
,
4256 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4259 "Send Community attribute to this neighbor\n"
4260 "Send Standard and Extended Community attributes\n"
4261 "Send Standard, Large and Extended Community attributes\n"
4262 "Send Extended Community attributes\n"
4263 "Send Standard Community attributes\n"
4264 "Send Large Community attributes\n")
4268 const char *type
= argv
[argc
- 1]->text
;
4270 if (strmatch(type
, "standard")) {
4271 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4272 } else if (strmatch(type
, "extended")) {
4273 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4274 } else if (strmatch(type
, "large")) {
4275 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4276 } else if (strmatch(type
, "both")) {
4277 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4278 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4279 } else { /* if (strmatch(type, "all")) */
4280 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4281 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4282 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4285 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4286 bgp_node_safi(vty
), flag
);
4290 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4291 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4292 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4293 "Send Community attribute to this neighbor\n"
4294 "Send Standard and Extended Community attributes\n"
4295 "Send Standard, Large and Extended Community attributes\n"
4296 "Send Extended Community attributes\n"
4297 "Send Standard Community attributes\n"
4298 "Send Large Community attributes\n")
4300 DEFUN (no_neighbor_send_community_type
,
4301 no_neighbor_send_community_type_cmd
,
4302 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4306 "Send Community attribute to this neighbor\n"
4307 "Send Standard and Extended Community attributes\n"
4308 "Send Standard, Large and Extended Community attributes\n"
4309 "Send Extended Community attributes\n"
4310 "Send Standard Community attributes\n"
4311 "Send Large Community attributes\n")
4315 const char *type
= argv
[argc
- 1]->text
;
4317 if (strmatch(type
, "standard")) {
4318 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4319 } else if (strmatch(type
, "extended")) {
4320 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4321 } else if (strmatch(type
, "large")) {
4322 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4323 } else if (strmatch(type
, "both")) {
4324 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4325 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4326 } else { /* if (strmatch(type, "all")) */
4327 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4328 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4329 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4332 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4333 bgp_node_afi(vty
), bgp_node_safi(vty
),
4338 no_neighbor_send_community_type
,
4339 no_neighbor_send_community_type_hidden_cmd
,
4340 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4341 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4342 "Send Community attribute to this neighbor\n"
4343 "Send Standard and Extended Community attributes\n"
4344 "Send Standard, Large and Extended Community attributes\n"
4345 "Send Extended Community attributes\n"
4346 "Send Standard Community attributes\n"
4347 "Send Large Community attributes\n")
4349 /* neighbor soft-reconfig. */
4350 DEFUN (neighbor_soft_reconfiguration
,
4351 neighbor_soft_reconfiguration_cmd
,
4352 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4355 "Per neighbor soft reconfiguration\n"
4356 "Allow inbound soft reconfiguration for this neighbor\n")
4359 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4361 PEER_FLAG_SOFT_RECONFIG
);
4364 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4365 neighbor_soft_reconfiguration_hidden_cmd
,
4366 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4367 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4368 "Per neighbor soft reconfiguration\n"
4369 "Allow inbound soft reconfiguration for this neighbor\n")
4371 DEFUN (no_neighbor_soft_reconfiguration
,
4372 no_neighbor_soft_reconfiguration_cmd
,
4373 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4377 "Per neighbor soft reconfiguration\n"
4378 "Allow inbound soft reconfiguration for this neighbor\n")
4381 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4382 bgp_node_afi(vty
), bgp_node_safi(vty
),
4383 PEER_FLAG_SOFT_RECONFIG
);
4386 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4387 no_neighbor_soft_reconfiguration_hidden_cmd
,
4388 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4389 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4390 "Per neighbor soft reconfiguration\n"
4391 "Allow inbound soft reconfiguration for this neighbor\n")
4393 DEFUN (neighbor_route_reflector_client
,
4394 neighbor_route_reflector_client_cmd
,
4395 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4398 "Configure a neighbor as Route Reflector client\n")
4404 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4406 return CMD_WARNING_CONFIG_FAILED
;
4408 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4410 PEER_FLAG_REFLECTOR_CLIENT
);
4413 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4414 neighbor_route_reflector_client_hidden_cmd
,
4415 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4416 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4417 "Configure a neighbor as Route Reflector client\n")
4419 DEFUN (no_neighbor_route_reflector_client
,
4420 no_neighbor_route_reflector_client_cmd
,
4421 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4425 "Configure a neighbor as Route Reflector client\n")
4428 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4429 bgp_node_afi(vty
), bgp_node_safi(vty
),
4430 PEER_FLAG_REFLECTOR_CLIENT
);
4433 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4434 no_neighbor_route_reflector_client_hidden_cmd
,
4435 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4436 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4437 "Configure a neighbor as Route Reflector client\n")
4439 /* neighbor route-server-client. */
4440 DEFUN (neighbor_route_server_client
,
4441 neighbor_route_server_client_cmd
,
4442 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4445 "Configure a neighbor as Route Server client\n")
4450 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4452 return CMD_WARNING_CONFIG_FAILED
;
4453 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4455 PEER_FLAG_RSERVER_CLIENT
);
4458 ALIAS_HIDDEN(neighbor_route_server_client
,
4459 neighbor_route_server_client_hidden_cmd
,
4460 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4461 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4462 "Configure a neighbor as Route Server client\n")
4464 DEFUN (no_neighbor_route_server_client
,
4465 no_neighbor_route_server_client_cmd
,
4466 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4470 "Configure a neighbor as Route Server client\n")
4473 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4474 bgp_node_afi(vty
), bgp_node_safi(vty
),
4475 PEER_FLAG_RSERVER_CLIENT
);
4478 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4479 no_neighbor_route_server_client_hidden_cmd
,
4480 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4481 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4482 "Configure a neighbor as Route Server client\n")
4484 DEFUN (neighbor_nexthop_local_unchanged
,
4485 neighbor_nexthop_local_unchanged_cmd
,
4486 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4489 "Configure treatment of outgoing link-local nexthop attribute\n"
4490 "Leave link-local nexthop unchanged for this peer\n")
4493 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4495 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4498 DEFUN (no_neighbor_nexthop_local_unchanged
,
4499 no_neighbor_nexthop_local_unchanged_cmd
,
4500 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4504 "Configure treatment of outgoing link-local-nexthop attribute\n"
4505 "Leave link-local nexthop unchanged for this peer\n")
4508 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4509 bgp_node_afi(vty
), bgp_node_safi(vty
),
4510 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4513 DEFUN (neighbor_attr_unchanged
,
4514 neighbor_attr_unchanged_cmd
,
4515 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4518 "BGP attribute is propagated unchanged to this neighbor\n"
4519 "As-path attribute\n"
4520 "Nexthop attribute\n"
4524 char *peer_str
= argv
[1]->arg
;
4527 afi_t afi
= bgp_node_afi(vty
);
4528 safi_t safi
= bgp_node_safi(vty
);
4530 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4532 return CMD_WARNING_CONFIG_FAILED
;
4534 if (argv_find(argv
, argc
, "as-path", &idx
))
4535 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4537 if (argv_find(argv
, argc
, "next-hop", &idx
))
4538 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4540 if (argv_find(argv
, argc
, "med", &idx
))
4541 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4543 /* no flags means all of them! */
4545 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4546 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4547 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4549 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4550 && peer_af_flag_check(peer
, afi
, safi
,
4551 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4552 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4553 PEER_FLAG_AS_PATH_UNCHANGED
);
4556 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4557 && peer_af_flag_check(peer
, afi
, safi
,
4558 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4559 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4560 PEER_FLAG_NEXTHOP_UNCHANGED
);
4563 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4564 && peer_af_flag_check(peer
, afi
, safi
,
4565 PEER_FLAG_MED_UNCHANGED
)) {
4566 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4567 PEER_FLAG_MED_UNCHANGED
);
4571 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4575 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4576 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4577 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4578 "BGP attribute is propagated unchanged to this neighbor\n"
4579 "As-path attribute\n"
4580 "Nexthop attribute\n"
4583 DEFUN (no_neighbor_attr_unchanged
,
4584 no_neighbor_attr_unchanged_cmd
,
4585 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4589 "BGP attribute is propagated unchanged to this neighbor\n"
4590 "As-path attribute\n"
4591 "Nexthop attribute\n"
4595 char *peer
= argv
[2]->arg
;
4598 if (argv_find(argv
, argc
, "as-path", &idx
))
4599 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4601 if (argv_find(argv
, argc
, "next-hop", &idx
))
4602 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4604 if (argv_find(argv
, argc
, "med", &idx
))
4605 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4607 if (!flags
) // no flags means all of them!
4609 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4610 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4611 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4614 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4615 bgp_node_safi(vty
), flags
);
4619 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4620 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4621 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4622 "BGP attribute is propagated unchanged to this neighbor\n"
4623 "As-path attribute\n"
4624 "Nexthop attribute\n"
4627 /* EBGP multihop configuration. */
4628 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4629 const char *ttl_str
)
4634 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4636 return CMD_WARNING_CONFIG_FAILED
;
4639 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4644 ttl
= strtoul(ttl_str
, NULL
, 10);
4646 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4649 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4653 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4655 return CMD_WARNING_CONFIG_FAILED
;
4657 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4660 /* neighbor ebgp-multihop. */
4661 DEFUN (neighbor_ebgp_multihop
,
4662 neighbor_ebgp_multihop_cmd
,
4663 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4666 "Allow EBGP neighbors not on directly connected networks\n")
4669 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4672 DEFUN (neighbor_ebgp_multihop_ttl
,
4673 neighbor_ebgp_multihop_ttl_cmd
,
4674 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4677 "Allow EBGP neighbors not on directly connected networks\n"
4678 "maximum hop count\n")
4682 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4683 argv
[idx_number
]->arg
);
4686 DEFUN (no_neighbor_ebgp_multihop
,
4687 no_neighbor_ebgp_multihop_cmd
,
4688 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4692 "Allow EBGP neighbors not on directly connected networks\n"
4693 "maximum hop count\n")
4696 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4700 /* disable-connected-check */
4701 DEFUN (neighbor_disable_connected_check
,
4702 neighbor_disable_connected_check_cmd
,
4703 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4706 "one-hop away EBGP peer using loopback address\n"
4707 "Enforce EBGP neighbors perform multihop\n")
4710 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4711 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4714 DEFUN (no_neighbor_disable_connected_check
,
4715 no_neighbor_disable_connected_check_cmd
,
4716 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4720 "one-hop away EBGP peer using loopback address\n"
4721 "Enforce EBGP neighbors perform multihop\n")
4724 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4725 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4729 /* enforce-first-as */
4730 DEFUN (neighbor_enforce_first_as
,
4731 neighbor_enforce_first_as_cmd
,
4732 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4735 "Enforce the first AS for EBGP routes\n")
4739 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4740 PEER_FLAG_ENFORCE_FIRST_AS
);
4743 DEFUN (no_neighbor_enforce_first_as
,
4744 no_neighbor_enforce_first_as_cmd
,
4745 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4749 "Enforce the first AS for EBGP routes\n")
4753 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4754 PEER_FLAG_ENFORCE_FIRST_AS
);
4758 DEFUN (neighbor_description
,
4759 neighbor_description_cmd
,
4760 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4763 "Neighbor specific description\n"
4764 "Up to 80 characters describing this neighbor\n")
4771 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4773 return CMD_WARNING_CONFIG_FAILED
;
4775 str
= argv_concat(argv
, argc
, idx_line
);
4777 peer_description_set(peer
, str
);
4779 XFREE(MTYPE_TMP
, str
);
4784 DEFUN (no_neighbor_description
,
4785 no_neighbor_description_cmd
,
4786 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4790 "Neighbor specific description\n")
4795 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4797 return CMD_WARNING_CONFIG_FAILED
;
4799 peer_description_unset(peer
);
4804 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4805 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4806 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4807 "Neighbor specific description\n"
4808 "Up to 80 characters describing this neighbor\n")
4810 /* Neighbor update-source. */
4811 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4812 const char *source_str
)
4818 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4820 return CMD_WARNING_CONFIG_FAILED
;
4826 if (str2sockunion(source_str
, &su
) == 0)
4827 peer_update_source_addr_set(peer
, &su
);
4829 if (str2prefix(source_str
, &p
)) {
4831 "%% Invalid update-source, remove prefix length \n");
4832 return CMD_WARNING_CONFIG_FAILED
;
4834 peer_update_source_if_set(peer
, source_str
);
4837 peer_update_source_unset(peer
);
4842 #define BGP_UPDATE_SOURCE_HELP_STR \
4845 "Interface name (requires zebra to be running)\n"
4847 DEFUN (neighbor_update_source
,
4848 neighbor_update_source_cmd
,
4849 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4852 "Source of routing updates\n"
4853 BGP_UPDATE_SOURCE_HELP_STR
)
4857 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4858 argv
[idx_peer_2
]->arg
);
4861 DEFUN (no_neighbor_update_source
,
4862 no_neighbor_update_source_cmd
,
4863 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4867 "Source of routing updates\n"
4868 BGP_UPDATE_SOURCE_HELP_STR
)
4871 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4874 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4875 afi_t afi
, safi_t safi
,
4876 const char *rmap
, int set
)
4880 struct route_map
*route_map
;
4882 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4884 return CMD_WARNING_CONFIG_FAILED
;
4887 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4888 ret
= peer_default_originate_set(peer
, afi
, safi
,
4891 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4893 return bgp_vty_return(vty
, ret
);
4896 /* neighbor default-originate. */
4897 DEFUN (neighbor_default_originate
,
4898 neighbor_default_originate_cmd
,
4899 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4902 "Originate default route to this neighbor\n")
4905 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4907 bgp_node_safi(vty
), NULL
, 1);
4910 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4911 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4912 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4913 "Originate default route to this neighbor\n")
4915 DEFUN (neighbor_default_originate_rmap
,
4916 neighbor_default_originate_rmap_cmd
,
4917 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4920 "Originate default route to this neighbor\n"
4921 "Route-map to specify criteria to originate default\n"
4926 return peer_default_originate_set_vty(
4927 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4928 argv
[idx_word
]->arg
, 1);
4932 neighbor_default_originate_rmap
,
4933 neighbor_default_originate_rmap_hidden_cmd
,
4934 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4935 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4936 "Originate default route to this neighbor\n"
4937 "Route-map to specify criteria to originate default\n"
4940 DEFUN (no_neighbor_default_originate
,
4941 no_neighbor_default_originate_cmd
,
4942 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4946 "Originate default route to this neighbor\n"
4947 "Route-map to specify criteria to originate default\n"
4951 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4953 bgp_node_safi(vty
), NULL
, 0);
4957 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4958 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4959 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4960 "Originate default route to this neighbor\n"
4961 "Route-map to specify criteria to originate default\n"
4965 /* Set neighbor's BGP port. */
4966 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4967 const char *port_str
)
4973 peer
= peer_lookup_vty(vty
, ip_str
);
4975 return CMD_WARNING_CONFIG_FAILED
;
4978 sp
= getservbyname("bgp", "tcp");
4979 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4981 port
= strtoul(port_str
, NULL
, 10);
4984 peer_port_set(peer
, port
);
4989 /* Set specified peer's BGP port. */
4990 DEFUN (neighbor_port
,
4992 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4995 "Neighbor's BGP port\n"
4996 "TCP port number\n")
5000 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5001 argv
[idx_number
]->arg
);
5004 DEFUN (no_neighbor_port
,
5005 no_neighbor_port_cmd
,
5006 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5010 "Neighbor's BGP port\n"
5011 "TCP port number\n")
5014 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5018 /* neighbor weight. */
5019 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5020 safi_t safi
, const char *weight_str
)
5024 unsigned long weight
;
5026 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5028 return CMD_WARNING_CONFIG_FAILED
;
5030 weight
= strtoul(weight_str
, NULL
, 10);
5032 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5033 return bgp_vty_return(vty
, ret
);
5036 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5042 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5044 return CMD_WARNING_CONFIG_FAILED
;
5046 ret
= peer_weight_unset(peer
, afi
, safi
);
5047 return bgp_vty_return(vty
, ret
);
5050 DEFUN (neighbor_weight
,
5051 neighbor_weight_cmd
,
5052 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5055 "Set default weight for routes from this neighbor\n"
5060 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5061 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5064 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5065 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5066 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5067 "Set default weight for routes from this neighbor\n"
5070 DEFUN (no_neighbor_weight
,
5071 no_neighbor_weight_cmd
,
5072 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5076 "Set default weight for routes from this neighbor\n"
5080 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5081 bgp_node_afi(vty
), bgp_node_safi(vty
));
5084 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5085 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5086 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5087 "Set default weight for routes from this neighbor\n"
5091 /* Override capability negotiation. */
5092 DEFUN (neighbor_override_capability
,
5093 neighbor_override_capability_cmd
,
5094 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5097 "Override capability negotiation result\n")
5100 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5101 PEER_FLAG_OVERRIDE_CAPABILITY
);
5104 DEFUN (no_neighbor_override_capability
,
5105 no_neighbor_override_capability_cmd
,
5106 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5110 "Override capability negotiation result\n")
5113 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5114 PEER_FLAG_OVERRIDE_CAPABILITY
);
5117 DEFUN (neighbor_strict_capability
,
5118 neighbor_strict_capability_cmd
,
5119 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5122 "Strict capability negotiation match\n")
5126 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5127 PEER_FLAG_STRICT_CAP_MATCH
);
5130 DEFUN (no_neighbor_strict_capability
,
5131 no_neighbor_strict_capability_cmd
,
5132 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5136 "Strict capability negotiation match\n")
5140 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5141 PEER_FLAG_STRICT_CAP_MATCH
);
5144 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5145 const char *keep_str
, const char *hold_str
)
5152 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5154 return CMD_WARNING_CONFIG_FAILED
;
5156 keepalive
= strtoul(keep_str
, NULL
, 10);
5157 holdtime
= strtoul(hold_str
, NULL
, 10);
5159 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5161 return bgp_vty_return(vty
, ret
);
5164 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5169 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5171 return CMD_WARNING_CONFIG_FAILED
;
5173 ret
= peer_timers_unset(peer
);
5175 return bgp_vty_return(vty
, ret
);
5178 DEFUN (neighbor_timers
,
5179 neighbor_timers_cmd
,
5180 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5183 "BGP per neighbor timers\n"
5184 "Keepalive interval\n"
5189 int idx_number_2
= 4;
5190 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5191 argv
[idx_number
]->arg
,
5192 argv
[idx_number_2
]->arg
);
5195 DEFUN (no_neighbor_timers
,
5196 no_neighbor_timers_cmd
,
5197 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5201 "BGP per neighbor timers\n"
5202 "Keepalive interval\n"
5206 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5210 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5211 const char *time_str
)
5217 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5219 return CMD_WARNING_CONFIG_FAILED
;
5221 connect
= strtoul(time_str
, NULL
, 10);
5223 ret
= peer_timers_connect_set(peer
, connect
);
5225 return bgp_vty_return(vty
, ret
);
5228 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5233 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5235 return CMD_WARNING_CONFIG_FAILED
;
5237 ret
= peer_timers_connect_unset(peer
);
5239 return bgp_vty_return(vty
, ret
);
5242 DEFUN (neighbor_timers_connect
,
5243 neighbor_timers_connect_cmd
,
5244 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5247 "BGP per neighbor timers\n"
5248 "BGP connect timer\n"
5253 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5254 argv
[idx_number
]->arg
);
5257 DEFUN (no_neighbor_timers_connect
,
5258 no_neighbor_timers_connect_cmd
,
5259 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5263 "BGP per neighbor timers\n"
5264 "BGP connect timer\n"
5268 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5272 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5273 const char *time_str
, int set
)
5277 uint32_t routeadv
= 0;
5279 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5281 return CMD_WARNING_CONFIG_FAILED
;
5284 routeadv
= strtoul(time_str
, NULL
, 10);
5287 ret
= peer_advertise_interval_set(peer
, routeadv
);
5289 ret
= peer_advertise_interval_unset(peer
);
5291 return bgp_vty_return(vty
, ret
);
5294 DEFUN (neighbor_advertise_interval
,
5295 neighbor_advertise_interval_cmd
,
5296 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5299 "Minimum interval between sending BGP routing updates\n"
5300 "time in seconds\n")
5304 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5305 argv
[idx_number
]->arg
, 1);
5308 DEFUN (no_neighbor_advertise_interval
,
5309 no_neighbor_advertise_interval_cmd
,
5310 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5314 "Minimum interval between sending BGP routing updates\n"
5315 "time in seconds\n")
5318 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5322 /* Time to wait before processing route-map updates */
5323 DEFUN (bgp_set_route_map_delay_timer
,
5324 bgp_set_route_map_delay_timer_cmd
,
5325 "bgp route-map delay-timer (0-600)",
5327 "BGP route-map delay timer\n"
5328 "Time in secs to wait before processing route-map changes\n"
5329 "0 disables the timer, no route updates happen when route-maps change\n")
5332 uint32_t rmap_delay_timer
;
5334 if (argv
[idx_number
]->arg
) {
5335 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5336 bm
->rmap_update_timer
= rmap_delay_timer
;
5338 /* if the dynamic update handling is being disabled, and a timer
5340 * running, stop the timer and act as if the timer has already
5343 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5344 BGP_TIMER_OFF(bm
->t_rmap_update
);
5345 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5350 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5351 return CMD_WARNING_CONFIG_FAILED
;
5355 DEFUN (no_bgp_set_route_map_delay_timer
,
5356 no_bgp_set_route_map_delay_timer_cmd
,
5357 "no bgp route-map delay-timer [(0-600)]",
5360 "Default BGP route-map delay timer\n"
5361 "Reset to default time to wait for processing route-map changes\n"
5362 "0 disables the timer, no route updates happen when route-maps change\n")
5365 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5371 /* neighbor interface */
5372 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5377 peer
= peer_lookup_vty(vty
, ip_str
);
5378 if (!peer
|| peer
->conf_if
) {
5379 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5380 return CMD_WARNING_CONFIG_FAILED
;
5384 peer_interface_set(peer
, str
);
5386 peer_interface_unset(peer
);
5391 DEFUN (neighbor_interface
,
5392 neighbor_interface_cmd
,
5393 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5401 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5404 DEFUN (no_neighbor_interface
,
5405 no_neighbor_interface_cmd
,
5406 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5414 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5417 DEFUN (neighbor_distribute_list
,
5418 neighbor_distribute_list_cmd
,
5419 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5422 "Filter updates to/from this neighbor\n"
5423 "IP access-list number\n"
5424 "IP access-list number (expanded range)\n"
5425 "IP Access-list name\n"
5426 "Filter incoming updates\n"
5427 "Filter outgoing updates\n")
5434 const char *pstr
= argv
[idx_peer
]->arg
;
5435 const char *acl
= argv
[idx_acl
]->arg
;
5436 const char *inout
= argv
[argc
- 1]->text
;
5438 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5440 return CMD_WARNING_CONFIG_FAILED
;
5442 /* Check filter direction. */
5443 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5444 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5447 return bgp_vty_return(vty
, ret
);
5451 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5452 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5453 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5454 "Filter updates to/from this neighbor\n"
5455 "IP access-list number\n"
5456 "IP access-list number (expanded range)\n"
5457 "IP Access-list name\n"
5458 "Filter incoming updates\n"
5459 "Filter outgoing updates\n")
5461 DEFUN (no_neighbor_distribute_list
,
5462 no_neighbor_distribute_list_cmd
,
5463 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5467 "Filter updates to/from this neighbor\n"
5468 "IP access-list number\n"
5469 "IP access-list number (expanded range)\n"
5470 "IP Access-list name\n"
5471 "Filter incoming updates\n"
5472 "Filter outgoing updates\n")
5478 const char *pstr
= argv
[idx_peer
]->arg
;
5479 const char *inout
= argv
[argc
- 1]->text
;
5481 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5483 return CMD_WARNING_CONFIG_FAILED
;
5485 /* Check filter direction. */
5486 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5487 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5490 return bgp_vty_return(vty
, ret
);
5494 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5495 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5496 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5497 "Filter updates to/from this neighbor\n"
5498 "IP access-list number\n"
5499 "IP access-list number (expanded range)\n"
5500 "IP Access-list name\n"
5501 "Filter incoming updates\n"
5502 "Filter outgoing updates\n")
5504 /* Set prefix list to the peer. */
5505 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5506 afi_t afi
, safi_t safi
,
5507 const char *name_str
,
5508 const char *direct_str
)
5511 int direct
= FILTER_IN
;
5514 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5516 return CMD_WARNING_CONFIG_FAILED
;
5518 /* Check filter direction. */
5519 if (strncmp(direct_str
, "i", 1) == 0)
5521 else if (strncmp(direct_str
, "o", 1) == 0)
5522 direct
= FILTER_OUT
;
5524 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5526 return bgp_vty_return(vty
, ret
);
5529 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5530 afi_t afi
, safi_t safi
,
5531 const char *direct_str
)
5535 int direct
= FILTER_IN
;
5537 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5539 return CMD_WARNING_CONFIG_FAILED
;
5541 /* Check filter direction. */
5542 if (strncmp(direct_str
, "i", 1) == 0)
5544 else if (strncmp(direct_str
, "o", 1) == 0)
5545 direct
= FILTER_OUT
;
5547 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5549 return bgp_vty_return(vty
, ret
);
5552 DEFUN (neighbor_prefix_list
,
5553 neighbor_prefix_list_cmd
,
5554 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5557 "Filter updates to/from this neighbor\n"
5558 "Name of a prefix list\n"
5559 "Filter incoming updates\n"
5560 "Filter outgoing updates\n")
5565 return peer_prefix_list_set_vty(
5566 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5567 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5570 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5571 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5572 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5573 "Filter updates to/from this neighbor\n"
5574 "Name of a prefix list\n"
5575 "Filter incoming updates\n"
5576 "Filter outgoing updates\n")
5578 DEFUN (no_neighbor_prefix_list
,
5579 no_neighbor_prefix_list_cmd
,
5580 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5584 "Filter updates to/from this neighbor\n"
5585 "Name of a prefix list\n"
5586 "Filter incoming updates\n"
5587 "Filter outgoing updates\n")
5591 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5592 bgp_node_afi(vty
), bgp_node_safi(vty
),
5593 argv
[idx_in_out
]->arg
);
5596 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5597 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5598 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5599 "Filter updates to/from this neighbor\n"
5600 "Name of a prefix list\n"
5601 "Filter incoming updates\n"
5602 "Filter outgoing updates\n")
5604 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5605 safi_t safi
, const char *name_str
,
5606 const char *direct_str
)
5610 int direct
= FILTER_IN
;
5612 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5614 return CMD_WARNING_CONFIG_FAILED
;
5616 /* Check filter direction. */
5617 if (strncmp(direct_str
, "i", 1) == 0)
5619 else if (strncmp(direct_str
, "o", 1) == 0)
5620 direct
= FILTER_OUT
;
5622 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5624 return bgp_vty_return(vty
, ret
);
5627 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5628 safi_t safi
, const char *direct_str
)
5632 int direct
= FILTER_IN
;
5634 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5636 return CMD_WARNING_CONFIG_FAILED
;
5638 /* Check filter direction. */
5639 if (strncmp(direct_str
, "i", 1) == 0)
5641 else if (strncmp(direct_str
, "o", 1) == 0)
5642 direct
= FILTER_OUT
;
5644 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5646 return bgp_vty_return(vty
, ret
);
5649 DEFUN (neighbor_filter_list
,
5650 neighbor_filter_list_cmd
,
5651 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5654 "Establish BGP filters\n"
5655 "AS path access-list name\n"
5656 "Filter incoming routes\n"
5657 "Filter outgoing routes\n")
5662 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5663 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5664 argv
[idx_in_out
]->arg
);
5667 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5668 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5669 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5670 "Establish BGP filters\n"
5671 "AS path access-list name\n"
5672 "Filter incoming routes\n"
5673 "Filter outgoing routes\n")
5675 DEFUN (no_neighbor_filter_list
,
5676 no_neighbor_filter_list_cmd
,
5677 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5681 "Establish BGP filters\n"
5682 "AS path access-list name\n"
5683 "Filter incoming routes\n"
5684 "Filter outgoing routes\n")
5688 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5689 bgp_node_afi(vty
), bgp_node_safi(vty
),
5690 argv
[idx_in_out
]->arg
);
5693 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5694 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5695 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5696 "Establish BGP filters\n"
5697 "AS path access-list name\n"
5698 "Filter incoming routes\n"
5699 "Filter outgoing routes\n")
5701 /* Set route-map to the peer. */
5702 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5703 afi_t afi
, safi_t safi
, const char *name_str
,
5704 const char *direct_str
)
5708 int direct
= RMAP_IN
;
5709 struct route_map
*route_map
;
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 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5722 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5724 return bgp_vty_return(vty
, ret
);
5727 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5728 afi_t afi
, safi_t safi
,
5729 const char *direct_str
)
5733 int direct
= RMAP_IN
;
5735 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5737 return CMD_WARNING_CONFIG_FAILED
;
5739 /* Check filter direction. */
5740 if (strncmp(direct_str
, "in", 2) == 0)
5742 else if (strncmp(direct_str
, "o", 1) == 0)
5745 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5747 return bgp_vty_return(vty
, ret
);
5750 DEFUN (neighbor_route_map
,
5751 neighbor_route_map_cmd
,
5752 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5755 "Apply route map to neighbor\n"
5756 "Name of route map\n"
5757 "Apply map to incoming routes\n"
5758 "Apply map to outbound routes\n")
5763 return peer_route_map_set_vty(
5764 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5765 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5768 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5769 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5770 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5771 "Apply route map to neighbor\n"
5772 "Name of route map\n"
5773 "Apply map to incoming routes\n"
5774 "Apply map to outbound routes\n")
5776 DEFUN (no_neighbor_route_map
,
5777 no_neighbor_route_map_cmd
,
5778 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5782 "Apply route map to neighbor\n"
5783 "Name of route map\n"
5784 "Apply map to incoming routes\n"
5785 "Apply map to outbound routes\n")
5789 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5790 bgp_node_afi(vty
), bgp_node_safi(vty
),
5791 argv
[idx_in_out
]->arg
);
5794 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5795 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5796 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5797 "Apply route map to neighbor\n"
5798 "Name of route map\n"
5799 "Apply map to incoming routes\n"
5800 "Apply map to outbound routes\n")
5802 /* Set unsuppress-map to the peer. */
5803 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5804 afi_t afi
, safi_t safi
,
5805 const char *name_str
)
5809 struct route_map
*route_map
;
5811 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5813 return CMD_WARNING_CONFIG_FAILED
;
5815 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5816 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5818 return bgp_vty_return(vty
, ret
);
5821 /* Unset route-map from the peer. */
5822 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5823 afi_t afi
, safi_t safi
)
5828 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5830 return CMD_WARNING_CONFIG_FAILED
;
5832 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5834 return bgp_vty_return(vty
, ret
);
5837 DEFUN (neighbor_unsuppress_map
,
5838 neighbor_unsuppress_map_cmd
,
5839 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5842 "Route-map to selectively unsuppress suppressed routes\n"
5843 "Name of route map\n")
5847 return peer_unsuppress_map_set_vty(
5848 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5849 argv
[idx_word
]->arg
);
5852 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5853 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5854 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5855 "Route-map to selectively unsuppress suppressed routes\n"
5856 "Name of route map\n")
5858 DEFUN (no_neighbor_unsuppress_map
,
5859 no_neighbor_unsuppress_map_cmd
,
5860 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5864 "Route-map to selectively unsuppress suppressed routes\n"
5865 "Name of route map\n")
5868 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5870 bgp_node_safi(vty
));
5873 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5874 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5875 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5876 "Route-map to selectively unsuppress suppressed routes\n"
5877 "Name of route map\n")
5879 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5880 afi_t afi
, safi_t safi
,
5881 const char *num_str
,
5882 const char *threshold_str
, int warning
,
5883 const char *restart_str
)
5891 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5893 return CMD_WARNING_CONFIG_FAILED
;
5895 max
= strtoul(num_str
, NULL
, 10);
5897 threshold
= atoi(threshold_str
);
5899 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5902 restart
= atoi(restart_str
);
5906 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5909 return bgp_vty_return(vty
, ret
);
5912 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5913 afi_t afi
, safi_t safi
)
5918 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5920 return CMD_WARNING_CONFIG_FAILED
;
5922 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5924 return bgp_vty_return(vty
, ret
);
5927 /* Maximum number of prefix configuration. prefix count is different
5928 for each peer configuration. So this configuration can be set for
5929 each peer configuration. */
5930 DEFUN (neighbor_maximum_prefix
,
5931 neighbor_maximum_prefix_cmd
,
5932 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5935 "Maximum number of prefix accept from this peer\n"
5936 "maximum no. of prefix limit\n")
5940 return peer_maximum_prefix_set_vty(
5941 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5942 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5945 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5946 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5947 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5948 "Maximum number of prefix accept from this peer\n"
5949 "maximum no. of prefix limit\n")
5951 DEFUN (neighbor_maximum_prefix_threshold
,
5952 neighbor_maximum_prefix_threshold_cmd
,
5953 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5956 "Maximum number of prefix accept from this peer\n"
5957 "maximum no. of prefix limit\n"
5958 "Threshold value (%) at which to generate a warning msg\n")
5962 int idx_number_2
= 4;
5963 return peer_maximum_prefix_set_vty(
5964 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5965 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5969 neighbor_maximum_prefix_threshold
,
5970 neighbor_maximum_prefix_threshold_hidden_cmd
,
5971 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5972 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5973 "Maximum number of prefix accept from this peer\n"
5974 "maximum no. of prefix limit\n"
5975 "Threshold value (%) at which to generate a warning msg\n")
5977 DEFUN (neighbor_maximum_prefix_warning
,
5978 neighbor_maximum_prefix_warning_cmd
,
5979 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5982 "Maximum number of prefix accept from this peer\n"
5983 "maximum no. of prefix limit\n"
5984 "Only give warning message when limit is exceeded\n")
5988 return peer_maximum_prefix_set_vty(
5989 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5990 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5994 neighbor_maximum_prefix_warning
,
5995 neighbor_maximum_prefix_warning_hidden_cmd
,
5996 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5997 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5998 "Maximum number of prefix accept from this peer\n"
5999 "maximum no. of prefix limit\n"
6000 "Only give warning message when limit is exceeded\n")
6002 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6003 neighbor_maximum_prefix_threshold_warning_cmd
,
6004 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6007 "Maximum number of prefix accept from this peer\n"
6008 "maximum no. of prefix limit\n"
6009 "Threshold value (%) at which to generate a warning msg\n"
6010 "Only give warning message when limit is exceeded\n")
6014 int idx_number_2
= 4;
6015 return peer_maximum_prefix_set_vty(
6016 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6017 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6021 neighbor_maximum_prefix_threshold_warning
,
6022 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6023 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6024 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6025 "Maximum number of prefix accept from this peer\n"
6026 "maximum no. of prefix limit\n"
6027 "Threshold value (%) at which to generate a warning msg\n"
6028 "Only give warning message when limit is exceeded\n")
6030 DEFUN (neighbor_maximum_prefix_restart
,
6031 neighbor_maximum_prefix_restart_cmd
,
6032 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6035 "Maximum number of prefix accept from this peer\n"
6036 "maximum no. of prefix limit\n"
6037 "Restart bgp connection after limit is exceeded\n"
6038 "Restart interval in minutes\n")
6042 int idx_number_2
= 5;
6043 return peer_maximum_prefix_set_vty(
6044 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6045 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6049 neighbor_maximum_prefix_restart
,
6050 neighbor_maximum_prefix_restart_hidden_cmd
,
6051 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6052 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6053 "Maximum number of prefix accept from this peer\n"
6054 "maximum no. of prefix limit\n"
6055 "Restart bgp connection after limit is exceeded\n"
6056 "Restart interval in minutes\n")
6058 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6059 neighbor_maximum_prefix_threshold_restart_cmd
,
6060 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6063 "Maximum number of prefixes to accept from this peer\n"
6064 "maximum no. of prefix limit\n"
6065 "Threshold value (%) at which to generate a warning msg\n"
6066 "Restart bgp connection after limit is exceeded\n"
6067 "Restart interval in minutes\n")
6071 int idx_number_2
= 4;
6072 int idx_number_3
= 6;
6073 return peer_maximum_prefix_set_vty(
6074 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6075 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6076 argv
[idx_number_3
]->arg
);
6080 neighbor_maximum_prefix_threshold_restart
,
6081 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6082 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6083 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6084 "Maximum number of prefixes to accept from this peer\n"
6085 "maximum no. of prefix limit\n"
6086 "Threshold value (%) at which to generate a warning msg\n"
6087 "Restart bgp connection after limit is exceeded\n"
6088 "Restart interval in minutes\n")
6090 DEFUN (no_neighbor_maximum_prefix
,
6091 no_neighbor_maximum_prefix_cmd
,
6092 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6096 "Maximum number of prefixes to accept from this peer\n"
6097 "maximum no. of prefix limit\n"
6098 "Threshold value (%) at which to generate a warning msg\n"
6099 "Restart bgp connection after limit is exceeded\n"
6100 "Restart interval in minutes\n"
6101 "Only give warning message when limit is exceeded\n")
6104 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6106 bgp_node_safi(vty
));
6110 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6111 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6112 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6113 "Maximum number of prefixes to accept from this peer\n"
6114 "maximum no. of prefix limit\n"
6115 "Threshold value (%) at which to generate a warning msg\n"
6116 "Restart bgp connection after limit is exceeded\n"
6117 "Restart interval in minutes\n"
6118 "Only give warning message when limit is exceeded\n")
6121 /* "neighbor allowas-in" */
6122 DEFUN (neighbor_allowas_in
,
6123 neighbor_allowas_in_cmd
,
6124 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6127 "Accept as-path with my AS present in it\n"
6128 "Number of occurences of AS number\n"
6129 "Only accept my AS in the as-path if the route was originated in my AS\n")
6132 int idx_number_origin
= 3;
6138 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6140 return CMD_WARNING_CONFIG_FAILED
;
6142 if (argc
<= idx_number_origin
)
6145 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6148 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6151 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6154 return bgp_vty_return(vty
, ret
);
6158 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6159 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6160 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6161 "Accept as-path with my AS present in it\n"
6162 "Number of occurences of AS number\n"
6163 "Only accept my AS in the as-path if the route was originated in my AS\n")
6165 DEFUN (no_neighbor_allowas_in
,
6166 no_neighbor_allowas_in_cmd
,
6167 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6171 "allow local ASN appears in aspath attribute\n"
6172 "Number of occurences of AS number\n"
6173 "Only accept my AS in the as-path if the route was originated in my AS\n")
6179 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6181 return CMD_WARNING_CONFIG_FAILED
;
6183 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6184 bgp_node_safi(vty
));
6186 return bgp_vty_return(vty
, ret
);
6190 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6191 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6192 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6193 "allow local ASN appears in aspath attribute\n"
6194 "Number of occurences of AS number\n"
6195 "Only accept my AS in the as-path if the route was originated in my AS\n")
6197 DEFUN (neighbor_ttl_security
,
6198 neighbor_ttl_security_cmd
,
6199 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6202 "BGP ttl-security parameters\n"
6203 "Specify the maximum number of hops to the BGP peer\n"
6204 "Number of hops to BGP peer\n")
6211 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6213 return CMD_WARNING_CONFIG_FAILED
;
6215 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6218 * If 'neighbor swpX', then this is for directly connected peers,
6219 * we should not accept a ttl-security hops value greater than 1.
6221 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6223 "%s is directly connected peer, hops cannot exceed 1\n",
6224 argv
[idx_peer
]->arg
);
6225 return CMD_WARNING_CONFIG_FAILED
;
6228 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6231 DEFUN (no_neighbor_ttl_security
,
6232 no_neighbor_ttl_security_cmd
,
6233 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6237 "BGP ttl-security parameters\n"
6238 "Specify the maximum number of hops to the BGP peer\n"
6239 "Number of hops to BGP peer\n")
6244 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6246 return CMD_WARNING_CONFIG_FAILED
;
6248 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6251 DEFUN (neighbor_addpath_tx_all_paths
,
6252 neighbor_addpath_tx_all_paths_cmd
,
6253 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6256 "Use addpath to advertise all paths to a neighbor\n")
6261 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6263 return CMD_WARNING_CONFIG_FAILED
;
6265 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6270 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6271 neighbor_addpath_tx_all_paths_hidden_cmd
,
6272 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6273 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6274 "Use addpath to advertise all paths to a neighbor\n")
6276 DEFUN (no_neighbor_addpath_tx_all_paths
,
6277 no_neighbor_addpath_tx_all_paths_cmd
,
6278 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6282 "Use addpath to advertise all paths to a neighbor\n")
6287 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6289 return CMD_WARNING_CONFIG_FAILED
;
6291 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6292 != BGP_ADDPATH_ALL
) {
6294 "%% Peer not currently configured to transmit all paths.");
6295 return CMD_WARNING_CONFIG_FAILED
;
6298 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6304 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6305 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6306 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6307 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6308 "Use addpath to advertise all paths to a neighbor\n")
6310 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6311 neighbor_addpath_tx_bestpath_per_as_cmd
,
6312 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6315 "Use addpath to advertise the bestpath per each neighboring AS\n")
6320 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6322 return CMD_WARNING_CONFIG_FAILED
;
6324 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6325 BGP_ADDPATH_BEST_PER_AS
);
6330 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6331 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6332 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6333 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6334 "Use addpath to advertise the bestpath per each neighboring AS\n")
6336 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6337 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6338 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6342 "Use addpath to advertise the bestpath per each neighboring AS\n")
6347 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6349 return CMD_WARNING_CONFIG_FAILED
;
6351 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6352 != BGP_ADDPATH_BEST_PER_AS
) {
6354 "%% Peer not currently configured to transmit all best path per as.");
6355 return CMD_WARNING_CONFIG_FAILED
;
6358 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6364 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6365 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6366 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6367 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6368 "Use addpath to advertise the bestpath per each neighboring AS\n")
6370 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6371 struct ecommunity
**list
)
6373 struct ecommunity
*ecom
= NULL
;
6374 struct ecommunity
*ecomadd
;
6376 for (; argc
; --argc
, ++argv
) {
6378 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6379 ECOMMUNITY_ROUTE_TARGET
, 0);
6381 vty_out(vty
, "Malformed community-list value\n");
6383 ecommunity_free(&ecom
);
6384 return CMD_WARNING_CONFIG_FAILED
;
6388 ecommunity_merge(ecom
, ecomadd
);
6389 ecommunity_free(&ecomadd
);
6396 ecommunity_free(&*list
);
6404 * v2vimport is true if we are handling a `import vrf ...` command
6406 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6410 switch (vty
->node
) {
6419 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6424 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6425 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6426 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6427 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6429 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6433 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6434 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6435 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6436 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6438 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6445 DEFPY (af_rd_vpn_export
,
6446 af_rd_vpn_export_cmd
,
6447 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6449 "Specify route distinguisher\n"
6450 "Between current address-family and vpn\n"
6451 "For routes leaked from current address-family to vpn\n"
6452 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6454 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6455 struct prefix_rd prd
;
6461 if (argv_find(argv
, argc
, "no", &idx
))
6465 ret
= str2prefix_rd(rd_str
, &prd
);
6467 vty_out(vty
, "%% Malformed rd\n");
6468 return CMD_WARNING_CONFIG_FAILED
;
6472 afi
= vpn_policy_getafi(vty
, bgp
, false);
6474 return CMD_WARNING_CONFIG_FAILED
;
6477 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6479 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6480 bgp_get_default(), bgp
);
6483 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6484 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6485 BGP_VPN_POLICY_TOVPN_RD_SET
);
6487 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6488 BGP_VPN_POLICY_TOVPN_RD_SET
);
6491 /* post-change: re-export vpn routes */
6492 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6493 bgp_get_default(), bgp
);
6498 ALIAS (af_rd_vpn_export
,
6499 af_no_rd_vpn_export_cmd
,
6502 "Specify route distinguisher\n"
6503 "Between current address-family and vpn\n"
6504 "For routes leaked from current address-family to vpn\n")
6506 DEFPY (af_label_vpn_export
,
6507 af_label_vpn_export_cmd
,
6508 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6510 "label value for VRF\n"
6511 "Between current address-family and vpn\n"
6512 "For routes leaked from current address-family to vpn\n"
6513 "Label Value <0-1048575>\n"
6514 "Automatically assign a label\n")
6516 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6517 mpls_label_t label
= MPLS_LABEL_NONE
;
6522 if (argv_find(argv
, argc
, "no", &idx
))
6525 /* If "no ...", squash trailing parameter */
6531 label
= label_val
; /* parser should force unsigned */
6534 afi
= vpn_policy_getafi(vty
, bgp
, false);
6536 return CMD_WARNING_CONFIG_FAILED
;
6539 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6540 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6545 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6547 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6548 bgp_get_default(), bgp
);
6550 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6551 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6553 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6556 * label has previously been automatically
6557 * assigned by labelpool: release it
6559 * NB if tovpn_label == MPLS_LABEL_NONE it
6560 * means the automatic assignment is in flight
6561 * and therefore the labelpool callback must
6562 * detect that the auto label is not needed.
6565 bgp_lp_release(LP_TYPE_VRF
,
6566 &bgp
->vpn_policy
[afi
],
6567 bgp
->vpn_policy
[afi
].tovpn_label
);
6569 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6570 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6573 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6575 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6576 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6577 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6578 vpn_leak_label_callback
);
6581 /* post-change: re-export vpn routes */
6582 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6583 bgp_get_default(), bgp
);
6588 ALIAS (af_label_vpn_export
,
6589 af_no_label_vpn_export_cmd
,
6590 "no label vpn export",
6592 "label value for VRF\n"
6593 "Between current address-family and vpn\n"
6594 "For routes leaked from current address-family to vpn\n")
6596 DEFPY (af_nexthop_vpn_export
,
6597 af_nexthop_vpn_export_cmd
,
6598 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6600 "Specify next hop to use for VRF advertised prefixes\n"
6601 "Between current address-family and vpn\n"
6602 "For routes leaked from current address-family to vpn\n"
6606 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6612 if (argv_find(argv
, argc
, "no", &idx
))
6616 if (!sockunion2hostprefix(nexthop_str
, &p
))
6617 return CMD_WARNING_CONFIG_FAILED
;
6620 afi
= vpn_policy_getafi(vty
, bgp
, false);
6622 return CMD_WARNING_CONFIG_FAILED
;
6625 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6627 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6628 bgp_get_default(), bgp
);
6631 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6632 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6633 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6635 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6636 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6639 /* post-change: re-export vpn routes */
6640 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6641 bgp_get_default(), bgp
);
6646 ALIAS (af_nexthop_vpn_export
,
6647 af_no_nexthop_vpn_export_cmd
,
6648 "no nexthop vpn export",
6650 "Specify next hop to use for VRF advertised prefixes\n"
6651 "Between current address-family and vpn\n"
6652 "For routes leaked from current address-family to vpn\n")
6654 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6656 if (!strcmp(dstr
, "import")) {
6657 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6658 } else if (!strcmp(dstr
, "export")) {
6659 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6660 } else if (!strcmp(dstr
, "both")) {
6661 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6662 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6664 vty_out(vty
, "%% direction parse error\n");
6665 return CMD_WARNING_CONFIG_FAILED
;
6670 DEFPY (af_rt_vpn_imexport
,
6671 af_rt_vpn_imexport_cmd
,
6672 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6674 "Specify route target list\n"
6675 "Specify route target list\n"
6676 "Between current address-family and vpn\n"
6677 "For routes leaked from vpn to current address-family: match any\n"
6678 "For routes leaked from current address-family to vpn: set\n"
6679 "both import: match any and export: set\n"
6680 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6682 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6684 struct ecommunity
*ecom
= NULL
;
6685 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6686 vpn_policy_direction_t dir
;
6691 if (argv_find(argv
, argc
, "no", &idx
))
6694 afi
= vpn_policy_getafi(vty
, bgp
, false);
6696 return CMD_WARNING_CONFIG_FAILED
;
6698 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6699 if (ret
!= CMD_SUCCESS
)
6703 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6704 vty_out(vty
, "%% Missing RTLIST\n");
6705 return CMD_WARNING_CONFIG_FAILED
;
6707 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6708 if (ret
!= CMD_SUCCESS
) {
6713 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6717 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6720 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6722 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6723 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6724 ecommunity_dup(ecom
);
6726 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6728 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6729 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6732 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6736 ecommunity_free(&ecom
);
6741 ALIAS (af_rt_vpn_imexport
,
6742 af_no_rt_vpn_imexport_cmd
,
6743 "no <rt|route-target> vpn <import|export|both>$direction_str",
6745 "Specify route target list\n"
6746 "Specify route target list\n"
6747 "Between current address-family and vpn\n"
6748 "For routes leaked from vpn to current address-family\n"
6749 "For routes leaked from current address-family to vpn\n"
6750 "both import and export\n")
6752 DEFPY (af_route_map_vpn_imexport
,
6753 af_route_map_vpn_imexport_cmd
,
6754 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6755 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6757 "Specify route map\n"
6758 "Between current address-family and vpn\n"
6759 "For routes leaked from vpn to current address-family\n"
6760 "For routes leaked from current address-family to vpn\n"
6761 "name of route-map\n")
6763 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6765 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6766 vpn_policy_direction_t dir
;
6771 if (argv_find(argv
, argc
, "no", &idx
))
6774 afi
= vpn_policy_getafi(vty
, bgp
, false);
6776 return CMD_WARNING_CONFIG_FAILED
;
6778 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6779 if (ret
!= CMD_SUCCESS
)
6782 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6786 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6789 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6790 XFREE(MTYPE_ROUTE_MAP_NAME
,
6791 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6792 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6793 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6794 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6795 route_map_lookup_warn_noexist(vty
, rmap_str
);
6796 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6799 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6800 XFREE(MTYPE_ROUTE_MAP_NAME
,
6801 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6802 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6803 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6806 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6812 ALIAS (af_route_map_vpn_imexport
,
6813 af_no_route_map_vpn_imexport_cmd
,
6814 "no route-map vpn <import|export>$direction_str",
6816 "Specify route map\n"
6817 "Between current address-family and vpn\n"
6818 "For routes leaked from vpn to current address-family\n"
6819 "For routes leaked from current address-family to vpn\n")
6821 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6822 "[no] import vrf route-map RMAP$rmap_str",
6824 "Import routes from another VRF\n"
6825 "Vrf routes being filtered\n"
6826 "Specify route map\n"
6827 "name of route-map\n")
6829 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6830 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6834 struct bgp
*bgp_default
;
6836 if (argv_find(argv
, argc
, "no", &idx
))
6839 afi
= vpn_policy_getafi(vty
, bgp
, true);
6841 return CMD_WARNING_CONFIG_FAILED
;
6843 bgp_default
= bgp_get_default();
6848 /* Auto-create assuming the same AS */
6849 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6850 BGP_INSTANCE_TYPE_DEFAULT
);
6854 "VRF default is not configured as a bgp instance\n");
6859 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6862 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6863 XFREE(MTYPE_ROUTE_MAP_NAME
,
6864 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6865 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6866 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6867 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6868 route_map_lookup_warn_noexist(vty
, rmap_str
);
6869 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6872 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6873 XFREE(MTYPE_ROUTE_MAP_NAME
,
6874 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6875 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6876 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6879 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6884 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6885 "no import vrf route-map",
6887 "Import routes from another VRF\n"
6888 "Vrf routes being filtered\n"
6889 "Specify route map\n")
6891 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6892 "[no] import vrf VIEWVRFNAME$import_name",
6894 "Import routes from another VRF\n"
6895 "VRF to import from\n"
6896 "The name of the VRF\n")
6898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6899 struct listnode
*node
;
6900 struct bgp
*vrf_bgp
, *bgp_default
;
6903 bool remove
= false;
6906 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6910 if (import_name
== NULL
) {
6911 vty_out(vty
, "%% Missing import name\n");
6915 if (argv_find(argv
, argc
, "no", &idx
))
6918 afi
= vpn_policy_getafi(vty
, bgp
, true);
6920 return CMD_WARNING_CONFIG_FAILED
;
6922 safi
= bgp_node_safi(vty
);
6924 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6925 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6926 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6927 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6928 remove
? "unimport" : "import", import_name
);
6932 bgp_default
= bgp_get_default();
6934 /* Auto-create assuming the same AS */
6935 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6936 BGP_INSTANCE_TYPE_DEFAULT
);
6940 "VRF default is not configured as a bgp instance\n");
6945 vrf_bgp
= bgp_lookup_by_name(import_name
);
6947 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6948 vrf_bgp
= bgp_default
;
6950 /* Auto-create assuming the same AS */
6951 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6955 "VRF %s is not configured as a bgp instance\n",
6962 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6964 /* Already importing from "import_vrf"? */
6965 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6967 if (strcmp(vname
, import_name
) == 0)
6971 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6977 /* This command is valid only in a bgp vrf instance or the default instance */
6978 DEFPY (bgp_imexport_vpn
,
6979 bgp_imexport_vpn_cmd
,
6980 "[no] <import|export>$direction_str vpn",
6982 "Import routes to this address-family\n"
6983 "Export routes from this address-family\n"
6984 "to/from default instance VPN RIB\n")
6986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6993 vpn_policy_direction_t dir
;
6995 if (argv_find(argv
, argc
, "no", &idx
))
6998 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6999 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7001 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7002 return CMD_WARNING_CONFIG_FAILED
;
7005 afi
= bgp_node_afi(vty
);
7006 safi
= bgp_node_safi(vty
);
7007 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7008 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7009 return CMD_WARNING_CONFIG_FAILED
;
7012 if (!strcmp(direction_str
, "import")) {
7013 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7014 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7015 } else if (!strcmp(direction_str
, "export")) {
7016 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7017 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7019 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7020 return CMD_WARNING_CONFIG_FAILED
;
7023 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7026 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7027 if (!previous_state
) {
7028 /* trigger export current vrf */
7029 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7032 if (previous_state
) {
7033 /* trigger un-export current vrf */
7034 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7036 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7042 DEFPY (af_routetarget_import
,
7043 af_routetarget_import_cmd
,
7044 "[no] <rt|route-target> redirect import RTLIST...",
7046 "Specify route target list\n"
7047 "Specify route target list\n"
7048 "Flow-spec redirect type route target\n"
7049 "Import routes to this address-family\n"
7050 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7052 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7054 struct ecommunity
*ecom
= NULL
;
7059 if (argv_find(argv
, argc
, "no", &idx
))
7062 afi
= vpn_policy_getafi(vty
, bgp
, false);
7064 return CMD_WARNING_CONFIG_FAILED
;
7067 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7068 vty_out(vty
, "%% Missing RTLIST\n");
7069 return CMD_WARNING_CONFIG_FAILED
;
7071 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7072 if (ret
!= CMD_SUCCESS
)
7077 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7078 ecommunity_free(&bgp
->vpn_policy
[afi
]
7079 .import_redirect_rtlist
);
7080 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7081 ecommunity_dup(ecom
);
7083 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7084 ecommunity_free(&bgp
->vpn_policy
[afi
]
7085 .import_redirect_rtlist
);
7086 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7090 ecommunity_free(&ecom
);
7095 DEFUN_NOSH (address_family_ipv4_safi
,
7096 address_family_ipv4_safi_cmd
,
7097 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7098 "Enter Address Family command mode\n"
7100 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_IP
, safi
);
7115 vty
->node
= BGP_IPV4_NODE
;
7120 DEFUN_NOSH (address_family_ipv6_safi
,
7121 address_family_ipv6_safi_cmd
,
7122 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7123 "Enter Address Family command mode\n"
7125 BGP_SAFI_WITH_LABEL_HELP_STR
)
7128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7129 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7130 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7131 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7132 && safi
!= SAFI_EVPN
) {
7134 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7135 return CMD_WARNING_CONFIG_FAILED
;
7137 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7139 vty
->node
= BGP_IPV6_NODE
;
7144 #ifdef KEEP_OLD_VPN_COMMANDS
7145 DEFUN_NOSH (address_family_vpnv4
,
7146 address_family_vpnv4_cmd
,
7147 "address-family vpnv4 [unicast]",
7148 "Enter Address Family command mode\n"
7150 "Address Family modifier\n")
7152 vty
->node
= BGP_VPNV4_NODE
;
7156 DEFUN_NOSH (address_family_vpnv6
,
7157 address_family_vpnv6_cmd
,
7158 "address-family vpnv6 [unicast]",
7159 "Enter Address Family command mode\n"
7161 "Address Family modifier\n")
7163 vty
->node
= BGP_VPNV6_NODE
;
7166 #endif /* KEEP_OLD_VPN_COMMANDS */
7168 DEFUN_NOSH (address_family_evpn
,
7169 address_family_evpn_cmd
,
7170 "address-family l2vpn evpn",
7171 "Enter Address Family command mode\n"
7173 "Address Family modifier\n")
7175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7176 vty
->node
= BGP_EVPN_NODE
;
7180 DEFUN_NOSH (exit_address_family
,
7181 exit_address_family_cmd
,
7182 "exit-address-family",
7183 "Exit from Address Family configuration mode\n")
7185 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7186 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7187 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7188 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7189 || vty
->node
== BGP_EVPN_NODE
7190 || vty
->node
== BGP_FLOWSPECV4_NODE
7191 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7192 vty
->node
= BGP_NODE
;
7196 /* Recalculate bestpath and re-advertise a prefix */
7197 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7198 const char *ip_str
, afi_t afi
, safi_t safi
,
7199 struct prefix_rd
*prd
)
7202 struct prefix match
;
7203 struct bgp_node
*rn
;
7204 struct bgp_node
*rm
;
7206 struct bgp_table
*table
;
7207 struct bgp_table
*rib
;
7209 /* BGP structure lookup. */
7211 bgp
= bgp_lookup_by_name(view_name
);
7213 vty_out(vty
, "%% Can't find BGP instance %s\n",
7218 bgp
= bgp_get_default();
7220 vty_out(vty
, "%% No BGP process is configured\n");
7225 /* Check IP address argument. */
7226 ret
= str2prefix(ip_str
, &match
);
7228 vty_out(vty
, "%% address is malformed\n");
7232 match
.family
= afi2family(afi
);
7233 rib
= bgp
->rib
[afi
][safi
];
7235 if (safi
== SAFI_MPLS_VPN
) {
7236 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7237 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7240 table
= bgp_node_get_bgp_table_info(rn
);
7241 if (table
!= NULL
) {
7243 if ((rm
= bgp_node_match(table
, &match
))
7246 == match
.prefixlen
) {
7248 BGP_NODE_USER_CLEAR
);
7249 bgp_process(bgp
, rm
, afi
, safi
);
7251 bgp_unlock_node(rm
);
7256 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7257 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7258 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7259 bgp_process(bgp
, rn
, afi
, safi
);
7261 bgp_unlock_node(rn
);
7268 /* one clear bgp command to rule them all */
7269 DEFUN (clear_ip_bgp_all
,
7270 clear_ip_bgp_all_cmd
,
7271 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]",
7275 BGP_INSTANCE_HELP_STR
7278 BGP_SAFI_WITH_LABEL_HELP_STR
7279 "Address Family modifier\n"
7281 "BGP neighbor address to clear\n"
7282 "BGP IPv6 neighbor to clear\n"
7283 "BGP neighbor on interface to clear\n"
7284 "Clear peers with the AS number\n"
7285 "Clear all external peers\n"
7286 "Clear all members of peer-group\n"
7287 "BGP peer-group name\n"
7292 "Push out prefix-list ORF and do inbound soft reconfig\n"
7297 afi_t afi
= AFI_IP6
;
7298 safi_t safi
= SAFI_UNICAST
;
7299 enum clear_sort clr_sort
= clear_peer
;
7300 enum bgp_clear_type clr_type
;
7301 char *clr_arg
= NULL
;
7305 /* clear [ip] bgp */
7306 if (argv_find(argv
, argc
, "ip", &idx
))
7309 /* [<vrf> VIEWVRFNAME] */
7310 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7311 vrf
= argv
[idx
+ 1]->arg
;
7313 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7315 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7316 /* [<view> VIEWVRFNAME] */
7317 vrf
= argv
[idx
+ 1]->arg
;
7320 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7321 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7322 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7324 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7325 if (argv_find(argv
, argc
, "*", &idx
)) {
7326 clr_sort
= clear_all
;
7327 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7328 clr_sort
= clear_peer
;
7329 clr_arg
= argv
[idx
]->arg
;
7330 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7331 clr_sort
= clear_peer
;
7332 clr_arg
= argv
[idx
]->arg
;
7333 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7334 clr_sort
= clear_group
;
7336 clr_arg
= argv
[idx
]->arg
;
7337 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7338 clr_sort
= clear_peer
;
7339 clr_arg
= argv
[idx
]->arg
;
7340 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7341 clr_sort
= clear_as
;
7342 clr_arg
= argv
[idx
]->arg
;
7343 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7344 clr_sort
= clear_external
;
7347 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7348 if (argv_find(argv
, argc
, "soft", &idx
)) {
7349 if (argv_find(argv
, argc
, "in", &idx
)
7350 || argv_find(argv
, argc
, "out", &idx
))
7351 clr_type
= strmatch(argv
[idx
]->text
, "in")
7353 : BGP_CLEAR_SOFT_OUT
;
7355 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7356 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7357 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7358 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7359 : BGP_CLEAR_SOFT_IN
;
7360 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7361 clr_type
= BGP_CLEAR_SOFT_OUT
;
7363 clr_type
= BGP_CLEAR_SOFT_NONE
;
7365 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7368 DEFUN (clear_ip_bgp_prefix
,
7369 clear_ip_bgp_prefix_cmd
,
7370 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7374 BGP_INSTANCE_HELP_STR
7375 "Clear bestpath and re-advertise\n"
7379 char *prefix
= NULL
;
7383 /* [<view|vrf> VIEWVRFNAME] */
7384 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7385 vrf
= argv
[idx
+ 1]->arg
;
7387 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7389 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7390 /* [<view> VIEWVRFNAME] */
7391 vrf
= argv
[idx
+ 1]->arg
;
7395 prefix
= argv
[argc
- 1]->arg
;
7397 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7400 DEFUN (clear_bgp_ipv6_safi_prefix
,
7401 clear_bgp_ipv6_safi_prefix_cmd
,
7402 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7408 "Clear bestpath and re-advertise\n"
7412 int idx_ipv6_prefix
= 0;
7413 safi_t safi
= SAFI_UNICAST
;
7414 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7415 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7417 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7418 return bgp_clear_prefix(
7419 vty
, NULL
, prefix
, AFI_IP6
,
7423 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7424 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7425 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7429 BGP_INSTANCE_HELP_STR
7432 "Clear bestpath and re-advertise\n"
7436 int idx_vrfview
= 0;
7437 int idx_ipv6_prefix
= 0;
7438 safi_t safi
= SAFI_UNICAST
;
7439 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7440 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7441 char *vrfview
= NULL
;
7443 /* [<view|vrf> VIEWVRFNAME] */
7444 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7445 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7446 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7448 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7449 /* [<view> VIEWVRFNAME] */
7450 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7452 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7454 return bgp_clear_prefix(
7455 vty
, vrfview
, prefix
,
7456 AFI_IP6
, safi
, NULL
);
7459 DEFUN (show_bgp_views
,
7461 "show [ip] bgp views",
7465 "Show the defined BGP views\n")
7467 struct list
*inst
= bm
->bgp
;
7468 struct listnode
*node
;
7471 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7472 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7476 vty_out(vty
, "Defined BGP views:\n");
7477 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7479 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7481 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7488 DEFUN (show_bgp_vrfs
,
7490 "show [ip] bgp vrfs [json]",
7497 char buf
[ETHER_ADDR_STRLEN
];
7498 struct list
*inst
= bm
->bgp
;
7499 struct listnode
*node
;
7501 bool uj
= use_json(argc
, argv
);
7502 json_object
*json
= NULL
;
7503 json_object
*json_vrfs
= NULL
;
7506 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7507 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7512 json
= json_object_new_object();
7513 json_vrfs
= json_object_new_object();
7516 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7517 const char *name
, *type
;
7519 struct listnode
*node2
, *nnode2
;
7520 int peers_cfg
, peers_estb
;
7521 json_object
*json_vrf
= NULL
;
7524 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7528 if (!uj
&& count
== 1)
7530 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7531 "Type", "Id", "routerId", "#PeersVfg",
7532 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7534 peers_cfg
= peers_estb
= 0;
7536 json_vrf
= json_object_new_object();
7539 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7540 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7543 if (peer
->status
== Established
)
7547 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7548 name
= VRF_DEFAULT_NAME
;
7557 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7559 : (int64_t)bgp
->vrf_id
;
7560 json_object_string_add(json_vrf
, "type", type
);
7561 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7562 json_object_string_add(json_vrf
, "routerId",
7563 inet_ntoa(bgp
->router_id
));
7564 json_object_int_add(json_vrf
, "numConfiguredPeers",
7566 json_object_int_add(json_vrf
, "numEstablishedPeers",
7569 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7570 json_object_string_add(
7572 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7573 json_object_object_add(json_vrfs
, name
, json_vrf
);
7576 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7578 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7580 inet_ntoa(bgp
->router_id
), peers_cfg
,
7581 peers_estb
, name
, bgp
->l3vni
,
7582 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7586 json_object_object_add(json
, "vrfs", json_vrfs
);
7588 json_object_int_add(json
, "totalVrfs", count
);
7590 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7591 json
, JSON_C_TO_STRING_PRETTY
));
7592 json_object_free(json
);
7596 "\nTotal number of VRFs (including default): %d\n",
7603 DEFUN (show_bgp_mac_hash
,
7604 show_bgp_mac_hash_cmd
,
7605 "show bgp mac hash",
7609 "Mac Address database\n")
7611 bgp_mac_dump_table(vty
);
7616 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7618 struct vty
*vty
= (struct vty
*)args
;
7619 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7621 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7625 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7627 vty_out(vty
, "self nexthop database:\n");
7628 bgp_nexthop_show_address_hash(vty
, bgp
);
7630 vty_out(vty
, "Tunnel-ip database:\n");
7631 hash_iterate(bgp
->tip_hash
,
7632 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7636 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7637 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7638 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7639 "martian next-hops\n"
7640 "martian next-hop database\n")
7642 struct bgp
*bgp
= NULL
;
7646 /* [<vrf> VIEWVRFNAME] */
7647 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7648 name
= argv
[idx
+ 1]->arg
;
7649 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7651 } else if (argv_find(argv
, argc
, "view", &idx
))
7652 /* [<view> VIEWVRFNAME] */
7653 name
= argv
[idx
+ 1]->arg
;
7655 bgp
= bgp_lookup_by_name(name
);
7657 bgp
= bgp_get_default();
7660 vty_out(vty
, "%% No BGP process is configured\n");
7663 bgp_show_martian_nexthops(vty
, bgp
);
7668 DEFUN (show_bgp_memory
,
7669 show_bgp_memory_cmd
,
7670 "show [ip] bgp memory",
7674 "Global BGP memory statistics\n")
7676 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7677 unsigned long count
;
7679 /* RIB related usage stats */
7680 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7681 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7682 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7683 count
* sizeof(struct bgp_node
)));
7685 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7686 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7687 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7688 count
* sizeof(struct bgp_path_info
)));
7689 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7690 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7693 memstrbuf
, sizeof(memstrbuf
),
7694 count
* sizeof(struct bgp_path_info_extra
)));
7696 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7697 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7698 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7699 count
* sizeof(struct bgp_static
)));
7701 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7702 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7703 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7704 count
* sizeof(struct bpacket
)));
7707 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7708 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7709 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7710 count
* sizeof(struct bgp_adj_in
)));
7711 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7712 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7713 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7714 count
* sizeof(struct bgp_adj_out
)));
7716 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7717 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7719 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7720 count
* sizeof(struct bgp_nexthop_cache
)));
7722 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7723 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7725 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7726 count
* sizeof(struct bgp_damp_info
)));
7729 count
= attr_count();
7730 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7731 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7732 count
* sizeof(struct attr
)));
7734 if ((count
= attr_unknown_count()))
7735 vty_out(vty
, "%ld unknown attributes\n", count
);
7737 /* AS_PATH attributes */
7738 count
= aspath_count();
7739 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7740 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7741 count
* sizeof(struct aspath
)));
7743 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7744 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7745 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7746 count
* sizeof(struct assegment
)));
7748 /* Other attributes */
7749 if ((count
= community_count()))
7750 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7751 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7752 count
* sizeof(struct community
)));
7753 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7754 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7755 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7756 count
* sizeof(struct ecommunity
)));
7757 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7759 "%ld BGP large-community entries, using %s of memory\n",
7760 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7761 count
* sizeof(struct lcommunity
)));
7763 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7764 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7765 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7766 count
* sizeof(struct cluster_list
)));
7768 /* Peer related usage */
7769 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7770 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7771 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7772 count
* sizeof(struct peer
)));
7774 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7775 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7776 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7777 count
* sizeof(struct peer_group
)));
7780 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7781 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7782 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7783 count
* sizeof(struct hash
)));
7784 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7785 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7786 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7787 count
* sizeof(struct hash_bucket
)));
7788 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7789 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7790 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7791 count
* sizeof(regex_t
)));
7795 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7797 json_object
*bestpath
= json_object_new_object();
7799 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7800 json_object_string_add(bestpath
, "asPath", "ignore");
7802 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7803 json_object_string_add(bestpath
, "asPath", "confed");
7805 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7806 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7807 json_object_string_add(bestpath
, "multiPathRelax",
7810 json_object_string_add(bestpath
, "multiPathRelax",
7813 json_object_string_add(bestpath
, "multiPathRelax", "false");
7815 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7816 json_object_string_add(bestpath
, "compareRouterId", "true");
7817 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7818 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7819 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7820 json_object_string_add(bestpath
, "med", "confed");
7821 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7822 json_object_string_add(bestpath
, "med",
7823 "missing-as-worst");
7825 json_object_string_add(bestpath
, "med", "true");
7828 json_object_object_add(json
, "bestPath", bestpath
);
7831 /* Show BGP peer's summary information. */
7832 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7833 bool use_json
, json_object
*json
)
7836 struct listnode
*node
, *nnode
;
7837 unsigned int count
= 0, dn_count
= 0;
7838 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7839 char neighbor_buf
[VTY_BUFSIZ
];
7840 int neighbor_col_default_width
= 16;
7842 int max_neighbor_width
= 0;
7844 json_object
*json_peer
= NULL
;
7845 json_object
*json_peers
= NULL
;
7846 struct peer_af
*paf
;
7848 /* labeled-unicast routes are installed in the unicast table so in order
7850 * display the correct PfxRcd value we must look at SAFI_UNICAST
7852 if (safi
== SAFI_LABELED_UNICAST
)
7853 pfx_rcd_safi
= SAFI_UNICAST
;
7855 pfx_rcd_safi
= safi
;
7859 json
= json_object_new_object();
7861 json_peers
= json_object_new_object();
7863 /* Loop over all neighbors that will be displayed to determine
7865 * characters are needed for the Neighbor column
7867 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7868 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7871 if (peer
->afc
[afi
][safi
]) {
7872 memset(dn_flag
, '\0', sizeof(dn_flag
));
7873 if (peer_dynamic_neighbor(peer
))
7877 && bgp_flag_check(bgp
,
7878 BGP_FLAG_SHOW_HOSTNAME
))
7879 sprintf(neighbor_buf
, "%s%s(%s) ",
7880 dn_flag
, peer
->hostname
,
7883 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7886 len
= strlen(neighbor_buf
);
7888 if (len
> max_neighbor_width
)
7889 max_neighbor_width
= len
;
7893 /* Originally we displayed the Neighbor column as 16
7894 * characters wide so make that the default
7896 if (max_neighbor_width
< neighbor_col_default_width
)
7897 max_neighbor_width
= neighbor_col_default_width
;
7900 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7901 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7904 if (!peer
->afc
[afi
][safi
])
7909 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7912 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7914 : (int64_t)bgp
->vrf_id
;
7916 /* Usage summary and header */
7918 json_object_string_add(
7920 inet_ntoa(bgp
->router_id
));
7921 json_object_int_add(json
, "as", bgp
->as
);
7922 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7923 json_object_string_add(
7926 == BGP_INSTANCE_TYPE_DEFAULT
)
7931 "BGP router identifier %s, local AS number %u vrf-id %d",
7932 inet_ntoa(bgp
->router_id
), bgp
->as
,
7933 bgp
->vrf_id
== VRF_UNKNOWN
7935 : (int)bgp
->vrf_id
);
7939 if (bgp_update_delay_configured(bgp
)) {
7941 json_object_int_add(
7942 json
, "updateDelayLimit",
7943 bgp
->v_update_delay
);
7945 if (bgp
->v_update_delay
7946 != bgp
->v_establish_wait
)
7947 json_object_int_add(
7949 "updateDelayEstablishWait",
7950 bgp
->v_establish_wait
);
7952 if (bgp_update_delay_active(bgp
)) {
7953 json_object_string_add(
7955 "updateDelayFirstNeighbor",
7956 bgp
->update_delay_begin_time
);
7957 json_object_boolean_true_add(
7959 "updateDelayInProgress");
7961 if (bgp
->update_delay_over
) {
7962 json_object_string_add(
7964 "updateDelayFirstNeighbor",
7965 bgp
->update_delay_begin_time
);
7966 json_object_string_add(
7968 "updateDelayBestpathResumed",
7969 bgp
->update_delay_end_time
);
7970 json_object_string_add(
7972 "updateDelayZebraUpdateResume",
7973 bgp
->update_delay_zebra_resume_time
);
7974 json_object_string_add(
7976 "updateDelayPeerUpdateResume",
7977 bgp
->update_delay_peers_resume_time
);
7982 "Read-only mode update-delay limit: %d seconds\n",
7983 bgp
->v_update_delay
);
7984 if (bgp
->v_update_delay
7985 != bgp
->v_establish_wait
)
7987 " Establish wait: %d seconds\n",
7988 bgp
->v_establish_wait
);
7990 if (bgp_update_delay_active(bgp
)) {
7992 " First neighbor established: %s\n",
7993 bgp
->update_delay_begin_time
);
7995 " Delay in progress\n");
7997 if (bgp
->update_delay_over
) {
7999 " First neighbor established: %s\n",
8000 bgp
->update_delay_begin_time
);
8002 " Best-paths resumed: %s\n",
8003 bgp
->update_delay_end_time
);
8005 " zebra update resumed: %s\n",
8006 bgp
->update_delay_zebra_resume_time
);
8008 " peers update resumed: %s\n",
8009 bgp
->update_delay_peers_resume_time
);
8016 if (bgp_maxmed_onstartup_configured(bgp
)
8017 && bgp
->maxmed_active
)
8018 json_object_boolean_true_add(
8019 json
, "maxMedOnStartup");
8020 if (bgp
->v_maxmed_admin
)
8021 json_object_boolean_true_add(
8022 json
, "maxMedAdministrative");
8024 json_object_int_add(
8025 json
, "tableVersion",
8026 bgp_table_version(bgp
->rib
[afi
][safi
]));
8028 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8029 json_object_int_add(json
, "ribCount", ents
);
8030 json_object_int_add(
8032 ents
* sizeof(struct bgp_node
));
8034 ents
= bgp
->af_peer_count
[afi
][safi
];
8035 json_object_int_add(json
, "peerCount", ents
);
8036 json_object_int_add(json
, "peerMemory",
8037 ents
* sizeof(struct peer
));
8039 if ((ents
= listcount(bgp
->group
))) {
8040 json_object_int_add(
8041 json
, "peerGroupCount", ents
);
8042 json_object_int_add(
8043 json
, "peerGroupMemory",
8044 ents
* sizeof(struct
8048 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8049 BGP_CONFIG_DAMPENING
))
8050 json_object_boolean_true_add(
8051 json
, "dampeningEnabled");
8053 if (bgp_maxmed_onstartup_configured(bgp
)
8054 && bgp
->maxmed_active
)
8056 "Max-med on-startup active\n");
8057 if (bgp
->v_maxmed_admin
)
8059 "Max-med administrative active\n");
8061 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8062 bgp_table_version(bgp
->rib
[afi
][safi
]));
8064 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8066 "RIB entries %ld, using %s of memory\n",
8068 mtype_memstr(memstrbuf
,
8070 ents
* sizeof(struct
8073 /* Peer related usage */
8074 ents
= bgp
->af_peer_count
[afi
][safi
];
8075 vty_out(vty
, "Peers %ld, using %s of memory\n",
8078 memstrbuf
, sizeof(memstrbuf
),
8079 ents
* sizeof(struct peer
)));
8081 if ((ents
= listcount(bgp
->group
)))
8083 "Peer groups %ld, using %s of memory\n",
8088 ents
* sizeof(struct
8091 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8092 BGP_CONFIG_DAMPENING
))
8093 vty_out(vty
, "Dampening enabled.\n");
8096 /* Subtract 8 here because 'Neighbor' is
8098 vty_out(vty
, "Neighbor");
8099 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8102 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8109 json_peer
= json_object_new_object();
8111 if (peer_dynamic_neighbor(peer
)) {
8113 json_object_boolean_true_add(json_peer
,
8118 json_object_string_add(json_peer
, "hostname",
8121 if (peer
->domainname
)
8122 json_object_string_add(json_peer
, "domainname",
8125 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8126 json_object_int_add(json_peer
, "version", 4);
8127 json_object_int_add(json_peer
, "msgRcvd",
8128 PEER_TOTAL_RX(peer
));
8129 json_object_int_add(json_peer
, "msgSent",
8130 PEER_TOTAL_TX(peer
));
8132 json_object_int_add(json_peer
, "tableVersion",
8133 peer
->version
[afi
][safi
]);
8134 json_object_int_add(json_peer
, "outq",
8136 json_object_int_add(json_peer
, "inq", 0);
8137 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8138 use_json
, json_peer
);
8141 * Adding "pfxRcd" field to match with the corresponding
8142 * CLI. "prefixReceivedCount" will be deprecated in
8145 json_object_int_add(json_peer
, "prefixReceivedCount",
8146 peer
->pcount
[afi
][pfx_rcd_safi
]);
8147 json_object_int_add(json_peer
, "pfxRcd",
8148 peer
->pcount
[afi
][pfx_rcd_safi
]);
8150 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8151 if (paf
&& PAF_SUBGRP(paf
))
8152 json_object_int_add(json_peer
,
8154 (PAF_SUBGRP(paf
))->scount
);
8156 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8157 json_object_string_add(json_peer
, "state",
8159 else if (peer
->afc_recv
[afi
][safi
])
8160 json_object_string_add(
8162 lookup_msg(bgp_status_msg
, peer
->status
,
8164 else if (CHECK_FLAG(peer
->sflags
,
8165 PEER_STATUS_PREFIX_OVERFLOW
))
8166 json_object_string_add(json_peer
, "state",
8169 json_object_string_add(
8171 lookup_msg(bgp_status_msg
, peer
->status
,
8175 json_object_string_add(json_peer
, "idType",
8177 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8178 json_object_string_add(json_peer
, "idType",
8180 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8181 json_object_string_add(json_peer
, "idType",
8184 json_object_object_add(json_peers
, peer
->host
,
8187 memset(dn_flag
, '\0', sizeof(dn_flag
));
8188 if (peer_dynamic_neighbor(peer
)) {
8194 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8195 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8196 peer
->hostname
, peer
->host
);
8198 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8200 /* pad the neighbor column with spaces */
8201 if (len
< max_neighbor_width
)
8202 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8205 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8206 peer
->as
, PEER_TOTAL_RX(peer
),
8207 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8208 0, peer
->obuf
->count
,
8209 peer_uptime(peer
->uptime
, timebuf
,
8210 BGP_UPTIME_LEN
, 0, NULL
));
8212 if (peer
->status
== Established
)
8213 if (peer
->afc_recv
[afi
][safi
])
8214 vty_out(vty
, " %12ld",
8218 vty_out(vty
, " NoNeg");
8220 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8221 vty_out(vty
, " Idle (Admin)");
8222 else if (CHECK_FLAG(
8224 PEER_STATUS_PREFIX_OVERFLOW
))
8225 vty_out(vty
, " Idle (PfxCt)");
8227 vty_out(vty
, " %12s",
8228 lookup_msg(bgp_status_msg
,
8229 peer
->status
, NULL
));
8236 json_object_object_add(json
, "peers", json_peers
);
8238 json_object_int_add(json
, "totalPeers", count
);
8239 json_object_int_add(json
, "dynamicPeers", dn_count
);
8241 bgp_show_bestpath_json(bgp
, json
);
8243 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8244 json
, JSON_C_TO_STRING_PRETTY
));
8245 json_object_free(json
);
8248 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8250 vty_out(vty
, "No %s neighbor is configured\n",
8251 afi_safi_print(afi
, safi
));
8255 vty_out(vty
, "* - dynamic neighbor\n");
8256 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8257 dn_count
, bgp
->dynamic_neighbors_limit
);
8264 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8265 int safi
, bool use_json
,
8269 int afi_wildcard
= (afi
== AFI_MAX
);
8270 int safi_wildcard
= (safi
== SAFI_MAX
);
8271 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8272 bool nbr_output
= false;
8274 if (use_json
&& is_wildcard
)
8275 vty_out(vty
, "{\n");
8277 afi
= 1; /* AFI_IP */
8278 while (afi
< AFI_MAX
) {
8280 safi
= 1; /* SAFI_UNICAST */
8281 while (safi
< SAFI_MAX
) {
8282 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8286 * So limit output to those afi/safi
8288 * actualy have something interesting in
8292 json
= json_object_new_object();
8295 vty_out(vty
, ",\n");
8299 vty_out(vty
, "\"%s\":",
8303 vty_out(vty
, "\n%s Summary:\n",
8308 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8320 if (use_json
&& is_wildcard
)
8321 vty_out(vty
, "}\n");
8322 else if (!nbr_output
) {
8324 vty_out(vty
, "{}\n");
8326 vty_out(vty
, "%% No BGP neighbors found\n");
8330 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8331 safi_t safi
, bool use_json
)
8333 struct listnode
*node
, *nnode
;
8335 json_object
*json
= NULL
;
8337 bool nbr_output
= false;
8340 vty_out(vty
, "{\n");
8342 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8345 json
= json_object_new_object();
8348 vty_out(vty
, ",\n");
8352 vty_out(vty
, "\"%s\":",
8353 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8357 vty_out(vty
, "\nInstance %s:\n",
8358 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8362 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8366 vty_out(vty
, "}\n");
8367 else if (!nbr_output
)
8368 vty_out(vty
, "%% BGP instance not found\n");
8371 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8372 safi_t safi
, bool use_json
)
8377 if (strmatch(name
, "all")) {
8378 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8382 bgp
= bgp_lookup_by_name(name
);
8386 vty_out(vty
, "{}\n");
8389 "%% BGP instance not found\n");
8393 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8399 bgp
= bgp_get_default();
8402 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8405 vty_out(vty
, "{}\n");
8407 vty_out(vty
, "%% BGP instance not found\n");
8414 /* `show [ip] bgp summary' commands. */
8415 DEFUN (show_ip_bgp_summary
,
8416 show_ip_bgp_summary_cmd
,
8417 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8421 BGP_INSTANCE_HELP_STR
8423 BGP_SAFI_WITH_LABEL_HELP_STR
8424 "Summary of BGP neighbor status\n"
8428 afi_t afi
= AFI_MAX
;
8429 safi_t safi
= SAFI_MAX
;
8434 if (argv_find(argv
, argc
, "ip", &idx
))
8436 /* [<vrf> VIEWVRFNAME] */
8437 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8438 vrf
= argv
[idx
+ 1]->arg
;
8439 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8441 } else if (argv_find(argv
, argc
, "view", &idx
))
8442 /* [<view> VIEWVRFNAME] */
8443 vrf
= argv
[idx
+ 1]->arg
;
8444 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8445 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8446 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8449 bool uj
= use_json(argc
, argv
);
8451 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8454 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8456 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8457 return "IPv4 Unicast";
8458 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8459 return "IPv4 Multicast";
8460 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8461 return "IPv4 Labeled Unicast";
8462 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8464 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8465 return "IPv4 Encap";
8466 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8467 return "IPv4 Flowspec";
8468 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8469 return "IPv6 Unicast";
8470 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8471 return "IPv6 Multicast";
8472 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8473 return "IPv6 Labeled Unicast";
8474 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8476 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8477 return "IPv6 Encap";
8478 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8479 return "IPv6 Flowspec";
8480 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8481 return "L2VPN EVPN";
8487 * Please note that we have intentionally camelCased
8488 * the return strings here. So if you want
8489 * to use this function, please ensure you
8490 * are doing this within json output
8492 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8494 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8495 return "ipv4Unicast";
8496 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8497 return "ipv4Multicast";
8498 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8499 return "ipv4LabeledUnicast";
8500 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8502 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8504 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8505 return "ipv4Flowspec";
8506 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8507 return "ipv6Unicast";
8508 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8509 return "ipv6Multicast";
8510 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8511 return "ipv6LabeledUnicast";
8512 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8514 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8516 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8517 return "ipv6Flowspec";
8518 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8524 /* Show BGP peer's information. */
8525 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8527 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8528 afi_t afi
, safi_t safi
,
8529 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8530 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8531 bool use_json
, json_object
*json_pref
)
8534 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8535 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8537 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8538 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8539 json_object_string_add(json_pref
, "sendMode",
8540 "advertisedAndReceived");
8541 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8542 json_object_string_add(json_pref
, "sendMode",
8544 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8545 json_object_string_add(json_pref
, "sendMode",
8548 vty_out(vty
, " Send-mode: ");
8549 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8550 vty_out(vty
, "advertised");
8551 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8552 vty_out(vty
, "%sreceived",
8553 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8562 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8563 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8565 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8566 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8567 json_object_string_add(json_pref
, "recvMode",
8568 "advertisedAndReceived");
8569 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8570 json_object_string_add(json_pref
, "recvMode",
8572 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8573 json_object_string_add(json_pref
, "recvMode",
8576 vty_out(vty
, " Receive-mode: ");
8577 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8578 vty_out(vty
, "advertised");
8579 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8580 vty_out(vty
, "%sreceived",
8581 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8590 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8591 safi_t safi
, bool use_json
,
8592 json_object
*json_neigh
)
8594 struct bgp_filter
*filter
;
8595 struct peer_af
*paf
;
8596 char orf_pfx_name
[BUFSIZ
];
8598 json_object
*json_af
= NULL
;
8599 json_object
*json_prefA
= NULL
;
8600 json_object
*json_prefB
= NULL
;
8601 json_object
*json_addr
= NULL
;
8604 json_addr
= json_object_new_object();
8605 json_af
= json_object_new_object();
8606 filter
= &p
->filter
[afi
][safi
];
8608 if (peer_group_active(p
))
8609 json_object_string_add(json_addr
, "peerGroupMember",
8612 paf
= peer_af_find(p
, afi
, safi
);
8613 if (paf
&& PAF_SUBGRP(paf
)) {
8614 json_object_int_add(json_addr
, "updateGroupId",
8615 PAF_UPDGRP(paf
)->id
);
8616 json_object_int_add(json_addr
, "subGroupId",
8617 PAF_SUBGRP(paf
)->id
);
8618 json_object_int_add(json_addr
, "packetQueueLength",
8619 bpacket_queue_virtual_length(paf
));
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_RM_ADV
)
8627 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8628 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8629 json_object_int_add(json_af
, "orfType",
8631 json_prefA
= json_object_new_object();
8632 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8633 PEER_CAP_ORF_PREFIX_SM_ADV
,
8634 PEER_CAP_ORF_PREFIX_RM_ADV
,
8635 PEER_CAP_ORF_PREFIX_SM_RCV
,
8636 PEER_CAP_ORF_PREFIX_RM_RCV
,
8637 use_json
, json_prefA
);
8638 json_object_object_add(json_af
, "orfPrefixList",
8642 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8643 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8644 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8645 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8646 PEER_CAP_ORF_PREFIX_RM_ADV
)
8647 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8648 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8649 json_object_int_add(json_af
, "orfOldType",
8650 ORF_TYPE_PREFIX_OLD
);
8651 json_prefB
= json_object_new_object();
8652 bgp_show_peer_afi_orf_cap(
8653 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8654 PEER_CAP_ORF_PREFIX_RM_ADV
,
8655 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8656 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8658 json_object_object_add(json_af
, "orfOldPrefixList",
8662 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8663 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8664 PEER_CAP_ORF_PREFIX_SM_RCV
)
8665 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8666 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8667 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8668 PEER_CAP_ORF_PREFIX_RM_ADV
)
8669 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8670 PEER_CAP_ORF_PREFIX_RM_RCV
)
8671 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8672 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8673 json_object_object_add(json_addr
, "afDependentCap",
8676 json_object_free(json_af
);
8678 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8679 orf_pfx_count
= prefix_bgp_show_prefix_list(
8680 NULL
, afi
, orf_pfx_name
, use_json
);
8682 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8683 PEER_STATUS_ORF_PREFIX_SEND
)
8685 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8686 PEER_STATUS_ORF_PREFIX_SEND
))
8687 json_object_boolean_true_add(json_neigh
,
8690 json_object_int_add(json_addr
, "orfRecvCounter",
8693 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8694 PEER_STATUS_ORF_WAIT_REFRESH
))
8695 json_object_string_add(
8696 json_addr
, "orfFirstUpdate",
8697 "deferredUntilORFOrRouteRefreshRecvd");
8699 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8700 PEER_FLAG_REFLECTOR_CLIENT
))
8701 json_object_boolean_true_add(json_addr
,
8702 "routeReflectorClient");
8703 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8704 PEER_FLAG_RSERVER_CLIENT
))
8705 json_object_boolean_true_add(json_addr
,
8706 "routeServerClient");
8707 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8708 json_object_boolean_true_add(json_addr
,
8709 "inboundSoftConfigPermit");
8711 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8712 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8713 json_object_boolean_true_add(
8715 "privateAsNumsAllReplacedInUpdatesToNbr");
8716 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8717 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8718 json_object_boolean_true_add(
8720 "privateAsNumsReplacedInUpdatesToNbr");
8721 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8722 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8723 json_object_boolean_true_add(
8725 "privateAsNumsAllRemovedInUpdatesToNbr");
8726 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8727 PEER_FLAG_REMOVE_PRIVATE_AS
))
8728 json_object_boolean_true_add(
8730 "privateAsNumsRemovedInUpdatesToNbr");
8732 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8733 json_object_boolean_true_add(
8735 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8738 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8739 json_object_string_add(json_addr
,
8740 "overrideASNsInOutboundUpdates",
8741 "ifAspathEqualRemoteAs");
8743 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8744 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8745 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8746 json_object_boolean_true_add(json_addr
,
8747 "routerAlwaysNextHop");
8748 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8749 PEER_FLAG_AS_PATH_UNCHANGED
))
8750 json_object_boolean_true_add(
8751 json_addr
, "unchangedAsPathPropogatedToNbr");
8752 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8753 PEER_FLAG_NEXTHOP_UNCHANGED
))
8754 json_object_boolean_true_add(
8755 json_addr
, "unchangedNextHopPropogatedToNbr");
8756 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8757 json_object_boolean_true_add(
8758 json_addr
, "unchangedMedPropogatedToNbr");
8759 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8760 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8761 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8762 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8763 PEER_FLAG_SEND_COMMUNITY
)
8764 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8765 PEER_FLAG_SEND_EXT_COMMUNITY
))
8766 json_object_string_add(json_addr
,
8767 "commAttriSentToNbr",
8768 "extendedAndStandard");
8769 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8770 PEER_FLAG_SEND_EXT_COMMUNITY
))
8771 json_object_string_add(json_addr
,
8772 "commAttriSentToNbr",
8775 json_object_string_add(json_addr
,
8776 "commAttriSentToNbr",
8779 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8780 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8781 if (p
->default_rmap
[afi
][safi
].name
)
8782 json_object_string_add(
8783 json_addr
, "defaultRouteMap",
8784 p
->default_rmap
[afi
][safi
].name
);
8786 if (paf
&& PAF_SUBGRP(paf
)
8787 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8788 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8789 json_object_boolean_true_add(json_addr
,
8792 json_object_boolean_true_add(json_addr
,
8796 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8797 if (is_evpn_enabled())
8798 json_object_boolean_true_add(
8799 json_addr
, "advertiseAllVnis");
8802 if (filter
->plist
[FILTER_IN
].name
8803 || filter
->dlist
[FILTER_IN
].name
8804 || filter
->aslist
[FILTER_IN
].name
8805 || filter
->map
[RMAP_IN
].name
)
8806 json_object_boolean_true_add(json_addr
,
8807 "inboundPathPolicyConfig");
8808 if (filter
->plist
[FILTER_OUT
].name
8809 || filter
->dlist
[FILTER_OUT
].name
8810 || filter
->aslist
[FILTER_OUT
].name
8811 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8812 json_object_boolean_true_add(
8813 json_addr
, "outboundPathPolicyConfig");
8816 if (filter
->plist
[FILTER_IN
].name
)
8817 json_object_string_add(json_addr
,
8818 "incomingUpdatePrefixFilterList",
8819 filter
->plist
[FILTER_IN
].name
);
8820 if (filter
->plist
[FILTER_OUT
].name
)
8821 json_object_string_add(json_addr
,
8822 "outgoingUpdatePrefixFilterList",
8823 filter
->plist
[FILTER_OUT
].name
);
8825 /* distribute-list */
8826 if (filter
->dlist
[FILTER_IN
].name
)
8827 json_object_string_add(
8828 json_addr
, "incomingUpdateNetworkFilterList",
8829 filter
->dlist
[FILTER_IN
].name
);
8830 if (filter
->dlist
[FILTER_OUT
].name
)
8831 json_object_string_add(
8832 json_addr
, "outgoingUpdateNetworkFilterList",
8833 filter
->dlist
[FILTER_OUT
].name
);
8836 if (filter
->aslist
[FILTER_IN
].name
)
8837 json_object_string_add(json_addr
,
8838 "incomingUpdateAsPathFilterList",
8839 filter
->aslist
[FILTER_IN
].name
);
8840 if (filter
->aslist
[FILTER_OUT
].name
)
8841 json_object_string_add(json_addr
,
8842 "outgoingUpdateAsPathFilterList",
8843 filter
->aslist
[FILTER_OUT
].name
);
8846 if (filter
->map
[RMAP_IN
].name
)
8847 json_object_string_add(
8848 json_addr
, "routeMapForIncomingAdvertisements",
8849 filter
->map
[RMAP_IN
].name
);
8850 if (filter
->map
[RMAP_OUT
].name
)
8851 json_object_string_add(
8852 json_addr
, "routeMapForOutgoingAdvertisements",
8853 filter
->map
[RMAP_OUT
].name
);
8855 /* ebgp-requires-policy (inbound) */
8856 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8857 && !bgp_inbound_policy_exists(p
, filter
))
8858 json_object_string_add(
8859 json_addr
, "inboundEbgpRequiresPolicy",
8860 "Inbound updates discarded due to missing policy");
8862 /* ebgp-requires-policy (outbound) */
8863 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8864 && (!bgp_outbound_policy_exists(p
, filter
)))
8865 json_object_string_add(
8866 json_addr
, "outboundEbgpRequiresPolicy",
8867 "Outbound updates discarded due to missing policy");
8869 /* unsuppress-map */
8870 if (filter
->usmap
.name
)
8871 json_object_string_add(json_addr
,
8872 "selectiveUnsuppressRouteMap",
8873 filter
->usmap
.name
);
8875 /* Receive prefix count */
8876 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8877 p
->pcount
[afi
][safi
]);
8878 if (paf
&& PAF_SUBGRP(paf
))
8879 json_object_int_add(json_addr
, "sentPrefixCounter",
8880 (PAF_SUBGRP(paf
))->scount
);
8882 /* Maximum prefix */
8883 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8884 json_object_int_add(json_addr
, "prefixAllowedMax",
8885 p
->pmax
[afi
][safi
]);
8886 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8887 PEER_FLAG_MAX_PREFIX_WARNING
))
8888 json_object_boolean_true_add(
8889 json_addr
, "prefixAllowedMaxWarning");
8890 json_object_int_add(json_addr
,
8891 "prefixAllowedWarningThresh",
8892 p
->pmax_threshold
[afi
][safi
]);
8893 if (p
->pmax_restart
[afi
][safi
])
8894 json_object_int_add(
8896 "prefixAllowedRestartIntervalMsecs",
8897 p
->pmax_restart
[afi
][safi
] * 60000);
8899 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8903 filter
= &p
->filter
[afi
][safi
];
8905 vty_out(vty
, " For address family: %s\n",
8906 afi_safi_print(afi
, safi
));
8908 if (peer_group_active(p
))
8909 vty_out(vty
, " %s peer-group member\n",
8912 paf
= peer_af_find(p
, afi
, safi
);
8913 if (paf
&& PAF_SUBGRP(paf
)) {
8914 vty_out(vty
, " Update group %" PRIu64
8915 ", subgroup %" PRIu64
"\n",
8916 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8917 vty_out(vty
, " Packet Queue length %d\n",
8918 bpacket_queue_virtual_length(paf
));
8920 vty_out(vty
, " Not part of any update group\n");
8922 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8923 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8924 PEER_CAP_ORF_PREFIX_SM_RCV
)
8925 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8926 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8927 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8928 PEER_CAP_ORF_PREFIX_RM_ADV
)
8929 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8930 PEER_CAP_ORF_PREFIX_RM_RCV
)
8931 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8932 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8933 vty_out(vty
, " AF-dependant capabilities:\n");
8935 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8936 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8937 PEER_CAP_ORF_PREFIX_SM_RCV
)
8938 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8939 PEER_CAP_ORF_PREFIX_RM_ADV
)
8940 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8941 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8943 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8945 bgp_show_peer_afi_orf_cap(
8946 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8947 PEER_CAP_ORF_PREFIX_RM_ADV
,
8948 PEER_CAP_ORF_PREFIX_SM_RCV
,
8949 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8951 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8952 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8953 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8954 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8955 PEER_CAP_ORF_PREFIX_RM_ADV
)
8956 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8957 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8959 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8960 ORF_TYPE_PREFIX_OLD
);
8961 bgp_show_peer_afi_orf_cap(
8962 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8963 PEER_CAP_ORF_PREFIX_RM_ADV
,
8964 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8965 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8968 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8969 orf_pfx_count
= prefix_bgp_show_prefix_list(
8970 NULL
, afi
, orf_pfx_name
, use_json
);
8972 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8973 PEER_STATUS_ORF_PREFIX_SEND
)
8975 vty_out(vty
, " Outbound Route Filter (ORF):");
8976 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8977 PEER_STATUS_ORF_PREFIX_SEND
))
8978 vty_out(vty
, " sent;");
8980 vty_out(vty
, " received (%d entries)",
8984 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8985 PEER_STATUS_ORF_WAIT_REFRESH
))
8987 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8989 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8990 PEER_FLAG_REFLECTOR_CLIENT
))
8991 vty_out(vty
, " Route-Reflector Client\n");
8992 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8993 PEER_FLAG_RSERVER_CLIENT
))
8994 vty_out(vty
, " Route-Server Client\n");
8995 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8997 " Inbound soft reconfiguration allowed\n");
8999 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9000 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9002 " Private AS numbers (all) replaced in updates to this neighbor\n");
9003 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9004 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9006 " Private AS numbers replaced in updates to this neighbor\n");
9007 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9008 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9010 " Private AS numbers (all) removed in updates to this neighbor\n");
9011 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9012 PEER_FLAG_REMOVE_PRIVATE_AS
))
9014 " Private AS numbers removed in updates to this neighbor\n");
9016 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9017 vty_out(vty
, " %s\n",
9018 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9019 ->human_description
);
9021 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9023 " Override ASNs in outbound updates if aspath equals remote-as\n");
9025 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9026 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9027 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9028 vty_out(vty
, " NEXT_HOP is always this router\n");
9029 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9030 PEER_FLAG_AS_PATH_UNCHANGED
))
9032 " AS_PATH is propagated unchanged to this neighbor\n");
9033 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9034 PEER_FLAG_NEXTHOP_UNCHANGED
))
9036 " NEXT_HOP is propagated unchanged to this neighbor\n");
9037 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9039 " MED is propagated unchanged to this neighbor\n");
9040 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9041 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9042 PEER_FLAG_SEND_EXT_COMMUNITY
)
9043 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9044 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9046 " Community attribute sent to this neighbor");
9047 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9048 PEER_FLAG_SEND_COMMUNITY
)
9049 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9050 PEER_FLAG_SEND_EXT_COMMUNITY
)
9051 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9052 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9053 vty_out(vty
, "(all)\n");
9054 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9055 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9056 vty_out(vty
, "(large)\n");
9057 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9058 PEER_FLAG_SEND_EXT_COMMUNITY
))
9059 vty_out(vty
, "(extended)\n");
9061 vty_out(vty
, "(standard)\n");
9063 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9064 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9065 vty_out(vty
, " Default information originate,");
9067 if (p
->default_rmap
[afi
][safi
].name
)
9068 vty_out(vty
, " default route-map %s%s,",
9069 p
->default_rmap
[afi
][safi
].map
? "*"
9071 p
->default_rmap
[afi
][safi
].name
);
9072 if (paf
&& PAF_SUBGRP(paf
)
9073 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9074 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9075 vty_out(vty
, " default sent\n");
9077 vty_out(vty
, " default not sent\n");
9080 /* advertise-vni-all */
9081 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9082 if (is_evpn_enabled())
9083 vty_out(vty
, " advertise-all-vni\n");
9086 if (filter
->plist
[FILTER_IN
].name
9087 || filter
->dlist
[FILTER_IN
].name
9088 || filter
->aslist
[FILTER_IN
].name
9089 || filter
->map
[RMAP_IN
].name
)
9090 vty_out(vty
, " Inbound path policy configured\n");
9091 if (filter
->plist
[FILTER_OUT
].name
9092 || filter
->dlist
[FILTER_OUT
].name
9093 || filter
->aslist
[FILTER_OUT
].name
9094 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9095 vty_out(vty
, " Outbound path policy configured\n");
9098 if (filter
->plist
[FILTER_IN
].name
)
9100 " Incoming update prefix filter list is %s%s\n",
9101 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9102 filter
->plist
[FILTER_IN
].name
);
9103 if (filter
->plist
[FILTER_OUT
].name
)
9105 " Outgoing update prefix filter list is %s%s\n",
9106 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9107 filter
->plist
[FILTER_OUT
].name
);
9109 /* distribute-list */
9110 if (filter
->dlist
[FILTER_IN
].name
)
9112 " Incoming update network filter list is %s%s\n",
9113 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9114 filter
->dlist
[FILTER_IN
].name
);
9115 if (filter
->dlist
[FILTER_OUT
].name
)
9117 " Outgoing update network filter list is %s%s\n",
9118 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9119 filter
->dlist
[FILTER_OUT
].name
);
9122 if (filter
->aslist
[FILTER_IN
].name
)
9124 " Incoming update AS path filter list is %s%s\n",
9125 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9126 filter
->aslist
[FILTER_IN
].name
);
9127 if (filter
->aslist
[FILTER_OUT
].name
)
9129 " Outgoing update AS path filter list is %s%s\n",
9130 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9131 filter
->aslist
[FILTER_OUT
].name
);
9134 if (filter
->map
[RMAP_IN
].name
)
9136 " Route map for incoming advertisements is %s%s\n",
9137 filter
->map
[RMAP_IN
].map
? "*" : "",
9138 filter
->map
[RMAP_IN
].name
);
9139 if (filter
->map
[RMAP_OUT
].name
)
9141 " Route map for outgoing advertisements is %s%s\n",
9142 filter
->map
[RMAP_OUT
].map
? "*" : "",
9143 filter
->map
[RMAP_OUT
].name
);
9145 /* ebgp-requires-policy (inbound) */
9146 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9147 && !bgp_inbound_policy_exists(p
, filter
))
9149 " Inbound updates discarded due to missing policy\n");
9151 /* ebgp-requires-policy (outbound) */
9152 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9153 && !bgp_outbound_policy_exists(p
, filter
))
9155 " Outbound updates discarded due to missing policy\n");
9157 /* unsuppress-map */
9158 if (filter
->usmap
.name
)
9160 " Route map for selective unsuppress is %s%s\n",
9161 filter
->usmap
.map
? "*" : "",
9162 filter
->usmap
.name
);
9164 /* Receive prefix count */
9165 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9167 /* Maximum prefix */
9168 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9169 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9171 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9172 PEER_FLAG_MAX_PREFIX_WARNING
)
9175 vty_out(vty
, " Threshold for warning message %d%%",
9176 p
->pmax_threshold
[afi
][safi
]);
9177 if (p
->pmax_restart
[afi
][safi
])
9178 vty_out(vty
, ", restart interval %d min",
9179 p
->pmax_restart
[afi
][safi
]);
9187 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9191 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9192 char timebuf
[BGP_UPTIME_LEN
];
9194 const char *subcode_str
;
9195 const char *code_str
;
9200 json_object
*json_neigh
= NULL
;
9206 json_neigh
= json_object_new_object();
9208 memset(dn_flag
, '\0', sizeof(dn_flag
));
9209 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9213 if (p
->conf_if
) /* Configured interface name. */
9214 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9215 BGP_PEER_SU_UNSPEC(p
)
9217 : sockunion2str(&p
->su
, buf
,
9219 else /* Configured IP address. */
9220 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9225 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9226 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9228 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9229 json_object_string_add(
9230 json_neigh
, "bgpNeighborAddr",
9231 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9233 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9235 if (p
->change_local_as
)
9236 json_object_int_add(json_neigh
, "localAs",
9237 p
->change_local_as
);
9239 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9241 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9242 json_object_boolean_true_add(json_neigh
,
9243 "localAsNoPrepend");
9245 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9246 json_object_boolean_true_add(json_neigh
,
9247 "localAsReplaceAs");
9249 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9250 || (p
->as_type
== AS_INTERNAL
))
9251 vty_out(vty
, "remote AS %u, ", p
->as
);
9253 vty_out(vty
, "remote AS Unspecified, ");
9254 vty_out(vty
, "local AS %u%s%s, ",
9255 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9256 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9259 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9263 /* peer type internal or confed-internal */
9264 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9266 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9267 json_object_boolean_true_add(
9268 json_neigh
, "nbrConfedInternalLink");
9270 json_object_boolean_true_add(json_neigh
,
9273 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9274 vty_out(vty
, "confed-internal link\n");
9276 vty_out(vty
, "internal link\n");
9278 /* peer type external or confed-external */
9279 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9281 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9282 json_object_boolean_true_add(
9283 json_neigh
, "nbrConfedExternalLink");
9285 json_object_boolean_true_add(json_neigh
,
9288 if (bgp_confederation_peers_check(bgp
, p
->as
))
9289 vty_out(vty
, "confed-external link\n");
9291 vty_out(vty
, "external link\n");
9295 json_object_boolean_true_add(json_neigh
,
9296 "nbrUnspecifiedLink");
9298 vty_out(vty
, "unspecified link\n");
9304 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9306 vty_out(vty
, " Description: %s\n", p
->desc
);
9312 json_object_string_add(json_neigh
, "hostname",
9316 json_object_string_add(json_neigh
, "domainname",
9319 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9320 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9323 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9330 json_object_string_add(json_neigh
, "peerGroup",
9334 struct prefix prefix
, *range
= NULL
;
9336 sockunion2hostprefix(&(p
->su
), &prefix
);
9337 range
= peer_group_lookup_dynamic_neighbor_range(
9341 prefix2str(range
, buf1
, sizeof(buf1
));
9342 json_object_string_add(
9344 "peerSubnetRangeGroup", buf1
);
9349 " Member of peer-group %s for session parameters\n",
9353 struct prefix prefix
, *range
= NULL
;
9355 sockunion2hostprefix(&(p
->su
), &prefix
);
9356 range
= peer_group_lookup_dynamic_neighbor_range(
9360 prefix2str(range
, buf1
, sizeof(buf1
));
9362 " Belongs to the subnet range group: %s\n",
9370 /* Administrative shutdown. */
9371 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9372 json_object_boolean_true_add(json_neigh
,
9376 json_object_int_add(json_neigh
, "bgpVersion", 4);
9377 json_object_string_add(
9378 json_neigh
, "remoteRouterId",
9379 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9380 json_object_string_add(
9381 json_neigh
, "localRouterId",
9382 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9386 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9387 && bgp_confederation_peers_check(bgp
, p
->as
))
9388 json_object_boolean_true_add(json_neigh
,
9392 json_object_string_add(
9393 json_neigh
, "bgpState",
9394 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9396 if (p
->status
== Established
) {
9399 uptime
= bgp_clock();
9400 uptime
-= p
->uptime
;
9401 epoch_tbuf
= time(NULL
) - uptime
;
9403 #if CONFDATE > 20200101
9405 "bgpTimerUp should be deprecated and can be removed now");
9408 * bgpTimerUp was miliseconds that was accurate
9409 * up to 1 day, then the value returned
9410 * became garbage. So in order to provide
9411 * some level of backwards compatability,
9412 * we still provde the data, but now
9413 * we are returning the correct value
9414 * and also adding a new bgpTimerUpMsec
9415 * which will allow us to deprecate
9418 json_object_int_add(json_neigh
, "bgpTimerUp",
9420 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9422 json_object_string_add(json_neigh
, "bgpTimerUpString",
9423 peer_uptime(p
->uptime
, timebuf
,
9426 json_object_int_add(json_neigh
,
9427 "bgpTimerUpEstablishedEpoch",
9431 else if (p
->status
== Active
) {
9432 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9433 json_object_string_add(json_neigh
, "bgpStateIs",
9435 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9436 json_object_string_add(json_neigh
, "bgpStateIs",
9444 uptime
= bgp_clock();
9445 uptime
-= p
->readtime
;
9446 tm
= gmtime(&uptime
);
9447 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9448 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9449 + (tm
->tm_hour
* 3600000));
9451 uptime
= bgp_clock();
9452 uptime
-= p
->last_write
;
9453 tm
= gmtime(&uptime
);
9454 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9455 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9456 + (tm
->tm_hour
* 3600000));
9458 uptime
= bgp_clock();
9459 uptime
-= p
->update_time
;
9460 tm
= gmtime(&uptime
);
9461 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9462 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9463 + (tm
->tm_hour
* 3600000));
9465 /* Configured timer values. */
9466 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9467 p
->v_holdtime
* 1000);
9468 json_object_int_add(json_neigh
,
9469 "bgpTimerKeepAliveIntervalMsecs",
9470 p
->v_keepalive
* 1000);
9471 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9472 json_object_int_add(json_neigh
,
9473 "bgpTimerConfiguredHoldTimeMsecs",
9474 p
->holdtime
* 1000);
9475 json_object_int_add(
9477 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9478 p
->keepalive
* 1000);
9479 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9480 || (bgp
->default_keepalive
9481 != BGP_DEFAULT_KEEPALIVE
)) {
9482 json_object_int_add(json_neigh
,
9483 "bgpTimerConfiguredHoldTimeMsecs",
9484 bgp
->default_holdtime
);
9485 json_object_int_add(
9487 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9488 bgp
->default_keepalive
);
9491 /* Administrative shutdown. */
9492 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9493 vty_out(vty
, " Administratively shut down\n");
9496 vty_out(vty
, " BGP version 4");
9497 vty_out(vty
, ", remote router ID %s",
9498 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9499 vty_out(vty
, ", local router ID %s\n",
9500 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9504 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9505 && bgp_confederation_peers_check(bgp
, p
->as
))
9507 " Neighbor under common administration\n");
9510 vty_out(vty
, " BGP state = %s",
9511 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9513 if (p
->status
== Established
)
9514 vty_out(vty
, ", up for %8s",
9515 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9518 else if (p
->status
== Active
) {
9519 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9520 vty_out(vty
, " (passive)");
9521 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9522 vty_out(vty
, " (NSF passive)");
9527 vty_out(vty
, " Last read %s",
9528 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9530 vty_out(vty
, ", Last write %s\n",
9531 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9534 /* Configured timer values. */
9536 " Hold time is %d, keepalive interval is %d seconds\n",
9537 p
->v_holdtime
, p
->v_keepalive
);
9538 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9539 vty_out(vty
, " Configured hold time is %d",
9541 vty_out(vty
, ", keepalive interval is %d seconds\n",
9543 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9544 || (bgp
->default_keepalive
9545 != BGP_DEFAULT_KEEPALIVE
)) {
9546 vty_out(vty
, " Configured hold time is %d",
9547 bgp
->default_holdtime
);
9548 vty_out(vty
, ", keepalive interval is %d seconds\n",
9549 bgp
->default_keepalive
);
9553 if (p
->status
== Established
) {
9554 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9555 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9556 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9557 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9558 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9559 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9560 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9561 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9562 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9563 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9564 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9565 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9566 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9567 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9568 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9569 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9570 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9571 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9572 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9573 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9575 json_object
*json_cap
= NULL
;
9577 json_cap
= json_object_new_object();
9580 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9581 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9582 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9583 && CHECK_FLAG(p
->cap
,
9585 json_object_string_add(
9586 json_cap
, "4byteAs",
9587 "advertisedAndReceived");
9588 else if (CHECK_FLAG(p
->cap
,
9590 json_object_string_add(
9591 json_cap
, "4byteAs",
9593 else if (CHECK_FLAG(p
->cap
,
9595 json_object_string_add(
9596 json_cap
, "4byteAs",
9601 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9602 || CHECK_FLAG(p
->cap
,
9603 PEER_CAP_ADDPATH_ADV
)) {
9604 json_object
*json_add
= NULL
;
9605 const char *print_store
;
9607 json_add
= json_object_new_object();
9609 FOREACH_AFI_SAFI (afi
, safi
) {
9610 json_object
*json_sub
= NULL
;
9612 json_object_new_object();
9613 print_store
= afi_safi_print(
9619 PEER_CAP_ADDPATH_AF_TX_ADV
)
9623 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9628 PEER_CAP_ADDPATH_AF_TX_ADV
)
9633 PEER_CAP_ADDPATH_AF_TX_RCV
))
9634 json_object_boolean_true_add(
9636 "txAdvertisedAndReceived");
9642 PEER_CAP_ADDPATH_AF_TX_ADV
))
9643 json_object_boolean_true_add(
9651 PEER_CAP_ADDPATH_AF_TX_RCV
))
9652 json_object_boolean_true_add(
9660 PEER_CAP_ADDPATH_AF_RX_ADV
)
9664 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9669 PEER_CAP_ADDPATH_AF_RX_ADV
)
9674 PEER_CAP_ADDPATH_AF_RX_RCV
))
9675 json_object_boolean_true_add(
9677 "rxAdvertisedAndReceived");
9683 PEER_CAP_ADDPATH_AF_RX_ADV
))
9684 json_object_boolean_true_add(
9692 PEER_CAP_ADDPATH_AF_RX_RCV
))
9693 json_object_boolean_true_add(
9701 PEER_CAP_ADDPATH_AF_TX_ADV
)
9705 PEER_CAP_ADDPATH_AF_TX_RCV
)
9709 PEER_CAP_ADDPATH_AF_RX_ADV
)
9713 PEER_CAP_ADDPATH_AF_RX_RCV
))
9714 json_object_object_add(
9723 json_object_object_add(
9724 json_cap
, "addPath", json_add
);
9728 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9729 || CHECK_FLAG(p
->cap
,
9730 PEER_CAP_DYNAMIC_ADV
)) {
9731 if (CHECK_FLAG(p
->cap
,
9732 PEER_CAP_DYNAMIC_ADV
)
9733 && CHECK_FLAG(p
->cap
,
9734 PEER_CAP_DYNAMIC_RCV
))
9735 json_object_string_add(
9736 json_cap
, "dynamic",
9737 "advertisedAndReceived");
9738 else if (CHECK_FLAG(
9740 PEER_CAP_DYNAMIC_ADV
))
9741 json_object_string_add(
9742 json_cap
, "dynamic",
9744 else if (CHECK_FLAG(
9746 PEER_CAP_DYNAMIC_RCV
))
9747 json_object_string_add(
9748 json_cap
, "dynamic",
9752 /* Extended nexthop */
9753 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9754 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9755 json_object
*json_nxt
= NULL
;
9756 const char *print_store
;
9759 if (CHECK_FLAG(p
->cap
,
9761 && CHECK_FLAG(p
->cap
,
9763 json_object_string_add(
9766 "advertisedAndReceived");
9767 else if (CHECK_FLAG(p
->cap
,
9769 json_object_string_add(
9773 else if (CHECK_FLAG(p
->cap
,
9775 json_object_string_add(
9780 if (CHECK_FLAG(p
->cap
,
9781 PEER_CAP_ENHE_RCV
)) {
9783 json_object_new_object();
9785 for (safi
= SAFI_UNICAST
;
9786 safi
< SAFI_MAX
; safi
++) {
9791 PEER_CAP_ENHE_AF_RCV
)) {
9792 print_store
= afi_safi_print(
9795 json_object_string_add(
9798 "recieved"); /* misspelled for compatibility */
9801 json_object_object_add(
9803 "extendedNexthopFamililesByPeer",
9809 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9810 || CHECK_FLAG(p
->cap
,
9811 PEER_CAP_REFRESH_NEW_RCV
)
9812 || CHECK_FLAG(p
->cap
,
9813 PEER_CAP_REFRESH_OLD_RCV
)) {
9814 if (CHECK_FLAG(p
->cap
,
9815 PEER_CAP_REFRESH_ADV
)
9818 PEER_CAP_REFRESH_NEW_RCV
)
9821 PEER_CAP_REFRESH_OLD_RCV
))) {
9824 PEER_CAP_REFRESH_OLD_RCV
)
9827 PEER_CAP_REFRESH_NEW_RCV
))
9828 json_object_string_add(
9831 "advertisedAndReceivedOldNew");
9835 PEER_CAP_REFRESH_OLD_RCV
))
9836 json_object_string_add(
9839 "advertisedAndReceivedOld");
9841 json_object_string_add(
9844 "advertisedAndReceivedNew");
9849 PEER_CAP_REFRESH_ADV
))
9850 json_object_string_add(
9857 PEER_CAP_REFRESH_NEW_RCV
)
9860 PEER_CAP_REFRESH_OLD_RCV
))
9861 json_object_string_add(
9867 /* Multiprotocol Extensions */
9868 json_object
*json_multi
= NULL
;
9869 json_multi
= json_object_new_object();
9871 FOREACH_AFI_SAFI (afi
, safi
) {
9872 if (p
->afc_adv
[afi
][safi
]
9873 || p
->afc_recv
[afi
][safi
]) {
9874 json_object
*json_exten
= NULL
;
9876 json_object_new_object();
9878 if (p
->afc_adv
[afi
][safi
]
9879 && p
->afc_recv
[afi
][safi
])
9880 json_object_boolean_true_add(
9882 "advertisedAndReceived");
9883 else if (p
->afc_adv
[afi
][safi
])
9884 json_object_boolean_true_add(
9887 else if (p
->afc_recv
[afi
][safi
])
9888 json_object_boolean_true_add(
9892 json_object_object_add(
9899 json_object_object_add(
9900 json_cap
, "multiprotocolExtensions",
9903 /* Hostname capabilities */
9904 json_object
*json_hname
= NULL
;
9906 json_hname
= json_object_new_object();
9908 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9909 json_object_string_add(
9910 json_hname
, "advHostName",
9911 bgp
->peer_self
->hostname
9915 json_object_string_add(
9916 json_hname
, "advDomainName",
9917 bgp
->peer_self
->domainname
9924 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9925 json_object_string_add(
9926 json_hname
, "rcvHostName",
9927 p
->hostname
? p
->hostname
9929 json_object_string_add(
9930 json_hname
, "rcvDomainName",
9931 p
->domainname
? p
->domainname
9935 json_object_object_add(json_cap
, "hostName",
9938 /* Gracefull Restart */
9939 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9940 || CHECK_FLAG(p
->cap
,
9941 PEER_CAP_RESTART_ADV
)) {
9942 if (CHECK_FLAG(p
->cap
,
9943 PEER_CAP_RESTART_ADV
)
9944 && CHECK_FLAG(p
->cap
,
9945 PEER_CAP_RESTART_RCV
))
9946 json_object_string_add(
9949 "advertisedAndReceived");
9950 else if (CHECK_FLAG(
9952 PEER_CAP_RESTART_ADV
))
9953 json_object_string_add(
9955 "gracefulRestartCapability",
9957 else if (CHECK_FLAG(
9959 PEER_CAP_RESTART_RCV
))
9960 json_object_string_add(
9962 "gracefulRestartCapability",
9965 if (CHECK_FLAG(p
->cap
,
9966 PEER_CAP_RESTART_RCV
)) {
9967 int restart_af_count
= 0;
9968 json_object
*json_restart
=
9971 json_object_new_object();
9973 json_object_int_add(
9975 "gracefulRestartRemoteTimerMsecs",
9976 p
->v_gr_restart
* 1000);
9978 FOREACH_AFI_SAFI (afi
, safi
) {
9983 PEER_CAP_RESTART_AF_RCV
)) {
9988 json_object_new_object();
9994 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9995 json_object_boolean_true_add(
9999 json_object_object_add(
10007 if (!restart_af_count
) {
10008 json_object_string_add(
10010 "addressFamiliesByPeer",
10015 json_object_object_add(
10017 "addressFamiliesByPeer",
10021 json_object_object_add(json_neigh
,
10022 "neighborCapabilities",
10025 vty_out(vty
, " Neighbor capabilities:\n");
10028 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10029 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10030 vty_out(vty
, " 4 Byte AS:");
10031 if (CHECK_FLAG(p
->cap
,
10033 vty_out(vty
, " advertised");
10034 if (CHECK_FLAG(p
->cap
,
10036 vty_out(vty
, " %sreceived",
10042 vty_out(vty
, "\n");
10046 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10047 || CHECK_FLAG(p
->cap
,
10048 PEER_CAP_ADDPATH_ADV
)) {
10049 vty_out(vty
, " AddPath:\n");
10051 FOREACH_AFI_SAFI (afi
, safi
) {
10055 PEER_CAP_ADDPATH_AF_TX_ADV
)
10059 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10070 PEER_CAP_ADDPATH_AF_TX_ADV
))
10081 PEER_CAP_ADDPATH_AF_TX_RCV
))
10088 PEER_CAP_ADDPATH_AF_TX_ADV
)
10092 vty_out(vty
, "\n");
10098 PEER_CAP_ADDPATH_AF_RX_ADV
)
10102 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10113 PEER_CAP_ADDPATH_AF_RX_ADV
))
10124 PEER_CAP_ADDPATH_AF_RX_RCV
))
10131 PEER_CAP_ADDPATH_AF_RX_ADV
)
10135 vty_out(vty
, "\n");
10141 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10142 || CHECK_FLAG(p
->cap
,
10143 PEER_CAP_DYNAMIC_ADV
)) {
10144 vty_out(vty
, " Dynamic:");
10145 if (CHECK_FLAG(p
->cap
,
10146 PEER_CAP_DYNAMIC_ADV
))
10147 vty_out(vty
, " advertised");
10148 if (CHECK_FLAG(p
->cap
,
10149 PEER_CAP_DYNAMIC_RCV
))
10150 vty_out(vty
, " %sreceived",
10153 PEER_CAP_DYNAMIC_ADV
)
10156 vty_out(vty
, "\n");
10159 /* Extended nexthop */
10160 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10161 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10162 vty_out(vty
, " Extended nexthop:");
10163 if (CHECK_FLAG(p
->cap
,
10164 PEER_CAP_ENHE_ADV
))
10165 vty_out(vty
, " advertised");
10166 if (CHECK_FLAG(p
->cap
,
10167 PEER_CAP_ENHE_RCV
))
10168 vty_out(vty
, " %sreceived",
10174 vty_out(vty
, "\n");
10176 if (CHECK_FLAG(p
->cap
,
10177 PEER_CAP_ENHE_RCV
)) {
10179 " Address families by peer:\n ");
10180 for (safi
= SAFI_UNICAST
;
10181 safi
< SAFI_MAX
; safi
++)
10186 PEER_CAP_ENHE_AF_RCV
))
10195 /* Route Refresh */
10196 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10197 || CHECK_FLAG(p
->cap
,
10198 PEER_CAP_REFRESH_NEW_RCV
)
10199 || CHECK_FLAG(p
->cap
,
10200 PEER_CAP_REFRESH_OLD_RCV
)) {
10201 vty_out(vty
, " Route refresh:");
10202 if (CHECK_FLAG(p
->cap
,
10203 PEER_CAP_REFRESH_ADV
))
10204 vty_out(vty
, " advertised");
10205 if (CHECK_FLAG(p
->cap
,
10206 PEER_CAP_REFRESH_NEW_RCV
)
10209 PEER_CAP_REFRESH_OLD_RCV
))
10210 vty_out(vty
, " %sreceived(%s)",
10213 PEER_CAP_REFRESH_ADV
)
10218 PEER_CAP_REFRESH_OLD_RCV
)
10221 PEER_CAP_REFRESH_NEW_RCV
))
10225 PEER_CAP_REFRESH_OLD_RCV
)
10229 vty_out(vty
, "\n");
10232 /* Multiprotocol Extensions */
10233 FOREACH_AFI_SAFI (afi
, safi
)
10234 if (p
->afc_adv
[afi
][safi
]
10235 || p
->afc_recv
[afi
][safi
]) {
10237 " Address Family %s:",
10238 afi_safi_print(afi
,
10240 if (p
->afc_adv
[afi
][safi
])
10243 if (p
->afc_recv
[afi
][safi
])
10250 vty_out(vty
, "\n");
10253 /* Hostname capability */
10254 vty_out(vty
, " Hostname Capability:");
10256 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10258 " advertised (name: %s,domain name: %s)",
10259 bgp
->peer_self
->hostname
10263 bgp
->peer_self
->domainname
10268 vty_out(vty
, " not advertised");
10271 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10273 " received (name: %s,domain name: %s)",
10274 p
->hostname
? p
->hostname
10276 p
->domainname
? p
->domainname
10279 vty_out(vty
, " not received");
10282 vty_out(vty
, "\n");
10284 /* Gracefull Restart */
10285 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10286 || CHECK_FLAG(p
->cap
,
10287 PEER_CAP_RESTART_ADV
)) {
10289 " Graceful Restart Capabilty:");
10290 if (CHECK_FLAG(p
->cap
,
10291 PEER_CAP_RESTART_ADV
))
10292 vty_out(vty
, " advertised");
10293 if (CHECK_FLAG(p
->cap
,
10294 PEER_CAP_RESTART_RCV
))
10295 vty_out(vty
, " %sreceived",
10298 PEER_CAP_RESTART_ADV
)
10301 vty_out(vty
, "\n");
10303 if (CHECK_FLAG(p
->cap
,
10304 PEER_CAP_RESTART_RCV
)) {
10305 int restart_af_count
= 0;
10308 " Remote Restart timer is %d seconds\n",
10311 " Address families by peer:\n ");
10313 FOREACH_AFI_SAFI (afi
, safi
)
10318 PEER_CAP_RESTART_AF_RCV
)) {
10331 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10333 : "not preserved");
10334 restart_af_count
++;
10336 if (!restart_af_count
)
10337 vty_out(vty
, "none");
10338 vty_out(vty
, "\n");
10345 /* graceful restart information */
10346 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10347 || p
->t_gr_stale
) {
10348 json_object
*json_grace
= NULL
;
10349 json_object
*json_grace_send
= NULL
;
10350 json_object
*json_grace_recv
= NULL
;
10351 int eor_send_af_count
= 0;
10352 int eor_receive_af_count
= 0;
10355 json_grace
= json_object_new_object();
10356 json_grace_send
= json_object_new_object();
10357 json_grace_recv
= json_object_new_object();
10359 if (p
->status
== Established
) {
10360 FOREACH_AFI_SAFI (afi
, safi
) {
10361 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10362 PEER_STATUS_EOR_SEND
)) {
10363 json_object_boolean_true_add(
10365 afi_safi_print(afi
,
10367 eor_send_af_count
++;
10370 FOREACH_AFI_SAFI (afi
, safi
) {
10372 p
->af_sflags
[afi
][safi
],
10373 PEER_STATUS_EOR_RECEIVED
)) {
10374 json_object_boolean_true_add(
10376 afi_safi_print(afi
,
10378 eor_receive_af_count
++;
10383 json_object_object_add(json_grace
, "endOfRibSend",
10385 json_object_object_add(json_grace
, "endOfRibRecv",
10388 if (p
->t_gr_restart
)
10389 json_object_int_add(json_grace
,
10390 "gracefulRestartTimerMsecs",
10391 thread_timer_remain_second(
10396 json_object_int_add(
10398 "gracefulStalepathTimerMsecs",
10399 thread_timer_remain_second(
10403 json_object_object_add(
10404 json_neigh
, "gracefulRestartInfo", json_grace
);
10406 vty_out(vty
, " Graceful restart information:\n");
10407 if (p
->status
== Established
) {
10408 vty_out(vty
, " End-of-RIB send: ");
10409 FOREACH_AFI_SAFI (afi
, safi
) {
10410 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10411 PEER_STATUS_EOR_SEND
)) {
10412 vty_out(vty
, "%s%s",
10413 eor_send_af_count
? ", "
10415 afi_safi_print(afi
,
10417 eor_send_af_count
++;
10420 vty_out(vty
, "\n");
10421 vty_out(vty
, " End-of-RIB received: ");
10422 FOREACH_AFI_SAFI (afi
, safi
) {
10424 p
->af_sflags
[afi
][safi
],
10425 PEER_STATUS_EOR_RECEIVED
)) {
10426 vty_out(vty
, "%s%s",
10427 eor_receive_af_count
10430 afi_safi_print(afi
,
10432 eor_receive_af_count
++;
10435 vty_out(vty
, "\n");
10438 if (p
->t_gr_restart
)
10440 " The remaining time of restart timer is %ld\n",
10441 thread_timer_remain_second(
10446 " The remaining time of stalepath timer is %ld\n",
10447 thread_timer_remain_second(
10452 json_object
*json_stat
= NULL
;
10453 json_stat
= json_object_new_object();
10454 /* Packet counts. */
10455 json_object_int_add(json_stat
, "depthInq", 0);
10456 json_object_int_add(json_stat
, "depthOutq",
10457 (unsigned long)p
->obuf
->count
);
10458 json_object_int_add(json_stat
, "opensSent",
10459 atomic_load_explicit(&p
->open_out
,
10460 memory_order_relaxed
));
10461 json_object_int_add(json_stat
, "opensRecv",
10462 atomic_load_explicit(&p
->open_in
,
10463 memory_order_relaxed
));
10464 json_object_int_add(json_stat
, "notificationsSent",
10465 atomic_load_explicit(&p
->notify_out
,
10466 memory_order_relaxed
));
10467 json_object_int_add(json_stat
, "notificationsRecv",
10468 atomic_load_explicit(&p
->notify_in
,
10469 memory_order_relaxed
));
10470 json_object_int_add(json_stat
, "updatesSent",
10471 atomic_load_explicit(&p
->update_out
,
10472 memory_order_relaxed
));
10473 json_object_int_add(json_stat
, "updatesRecv",
10474 atomic_load_explicit(&p
->update_in
,
10475 memory_order_relaxed
));
10476 json_object_int_add(json_stat
, "keepalivesSent",
10477 atomic_load_explicit(&p
->keepalive_out
,
10478 memory_order_relaxed
));
10479 json_object_int_add(json_stat
, "keepalivesRecv",
10480 atomic_load_explicit(&p
->keepalive_in
,
10481 memory_order_relaxed
));
10482 json_object_int_add(json_stat
, "routeRefreshSent",
10483 atomic_load_explicit(&p
->refresh_out
,
10484 memory_order_relaxed
));
10485 json_object_int_add(json_stat
, "routeRefreshRecv",
10486 atomic_load_explicit(&p
->refresh_in
,
10487 memory_order_relaxed
));
10488 json_object_int_add(json_stat
, "capabilitySent",
10489 atomic_load_explicit(&p
->dynamic_cap_out
,
10490 memory_order_relaxed
));
10491 json_object_int_add(json_stat
, "capabilityRecv",
10492 atomic_load_explicit(&p
->dynamic_cap_in
,
10493 memory_order_relaxed
));
10494 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10495 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10496 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10498 /* Packet counts. */
10499 vty_out(vty
, " Message statistics:\n");
10500 vty_out(vty
, " Inq depth is 0\n");
10501 vty_out(vty
, " Outq depth is %lu\n",
10502 (unsigned long)p
->obuf
->count
);
10503 vty_out(vty
, " Sent Rcvd\n");
10504 vty_out(vty
, " Opens: %10d %10d\n",
10505 atomic_load_explicit(&p
->open_out
,
10506 memory_order_relaxed
),
10507 atomic_load_explicit(&p
->open_in
,
10508 memory_order_relaxed
));
10509 vty_out(vty
, " Notifications: %10d %10d\n",
10510 atomic_load_explicit(&p
->notify_out
,
10511 memory_order_relaxed
),
10512 atomic_load_explicit(&p
->notify_in
,
10513 memory_order_relaxed
));
10514 vty_out(vty
, " Updates: %10d %10d\n",
10515 atomic_load_explicit(&p
->update_out
,
10516 memory_order_relaxed
),
10517 atomic_load_explicit(&p
->update_in
,
10518 memory_order_relaxed
));
10519 vty_out(vty
, " Keepalives: %10d %10d\n",
10520 atomic_load_explicit(&p
->keepalive_out
,
10521 memory_order_relaxed
),
10522 atomic_load_explicit(&p
->keepalive_in
,
10523 memory_order_relaxed
));
10524 vty_out(vty
, " Route Refresh: %10d %10d\n",
10525 atomic_load_explicit(&p
->refresh_out
,
10526 memory_order_relaxed
),
10527 atomic_load_explicit(&p
->refresh_in
,
10528 memory_order_relaxed
));
10529 vty_out(vty
, " Capability: %10d %10d\n",
10530 atomic_load_explicit(&p
->dynamic_cap_out
,
10531 memory_order_relaxed
),
10532 atomic_load_explicit(&p
->dynamic_cap_in
,
10533 memory_order_relaxed
));
10534 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10539 /* advertisement-interval */
10540 json_object_int_add(json_neigh
,
10541 "minBtwnAdvertisementRunsTimerMsecs",
10542 p
->v_routeadv
* 1000);
10544 /* Update-source. */
10545 if (p
->update_if
|| p
->update_source
) {
10547 json_object_string_add(json_neigh
,
10550 else if (p
->update_source
)
10551 json_object_string_add(
10552 json_neigh
, "updateSource",
10553 sockunion2str(p
->update_source
, buf1
,
10557 /* advertisement-interval */
10559 " Minimum time between advertisement runs is %d seconds\n",
10562 /* Update-source. */
10563 if (p
->update_if
|| p
->update_source
) {
10564 vty_out(vty
, " Update source is ");
10566 vty_out(vty
, "%s", p
->update_if
);
10567 else if (p
->update_source
)
10569 sockunion2str(p
->update_source
, buf1
,
10571 vty_out(vty
, "\n");
10574 vty_out(vty
, "\n");
10577 /* Address Family Information */
10578 json_object
*json_hold
= NULL
;
10581 json_hold
= json_object_new_object();
10583 FOREACH_AFI_SAFI (afi
, safi
)
10584 if (p
->afc
[afi
][safi
])
10585 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10589 json_object_object_add(json_neigh
, "addressFamilyInfo",
10591 json_object_int_add(json_neigh
, "connectionsEstablished",
10593 json_object_int_add(json_neigh
, "connectionsDropped",
10596 vty_out(vty
, " Connections established %d; dropped %d\n",
10597 p
->established
, p
->dropped
);
10599 if (!p
->last_reset
) {
10601 json_object_string_add(json_neigh
, "lastReset",
10604 vty_out(vty
, " Last reset never\n");
10610 uptime
= bgp_clock();
10611 uptime
-= p
->resettime
;
10612 tm
= gmtime(&uptime
);
10613 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10614 (tm
->tm_sec
* 1000)
10615 + (tm
->tm_min
* 60000)
10616 + (tm
->tm_hour
* 3600000));
10617 json_object_string_add(
10618 json_neigh
, "lastResetDueTo",
10619 peer_down_str
[(int)p
->last_reset
]);
10620 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10621 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10622 char errorcodesubcode_hexstr
[5];
10623 char errorcodesubcode_str
[256];
10625 code_str
= bgp_notify_code_str(p
->notify
.code
);
10626 subcode_str
= bgp_notify_subcode_str(
10627 p
->notify
.code
, p
->notify
.subcode
);
10629 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10630 p
->notify
.code
, p
->notify
.subcode
);
10631 json_object_string_add(json_neigh
,
10632 "lastErrorCodeSubcode",
10633 errorcodesubcode_hexstr
);
10634 snprintf(errorcodesubcode_str
, 255, "%s%s",
10635 code_str
, subcode_str
);
10636 json_object_string_add(json_neigh
,
10637 "lastNotificationReason",
10638 errorcodesubcode_str
);
10639 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10640 && p
->notify
.code
== BGP_NOTIFY_CEASE
10641 && (p
->notify
.subcode
10642 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10643 || p
->notify
.subcode
10644 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10645 && p
->notify
.length
) {
10647 const char *msg_str
;
10649 msg_str
= bgp_notify_admin_message(
10650 msgbuf
, sizeof(msgbuf
),
10651 (uint8_t *)p
->notify
.data
,
10654 json_object_string_add(
10656 "lastShutdownDescription",
10661 vty_out(vty
, " Last reset %s, ",
10662 peer_uptime(p
->resettime
, timebuf
,
10663 BGP_UPTIME_LEN
, 0, NULL
));
10665 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10666 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10667 code_str
= bgp_notify_code_str(p
->notify
.code
);
10668 subcode_str
= bgp_notify_subcode_str(
10669 p
->notify
.code
, p
->notify
.subcode
);
10670 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10671 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10674 code_str
, subcode_str
);
10675 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10676 && p
->notify
.code
== BGP_NOTIFY_CEASE
10677 && (p
->notify
.subcode
10678 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10679 || p
->notify
.subcode
10680 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10681 && p
->notify
.length
) {
10683 const char *msg_str
;
10685 msg_str
= bgp_notify_admin_message(
10686 msgbuf
, sizeof(msgbuf
),
10687 (uint8_t *)p
->notify
.data
,
10691 " Message: \"%s\"\n",
10695 vty_out(vty
, "due to %s\n",
10696 peer_down_str
[(int)p
->last_reset
]);
10699 if (p
->last_reset_cause_size
) {
10700 msg
= p
->last_reset_cause
;
10702 " Message received that caused BGP to send a NOTIFICATION:\n ");
10703 for (i
= 1; i
<= p
->last_reset_cause_size
;
10705 vty_out(vty
, "%02X", *msg
++);
10707 if (i
!= p
->last_reset_cause_size
) {
10709 vty_out(vty
, "\n ");
10710 } else if (i
% 4 == 0) {
10715 vty_out(vty
, "\n");
10720 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10722 json_object_boolean_true_add(json_neigh
,
10723 "prefixesConfigExceedMax");
10726 " Peer had exceeded the max. no. of prefixes configured.\n");
10728 if (p
->t_pmax_restart
) {
10730 json_object_boolean_true_add(
10731 json_neigh
, "reducePrefixNumFrom");
10732 json_object_int_add(json_neigh
,
10733 "restartInTimerMsec",
10734 thread_timer_remain_second(
10739 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10740 p
->host
, thread_timer_remain_second(
10741 p
->t_pmax_restart
));
10744 json_object_boolean_true_add(
10746 "reducePrefixNumAndClearIpBgp");
10749 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10754 /* EBGP Multihop and GTSM */
10755 if (p
->sort
!= BGP_PEER_IBGP
) {
10757 if (p
->gtsm_hops
> 0)
10758 json_object_int_add(json_neigh
,
10759 "externalBgpNbrMaxHopsAway",
10761 else if (p
->ttl
> 1)
10762 json_object_int_add(json_neigh
,
10763 "externalBgpNbrMaxHopsAway",
10766 if (p
->gtsm_hops
> 0)
10768 " External BGP neighbor may be up to %d hops away.\n",
10770 else if (p
->ttl
> 1)
10772 " External BGP neighbor may be up to %d hops away.\n",
10776 if (p
->gtsm_hops
> 0) {
10778 json_object_int_add(json_neigh
,
10779 "internalBgpNbrMaxHopsAway",
10783 " Internal BGP neighbor may be up to %d hops away.\n",
10788 /* Local address. */
10791 json_object_string_add(json_neigh
, "hostLocal",
10792 sockunion2str(p
->su_local
, buf1
,
10794 json_object_int_add(json_neigh
, "portLocal",
10795 ntohs(p
->su_local
->sin
.sin_port
));
10797 vty_out(vty
, "Local host: %s, Local port: %d\n",
10798 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10799 ntohs(p
->su_local
->sin
.sin_port
));
10802 /* Remote address. */
10803 if (p
->su_remote
) {
10805 json_object_string_add(json_neigh
, "hostForeign",
10806 sockunion2str(p
->su_remote
, buf1
,
10808 json_object_int_add(json_neigh
, "portForeign",
10809 ntohs(p
->su_remote
->sin
.sin_port
));
10811 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10812 sockunion2str(p
->su_remote
, buf1
,
10814 ntohs(p
->su_remote
->sin
.sin_port
));
10817 /* Nexthop display. */
10820 json_object_string_add(json_neigh
, "nexthop",
10822 &p
->nexthop
.v4
, buf1
,
10824 json_object_string_add(json_neigh
, "nexthopGlobal",
10825 inet_ntop(AF_INET6
,
10826 &p
->nexthop
.v6_global
,
10827 buf1
, sizeof(buf1
)));
10828 json_object_string_add(json_neigh
, "nexthopLocal",
10829 inet_ntop(AF_INET6
,
10830 &p
->nexthop
.v6_local
,
10831 buf1
, sizeof(buf1
)));
10832 if (p
->shared_network
)
10833 json_object_string_add(json_neigh
,
10837 json_object_string_add(json_neigh
,
10839 "nonSharedNetwork");
10841 vty_out(vty
, "Nexthop: %s\n",
10842 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10844 vty_out(vty
, "Nexthop global: %s\n",
10845 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10847 vty_out(vty
, "Nexthop local: %s\n",
10848 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10850 vty_out(vty
, "BGP connection: %s\n",
10851 p
->shared_network
? "shared network"
10852 : "non shared network");
10856 /* Timer information. */
10858 json_object_int_add(json_neigh
, "connectRetryTimer",
10860 if (p
->status
== Established
&& p
->rtt
)
10861 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10864 json_object_int_add(
10865 json_neigh
, "nextStartTimerDueInMsecs",
10866 thread_timer_remain_second(p
->t_start
) * 1000);
10868 json_object_int_add(
10869 json_neigh
, "nextConnectTimerDueInMsecs",
10870 thread_timer_remain_second(p
->t_connect
)
10872 if (p
->t_routeadv
) {
10873 json_object_int_add(json_neigh
, "mraiInterval",
10875 json_object_int_add(
10876 json_neigh
, "mraiTimerExpireInMsecs",
10877 thread_timer_remain_second(p
->t_routeadv
)
10881 json_object_int_add(json_neigh
, "authenticationEnabled",
10885 json_object_string_add(json_neigh
, "readThread", "on");
10887 json_object_string_add(json_neigh
, "readThread", "off");
10889 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10890 json_object_string_add(json_neigh
, "writeThread", "on");
10892 json_object_string_add(json_neigh
, "writeThread",
10895 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10897 if (p
->status
== Established
&& p
->rtt
)
10898 vty_out(vty
, "Estimated round trip time: %d ms\n",
10901 vty_out(vty
, "Next start timer due in %ld seconds\n",
10902 thread_timer_remain_second(p
->t_start
));
10904 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10905 thread_timer_remain_second(p
->t_connect
));
10908 "MRAI (interval %u) timer expires in %ld seconds\n",
10910 thread_timer_remain_second(p
->t_routeadv
));
10912 vty_out(vty
, "Peer Authentication Enabled\n");
10914 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10915 p
->t_read
? "on" : "off",
10916 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10921 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10922 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10923 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10926 vty_out(vty
, "\n");
10928 /* BFD information. */
10929 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10932 if (p
->conf_if
) /* Configured interface name. */
10933 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10934 else /* Configured IP address. */
10935 json_object_object_add(json
, p
->host
, json_neigh
);
10939 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10940 enum show_type type
, union sockunion
*su
,
10941 const char *conf_if
, bool use_json
,
10944 struct listnode
*node
, *nnode
;
10947 bool nbr_output
= false;
10948 afi_t afi
= AFI_MAX
;
10949 safi_t safi
= SAFI_MAX
;
10951 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10953 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10957 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10958 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10963 bgp_show_peer(vty
, peer
, use_json
, json
);
10969 && !strcmp(peer
->conf_if
, conf_if
))
10971 && !strcmp(peer
->hostname
, conf_if
))) {
10973 bgp_show_peer(vty
, peer
, use_json
,
10977 if (sockunion_same(&peer
->su
, su
)) {
10979 bgp_show_peer(vty
, peer
, use_json
,
10984 case show_ipv4_peer
:
10985 case show_ipv6_peer
:
10986 FOREACH_SAFI (safi
) {
10987 if (peer
->afc
[afi
][safi
]) {
10990 && !strcmp(peer
->conf_if
, conf_if
))
10992 && !strcmp(peer
->hostname
, conf_if
))) {
10994 bgp_show_peer(vty
, peer
, use_json
,
10999 if (sockunion_same(&peer
->su
, su
)) {
11001 bgp_show_peer(vty
, peer
, use_json
,
11009 case show_ipv4_all
:
11010 case show_ipv6_all
:
11011 FOREACH_SAFI (safi
) {
11012 if (peer
->afc
[afi
][safi
]) {
11013 bgp_show_peer(vty
, peer
, use_json
, json
);
11022 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11023 type
== show_ipv6_peer
) && !find
) {
11025 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11027 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11030 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11031 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11032 vty_out(vty
, "%% No BGP neighbors found\n");
11035 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11036 json
, JSON_C_TO_STRING_PRETTY
));
11038 vty_out(vty
, "\n");
11041 return CMD_SUCCESS
;
11044 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11045 enum show_type type
,
11046 const char *ip_str
,
11049 struct listnode
*node
, *nnode
;
11051 union sockunion su
;
11052 json_object
*json
= NULL
;
11053 int ret
, is_first
= 1;
11054 bool nbr_output
= false;
11057 vty_out(vty
, "{\n");
11059 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11062 if (!(json
= json_object_new_object())) {
11064 EC_BGP_JSON_MEM_ERROR
,
11065 "Unable to allocate memory for JSON object");
11067 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11071 json_object_int_add(json
, "vrfId",
11072 (bgp
->vrf_id
== VRF_UNKNOWN
)
11074 : (int64_t)bgp
->vrf_id
);
11075 json_object_string_add(
11077 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11082 vty_out(vty
, ",\n");
11086 vty_out(vty
, "\"%s\":",
11087 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11091 vty_out(vty
, "\nInstance %s:\n",
11092 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11097 if (type
== show_peer
|| type
== show_ipv4_peer
||
11098 type
== show_ipv6_peer
) {
11099 ret
= str2sockunion(ip_str
, &su
);
11101 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11104 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11107 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11110 json_object_free(json
);
11114 vty_out(vty
, "}\n");
11115 json_object_free(json
);
11117 else if (!nbr_output
)
11118 vty_out(vty
, "%% BGP instance not found\n");
11121 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11122 enum show_type type
, const char *ip_str
,
11127 union sockunion su
;
11128 json_object
*json
= NULL
;
11131 if (strmatch(name
, "all")) {
11132 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11134 return CMD_SUCCESS
;
11136 bgp
= bgp_lookup_by_name(name
);
11139 json
= json_object_new_object();
11140 vty_out(vty
, "%s\n",
11141 json_object_to_json_string_ext(
11143 JSON_C_TO_STRING_PRETTY
));
11144 json_object_free(json
);
11147 "%% BGP instance not found\n");
11149 return CMD_WARNING
;
11153 bgp
= bgp_get_default();
11157 json
= json_object_new_object();
11159 ret
= str2sockunion(ip_str
, &su
);
11161 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11164 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11167 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11170 json_object_free(json
);
11173 vty_out(vty
, "{}\n");
11175 vty_out(vty
, "%% BGP instance not found\n");
11178 return CMD_SUCCESS
;
11181 /* "show [ip] bgp neighbors" commands. */
11182 DEFUN (show_ip_bgp_neighbors
,
11183 show_ip_bgp_neighbors_cmd
,
11184 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11188 BGP_INSTANCE_HELP_STR
11191 "Detailed information on TCP and BGP neighbor connections\n"
11192 "Neighbor to display information about\n"
11193 "Neighbor to display information about\n"
11194 "Neighbor on BGP configured interface\n"
11198 char *sh_arg
= NULL
;
11199 enum show_type sh_type
;
11200 afi_t afi
= AFI_MAX
;
11202 bool uj
= use_json(argc
, argv
);
11206 /* [<vrf> VIEWVRFNAME] */
11207 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11208 vrf
= argv
[idx
+ 1]->arg
;
11209 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11211 } else if (argv_find(argv
, argc
, "view", &idx
))
11212 /* [<view> VIEWVRFNAME] */
11213 vrf
= argv
[idx
+ 1]->arg
;
11217 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11218 sh_type
= show_ipv4_all
;
11220 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11221 sh_type
= show_ipv6_all
;
11224 sh_type
= show_all
;
11227 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11228 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11229 || argv_find(argv
, argc
, "WORD", &idx
)) {
11230 sh_type
= show_peer
;
11231 sh_arg
= argv
[idx
]->arg
;
11234 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11235 sh_type
= show_ipv4_peer
;
11236 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11237 sh_type
= show_ipv6_peer
;
11240 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11243 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11244 paths' and `show ip mbgp paths'. Those functions results are the
11246 DEFUN (show_ip_bgp_paths
,
11247 show_ip_bgp_paths_cmd
,
11248 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11253 "Path information\n")
11255 vty_out(vty
, "Address Refcnt Path\n");
11256 aspath_print_all_vty(vty
);
11257 return CMD_SUCCESS
;
11262 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11265 struct community
*com
;
11267 com
= (struct community
*)bucket
->data
;
11268 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11269 community_str(com
, false));
11272 /* Show BGP's community internal data. */
11273 DEFUN (show_ip_bgp_community_info
,
11274 show_ip_bgp_community_info_cmd
,
11275 "show [ip] bgp community-info",
11279 "List all bgp community information\n")
11281 vty_out(vty
, "Address Refcnt Community\n");
11283 hash_iterate(community_hash(),
11284 (void (*)(struct hash_bucket
*,
11285 void *))community_show_all_iterator
,
11288 return CMD_SUCCESS
;
11291 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11294 struct lcommunity
*lcom
;
11296 lcom
= (struct lcommunity
*)bucket
->data
;
11297 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11298 lcommunity_str(lcom
, false));
11301 /* Show BGP's community internal data. */
11302 DEFUN (show_ip_bgp_lcommunity_info
,
11303 show_ip_bgp_lcommunity_info_cmd
,
11304 "show ip bgp large-community-info",
11308 "List all bgp large-community information\n")
11310 vty_out(vty
, "Address Refcnt Large-community\n");
11312 hash_iterate(lcommunity_hash(),
11313 (void (*)(struct hash_bucket
*,
11314 void *))lcommunity_show_all_iterator
,
11317 return CMD_SUCCESS
;
11321 DEFUN (show_ip_bgp_attr_info
,
11322 show_ip_bgp_attr_info_cmd
,
11323 "show [ip] bgp attribute-info",
11327 "List all bgp attribute information\n")
11329 attr_show_all(vty
);
11330 return CMD_SUCCESS
;
11333 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11334 afi_t afi
, safi_t safi
,
11335 bool use_json
, json_object
*json
)
11338 struct listnode
*node
;
11340 char buf1
[INET6_ADDRSTRLEN
];
11342 vpn_policy_direction_t dir
;
11345 json_object
*json_import_vrfs
= NULL
;
11346 json_object
*json_export_vrfs
= NULL
;
11348 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11351 vty_out(vty
, "%s\n",
11352 json_object_to_json_string_ext(
11354 JSON_C_TO_STRING_PRETTY
));
11355 json_object_free(json
);
11357 return CMD_WARNING
;
11360 /* Provide context for the block */
11361 json_object_string_add(json
, "vrf", name
? name
: "default");
11362 json_object_string_add(json
, "afiSafi",
11363 afi_safi_print(afi
, safi
));
11365 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11366 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11367 json_object_string_add(json
, "importFromVrfs", "none");
11368 json_object_string_add(json
, "importRts", "none");
11370 json_import_vrfs
= json_object_new_array();
11372 for (ALL_LIST_ELEMENTS_RO(
11373 bgp
->vpn_policy
[afi
].import_vrf
,
11375 json_object_array_add(json_import_vrfs
,
11376 json_object_new_string(vname
));
11378 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11379 ecom_str
= ecommunity_ecom2str(
11380 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11381 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11382 json_object_object_add(json
, "importFromVrfs",
11384 json_object_string_add(json
, "importRts", ecom_str
);
11386 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11389 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11390 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11391 json_object_string_add(json
, "exportToVrfs", "none");
11392 json_object_string_add(json
, "routeDistinguisher",
11394 json_object_string_add(json
, "exportRts", "none");
11396 json_export_vrfs
= json_object_new_array();
11398 for (ALL_LIST_ELEMENTS_RO(
11399 bgp
->vpn_policy
[afi
].export_vrf
,
11401 json_object_array_add(json_export_vrfs
,
11402 json_object_new_string(vname
));
11403 json_object_object_add(json
, "exportToVrfs",
11405 json_object_string_add(json
, "routeDistinguisher",
11406 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11407 buf1
, RD_ADDRSTRLEN
));
11409 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11410 ecom_str
= ecommunity_ecom2str(
11411 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11412 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11413 json_object_string_add(json
, "exportRts", ecom_str
);
11415 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11419 vty_out(vty
, "%s\n",
11420 json_object_to_json_string_ext(json
,
11421 JSON_C_TO_STRING_PRETTY
));
11422 json_object_free(json
);
11425 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11428 vty_out(vty
, "%% No such BGP instance exist\n");
11429 return CMD_WARNING
;
11432 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11433 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11435 "This VRF is not importing %s routes from any other VRF\n",
11436 afi_safi_print(afi
, safi
));
11439 "This VRF is importing %s routes from the following VRFs:\n",
11440 afi_safi_print(afi
, safi
));
11442 for (ALL_LIST_ELEMENTS_RO(
11443 bgp
->vpn_policy
[afi
].import_vrf
,
11445 vty_out(vty
, " %s\n", vname
);
11447 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11448 ecom_str
= ecommunity_ecom2str(
11449 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11450 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11451 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11453 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11456 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11457 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11459 "This VRF is not exporting %s routes to any other VRF\n",
11460 afi_safi_print(afi
, safi
));
11463 "This VRF is exporting %s routes to the following VRFs:\n",
11464 afi_safi_print(afi
, safi
));
11466 for (ALL_LIST_ELEMENTS_RO(
11467 bgp
->vpn_policy
[afi
].export_vrf
,
11469 vty_out(vty
, " %s\n", vname
);
11471 vty_out(vty
, "RD: %s\n",
11472 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11473 buf1
, RD_ADDRSTRLEN
));
11475 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11476 ecom_str
= ecommunity_ecom2str(
11477 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11478 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11479 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11480 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11484 return CMD_SUCCESS
;
11487 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11488 safi_t safi
, bool use_json
)
11490 struct listnode
*node
, *nnode
;
11492 char *vrf_name
= NULL
;
11493 json_object
*json
= NULL
;
11494 json_object
*json_vrf
= NULL
;
11495 json_object
*json_vrfs
= NULL
;
11498 json
= json_object_new_object();
11499 json_vrfs
= json_object_new_object();
11502 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11504 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11505 vrf_name
= bgp
->name
;
11508 json_vrf
= json_object_new_object();
11510 vty_out(vty
, "\nInstance %s:\n",
11511 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11512 ? VRF_DEFAULT_NAME
: bgp
->name
);
11514 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11516 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11517 json_object_object_add(json_vrfs
,
11518 VRF_DEFAULT_NAME
, json_vrf
);
11520 json_object_object_add(json_vrfs
, vrf_name
,
11526 json_object_object_add(json
, "vrfs", json_vrfs
);
11527 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11528 JSON_C_TO_STRING_PRETTY
));
11529 json_object_free(json
);
11532 return CMD_SUCCESS
;
11535 /* "show [ip] bgp route-leak" command. */
11536 DEFUN (show_ip_bgp_route_leak
,
11537 show_ip_bgp_route_leak_cmd
,
11538 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11542 BGP_INSTANCE_HELP_STR
11545 "Route leaking information\n"
11549 afi_t afi
= AFI_MAX
;
11550 safi_t safi
= SAFI_MAX
;
11552 bool uj
= use_json(argc
, argv
);
11554 json_object
*json
= NULL
;
11556 /* show [ip] bgp */
11557 if (argv_find(argv
, argc
, "ip", &idx
)) {
11559 safi
= SAFI_UNICAST
;
11561 /* [vrf VIEWVRFNAME] */
11562 if (argv_find(argv
, argc
, "view", &idx
)) {
11564 "%% This command is not applicable to BGP views\n");
11565 return CMD_WARNING
;
11568 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11569 vrf
= argv
[idx
+ 1]->arg
;
11570 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11573 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11574 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11575 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11578 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11580 "%% This command is applicable only for unicast ipv4|ipv6\n");
11581 return CMD_WARNING
;
11584 if (vrf
&& strmatch(vrf
, "all"))
11585 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11588 json
= json_object_new_object();
11590 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11593 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11596 struct listnode
*node
, *nnode
;
11599 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11600 vty_out(vty
, "\nInstance %s:\n",
11601 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11604 update_group_show(bgp
, afi
, safi
, vty
, 0);
11608 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11609 int safi
, uint64_t subgrp_id
)
11614 if (strmatch(name
, "all")) {
11615 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11616 return CMD_SUCCESS
;
11618 bgp
= bgp_lookup_by_name(name
);
11621 bgp
= bgp_get_default();
11625 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11626 return CMD_SUCCESS
;
11629 DEFUN (show_ip_bgp_updgrps
,
11630 show_ip_bgp_updgrps_cmd
,
11631 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11635 BGP_INSTANCE_HELP_STR
11637 BGP_SAFI_WITH_LABEL_HELP_STR
11638 "Detailed info about dynamic update groups\n"
11639 "Specific subgroup to display detailed info for\n")
11642 afi_t afi
= AFI_IP6
;
11643 safi_t safi
= SAFI_UNICAST
;
11644 uint64_t subgrp_id
= 0;
11648 /* show [ip] bgp */
11649 if (argv_find(argv
, argc
, "ip", &idx
))
11651 /* [<vrf> VIEWVRFNAME] */
11652 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11653 vrf
= argv
[idx
+ 1]->arg
;
11654 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11656 } else if (argv_find(argv
, argc
, "view", &idx
))
11657 /* [<view> VIEWVRFNAME] */
11658 vrf
= argv
[idx
+ 1]->arg
;
11659 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11660 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11661 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11664 /* get subgroup id, if provided */
11666 if (argv
[idx
]->type
== VARIABLE_TKN
)
11667 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11669 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11672 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11673 show_bgp_instance_all_ipv6_updgrps_cmd
,
11674 "show [ip] bgp <view|vrf> all update-groups",
11678 BGP_INSTANCE_ALL_HELP_STR
11679 "Detailed info about dynamic update groups\n")
11681 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11682 return CMD_SUCCESS
;
11685 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11686 show_bgp_l2vpn_evpn_updgrps_cmd
,
11687 "show [ip] bgp l2vpn evpn update-groups",
11691 "l2vpn address family\n"
11692 "evpn sub-address family\n"
11693 "Detailed info about dynamic update groups\n")
11696 uint64_t subgrp_id
= 0;
11698 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11699 return CMD_SUCCESS
;
11702 DEFUN (show_bgp_updgrps_stats
,
11703 show_bgp_updgrps_stats_cmd
,
11704 "show [ip] bgp update-groups statistics",
11708 "Detailed info about dynamic update groups\n"
11713 bgp
= bgp_get_default();
11715 update_group_show_stats(bgp
, vty
);
11717 return CMD_SUCCESS
;
11720 DEFUN (show_bgp_instance_updgrps_stats
,
11721 show_bgp_instance_updgrps_stats_cmd
,
11722 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11726 BGP_INSTANCE_HELP_STR
11727 "Detailed info about dynamic update groups\n"
11733 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11735 update_group_show_stats(bgp
, vty
);
11737 return CMD_SUCCESS
;
11740 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11741 afi_t afi
, safi_t safi
,
11742 const char *what
, uint64_t subgrp_id
)
11747 bgp
= bgp_lookup_by_name(name
);
11749 bgp
= bgp_get_default();
11752 if (!strcmp(what
, "advertise-queue"))
11753 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11755 else if (!strcmp(what
, "advertised-routes"))
11756 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11758 else if (!strcmp(what
, "packet-queue"))
11759 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11764 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11765 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11766 "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",
11767 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11769 "Detailed info about dynamic update groups\n"
11770 "Specific subgroup to display info for\n"
11771 "Advertisement queue\n"
11772 "Announced routes\n"
11775 uint64_t subgrp_id
= 0;
11779 subgrp_id
= strtoull(sgid
, NULL
, 10);
11784 afiz
= bgp_vty_afi_from_str(afi
);
11788 afiz
= bgp_vty_afi_from_str(afi
);
11789 if (afiz
!= AFI_IP
)
11791 "%% Cannot specify both 'ip' and 'ipv6'\n");
11792 return CMD_WARNING
;
11795 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11797 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11798 return CMD_SUCCESS
;
11801 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11803 struct listnode
*node
, *nnode
;
11804 struct prefix
*range
;
11807 char buf
[PREFIX2STR_BUFFER
];
11810 const char *peer_status
;
11811 const char *af_str
;
11816 conf
= group
->conf
;
11818 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11819 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11820 group
->name
, conf
->as
);
11821 } else if (conf
->as_type
== AS_INTERNAL
) {
11822 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11823 group
->name
, group
->bgp
->as
);
11825 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11828 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11829 vty_out(vty
, " Peer-group type is internal\n");
11831 vty_out(vty
, " Peer-group type is external\n");
11833 /* Display AFs configured. */
11834 vty_out(vty
, " Configured address-families:");
11835 FOREACH_AFI_SAFI (afi
, safi
) {
11836 if (conf
->afc
[afi
][safi
]) {
11838 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11842 vty_out(vty
, " none\n");
11844 vty_out(vty
, "\n");
11846 /* Display listen ranges (for dynamic neighbors), if any */
11847 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11850 else if (afi
== AFI_IP6
)
11854 lr_count
= listcount(group
->listen_range
[afi
]);
11856 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11860 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11862 prefix2str(range
, buf
, sizeof(buf
));
11863 vty_out(vty
, " %s\n", buf
);
11868 /* Display group members and their status */
11869 if (listcount(group
->peer
)) {
11870 vty_out(vty
, " Peer-group members:\n");
11871 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11872 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11873 peer_status
= "Idle (Admin)";
11874 else if (CHECK_FLAG(peer
->sflags
,
11875 PEER_STATUS_PREFIX_OVERFLOW
))
11876 peer_status
= "Idle (PfxCt)";
11878 peer_status
= lookup_msg(bgp_status_msg
,
11879 peer
->status
, NULL
);
11881 dynamic
= peer_dynamic_neighbor(peer
);
11882 vty_out(vty
, " %s %s %s \n", peer
->host
,
11883 dynamic
? "(dynamic)" : "", peer_status
);
11887 return CMD_SUCCESS
;
11890 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11891 const char *group_name
)
11894 struct listnode
*node
, *nnode
;
11895 struct peer_group
*group
;
11896 bool found
= false;
11898 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11901 vty_out(vty
, "%% BGP instance not found\n");
11902 return CMD_WARNING
;
11905 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11907 if (strmatch(group
->name
, group_name
)) {
11908 bgp_show_one_peer_group(vty
, group
);
11913 bgp_show_one_peer_group(vty
, group
);
11917 if (group_name
&& !found
)
11918 vty_out(vty
, "%% No such peer-group\n");
11920 return CMD_SUCCESS
;
11923 DEFUN (show_ip_bgp_peer_groups
,
11924 show_ip_bgp_peer_groups_cmd
,
11925 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11929 BGP_INSTANCE_HELP_STR
11930 "Detailed information on BGP peer groups\n"
11931 "Peer group name\n")
11936 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11938 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11940 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11944 /* Redistribute VTY commands. */
11946 DEFUN (bgp_redistribute_ipv4
,
11947 bgp_redistribute_ipv4_cmd
,
11948 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11949 "Redistribute information from another routing protocol\n"
11950 FRR_IP_REDIST_HELP_STR_BGPD
)
11952 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11953 int idx_protocol
= 1;
11956 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11958 vty_out(vty
, "%% Invalid route type\n");
11959 return CMD_WARNING_CONFIG_FAILED
;
11962 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11963 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11967 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11968 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11969 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11971 DEFUN (bgp_redistribute_ipv4_rmap
,
11972 bgp_redistribute_ipv4_rmap_cmd
,
11973 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11974 "Redistribute information from another routing protocol\n"
11975 FRR_IP_REDIST_HELP_STR_BGPD
11976 "Route map reference\n"
11977 "Pointer to route-map entries\n")
11979 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11980 int idx_protocol
= 1;
11983 struct bgp_redist
*red
;
11985 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11986 vty
, argv
[idx_word
]->arg
);
11988 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11990 vty_out(vty
, "%% Invalid route type\n");
11991 return CMD_WARNING_CONFIG_FAILED
;
11994 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11996 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11997 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12001 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12002 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12003 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12004 "Route map reference\n"
12005 "Pointer to route-map entries\n")
12007 DEFUN (bgp_redistribute_ipv4_metric
,
12008 bgp_redistribute_ipv4_metric_cmd
,
12009 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12010 "Redistribute information from another routing protocol\n"
12011 FRR_IP_REDIST_HELP_STR_BGPD
12012 "Metric for redistributed routes\n"
12013 "Default metric\n")
12015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12016 int idx_protocol
= 1;
12017 int idx_number
= 3;
12020 struct bgp_redist
*red
;
12023 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12025 vty_out(vty
, "%% Invalid route type\n");
12026 return CMD_WARNING_CONFIG_FAILED
;
12028 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12030 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12031 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12032 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12036 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12037 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12038 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12039 "Metric for redistributed routes\n"
12040 "Default metric\n")
12042 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12043 bgp_redistribute_ipv4_rmap_metric_cmd
,
12044 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12045 "Redistribute information from another routing protocol\n"
12046 FRR_IP_REDIST_HELP_STR_BGPD
12047 "Route map reference\n"
12048 "Pointer to route-map entries\n"
12049 "Metric for redistributed routes\n"
12050 "Default metric\n")
12052 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12053 int idx_protocol
= 1;
12055 int idx_number
= 5;
12058 struct bgp_redist
*red
;
12060 struct route_map
*route_map
=
12061 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12063 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12065 vty_out(vty
, "%% Invalid route type\n");
12066 return CMD_WARNING_CONFIG_FAILED
;
12068 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12070 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12072 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12073 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12074 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12078 bgp_redistribute_ipv4_rmap_metric
,
12079 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12080 "redistribute " FRR_IP_REDIST_STR_BGPD
12081 " route-map WORD metric (0-4294967295)",
12082 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12083 "Route map reference\n"
12084 "Pointer to route-map entries\n"
12085 "Metric for redistributed routes\n"
12086 "Default metric\n")
12088 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12089 bgp_redistribute_ipv4_metric_rmap_cmd
,
12090 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12091 "Redistribute information from another routing protocol\n"
12092 FRR_IP_REDIST_HELP_STR_BGPD
12093 "Metric for redistributed routes\n"
12095 "Route map reference\n"
12096 "Pointer to route-map entries\n")
12098 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12099 int idx_protocol
= 1;
12100 int idx_number
= 3;
12104 struct bgp_redist
*red
;
12106 struct route_map
*route_map
=
12107 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12109 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12111 vty_out(vty
, "%% Invalid route type\n");
12112 return CMD_WARNING_CONFIG_FAILED
;
12114 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12116 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12117 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12119 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12120 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12124 bgp_redistribute_ipv4_metric_rmap
,
12125 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12126 "redistribute " FRR_IP_REDIST_STR_BGPD
12127 " metric (0-4294967295) route-map WORD",
12128 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12129 "Metric for redistributed routes\n"
12131 "Route map reference\n"
12132 "Pointer to route-map entries\n")
12134 DEFUN (bgp_redistribute_ipv4_ospf
,
12135 bgp_redistribute_ipv4_ospf_cmd
,
12136 "redistribute <ospf|table> (1-65535)",
12137 "Redistribute information from another routing protocol\n"
12138 "Open Shortest Path First (OSPFv2)\n"
12139 "Non-main Kernel Routing Table\n"
12140 "Instance ID/Table ID\n")
12142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12143 int idx_ospf_table
= 1;
12144 int idx_number
= 2;
12145 unsigned short instance
;
12146 unsigned short protocol
;
12148 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12150 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12151 protocol
= ZEBRA_ROUTE_OSPF
;
12153 protocol
= ZEBRA_ROUTE_TABLE
;
12155 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12156 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12159 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12160 "redistribute <ospf|table> (1-65535)",
12161 "Redistribute information from another routing protocol\n"
12162 "Open Shortest Path First (OSPFv2)\n"
12163 "Non-main Kernel Routing Table\n"
12164 "Instance ID/Table ID\n")
12166 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12167 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12168 "redistribute <ospf|table> (1-65535) route-map WORD",
12169 "Redistribute information from another routing protocol\n"
12170 "Open Shortest Path First (OSPFv2)\n"
12171 "Non-main Kernel Routing Table\n"
12172 "Instance ID/Table ID\n"
12173 "Route map reference\n"
12174 "Pointer to route-map entries\n")
12176 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12177 int idx_ospf_table
= 1;
12178 int idx_number
= 2;
12180 struct bgp_redist
*red
;
12181 unsigned short instance
;
12184 struct route_map
*route_map
=
12185 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12187 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12188 protocol
= ZEBRA_ROUTE_OSPF
;
12190 protocol
= ZEBRA_ROUTE_TABLE
;
12192 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12193 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12195 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12196 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12199 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12200 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12201 "redistribute <ospf|table> (1-65535) route-map WORD",
12202 "Redistribute information from another routing protocol\n"
12203 "Open Shortest Path First (OSPFv2)\n"
12204 "Non-main Kernel Routing Table\n"
12205 "Instance ID/Table ID\n"
12206 "Route map reference\n"
12207 "Pointer to route-map entries\n")
12209 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12210 bgp_redistribute_ipv4_ospf_metric_cmd
,
12211 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12212 "Redistribute information from another routing protocol\n"
12213 "Open Shortest Path First (OSPFv2)\n"
12214 "Non-main Kernel Routing Table\n"
12215 "Instance ID/Table ID\n"
12216 "Metric for redistributed routes\n"
12217 "Default metric\n")
12219 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12220 int idx_ospf_table
= 1;
12221 int idx_number
= 2;
12222 int idx_number_2
= 4;
12224 struct bgp_redist
*red
;
12225 unsigned short instance
;
12229 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12230 protocol
= ZEBRA_ROUTE_OSPF
;
12232 protocol
= ZEBRA_ROUTE_TABLE
;
12234 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12235 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12237 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12238 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12240 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12243 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12244 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12245 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12246 "Redistribute information from another routing protocol\n"
12247 "Open Shortest Path First (OSPFv2)\n"
12248 "Non-main Kernel Routing Table\n"
12249 "Instance ID/Table ID\n"
12250 "Metric for redistributed routes\n"
12251 "Default metric\n")
12253 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12254 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12255 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12256 "Redistribute information from another routing protocol\n"
12257 "Open Shortest Path First (OSPFv2)\n"
12258 "Non-main Kernel Routing Table\n"
12259 "Instance ID/Table ID\n"
12260 "Route map reference\n"
12261 "Pointer to route-map entries\n"
12262 "Metric for redistributed routes\n"
12263 "Default metric\n")
12265 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12266 int idx_ospf_table
= 1;
12267 int idx_number
= 2;
12269 int idx_number_2
= 6;
12271 struct bgp_redist
*red
;
12272 unsigned short instance
;
12275 struct route_map
*route_map
=
12276 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12278 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12279 protocol
= ZEBRA_ROUTE_OSPF
;
12281 protocol
= ZEBRA_ROUTE_TABLE
;
12283 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12284 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12286 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12288 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12289 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12291 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12295 bgp_redistribute_ipv4_ospf_rmap_metric
,
12296 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12297 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12298 "Redistribute information from another routing protocol\n"
12299 "Open Shortest Path First (OSPFv2)\n"
12300 "Non-main Kernel Routing Table\n"
12301 "Instance ID/Table ID\n"
12302 "Route map reference\n"
12303 "Pointer to route-map entries\n"
12304 "Metric for redistributed routes\n"
12305 "Default metric\n")
12307 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12308 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12309 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12310 "Redistribute information from another routing protocol\n"
12311 "Open Shortest Path First (OSPFv2)\n"
12312 "Non-main Kernel Routing Table\n"
12313 "Instance ID/Table ID\n"
12314 "Metric for redistributed routes\n"
12316 "Route map reference\n"
12317 "Pointer to route-map entries\n")
12319 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12320 int idx_ospf_table
= 1;
12321 int idx_number
= 2;
12322 int idx_number_2
= 4;
12325 struct bgp_redist
*red
;
12326 unsigned short instance
;
12329 struct route_map
*route_map
=
12330 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12332 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12333 protocol
= ZEBRA_ROUTE_OSPF
;
12335 protocol
= ZEBRA_ROUTE_TABLE
;
12337 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12338 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12340 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12341 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12344 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12345 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12349 bgp_redistribute_ipv4_ospf_metric_rmap
,
12350 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12351 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12352 "Redistribute information from another routing protocol\n"
12353 "Open Shortest Path First (OSPFv2)\n"
12354 "Non-main Kernel Routing Table\n"
12355 "Instance ID/Table ID\n"
12356 "Metric for redistributed routes\n"
12358 "Route map reference\n"
12359 "Pointer to route-map entries\n")
12361 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12362 no_bgp_redistribute_ipv4_ospf_cmd
,
12363 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12365 "Redistribute information from another routing protocol\n"
12366 "Open Shortest Path First (OSPFv2)\n"
12367 "Non-main Kernel Routing Table\n"
12368 "Instance ID/Table ID\n"
12369 "Metric for redistributed routes\n"
12371 "Route map reference\n"
12372 "Pointer to route-map entries\n")
12374 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12375 int idx_ospf_table
= 2;
12376 int idx_number
= 3;
12377 unsigned short instance
;
12380 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12381 protocol
= ZEBRA_ROUTE_OSPF
;
12383 protocol
= ZEBRA_ROUTE_TABLE
;
12385 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12386 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12390 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12391 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12393 "Redistribute information from another routing protocol\n"
12394 "Open Shortest Path First (OSPFv2)\n"
12395 "Non-main Kernel Routing Table\n"
12396 "Instance ID/Table ID\n"
12397 "Metric for redistributed routes\n"
12399 "Route map reference\n"
12400 "Pointer to route-map entries\n")
12402 DEFUN (no_bgp_redistribute_ipv4
,
12403 no_bgp_redistribute_ipv4_cmd
,
12404 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12406 "Redistribute information from another routing protocol\n"
12407 FRR_IP_REDIST_HELP_STR_BGPD
12408 "Metric for redistributed routes\n"
12410 "Route map reference\n"
12411 "Pointer to route-map entries\n")
12413 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12414 int idx_protocol
= 2;
12417 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12419 vty_out(vty
, "%% Invalid route type\n");
12420 return CMD_WARNING_CONFIG_FAILED
;
12422 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12426 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12427 "no redistribute " FRR_IP_REDIST_STR_BGPD
12428 " [metric (0-4294967295)] [route-map WORD]",
12430 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12431 "Metric for redistributed routes\n"
12433 "Route map reference\n"
12434 "Pointer to route-map entries\n")
12436 DEFUN (bgp_redistribute_ipv6
,
12437 bgp_redistribute_ipv6_cmd
,
12438 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12439 "Redistribute information from another routing protocol\n"
12440 FRR_IP6_REDIST_HELP_STR_BGPD
)
12442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12443 int idx_protocol
= 1;
12446 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12448 vty_out(vty
, "%% Invalid route type\n");
12449 return CMD_WARNING_CONFIG_FAILED
;
12452 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12453 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12456 DEFUN (bgp_redistribute_ipv6_rmap
,
12457 bgp_redistribute_ipv6_rmap_cmd
,
12458 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12459 "Redistribute information from another routing protocol\n"
12460 FRR_IP6_REDIST_HELP_STR_BGPD
12461 "Route map reference\n"
12462 "Pointer to route-map entries\n")
12464 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12465 int idx_protocol
= 1;
12468 struct bgp_redist
*red
;
12470 struct route_map
*route_map
=
12471 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12473 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12475 vty_out(vty
, "%% Invalid route type\n");
12476 return CMD_WARNING_CONFIG_FAILED
;
12479 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12481 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12482 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12485 DEFUN (bgp_redistribute_ipv6_metric
,
12486 bgp_redistribute_ipv6_metric_cmd
,
12487 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12488 "Redistribute information from another routing protocol\n"
12489 FRR_IP6_REDIST_HELP_STR_BGPD
12490 "Metric for redistributed routes\n"
12491 "Default metric\n")
12493 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12494 int idx_protocol
= 1;
12495 int idx_number
= 3;
12498 struct bgp_redist
*red
;
12501 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12503 vty_out(vty
, "%% Invalid route type\n");
12504 return CMD_WARNING_CONFIG_FAILED
;
12506 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12508 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12509 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12510 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12513 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12514 bgp_redistribute_ipv6_rmap_metric_cmd
,
12515 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12516 "Redistribute information from another routing protocol\n"
12517 FRR_IP6_REDIST_HELP_STR_BGPD
12518 "Route map reference\n"
12519 "Pointer to route-map entries\n"
12520 "Metric for redistributed routes\n"
12521 "Default metric\n")
12523 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12524 int idx_protocol
= 1;
12526 int idx_number
= 5;
12529 struct bgp_redist
*red
;
12531 struct route_map
*route_map
=
12532 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12534 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12536 vty_out(vty
, "%% Invalid route type\n");
12537 return CMD_WARNING_CONFIG_FAILED
;
12539 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12541 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12543 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12544 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12546 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12549 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12550 bgp_redistribute_ipv6_metric_rmap_cmd
,
12551 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12552 "Redistribute information from another routing protocol\n"
12553 FRR_IP6_REDIST_HELP_STR_BGPD
12554 "Metric for redistributed routes\n"
12556 "Route map reference\n"
12557 "Pointer to route-map entries\n")
12559 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12560 int idx_protocol
= 1;
12561 int idx_number
= 3;
12565 struct bgp_redist
*red
;
12567 struct route_map
*route_map
=
12568 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12570 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12572 vty_out(vty
, "%% Invalid route type\n");
12573 return CMD_WARNING_CONFIG_FAILED
;
12575 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12577 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12578 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12581 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12582 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12585 DEFUN (no_bgp_redistribute_ipv6
,
12586 no_bgp_redistribute_ipv6_cmd
,
12587 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12589 "Redistribute information from another routing protocol\n"
12590 FRR_IP6_REDIST_HELP_STR_BGPD
12591 "Metric for redistributed routes\n"
12593 "Route map reference\n"
12594 "Pointer to route-map entries\n")
12596 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12597 int idx_protocol
= 2;
12600 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12602 vty_out(vty
, "%% Invalid route type\n");
12603 return CMD_WARNING_CONFIG_FAILED
;
12606 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12609 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12614 /* Unicast redistribution only. */
12615 if (safi
!= SAFI_UNICAST
)
12618 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12619 /* Redistribute BGP does not make sense. */
12620 if (i
!= ZEBRA_ROUTE_BGP
) {
12621 struct list
*red_list
;
12622 struct listnode
*node
;
12623 struct bgp_redist
*red
;
12625 red_list
= bgp
->redist
[afi
][i
];
12629 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12630 /* "redistribute" configuration. */
12631 vty_out(vty
, " redistribute %s",
12632 zebra_route_string(i
));
12634 vty_out(vty
, " %d", red
->instance
);
12635 if (red
->redist_metric_flag
)
12636 vty_out(vty
, " metric %u",
12637 red
->redist_metric
);
12638 if (red
->rmap
.name
)
12639 vty_out(vty
, " route-map %s",
12641 vty_out(vty
, "\n");
12647 /* This is part of the address-family block (unicast only) */
12648 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12653 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12654 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12655 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12656 bgp
->vpn_policy
[afi
]
12657 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12659 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12660 bgp
->vpn_policy
[afi
]
12661 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12663 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12664 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12665 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12666 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12669 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12670 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12672 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12675 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12676 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12677 bgp
->vpn_policy
[afi
].tovpn_label
);
12680 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12681 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12682 char buf
[RD_ADDRSTRLEN
];
12683 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12684 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12687 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12688 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12690 char buf
[PREFIX_STRLEN
];
12691 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12692 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12695 vty_out(vty
, "%*snexthop vpn export %s\n",
12699 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12700 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12702 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12703 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12705 char *b
= ecommunity_ecom2str(
12706 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12707 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12708 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12709 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12711 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12712 char *b
= ecommunity_ecom2str(
12713 bgp
->vpn_policy
[afi
]
12714 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12715 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12716 ECOMMUNITY_ROUTE_TARGET
);
12717 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12718 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12720 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12721 char *b
= ecommunity_ecom2str(
12722 bgp
->vpn_policy
[afi
]
12723 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12724 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12725 ECOMMUNITY_ROUTE_TARGET
);
12726 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12727 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12731 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12732 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12733 bgp
->vpn_policy
[afi
]
12734 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12736 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12737 char *b
= ecommunity_ecom2str(
12738 bgp
->vpn_policy
[afi
]
12739 .import_redirect_rtlist
,
12740 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12741 ECOMMUNITY_ROUTE_TARGET
);
12743 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12744 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12749 /* BGP node structure. */
12750 static struct cmd_node bgp_node
= {
12751 BGP_NODE
, "%s(config-router)# ", 1,
12754 static struct cmd_node bgp_ipv4_unicast_node
= {
12755 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12758 static struct cmd_node bgp_ipv4_multicast_node
= {
12759 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12762 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12763 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12766 static struct cmd_node bgp_ipv6_unicast_node
= {
12767 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12770 static struct cmd_node bgp_ipv6_multicast_node
= {
12771 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12774 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12775 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12778 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12779 "%s(config-router-af)# ", 1};
12781 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12782 "%s(config-router-af-vpnv6)# ", 1};
12784 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12785 "%s(config-router-evpn)# ", 1};
12787 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12788 "%s(config-router-af-vni)# ", 1};
12790 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12791 "%s(config-router-af)# ", 1};
12793 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12794 "%s(config-router-af-vpnv6)# ", 1};
12796 static void community_list_vty(void);
12798 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12802 struct listnode
*lnbgp
, *lnpeer
;
12804 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12805 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12806 /* only provide suggestions on the appropriate input
12808 * they'll otherwise show up multiple times */
12809 enum cmd_token_type match_type
;
12810 char *name
= peer
->host
;
12812 if (peer
->conf_if
) {
12813 match_type
= VARIABLE_TKN
;
12814 name
= peer
->conf_if
;
12815 } else if (strchr(peer
->host
, ':'))
12816 match_type
= IPV6_TKN
;
12818 match_type
= IPV4_TKN
;
12820 if (token
->type
!= match_type
)
12823 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12828 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12829 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12830 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12831 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12832 {.completions
= NULL
}};
12834 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12837 struct peer_group
*group
;
12838 struct listnode
*lnbgp
, *lnpeer
;
12840 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12841 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12842 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12847 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12848 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12849 {.completions
= NULL
} };
12851 void bgp_vty_init(void)
12853 cmd_variable_handler_register(bgp_var_neighbor
);
12854 cmd_variable_handler_register(bgp_var_peergroup
);
12856 /* Install bgp top node. */
12857 install_node(&bgp_node
, bgp_config_write
);
12858 install_node(&bgp_ipv4_unicast_node
, NULL
);
12859 install_node(&bgp_ipv4_multicast_node
, NULL
);
12860 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12861 install_node(&bgp_ipv6_unicast_node
, NULL
);
12862 install_node(&bgp_ipv6_multicast_node
, NULL
);
12863 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12864 install_node(&bgp_vpnv4_node
, NULL
);
12865 install_node(&bgp_vpnv6_node
, NULL
);
12866 install_node(&bgp_evpn_node
, NULL
);
12867 install_node(&bgp_evpn_vni_node
, NULL
);
12868 install_node(&bgp_flowspecv4_node
, NULL
);
12869 install_node(&bgp_flowspecv6_node
, NULL
);
12871 /* Install default VTY commands to new nodes. */
12872 install_default(BGP_NODE
);
12873 install_default(BGP_IPV4_NODE
);
12874 install_default(BGP_IPV4M_NODE
);
12875 install_default(BGP_IPV4L_NODE
);
12876 install_default(BGP_IPV6_NODE
);
12877 install_default(BGP_IPV6M_NODE
);
12878 install_default(BGP_IPV6L_NODE
);
12879 install_default(BGP_VPNV4_NODE
);
12880 install_default(BGP_VPNV6_NODE
);
12881 install_default(BGP_FLOWSPECV4_NODE
);
12882 install_default(BGP_FLOWSPECV6_NODE
);
12883 install_default(BGP_EVPN_NODE
);
12884 install_default(BGP_EVPN_VNI_NODE
);
12886 /* "bgp multiple-instance" commands. */
12887 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12888 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12890 /* "bgp config-type" commands. */
12891 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12892 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12894 /* "bgp local-mac" hidden commands. */
12895 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12896 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12898 /* bgp route-map delay-timer commands. */
12899 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12900 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12902 /* Dummy commands (Currently not supported) */
12903 install_element(BGP_NODE
, &no_synchronization_cmd
);
12904 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12906 /* "router bgp" commands. */
12907 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12909 /* "no router bgp" commands. */
12910 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12912 /* "bgp router-id" commands. */
12913 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12914 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12916 /* "bgp cluster-id" commands. */
12917 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12918 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12920 /* "bgp confederation" commands. */
12921 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12922 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12924 /* "bgp confederation peers" commands. */
12925 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12926 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12928 /* bgp max-med command */
12929 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12930 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12931 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12932 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12933 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12935 /* bgp disable-ebgp-connected-nh-check */
12936 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12937 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12939 /* bgp update-delay command */
12940 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12941 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12942 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12944 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12945 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12946 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12947 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12949 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12950 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12952 /* "maximum-paths" commands. */
12953 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12954 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12955 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12956 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12957 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12958 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12959 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12960 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12961 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12962 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12963 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12964 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12965 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12966 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12967 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12969 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12970 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12971 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12972 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12973 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12975 /* "timers bgp" commands. */
12976 install_element(BGP_NODE
, &bgp_timers_cmd
);
12977 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12979 /* route-map delay-timer commands - per instance for backwards compat.
12981 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12982 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12984 /* "bgp client-to-client reflection" commands */
12985 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12986 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12988 /* "bgp always-compare-med" commands */
12989 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12990 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12992 /* bgp ebgp-requires-policy */
12993 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12994 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
12996 /* "bgp deterministic-med" commands */
12997 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12998 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
13000 /* "bgp graceful-restart" commands */
13001 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
13002 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
13003 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
13004 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
13005 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
13006 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
13008 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
13009 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
13011 /* "bgp graceful-shutdown" commands */
13012 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
13013 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13015 /* "bgp fast-external-failover" commands */
13016 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13017 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13019 /* "bgp enforce-first-as" commands */
13020 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
13022 /* "bgp bestpath compare-routerid" commands */
13023 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13024 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13026 /* "bgp bestpath as-path ignore" commands */
13027 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13028 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13030 /* "bgp bestpath as-path confed" commands */
13031 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13032 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13034 /* "bgp bestpath as-path multipath-relax" commands */
13035 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13036 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13038 /* "bgp log-neighbor-changes" commands */
13039 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13040 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13042 /* "bgp bestpath med" commands */
13043 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13044 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13046 /* "no bgp default ipv4-unicast" commands. */
13047 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13048 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13050 /* "bgp network import-check" commands. */
13051 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13052 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13053 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13055 /* "bgp default local-preference" commands. */
13056 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13057 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13059 /* bgp default show-hostname */
13060 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13061 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13063 /* "bgp default subgroup-pkt-queue-max" commands. */
13064 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13065 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13067 /* bgp ibgp-allow-policy-mods command */
13068 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13069 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13071 /* "bgp listen limit" commands. */
13072 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13073 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13075 /* "bgp listen range" commands. */
13076 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13077 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13079 /* "bgp default shutdown" command */
13080 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13082 /* "neighbor remote-as" commands. */
13083 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13084 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13085 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13086 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13087 install_element(BGP_NODE
,
13088 &neighbor_interface_v6only_config_remote_as_cmd
);
13089 install_element(BGP_NODE
, &no_neighbor_cmd
);
13090 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13092 /* "neighbor peer-group" commands. */
13093 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13094 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13095 install_element(BGP_NODE
,
13096 &no_neighbor_interface_peer_group_remote_as_cmd
);
13098 /* "neighbor local-as" commands. */
13099 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13100 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13101 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13102 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13104 /* "neighbor solo" commands. */
13105 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13106 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13108 /* "neighbor password" commands. */
13109 install_element(BGP_NODE
, &neighbor_password_cmd
);
13110 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13112 /* "neighbor activate" commands. */
13113 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13114 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13115 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13116 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13117 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13118 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13119 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13120 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13121 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13122 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13123 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13124 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13126 /* "no neighbor activate" commands. */
13127 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13128 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13129 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13130 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13131 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13132 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13133 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13134 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13135 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13136 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13137 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13138 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13140 /* "neighbor peer-group" set commands. */
13141 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13142 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13143 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13144 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13145 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13146 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13147 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13148 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13149 install_element(BGP_FLOWSPECV4_NODE
,
13150 &neighbor_set_peer_group_hidden_cmd
);
13151 install_element(BGP_FLOWSPECV6_NODE
,
13152 &neighbor_set_peer_group_hidden_cmd
);
13154 /* "no neighbor peer-group unset" commands. */
13155 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13156 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13157 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13158 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13159 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13160 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13161 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13162 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13163 install_element(BGP_FLOWSPECV4_NODE
,
13164 &no_neighbor_set_peer_group_hidden_cmd
);
13165 install_element(BGP_FLOWSPECV6_NODE
,
13166 &no_neighbor_set_peer_group_hidden_cmd
);
13168 /* "neighbor softreconfiguration inbound" commands.*/
13169 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13170 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13171 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13172 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13173 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13174 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13175 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13176 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13177 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13178 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13179 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13180 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13181 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13182 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13183 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13184 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13185 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13186 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13187 install_element(BGP_FLOWSPECV4_NODE
,
13188 &neighbor_soft_reconfiguration_cmd
);
13189 install_element(BGP_FLOWSPECV4_NODE
,
13190 &no_neighbor_soft_reconfiguration_cmd
);
13191 install_element(BGP_FLOWSPECV6_NODE
,
13192 &neighbor_soft_reconfiguration_cmd
);
13193 install_element(BGP_FLOWSPECV6_NODE
,
13194 &no_neighbor_soft_reconfiguration_cmd
);
13195 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13196 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13198 /* "neighbor attribute-unchanged" commands. */
13199 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13200 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13201 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13202 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13203 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13204 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13205 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13206 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13207 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13208 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13209 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13210 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13211 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13212 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13213 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13214 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13215 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13216 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13218 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13219 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13221 /* "nexthop-local unchanged" commands */
13222 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13223 install_element(BGP_IPV6_NODE
,
13224 &no_neighbor_nexthop_local_unchanged_cmd
);
13226 /* "neighbor next-hop-self" commands. */
13227 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13228 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13229 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13230 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13231 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13232 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13233 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13234 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13235 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13236 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13237 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13238 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13239 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13240 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13241 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13242 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13243 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13244 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13245 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13246 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13248 /* "neighbor next-hop-self force" commands. */
13249 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13250 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13251 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13252 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13253 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13254 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13255 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13256 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13257 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13258 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13259 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13260 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13261 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13262 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13263 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13264 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13265 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13266 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13267 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13268 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13270 /* "neighbor as-override" commands. */
13271 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13272 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13273 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13274 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13275 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13276 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13277 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13278 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13279 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13280 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13281 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13282 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13283 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13284 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13285 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13286 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13287 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13288 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13290 /* "neighbor remove-private-AS" commands. */
13291 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13292 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13293 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13294 install_element(BGP_NODE
,
13295 &no_neighbor_remove_private_as_all_hidden_cmd
);
13296 install_element(BGP_NODE
,
13297 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13298 install_element(BGP_NODE
,
13299 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13300 install_element(BGP_NODE
,
13301 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13304 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13305 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13306 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13307 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13308 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13309 install_element(BGP_IPV4_NODE
,
13310 &neighbor_remove_private_as_replace_as_cmd
);
13311 install_element(BGP_IPV4_NODE
,
13312 &no_neighbor_remove_private_as_replace_as_cmd
);
13313 install_element(BGP_IPV4_NODE
,
13314 &neighbor_remove_private_as_all_replace_as_cmd
);
13315 install_element(BGP_IPV4_NODE
,
13316 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13317 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13318 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13319 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13320 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13321 install_element(BGP_IPV4M_NODE
,
13322 &neighbor_remove_private_as_replace_as_cmd
);
13323 install_element(BGP_IPV4M_NODE
,
13324 &no_neighbor_remove_private_as_replace_as_cmd
);
13325 install_element(BGP_IPV4M_NODE
,
13326 &neighbor_remove_private_as_all_replace_as_cmd
);
13327 install_element(BGP_IPV4M_NODE
,
13328 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13329 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13330 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13331 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13332 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13333 install_element(BGP_IPV4L_NODE
,
13334 &neighbor_remove_private_as_replace_as_cmd
);
13335 install_element(BGP_IPV4L_NODE
,
13336 &no_neighbor_remove_private_as_replace_as_cmd
);
13337 install_element(BGP_IPV4L_NODE
,
13338 &neighbor_remove_private_as_all_replace_as_cmd
);
13339 install_element(BGP_IPV4L_NODE
,
13340 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13341 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13342 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13343 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13344 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13345 install_element(BGP_IPV6_NODE
,
13346 &neighbor_remove_private_as_replace_as_cmd
);
13347 install_element(BGP_IPV6_NODE
,
13348 &no_neighbor_remove_private_as_replace_as_cmd
);
13349 install_element(BGP_IPV6_NODE
,
13350 &neighbor_remove_private_as_all_replace_as_cmd
);
13351 install_element(BGP_IPV6_NODE
,
13352 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13353 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13354 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13355 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13356 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13357 install_element(BGP_IPV6M_NODE
,
13358 &neighbor_remove_private_as_replace_as_cmd
);
13359 install_element(BGP_IPV6M_NODE
,
13360 &no_neighbor_remove_private_as_replace_as_cmd
);
13361 install_element(BGP_IPV6M_NODE
,
13362 &neighbor_remove_private_as_all_replace_as_cmd
);
13363 install_element(BGP_IPV6M_NODE
,
13364 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13365 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13366 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13367 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13368 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13369 install_element(BGP_IPV6L_NODE
,
13370 &neighbor_remove_private_as_replace_as_cmd
);
13371 install_element(BGP_IPV6L_NODE
,
13372 &no_neighbor_remove_private_as_replace_as_cmd
);
13373 install_element(BGP_IPV6L_NODE
,
13374 &neighbor_remove_private_as_all_replace_as_cmd
);
13375 install_element(BGP_IPV6L_NODE
,
13376 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13377 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13378 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13379 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13380 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13381 install_element(BGP_VPNV4_NODE
,
13382 &neighbor_remove_private_as_replace_as_cmd
);
13383 install_element(BGP_VPNV4_NODE
,
13384 &no_neighbor_remove_private_as_replace_as_cmd
);
13385 install_element(BGP_VPNV4_NODE
,
13386 &neighbor_remove_private_as_all_replace_as_cmd
);
13387 install_element(BGP_VPNV4_NODE
,
13388 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13389 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13390 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13391 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13392 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13393 install_element(BGP_VPNV6_NODE
,
13394 &neighbor_remove_private_as_replace_as_cmd
);
13395 install_element(BGP_VPNV6_NODE
,
13396 &no_neighbor_remove_private_as_replace_as_cmd
);
13397 install_element(BGP_VPNV6_NODE
,
13398 &neighbor_remove_private_as_all_replace_as_cmd
);
13399 install_element(BGP_VPNV6_NODE
,
13400 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13402 /* "neighbor send-community" commands.*/
13403 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13404 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13405 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13406 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13407 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13408 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13409 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13410 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13411 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13412 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13413 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13414 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13415 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13416 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13417 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13418 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13419 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13420 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13421 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13422 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13423 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13424 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13425 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13426 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13427 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13428 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13429 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13430 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13431 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13432 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13433 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13434 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13435 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13436 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13437 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13438 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13440 /* "neighbor route-reflector" commands.*/
13441 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13442 install_element(BGP_NODE
,
13443 &no_neighbor_route_reflector_client_hidden_cmd
);
13444 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13445 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13446 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13447 install_element(BGP_IPV4M_NODE
,
13448 &no_neighbor_route_reflector_client_cmd
);
13449 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13450 install_element(BGP_IPV4L_NODE
,
13451 &no_neighbor_route_reflector_client_cmd
);
13452 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13453 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13454 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13455 install_element(BGP_IPV6M_NODE
,
13456 &no_neighbor_route_reflector_client_cmd
);
13457 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13458 install_element(BGP_IPV6L_NODE
,
13459 &no_neighbor_route_reflector_client_cmd
);
13460 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13461 install_element(BGP_VPNV4_NODE
,
13462 &no_neighbor_route_reflector_client_cmd
);
13463 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13464 install_element(BGP_VPNV6_NODE
,
13465 &no_neighbor_route_reflector_client_cmd
);
13466 install_element(BGP_FLOWSPECV4_NODE
,
13467 &neighbor_route_reflector_client_cmd
);
13468 install_element(BGP_FLOWSPECV4_NODE
,
13469 &no_neighbor_route_reflector_client_cmd
);
13470 install_element(BGP_FLOWSPECV6_NODE
,
13471 &neighbor_route_reflector_client_cmd
);
13472 install_element(BGP_FLOWSPECV6_NODE
,
13473 &no_neighbor_route_reflector_client_cmd
);
13474 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13475 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13477 /* "neighbor route-server" commands.*/
13478 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13479 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13480 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13481 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13482 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13483 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13484 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13485 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13486 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13487 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13488 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13489 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13490 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13491 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13492 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13493 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13494 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13495 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13496 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13497 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13498 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13499 install_element(BGP_FLOWSPECV4_NODE
,
13500 &no_neighbor_route_server_client_cmd
);
13501 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13502 install_element(BGP_FLOWSPECV6_NODE
,
13503 &no_neighbor_route_server_client_cmd
);
13505 /* "neighbor addpath-tx-all-paths" commands.*/
13506 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13507 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13508 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13509 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13510 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13511 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13512 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13513 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13514 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13515 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13516 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13517 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13518 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13519 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13520 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13521 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13522 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13523 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13525 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13526 install_element(BGP_NODE
,
13527 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13528 install_element(BGP_NODE
,
13529 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13530 install_element(BGP_IPV4_NODE
,
13531 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13532 install_element(BGP_IPV4_NODE
,
13533 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13534 install_element(BGP_IPV4M_NODE
,
13535 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13536 install_element(BGP_IPV4M_NODE
,
13537 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13538 install_element(BGP_IPV4L_NODE
,
13539 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13540 install_element(BGP_IPV4L_NODE
,
13541 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13542 install_element(BGP_IPV6_NODE
,
13543 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13544 install_element(BGP_IPV6_NODE
,
13545 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13546 install_element(BGP_IPV6M_NODE
,
13547 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13548 install_element(BGP_IPV6M_NODE
,
13549 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13550 install_element(BGP_IPV6L_NODE
,
13551 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13552 install_element(BGP_IPV6L_NODE
,
13553 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13554 install_element(BGP_VPNV4_NODE
,
13555 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13556 install_element(BGP_VPNV4_NODE
,
13557 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13558 install_element(BGP_VPNV6_NODE
,
13559 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13560 install_element(BGP_VPNV6_NODE
,
13561 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13563 /* "neighbor passive" commands. */
13564 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13565 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13568 /* "neighbor shutdown" commands. */
13569 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13570 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13571 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13572 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13574 /* "neighbor capability extended-nexthop" commands.*/
13575 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13576 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13578 /* "neighbor capability orf prefix-list" commands.*/
13579 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13580 install_element(BGP_NODE
,
13581 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13582 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13583 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13584 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13585 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13586 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13587 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13588 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13589 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13590 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13591 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13592 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13593 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13595 /* "neighbor capability dynamic" commands.*/
13596 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13597 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13599 /* "neighbor dont-capability-negotiate" commands. */
13600 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13601 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13603 /* "neighbor ebgp-multihop" commands. */
13604 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13605 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13606 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13608 /* "neighbor disable-connected-check" commands. */
13609 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13610 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13612 /* "neighbor enforce-first-as" commands. */
13613 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13614 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13616 /* "neighbor description" commands. */
13617 install_element(BGP_NODE
, &neighbor_description_cmd
);
13618 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13619 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13621 /* "neighbor update-source" commands. "*/
13622 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13623 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13625 /* "neighbor default-originate" commands. */
13626 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13627 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13628 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13629 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13630 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13631 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13632 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13633 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13634 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13635 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13636 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13637 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13638 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13639 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13640 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13641 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13642 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13643 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13644 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13645 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13646 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13648 /* "neighbor port" commands. */
13649 install_element(BGP_NODE
, &neighbor_port_cmd
);
13650 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13652 /* "neighbor weight" commands. */
13653 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13654 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13656 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13657 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13658 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13659 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13660 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13661 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13662 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13663 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13664 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13665 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13666 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13667 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13668 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13669 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13670 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13671 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13673 /* "neighbor override-capability" commands. */
13674 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13675 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13677 /* "neighbor strict-capability-match" commands. */
13678 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13679 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13681 /* "neighbor timers" commands. */
13682 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13683 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13685 /* "neighbor timers connect" commands. */
13686 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13687 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13689 /* "neighbor advertisement-interval" commands. */
13690 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13691 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13693 /* "neighbor interface" commands. */
13694 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13695 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13697 /* "neighbor distribute" commands. */
13698 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13699 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13700 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13701 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13702 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13703 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13704 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13705 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13706 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13707 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13708 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13709 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13710 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13711 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13712 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13713 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13714 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13715 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13717 /* "neighbor prefix-list" commands. */
13718 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13719 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13720 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13721 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13722 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13723 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13724 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13725 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13726 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13727 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13728 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13729 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13730 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13731 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13732 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13733 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13734 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13735 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13736 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13737 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13738 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13739 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13741 /* "neighbor filter-list" commands. */
13742 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13743 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13744 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13745 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13746 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13747 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13748 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13749 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13750 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13751 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13752 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13753 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13754 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13755 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13756 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13757 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13758 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13759 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13760 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13761 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13762 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13763 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13765 /* "neighbor route-map" commands. */
13766 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13767 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13768 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13769 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13770 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13771 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13772 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13773 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13774 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13775 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13776 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13777 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13778 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13779 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13780 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13781 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13782 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13783 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13784 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13785 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13786 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13787 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13788 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13789 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13791 /* "neighbor unsuppress-map" commands. */
13792 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13793 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13794 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13795 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13796 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13797 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13798 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13799 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13800 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13801 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13802 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13803 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13804 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13805 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13806 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13807 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13808 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13809 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13811 /* "neighbor maximum-prefix" commands. */
13812 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13813 install_element(BGP_NODE
,
13814 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13815 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13816 install_element(BGP_NODE
,
13817 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13818 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13819 install_element(BGP_NODE
,
13820 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13821 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13822 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13823 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13824 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13825 install_element(BGP_IPV4_NODE
,
13826 &neighbor_maximum_prefix_threshold_warning_cmd
);
13827 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13828 install_element(BGP_IPV4_NODE
,
13829 &neighbor_maximum_prefix_threshold_restart_cmd
);
13830 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13831 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13832 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13833 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13834 install_element(BGP_IPV4M_NODE
,
13835 &neighbor_maximum_prefix_threshold_warning_cmd
);
13836 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13837 install_element(BGP_IPV4M_NODE
,
13838 &neighbor_maximum_prefix_threshold_restart_cmd
);
13839 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13840 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13841 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13842 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13843 install_element(BGP_IPV4L_NODE
,
13844 &neighbor_maximum_prefix_threshold_warning_cmd
);
13845 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13846 install_element(BGP_IPV4L_NODE
,
13847 &neighbor_maximum_prefix_threshold_restart_cmd
);
13848 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13849 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13850 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13851 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13852 install_element(BGP_IPV6_NODE
,
13853 &neighbor_maximum_prefix_threshold_warning_cmd
);
13854 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13855 install_element(BGP_IPV6_NODE
,
13856 &neighbor_maximum_prefix_threshold_restart_cmd
);
13857 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13858 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13859 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13860 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13861 install_element(BGP_IPV6M_NODE
,
13862 &neighbor_maximum_prefix_threshold_warning_cmd
);
13863 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13864 install_element(BGP_IPV6M_NODE
,
13865 &neighbor_maximum_prefix_threshold_restart_cmd
);
13866 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13867 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13868 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13869 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13870 install_element(BGP_IPV6L_NODE
,
13871 &neighbor_maximum_prefix_threshold_warning_cmd
);
13872 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13873 install_element(BGP_IPV6L_NODE
,
13874 &neighbor_maximum_prefix_threshold_restart_cmd
);
13875 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13876 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13877 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13878 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13879 install_element(BGP_VPNV4_NODE
,
13880 &neighbor_maximum_prefix_threshold_warning_cmd
);
13881 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13882 install_element(BGP_VPNV4_NODE
,
13883 &neighbor_maximum_prefix_threshold_restart_cmd
);
13884 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13885 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13886 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13887 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13888 install_element(BGP_VPNV6_NODE
,
13889 &neighbor_maximum_prefix_threshold_warning_cmd
);
13890 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13891 install_element(BGP_VPNV6_NODE
,
13892 &neighbor_maximum_prefix_threshold_restart_cmd
);
13893 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13895 /* "neighbor allowas-in" */
13896 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13897 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13898 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13899 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13900 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13901 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13902 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13903 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13904 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13905 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13906 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13907 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13908 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13909 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13910 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13911 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13912 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13913 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13914 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13915 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13917 /* address-family commands. */
13918 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13919 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13920 #ifdef KEEP_OLD_VPN_COMMANDS
13921 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13922 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13923 #endif /* KEEP_OLD_VPN_COMMANDS */
13925 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13927 /* "exit-address-family" command. */
13928 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13929 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13930 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13931 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13932 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13933 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13934 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13935 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13936 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13937 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13938 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13940 /* "clear ip bgp commands" */
13941 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13943 /* clear ip bgp prefix */
13944 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13945 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13946 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13948 /* "show [ip] bgp summary" commands. */
13949 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13950 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13951 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13952 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13953 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13954 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13955 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13957 /* "show [ip] bgp neighbors" commands. */
13958 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13960 /* "show [ip] bgp peer-group" commands. */
13961 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13963 /* "show [ip] bgp paths" commands. */
13964 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13966 /* "show [ip] bgp community" commands. */
13967 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13969 /* "show ip bgp large-community" commands. */
13970 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13971 /* "show [ip] bgp attribute-info" commands. */
13972 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13973 /* "show [ip] bgp route-leak" command */
13974 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13976 /* "redistribute" commands. */
13977 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13978 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13979 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13980 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13981 install_element(BGP_NODE
,
13982 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13983 install_element(BGP_NODE
,
13984 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13985 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13986 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13987 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13988 install_element(BGP_NODE
,
13989 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13990 install_element(BGP_NODE
,
13991 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13992 install_element(BGP_NODE
,
13993 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13994 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13995 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13996 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13997 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13998 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13999 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
14000 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
14001 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
14002 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
14003 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
14004 install_element(BGP_IPV4_NODE
,
14005 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
14006 install_element(BGP_IPV4_NODE
,
14007 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
14008 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
14009 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
14010 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
14011 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
14012 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
14013 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
14015 /* import|export vpn [route-map WORD] */
14016 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14017 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14019 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14020 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14022 /* ttl_security commands */
14023 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14024 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14026 /* "show [ip] bgp memory" commands. */
14027 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14029 /* "show bgp martian next-hop" */
14030 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14032 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14034 /* "show [ip] bgp views" commands. */
14035 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14037 /* "show [ip] bgp vrfs" commands. */
14038 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14040 /* Community-list. */
14041 community_list_vty();
14043 /* vpn-policy commands */
14044 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14045 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14046 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14047 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14048 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14049 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14050 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14051 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14052 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14053 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14054 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14055 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14057 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14058 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14060 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14061 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14062 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14063 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14064 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14065 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14066 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14067 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14068 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14069 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14070 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14071 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14074 #include "memory.h"
14075 #include "bgp_regex.h"
14076 #include "bgp_clist.h"
14077 #include "bgp_ecommunity.h"
14079 /* VTY functions. */
14081 /* Direction value to string conversion. */
14082 static const char *community_direct_str(int direct
)
14085 case COMMUNITY_DENY
:
14087 case COMMUNITY_PERMIT
:
14094 /* Display error string. */
14095 static void community_list_perror(struct vty
*vty
, int ret
)
14098 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14099 vty_out(vty
, "%% Can't find community-list\n");
14101 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14102 vty_out(vty
, "%% Malformed community-list value\n");
14104 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14106 "%% Community name conflict, previously defined as standard community\n");
14108 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14110 "%% Community name conflict, previously defined as expanded community\n");
14115 /* "community-list" keyword help string. */
14116 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14118 /*community-list standard */
14119 DEFUN (community_list_standard
,
14120 bgp_community_list_standard_cmd
,
14121 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14124 "Community list number (standard)\n"
14125 "Add an standard community-list entry\n"
14126 "Community list name\n"
14127 "Specify community to reject\n"
14128 "Specify community to accept\n"
14131 char *cl_name_or_number
= NULL
;
14133 int style
= COMMUNITY_LIST_STANDARD
;
14137 if (argv_find(argv
, argc
, "ip", &idx
)) {
14138 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14139 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14140 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14141 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14144 argv_find(argv
, argc
, "(1-99)", &idx
);
14145 argv_find(argv
, argc
, "WORD", &idx
);
14146 cl_name_or_number
= argv
[idx
]->arg
;
14147 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14149 argv_find(argv
, argc
, "AA:NN", &idx
);
14150 char *str
= argv_concat(argv
, argc
, idx
);
14152 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14155 XFREE(MTYPE_TMP
, str
);
14158 /* Display error string. */
14159 community_list_perror(vty
, ret
);
14160 return CMD_WARNING_CONFIG_FAILED
;
14163 return CMD_SUCCESS
;
14166 #if CONFDATE > 20191005
14167 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14169 ALIAS (community_list_standard
,
14170 ip_community_list_standard_cmd
,
14171 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14174 "Community list number (standard)\n"
14175 "Add an standard community-list entry\n"
14176 "Community list name\n"
14177 "Specify community to reject\n"
14178 "Specify community to accept\n"
14181 DEFUN (no_community_list_standard_all
,
14182 no_bgp_community_list_standard_all_cmd
,
14183 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14187 "Community list number (standard)\n"
14188 "Add an standard community-list entry\n"
14189 "Community list name\n"
14190 "Specify community to reject\n"
14191 "Specify community to accept\n"
14194 char *cl_name_or_number
= NULL
;
14197 int style
= COMMUNITY_LIST_STANDARD
;
14201 if (argv_find(argv
, argc
, "ip", &idx
)) {
14202 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14203 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14204 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14205 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14208 argv_find(argv
, argc
, "permit", &idx
);
14209 argv_find(argv
, argc
, "deny", &idx
);
14212 direct
= argv_find(argv
, argc
, "permit", &idx
)
14217 argv_find(argv
, argc
, "AA:NN", &idx
);
14218 str
= argv_concat(argv
, argc
, idx
);
14222 argv_find(argv
, argc
, "(1-99)", &idx
);
14223 argv_find(argv
, argc
, "WORD", &idx
);
14224 cl_name_or_number
= argv
[idx
]->arg
;
14226 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14229 XFREE(MTYPE_TMP
, str
);
14232 community_list_perror(vty
, ret
);
14233 return CMD_WARNING_CONFIG_FAILED
;
14236 return CMD_SUCCESS
;
14238 ALIAS (no_community_list_standard_all
,
14239 no_ip_community_list_standard_all_cmd
,
14240 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14244 "Community list number (standard)\n"
14245 "Add an standard community-list entry\n"
14246 "Community list name\n"
14247 "Specify community to reject\n"
14248 "Specify community to accept\n"
14251 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14252 "no bgp community-list <(1-99)|standard WORD>",
14253 NO_STR BGP_STR COMMUNITY_LIST_STR
14254 "Community list number (standard)\n"
14255 "Add an standard community-list entry\n"
14256 "Community list name\n")
14258 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14259 "no ip community-list <(1-99)|standard WORD>",
14260 NO_STR BGP_STR COMMUNITY_LIST_STR
14261 "Community list number (standard)\n"
14262 "Add an standard community-list entry\n"
14263 "Community list name\n")
14265 /*community-list expanded */
14266 DEFUN (community_list_expanded_all
,
14267 bgp_community_list_expanded_all_cmd
,
14268 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14271 "Community list number (expanded)\n"
14272 "Add an expanded community-list entry\n"
14273 "Community list name\n"
14274 "Specify community to reject\n"
14275 "Specify community to accept\n"
14278 char *cl_name_or_number
= NULL
;
14280 int style
= COMMUNITY_LIST_EXPANDED
;
14283 if (argv_find(argv
, argc
, "ip", &idx
)) {
14284 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14285 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14286 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14287 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14289 argv_find(argv
, argc
, "(100-500)", &idx
);
14290 argv_find(argv
, argc
, "WORD", &idx
);
14291 cl_name_or_number
= argv
[idx
]->arg
;
14292 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14294 argv_find(argv
, argc
, "AA:NN", &idx
);
14295 char *str
= argv_concat(argv
, argc
, idx
);
14297 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14300 XFREE(MTYPE_TMP
, str
);
14303 /* Display error string. */
14304 community_list_perror(vty
, ret
);
14305 return CMD_WARNING_CONFIG_FAILED
;
14308 return CMD_SUCCESS
;
14311 ALIAS (community_list_expanded_all
,
14312 ip_community_list_expanded_all_cmd
,
14313 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14316 "Community list number (expanded)\n"
14317 "Add an expanded community-list entry\n"
14318 "Community list name\n"
14319 "Specify community to reject\n"
14320 "Specify community to accept\n"
14323 DEFUN (no_community_list_expanded_all
,
14324 no_bgp_community_list_expanded_all_cmd
,
14325 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14329 "Community list number (expanded)\n"
14330 "Add an expanded community-list entry\n"
14331 "Community list name\n"
14332 "Specify community to reject\n"
14333 "Specify community to accept\n"
14336 char *cl_name_or_number
= NULL
;
14339 int style
= COMMUNITY_LIST_EXPANDED
;
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 community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14346 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14350 argv_find(argv
, argc
, "permit", &idx
);
14351 argv_find(argv
, argc
, "deny", &idx
);
14354 direct
= argv_find(argv
, argc
, "permit", &idx
)
14359 argv_find(argv
, argc
, "AA:NN", &idx
);
14360 str
= argv_concat(argv
, argc
, idx
);
14364 argv_find(argv
, argc
, "(100-500)", &idx
);
14365 argv_find(argv
, argc
, "WORD", &idx
);
14366 cl_name_or_number
= argv
[idx
]->arg
;
14368 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14371 XFREE(MTYPE_TMP
, str
);
14374 community_list_perror(vty
, ret
);
14375 return CMD_WARNING_CONFIG_FAILED
;
14378 return CMD_SUCCESS
;
14381 ALIAS (no_community_list_expanded_all
,
14382 no_ip_community_list_expanded_all_cmd
,
14383 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14387 "Community list number (expanded)\n"
14388 "Add an expanded community-list entry\n"
14389 "Community list name\n"
14390 "Specify community to reject\n"
14391 "Specify community to accept\n"
14394 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14395 "no bgp community-list <(100-500)|expanded WORD>",
14396 NO_STR IP_STR COMMUNITY_LIST_STR
14397 "Community list number (expanded)\n"
14398 "Add an expanded community-list entry\n"
14399 "Community list name\n")
14401 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14402 "no ip community-list <(100-500)|expanded WORD>",
14403 NO_STR IP_STR COMMUNITY_LIST_STR
14404 "Community list number (expanded)\n"
14405 "Add an expanded community-list entry\n"
14406 "Community list name\n")
14408 /* Return configuration string of community-list entry. */
14409 static const char *community_list_config_str(struct community_entry
*entry
)
14416 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14417 str
= community_str(entry
->u
.com
, false);
14418 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14419 str
= lcommunity_str(entry
->u
.lcom
, false);
14421 str
= entry
->config
;
14426 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14428 struct community_entry
*entry
;
14430 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14431 if (entry
== list
->head
) {
14432 if (all_digit(list
->name
))
14433 vty_out(vty
, "Community %s list %s\n",
14434 entry
->style
== COMMUNITY_LIST_STANDARD
14436 : "(expanded) access",
14439 vty_out(vty
, "Named Community %s list %s\n",
14440 entry
->style
== COMMUNITY_LIST_STANDARD
14446 vty_out(vty
, " %s\n",
14447 community_direct_str(entry
->direct
));
14449 vty_out(vty
, " %s %s\n",
14450 community_direct_str(entry
->direct
),
14451 community_list_config_str(entry
));
14455 DEFUN (show_community_list
,
14456 show_bgp_community_list_cmd
,
14457 "show bgp community-list",
14460 "List community-list\n")
14462 struct community_list
*list
;
14463 struct community_list_master
*cm
;
14466 if (argv_find(argv
, argc
, "ip", &idx
)) {
14467 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14468 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14469 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14470 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14472 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14474 return CMD_SUCCESS
;
14476 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14477 community_list_show(vty
, list
);
14479 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14480 community_list_show(vty
, list
);
14482 return CMD_SUCCESS
;
14485 ALIAS (show_community_list
,
14486 show_ip_community_list_cmd
,
14487 "show ip community-list",
14490 "List community-list\n")
14492 DEFUN (show_community_list_arg
,
14493 show_bgp_community_list_arg_cmd
,
14494 "show bgp community-list <(1-500)|WORD>",
14497 "List community-list\n"
14498 "Community-list number\n"
14499 "Community-list name\n")
14501 int idx_comm_list
= 3;
14502 struct community_list
*list
;
14505 if (argv_find(argv
, argc
, "ip", &idx
)) {
14506 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14507 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14508 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14509 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14511 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14512 COMMUNITY_LIST_MASTER
);
14514 vty_out(vty
, "%% Can't find community-list\n");
14515 return CMD_WARNING
;
14518 community_list_show(vty
, list
);
14520 return CMD_SUCCESS
;
14523 ALIAS (show_community_list_arg
,
14524 show_ip_community_list_arg_cmd
,
14525 "show ip community-list <(1-500)|WORD>",
14528 "List community-list\n"
14529 "Community-list number\n"
14530 "Community-list name\n")
14533 * Large Community code.
14535 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14536 struct cmd_token
**argv
, int style
,
14537 int reject_all_digit_name
)
14545 if (argv_find(argv
, argc
, "ip", &idx
)) {
14546 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14547 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14548 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14549 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14551 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14554 /* All digit name check. */
14556 argv_find(argv
, argc
, "WORD", &idx
);
14557 argv_find(argv
, argc
, "(1-99)", &idx
);
14558 argv_find(argv
, argc
, "(100-500)", &idx
);
14559 cl_name
= argv
[idx
]->arg
;
14560 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14561 vty_out(vty
, "%% Community name cannot have all digits\n");
14562 return CMD_WARNING_CONFIG_FAILED
;
14566 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14567 argv_find(argv
, argc
, "LINE", &idx
);
14568 /* Concat community string argument. */
14570 str
= argv_concat(argv
, argc
, idx
);
14574 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14576 /* Free temporary community list string allocated by
14578 XFREE(MTYPE_TMP
, str
);
14581 community_list_perror(vty
, ret
);
14582 return CMD_WARNING_CONFIG_FAILED
;
14584 return CMD_SUCCESS
;
14587 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14588 struct cmd_token
**argv
, int style
)
14595 if (argv_find(argv
, argc
, "ip", &idx
)) {
14596 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14597 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14598 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14599 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14601 argv_find(argv
, argc
, "permit", &idx
);
14602 argv_find(argv
, argc
, "deny", &idx
);
14605 /* Check the list direct. */
14606 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14607 direct
= COMMUNITY_PERMIT
;
14609 direct
= COMMUNITY_DENY
;
14612 argv_find(argv
, argc
, "LINE", &idx
);
14613 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14614 /* Concat community string argument. */
14615 str
= argv_concat(argv
, argc
, idx
);
14619 argv_find(argv
, argc
, "(1-99)", &idx
);
14620 argv_find(argv
, argc
, "(100-500)", &idx
);
14621 argv_find(argv
, argc
, "WORD", &idx
);
14623 /* Unset community list. */
14624 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14627 /* Free temporary community list string allocated by
14629 XFREE(MTYPE_TMP
, str
);
14632 community_list_perror(vty
, ret
);
14633 return CMD_WARNING_CONFIG_FAILED
;
14636 return CMD_SUCCESS
;
14639 /* "large-community-list" keyword help string. */
14640 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14641 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14643 #if CONFDATE > 20191005
14644 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14646 DEFUN (lcommunity_list_standard
,
14647 bgp_lcommunity_list_standard_cmd
,
14648 "bgp large-community-list (1-99) <deny|permit>",
14650 LCOMMUNITY_LIST_STR
14651 "Large Community list number (standard)\n"
14652 "Specify large community to reject\n"
14653 "Specify large community to accept\n")
14655 return lcommunity_list_set_vty(vty
, argc
, argv
,
14656 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14659 ALIAS (lcommunity_list_standard
,
14660 ip_lcommunity_list_standard_cmd
,
14661 "ip large-community-list (1-99) <deny|permit>",
14663 LCOMMUNITY_LIST_STR
14664 "Large Community list number (standard)\n"
14665 "Specify large community to reject\n"
14666 "Specify large community to accept\n")
14668 DEFUN (lcommunity_list_standard1
,
14669 bgp_lcommunity_list_standard1_cmd
,
14670 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14672 LCOMMUNITY_LIST_STR
14673 "Large Community list number (standard)\n"
14674 "Specify large community to reject\n"
14675 "Specify large community to accept\n"
14676 LCOMMUNITY_VAL_STR
)
14678 return lcommunity_list_set_vty(vty
, argc
, argv
,
14679 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14682 ALIAS (lcommunity_list_standard1
,
14683 ip_lcommunity_list_standard1_cmd
,
14684 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14686 LCOMMUNITY_LIST_STR
14687 "Large Community list number (standard)\n"
14688 "Specify large community to reject\n"
14689 "Specify large community to accept\n"
14690 LCOMMUNITY_VAL_STR
)
14692 DEFUN (lcommunity_list_expanded
,
14693 bgp_lcommunity_list_expanded_cmd
,
14694 "bgp large-community-list (100-500) <deny|permit> LINE...",
14696 LCOMMUNITY_LIST_STR
14697 "Large Community list number (expanded)\n"
14698 "Specify large community to reject\n"
14699 "Specify large community to accept\n"
14700 "An ordered list as a regular-expression\n")
14702 return lcommunity_list_set_vty(vty
, argc
, argv
,
14703 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14706 ALIAS (lcommunity_list_expanded
,
14707 ip_lcommunity_list_expanded_cmd
,
14708 "ip large-community-list (100-500) <deny|permit> LINE...",
14710 LCOMMUNITY_LIST_STR
14711 "Large Community list number (expanded)\n"
14712 "Specify large community to reject\n"
14713 "Specify large community to accept\n"
14714 "An ordered list as a regular-expression\n")
14716 DEFUN (lcommunity_list_name_standard
,
14717 bgp_lcommunity_list_name_standard_cmd
,
14718 "bgp large-community-list standard WORD <deny|permit>",
14720 LCOMMUNITY_LIST_STR
14721 "Specify standard large-community-list\n"
14722 "Large Community list name\n"
14723 "Specify large community to reject\n"
14724 "Specify large community to accept\n")
14726 return lcommunity_list_set_vty(vty
, argc
, argv
,
14727 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14730 ALIAS (lcommunity_list_name_standard
,
14731 ip_lcommunity_list_name_standard_cmd
,
14732 "ip large-community-list standard WORD <deny|permit>",
14734 LCOMMUNITY_LIST_STR
14735 "Specify standard large-community-list\n"
14736 "Large Community list name\n"
14737 "Specify large community to reject\n"
14738 "Specify large community to accept\n")
14740 DEFUN (lcommunity_list_name_standard1
,
14741 bgp_lcommunity_list_name_standard1_cmd
,
14742 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14744 LCOMMUNITY_LIST_STR
14745 "Specify standard large-community-list\n"
14746 "Large Community list name\n"
14747 "Specify large community to reject\n"
14748 "Specify large community to accept\n"
14749 LCOMMUNITY_VAL_STR
)
14751 return lcommunity_list_set_vty(vty
, argc
, argv
,
14752 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14755 ALIAS (lcommunity_list_name_standard1
,
14756 ip_lcommunity_list_name_standard1_cmd
,
14757 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14759 LCOMMUNITY_LIST_STR
14760 "Specify standard large-community-list\n"
14761 "Large Community list name\n"
14762 "Specify large community to reject\n"
14763 "Specify large community to accept\n"
14764 LCOMMUNITY_VAL_STR
)
14766 DEFUN (lcommunity_list_name_expanded
,
14767 bgp_lcommunity_list_name_expanded_cmd
,
14768 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14770 LCOMMUNITY_LIST_STR
14771 "Specify expanded large-community-list\n"
14772 "Large Community list name\n"
14773 "Specify large community to reject\n"
14774 "Specify large community to accept\n"
14775 "An ordered list as a regular-expression\n")
14777 return lcommunity_list_set_vty(vty
, argc
, argv
,
14778 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14781 ALIAS (lcommunity_list_name_expanded
,
14782 ip_lcommunity_list_name_expanded_cmd
,
14783 "ip large-community-list expanded WORD <deny|permit> LINE...",
14785 LCOMMUNITY_LIST_STR
14786 "Specify expanded large-community-list\n"
14787 "Large Community list name\n"
14788 "Specify large community to reject\n"
14789 "Specify large community to accept\n"
14790 "An ordered list as a regular-expression\n")
14792 DEFUN (no_lcommunity_list_standard_all
,
14793 no_bgp_lcommunity_list_standard_all_cmd
,
14794 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14797 LCOMMUNITY_LIST_STR
14798 "Large Community list number (standard)\n"
14799 "Large Community list number (expanded)\n"
14800 "Large Community list name\n")
14802 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14803 LARGE_COMMUNITY_LIST_STANDARD
);
14806 ALIAS (no_lcommunity_list_standard_all
,
14807 no_ip_lcommunity_list_standard_all_cmd
,
14808 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14811 LCOMMUNITY_LIST_STR
14812 "Large Community list number (standard)\n"
14813 "Large Community list number (expanded)\n"
14814 "Large Community list name\n")
14816 DEFUN (no_lcommunity_list_name_expanded_all
,
14817 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14818 "no bgp large-community-list expanded WORD",
14821 LCOMMUNITY_LIST_STR
14822 "Specify expanded large-community-list\n"
14823 "Large Community list name\n")
14825 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14826 LARGE_COMMUNITY_LIST_EXPANDED
);
14829 ALIAS (no_lcommunity_list_name_expanded_all
,
14830 no_ip_lcommunity_list_name_expanded_all_cmd
,
14831 "no ip large-community-list expanded WORD",
14834 LCOMMUNITY_LIST_STR
14835 "Specify expanded large-community-list\n"
14836 "Large Community list name\n")
14838 DEFUN (no_lcommunity_list_standard
,
14839 no_bgp_lcommunity_list_standard_cmd
,
14840 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14843 LCOMMUNITY_LIST_STR
14844 "Large Community list number (standard)\n"
14845 "Specify large community to reject\n"
14846 "Specify large community to accept\n"
14847 LCOMMUNITY_VAL_STR
)
14849 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14850 LARGE_COMMUNITY_LIST_STANDARD
);
14853 ALIAS (no_lcommunity_list_standard
,
14854 no_ip_lcommunity_list_standard_cmd
,
14855 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14858 LCOMMUNITY_LIST_STR
14859 "Large Community list number (standard)\n"
14860 "Specify large community to reject\n"
14861 "Specify large community to accept\n"
14862 LCOMMUNITY_VAL_STR
)
14864 DEFUN (no_lcommunity_list_expanded
,
14865 no_bgp_lcommunity_list_expanded_cmd
,
14866 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14869 LCOMMUNITY_LIST_STR
14870 "Large Community list number (expanded)\n"
14871 "Specify large community to reject\n"
14872 "Specify large community to accept\n"
14873 "An ordered list as a regular-expression\n")
14875 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14876 LARGE_COMMUNITY_LIST_EXPANDED
);
14879 ALIAS (no_lcommunity_list_expanded
,
14880 no_ip_lcommunity_list_expanded_cmd
,
14881 "no ip large-community-list (100-500) <deny|permit> LINE...",
14884 LCOMMUNITY_LIST_STR
14885 "Large Community list number (expanded)\n"
14886 "Specify large community to reject\n"
14887 "Specify large community to accept\n"
14888 "An ordered list as a regular-expression\n")
14890 DEFUN (no_lcommunity_list_name_standard
,
14891 no_bgp_lcommunity_list_name_standard_cmd
,
14892 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14895 LCOMMUNITY_LIST_STR
14896 "Specify standard large-community-list\n"
14897 "Large Community list name\n"
14898 "Specify large community to reject\n"
14899 "Specify large community to accept\n"
14900 LCOMMUNITY_VAL_STR
)
14902 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14903 LARGE_COMMUNITY_LIST_STANDARD
);
14906 ALIAS (no_lcommunity_list_name_standard
,
14907 no_ip_lcommunity_list_name_standard_cmd
,
14908 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14911 LCOMMUNITY_LIST_STR
14912 "Specify standard large-community-list\n"
14913 "Large Community list name\n"
14914 "Specify large community to reject\n"
14915 "Specify large community to accept\n"
14916 LCOMMUNITY_VAL_STR
)
14918 DEFUN (no_lcommunity_list_name_expanded
,
14919 no_bgp_lcommunity_list_name_expanded_cmd
,
14920 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14923 LCOMMUNITY_LIST_STR
14924 "Specify expanded large-community-list\n"
14925 "Large community list name\n"
14926 "Specify large community to reject\n"
14927 "Specify large community to accept\n"
14928 "An ordered list as a regular-expression\n")
14930 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14931 LARGE_COMMUNITY_LIST_EXPANDED
);
14934 ALIAS (no_lcommunity_list_name_expanded
,
14935 no_ip_lcommunity_list_name_expanded_cmd
,
14936 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14939 LCOMMUNITY_LIST_STR
14940 "Specify expanded large-community-list\n"
14941 "Large community list name\n"
14942 "Specify large community to reject\n"
14943 "Specify large community to accept\n"
14944 "An ordered list as a regular-expression\n")
14946 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14948 struct community_entry
*entry
;
14950 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14951 if (entry
== list
->head
) {
14952 if (all_digit(list
->name
))
14953 vty_out(vty
, "Large community %s list %s\n",
14954 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14956 : "(expanded) access",
14960 "Named large community %s list %s\n",
14961 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14967 vty_out(vty
, " %s\n",
14968 community_direct_str(entry
->direct
));
14970 vty_out(vty
, " %s %s\n",
14971 community_direct_str(entry
->direct
),
14972 community_list_config_str(entry
));
14976 DEFUN (show_lcommunity_list
,
14977 show_bgp_lcommunity_list_cmd
,
14978 "show bgp large-community-list",
14981 "List large-community list\n")
14983 struct community_list
*list
;
14984 struct community_list_master
*cm
;
14987 if (argv_find(argv
, argc
, "ip", &idx
)) {
14988 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14989 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14990 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14991 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14994 cm
= community_list_master_lookup(bgp_clist
,
14995 LARGE_COMMUNITY_LIST_MASTER
);
14997 return CMD_SUCCESS
;
14999 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15000 lcommunity_list_show(vty
, list
);
15002 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15003 lcommunity_list_show(vty
, list
);
15005 return CMD_SUCCESS
;
15008 ALIAS (show_lcommunity_list
,
15009 show_ip_lcommunity_list_cmd
,
15010 "show ip large-community-list",
15013 "List large-community list\n")
15015 DEFUN (show_lcommunity_list_arg
,
15016 show_bgp_lcommunity_list_arg_cmd
,
15017 "show bgp large-community-list <(1-500)|WORD>",
15020 "List large-community list\n"
15021 "large-community-list number\n"
15022 "large-community-list name\n")
15024 struct community_list
*list
;
15027 if (argv_find(argv
, argc
, "ip", &idx
)) {
15028 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15029 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15030 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15031 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15034 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
15035 LARGE_COMMUNITY_LIST_MASTER
);
15037 vty_out(vty
, "%% Can't find extcommunity-list\n");
15038 return CMD_WARNING
;
15041 lcommunity_list_show(vty
, list
);
15043 return CMD_SUCCESS
;
15046 ALIAS (show_lcommunity_list_arg
,
15047 show_ip_lcommunity_list_arg_cmd
,
15048 "show ip large-community-list <(1-500)|WORD>",
15051 "List large-community list\n"
15052 "large-community-list number\n"
15053 "large-community-list name\n")
15055 /* "extcommunity-list" keyword help string. */
15056 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15057 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15059 DEFUN (extcommunity_list_standard
,
15060 bgp_extcommunity_list_standard_cmd
,
15061 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15063 EXTCOMMUNITY_LIST_STR
15064 "Extended Community list number (standard)\n"
15065 "Specify standard extcommunity-list\n"
15066 "Community list name\n"
15067 "Specify community to reject\n"
15068 "Specify community to accept\n"
15069 EXTCOMMUNITY_VAL_STR
)
15071 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15073 char *cl_number_or_name
= NULL
;
15076 if (argv_find(argv
, argc
, "ip", &idx
)) {
15077 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15078 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15079 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15080 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15082 argv_find(argv
, argc
, "(1-99)", &idx
);
15083 argv_find(argv
, argc
, "WORD", &idx
);
15084 cl_number_or_name
= argv
[idx
]->arg
;
15085 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15087 argv_find(argv
, argc
, "AA:NN", &idx
);
15088 char *str
= argv_concat(argv
, argc
, idx
);
15090 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15093 XFREE(MTYPE_TMP
, str
);
15096 community_list_perror(vty
, ret
);
15097 return CMD_WARNING_CONFIG_FAILED
;
15100 return CMD_SUCCESS
;
15103 #if CONFDATE > 20191005
15104 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15106 ALIAS (extcommunity_list_standard
,
15107 ip_extcommunity_list_standard_cmd
,
15108 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15110 EXTCOMMUNITY_LIST_STR
15111 "Extended Community list number (standard)\n"
15112 "Specify standard extcommunity-list\n"
15113 "Community list name\n"
15114 "Specify community to reject\n"
15115 "Specify community to accept\n"
15116 EXTCOMMUNITY_VAL_STR
)
15118 DEFUN (extcommunity_list_name_expanded
,
15119 bgp_extcommunity_list_name_expanded_cmd
,
15120 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15122 EXTCOMMUNITY_LIST_STR
15123 "Extended Community list number (expanded)\n"
15124 "Specify expanded extcommunity-list\n"
15125 "Extended Community list name\n"
15126 "Specify community to reject\n"
15127 "Specify community to accept\n"
15128 "An ordered list as a regular-expression\n")
15130 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15132 char *cl_number_or_name
= NULL
;
15135 if (argv_find(argv
, argc
, "ip", &idx
)) {
15136 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15137 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15138 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15139 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15142 argv_find(argv
, argc
, "(100-500)", &idx
);
15143 argv_find(argv
, argc
, "WORD", &idx
);
15144 cl_number_or_name
= argv
[idx
]->arg
;
15145 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15147 argv_find(argv
, argc
, "LINE", &idx
);
15148 char *str
= argv_concat(argv
, argc
, idx
);
15150 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15153 XFREE(MTYPE_TMP
, str
);
15156 community_list_perror(vty
, ret
);
15157 return CMD_WARNING_CONFIG_FAILED
;
15160 return CMD_SUCCESS
;
15163 ALIAS (extcommunity_list_name_expanded
,
15164 ip_extcommunity_list_name_expanded_cmd
,
15165 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15167 EXTCOMMUNITY_LIST_STR
15168 "Extended Community list number (expanded)\n"
15169 "Specify expanded extcommunity-list\n"
15170 "Extended Community list name\n"
15171 "Specify community to reject\n"
15172 "Specify community to accept\n"
15173 "An ordered list as a regular-expression\n")
15175 DEFUN (no_extcommunity_list_standard_all
,
15176 no_bgp_extcommunity_list_standard_all_cmd
,
15177 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15180 EXTCOMMUNITY_LIST_STR
15181 "Extended Community list number (standard)\n"
15182 "Specify standard extcommunity-list\n"
15183 "Community list name\n"
15184 "Specify community to reject\n"
15185 "Specify community to accept\n"
15186 EXTCOMMUNITY_VAL_STR
)
15188 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15190 char *cl_number_or_name
= NULL
;
15194 if (argv_find(argv
, argc
, "ip", &idx
)) {
15195 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15196 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15197 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15198 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15202 argv_find(argv
, argc
, "permit", &idx
);
15203 argv_find(argv
, argc
, "deny", &idx
);
15206 direct
= argv_find(argv
, argc
, "permit", &idx
)
15211 argv_find(argv
, argc
, "AA:NN", &idx
);
15212 str
= argv_concat(argv
, argc
, idx
);
15216 argv_find(argv
, argc
, "(1-99)", &idx
);
15217 argv_find(argv
, argc
, "WORD", &idx
);
15218 cl_number_or_name
= argv
[idx
]->arg
;
15220 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15223 XFREE(MTYPE_TMP
, str
);
15226 community_list_perror(vty
, ret
);
15227 return CMD_WARNING_CONFIG_FAILED
;
15230 return CMD_SUCCESS
;
15233 ALIAS (no_extcommunity_list_standard_all
,
15234 no_ip_extcommunity_list_standard_all_cmd
,
15235 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15238 EXTCOMMUNITY_LIST_STR
15239 "Extended Community list number (standard)\n"
15240 "Specify standard extcommunity-list\n"
15241 "Community list name\n"
15242 "Specify community to reject\n"
15243 "Specify community to accept\n"
15244 EXTCOMMUNITY_VAL_STR
)
15246 ALIAS(no_extcommunity_list_standard_all
,
15247 no_bgp_extcommunity_list_standard_all_list_cmd
,
15248 "no bgp extcommunity-list <(1-99)|standard WORD>",
15249 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15250 "Extended Community list number (standard)\n"
15251 "Specify standard extcommunity-list\n"
15252 "Community list name\n")
15254 ALIAS(no_extcommunity_list_standard_all
,
15255 no_ip_extcommunity_list_standard_all_list_cmd
,
15256 "no ip extcommunity-list <(1-99)|standard WORD>",
15257 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15258 "Extended Community list number (standard)\n"
15259 "Specify standard extcommunity-list\n"
15260 "Community list name\n")
15262 DEFUN (no_extcommunity_list_expanded_all
,
15263 no_bgp_extcommunity_list_expanded_all_cmd
,
15264 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15267 EXTCOMMUNITY_LIST_STR
15268 "Extended Community list number (expanded)\n"
15269 "Specify expanded extcommunity-list\n"
15270 "Extended Community list name\n"
15271 "Specify community to reject\n"
15272 "Specify community to accept\n"
15273 "An ordered list as a regular-expression\n")
15275 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15277 char *cl_number_or_name
= NULL
;
15281 if (argv_find(argv
, argc
, "ip", &idx
)) {
15282 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15283 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15284 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15285 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15289 argv_find(argv
, argc
, "permit", &idx
);
15290 argv_find(argv
, argc
, "deny", &idx
);
15293 direct
= argv_find(argv
, argc
, "permit", &idx
)
15298 argv_find(argv
, argc
, "LINE", &idx
);
15299 str
= argv_concat(argv
, argc
, idx
);
15303 argv_find(argv
, argc
, "(100-500)", &idx
);
15304 argv_find(argv
, argc
, "WORD", &idx
);
15305 cl_number_or_name
= argv
[idx
]->arg
;
15307 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15310 XFREE(MTYPE_TMP
, str
);
15313 community_list_perror(vty
, ret
);
15314 return CMD_WARNING_CONFIG_FAILED
;
15317 return CMD_SUCCESS
;
15320 ALIAS (no_extcommunity_list_expanded_all
,
15321 no_ip_extcommunity_list_expanded_all_cmd
,
15322 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15325 EXTCOMMUNITY_LIST_STR
15326 "Extended Community list number (expanded)\n"
15327 "Specify expanded extcommunity-list\n"
15328 "Extended Community list name\n"
15329 "Specify community to reject\n"
15330 "Specify community to accept\n"
15331 "An ordered list as a regular-expression\n")
15333 ALIAS(no_extcommunity_list_expanded_all
,
15334 no_ip_extcommunity_list_expanded_all_list_cmd
,
15335 "no ip extcommunity-list <(100-500)|expanded WORD>",
15336 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15337 "Extended Community list number (expanded)\n"
15338 "Specify expanded extcommunity-list\n"
15339 "Extended Community list name\n")
15341 ALIAS(no_extcommunity_list_expanded_all
,
15342 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15343 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15344 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15345 "Extended Community list number (expanded)\n"
15346 "Specify expanded extcommunity-list\n"
15347 "Extended Community list name\n")
15349 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15351 struct community_entry
*entry
;
15353 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15354 if (entry
== list
->head
) {
15355 if (all_digit(list
->name
))
15356 vty_out(vty
, "Extended community %s list %s\n",
15357 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15359 : "(expanded) access",
15363 "Named extended community %s list %s\n",
15364 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15370 vty_out(vty
, " %s\n",
15371 community_direct_str(entry
->direct
));
15373 vty_out(vty
, " %s %s\n",
15374 community_direct_str(entry
->direct
),
15375 community_list_config_str(entry
));
15379 DEFUN (show_extcommunity_list
,
15380 show_bgp_extcommunity_list_cmd
,
15381 "show bgp extcommunity-list",
15384 "List extended-community list\n")
15386 struct community_list
*list
;
15387 struct community_list_master
*cm
;
15390 if (argv_find(argv
, argc
, "ip", &idx
)) {
15391 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15392 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15393 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15394 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15396 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15398 return CMD_SUCCESS
;
15400 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15401 extcommunity_list_show(vty
, list
);
15403 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15404 extcommunity_list_show(vty
, list
);
15406 return CMD_SUCCESS
;
15409 ALIAS (show_extcommunity_list
,
15410 show_ip_extcommunity_list_cmd
,
15411 "show ip extcommunity-list",
15414 "List extended-community list\n")
15416 DEFUN (show_extcommunity_list_arg
,
15417 show_bgp_extcommunity_list_arg_cmd
,
15418 "show bgp extcommunity-list <(1-500)|WORD>",
15421 "List extended-community list\n"
15422 "Extcommunity-list number\n"
15423 "Extcommunity-list name\n")
15425 int idx_comm_list
= 3;
15426 struct community_list
*list
;
15429 if (argv_find(argv
, argc
, "ip", &idx
)) {
15430 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15431 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15432 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15433 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15435 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15436 EXTCOMMUNITY_LIST_MASTER
);
15438 vty_out(vty
, "%% Can't find extcommunity-list\n");
15439 return CMD_WARNING
;
15442 extcommunity_list_show(vty
, list
);
15444 return CMD_SUCCESS
;
15447 ALIAS (show_extcommunity_list_arg
,
15448 show_ip_extcommunity_list_arg_cmd
,
15449 "show ip extcommunity-list <(1-500)|WORD>",
15452 "List extended-community list\n"
15453 "Extcommunity-list number\n"
15454 "Extcommunity-list name\n")
15456 /* Display community-list and extcommunity-list configuration. */
15457 static int community_list_config_write(struct vty
*vty
)
15459 struct community_list
*list
;
15460 struct community_entry
*entry
;
15461 struct community_list_master
*cm
;
15464 /* Community-list. */
15465 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15467 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15468 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15469 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15470 community_direct_str(entry
->direct
),
15471 community_list_config_str(entry
));
15474 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15475 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15476 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15477 entry
->style
== COMMUNITY_LIST_STANDARD
15480 list
->name
, community_direct_str(entry
->direct
),
15481 community_list_config_str(entry
));
15485 /* Extcommunity-list. */
15486 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15488 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15489 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15490 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15491 list
->name
, community_direct_str(entry
->direct
),
15492 community_list_config_str(entry
));
15495 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15496 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15497 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15498 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15501 list
->name
, community_direct_str(entry
->direct
),
15502 community_list_config_str(entry
));
15507 /* lcommunity-list. */
15508 cm
= community_list_master_lookup(bgp_clist
,
15509 LARGE_COMMUNITY_LIST_MASTER
);
15511 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15512 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15513 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15514 list
->name
, community_direct_str(entry
->direct
),
15515 community_list_config_str(entry
));
15518 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15519 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15520 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15521 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15524 list
->name
, community_direct_str(entry
->direct
),
15525 community_list_config_str(entry
));
15532 static struct cmd_node community_list_node
= {
15533 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15536 static void community_list_vty(void)
15538 install_node(&community_list_node
, community_list_config_write
);
15540 /* Community-list. */
15541 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15542 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15543 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15544 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15545 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15546 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15547 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15548 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15549 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15550 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15551 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15552 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15553 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15554 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15555 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15556 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15558 /* Extcommunity-list. */
15559 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15560 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15561 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15562 install_element(CONFIG_NODE
,
15563 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15564 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15565 install_element(CONFIG_NODE
,
15566 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15567 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15568 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15569 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15570 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15571 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15572 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15573 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15574 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15575 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15576 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15578 /* Large Community List */
15579 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15580 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15581 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15582 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15583 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15584 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15585 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15586 install_element(CONFIG_NODE
,
15587 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15588 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15589 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15590 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15591 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15592 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15593 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15594 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15595 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15596 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15597 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15598 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15599 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15600 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15601 install_element(CONFIG_NODE
,
15602 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15603 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15604 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15605 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15606 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15607 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15608 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);