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 DEFUN (no_neighbor_nexthop_self
,
3947 no_neighbor_nexthop_self_cmd
,
3948 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3952 "Disable the next hop calculation for this neighbor\n")
3955 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3956 bgp_node_afi(vty
), bgp_node_safi(vty
),
3957 PEER_FLAG_NEXTHOP_SELF
);
3960 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3961 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3962 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3963 "Disable the next hop calculation for this neighbor\n")
3965 DEFUN (no_neighbor_nexthop_self_force
,
3966 no_neighbor_nexthop_self_force_cmd
,
3967 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3971 "Disable the next hop calculation for this neighbor\n"
3972 "Set the next hop to self for reflected routes\n")
3975 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3976 bgp_node_afi(vty
), bgp_node_safi(vty
),
3977 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3980 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3981 no_neighbor_nexthop_self_force_hidden_cmd
,
3982 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3983 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3984 "Disable the next hop calculation for this neighbor\n"
3985 "Set the next hop to self for reflected routes\n")
3987 /* neighbor as-override */
3988 DEFUN (neighbor_as_override
,
3989 neighbor_as_override_cmd
,
3990 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3993 "Override ASNs in outbound updates if aspath equals remote-as\n")
3996 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3997 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4000 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4001 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4002 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4003 "Override ASNs in outbound updates if aspath equals remote-as\n")
4005 DEFUN (no_neighbor_as_override
,
4006 no_neighbor_as_override_cmd
,
4007 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4011 "Override ASNs in outbound updates if aspath equals remote-as\n")
4014 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4015 bgp_node_afi(vty
), bgp_node_safi(vty
),
4016 PEER_FLAG_AS_OVERRIDE
);
4019 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4020 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4021 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4022 "Override ASNs in outbound updates if aspath equals remote-as\n")
4024 /* neighbor remove-private-AS. */
4025 DEFUN (neighbor_remove_private_as
,
4026 neighbor_remove_private_as_cmd
,
4027 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4030 "Remove private ASNs in outbound updates\n")
4033 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4035 PEER_FLAG_REMOVE_PRIVATE_AS
);
4038 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4039 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4040 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4041 "Remove private ASNs in outbound updates\n")
4043 DEFUN (neighbor_remove_private_as_all
,
4044 neighbor_remove_private_as_all_cmd
,
4045 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4048 "Remove private ASNs in outbound updates\n"
4049 "Apply to all AS numbers\n")
4052 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4054 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4057 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4058 neighbor_remove_private_as_all_hidden_cmd
,
4059 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4060 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4061 "Remove private ASNs in outbound updates\n"
4062 "Apply to all AS numbers")
4064 DEFUN (neighbor_remove_private_as_replace_as
,
4065 neighbor_remove_private_as_replace_as_cmd
,
4066 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4069 "Remove private ASNs in outbound updates\n"
4070 "Replace private ASNs with our ASN in outbound updates\n")
4073 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4075 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4078 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4079 neighbor_remove_private_as_replace_as_hidden_cmd
,
4080 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4081 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4082 "Remove private ASNs in outbound updates\n"
4083 "Replace private ASNs with our ASN in outbound updates\n")
4085 DEFUN (neighbor_remove_private_as_all_replace_as
,
4086 neighbor_remove_private_as_all_replace_as_cmd
,
4087 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4090 "Remove private ASNs in outbound updates\n"
4091 "Apply to all AS numbers\n"
4092 "Replace private ASNs with our ASN in outbound updates\n")
4095 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4097 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4101 neighbor_remove_private_as_all_replace_as
,
4102 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4103 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4104 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4105 "Remove private ASNs in outbound updates\n"
4106 "Apply to all AS numbers\n"
4107 "Replace private ASNs with our ASN in outbound updates\n")
4109 DEFUN (no_neighbor_remove_private_as
,
4110 no_neighbor_remove_private_as_cmd
,
4111 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4115 "Remove private ASNs in outbound updates\n")
4118 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4119 bgp_node_afi(vty
), bgp_node_safi(vty
),
4120 PEER_FLAG_REMOVE_PRIVATE_AS
);
4123 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4124 no_neighbor_remove_private_as_hidden_cmd
,
4125 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4126 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4127 "Remove private ASNs in outbound updates\n")
4129 DEFUN (no_neighbor_remove_private_as_all
,
4130 no_neighbor_remove_private_as_all_cmd
,
4131 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4135 "Remove private ASNs in outbound updates\n"
4136 "Apply to all AS numbers\n")
4139 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4140 bgp_node_afi(vty
), bgp_node_safi(vty
),
4141 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4144 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4145 no_neighbor_remove_private_as_all_hidden_cmd
,
4146 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4147 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4148 "Remove private ASNs in outbound updates\n"
4149 "Apply to all AS numbers\n")
4151 DEFUN (no_neighbor_remove_private_as_replace_as
,
4152 no_neighbor_remove_private_as_replace_as_cmd
,
4153 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4157 "Remove private ASNs in outbound updates\n"
4158 "Replace private ASNs with our ASN in outbound updates\n")
4161 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4162 bgp_node_afi(vty
), bgp_node_safi(vty
),
4163 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4166 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4167 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4168 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4169 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4170 "Remove private ASNs in outbound updates\n"
4171 "Replace private ASNs with our ASN in outbound updates\n")
4173 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4174 no_neighbor_remove_private_as_all_replace_as_cmd
,
4175 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4179 "Remove private ASNs in outbound updates\n"
4180 "Apply to all AS numbers\n"
4181 "Replace private ASNs with our ASN in outbound updates\n")
4184 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4185 bgp_node_afi(vty
), bgp_node_safi(vty
),
4186 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4190 no_neighbor_remove_private_as_all_replace_as
,
4191 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4192 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4193 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4194 "Remove private ASNs in outbound updates\n"
4195 "Apply to all AS numbers\n"
4196 "Replace private ASNs with our ASN in outbound updates\n")
4199 /* neighbor send-community. */
4200 DEFUN (neighbor_send_community
,
4201 neighbor_send_community_cmd
,
4202 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4205 "Send Community attribute to this neighbor\n")
4209 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4211 PEER_FLAG_SEND_COMMUNITY
);
4214 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4215 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4216 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4217 "Send Community attribute to this neighbor\n")
4219 DEFUN (no_neighbor_send_community
,
4220 no_neighbor_send_community_cmd
,
4221 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4225 "Send Community attribute to this neighbor\n")
4229 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4230 bgp_node_afi(vty
), bgp_node_safi(vty
),
4231 PEER_FLAG_SEND_COMMUNITY
);
4234 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4235 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4236 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4237 "Send Community attribute to this neighbor\n")
4239 /* neighbor send-community extended. */
4240 DEFUN (neighbor_send_community_type
,
4241 neighbor_send_community_type_cmd
,
4242 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4245 "Send Community attribute to this neighbor\n"
4246 "Send Standard and Extended Community attributes\n"
4247 "Send Standard, Large and Extended Community attributes\n"
4248 "Send Extended Community attributes\n"
4249 "Send Standard Community attributes\n"
4250 "Send Large Community attributes\n")
4254 const char *type
= argv
[argc
- 1]->text
;
4256 if (strmatch(type
, "standard")) {
4257 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4258 } else if (strmatch(type
, "extended")) {
4259 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4260 } else if (strmatch(type
, "large")) {
4261 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4262 } else if (strmatch(type
, "both")) {
4263 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4264 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4265 } else { /* if (strmatch(type, "all")) */
4266 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4267 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4268 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4271 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4272 bgp_node_safi(vty
), flag
);
4276 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4277 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4278 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4279 "Send Community attribute to this neighbor\n"
4280 "Send Standard and Extended Community attributes\n"
4281 "Send Standard, Large and Extended Community attributes\n"
4282 "Send Extended Community attributes\n"
4283 "Send Standard Community attributes\n"
4284 "Send Large Community attributes\n")
4286 DEFUN (no_neighbor_send_community_type
,
4287 no_neighbor_send_community_type_cmd
,
4288 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4292 "Send Community attribute to this neighbor\n"
4293 "Send Standard and Extended Community attributes\n"
4294 "Send Standard, Large and Extended Community attributes\n"
4295 "Send Extended Community attributes\n"
4296 "Send Standard Community attributes\n"
4297 "Send Large Community attributes\n")
4301 const char *type
= argv
[argc
- 1]->text
;
4303 if (strmatch(type
, "standard")) {
4304 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4305 } else if (strmatch(type
, "extended")) {
4306 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4307 } else if (strmatch(type
, "large")) {
4308 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4309 } else if (strmatch(type
, "both")) {
4310 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4311 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4312 } else { /* if (strmatch(type, "all")) */
4313 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4314 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4315 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4318 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4319 bgp_node_afi(vty
), bgp_node_safi(vty
),
4324 no_neighbor_send_community_type
,
4325 no_neighbor_send_community_type_hidden_cmd
,
4326 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4327 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4328 "Send Community attribute to this neighbor\n"
4329 "Send Standard and Extended Community attributes\n"
4330 "Send Standard, Large and Extended Community attributes\n"
4331 "Send Extended Community attributes\n"
4332 "Send Standard Community attributes\n"
4333 "Send Large Community attributes\n")
4335 /* neighbor soft-reconfig. */
4336 DEFUN (neighbor_soft_reconfiguration
,
4337 neighbor_soft_reconfiguration_cmd
,
4338 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4341 "Per neighbor soft reconfiguration\n"
4342 "Allow inbound soft reconfiguration for this neighbor\n")
4345 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4347 PEER_FLAG_SOFT_RECONFIG
);
4350 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4351 neighbor_soft_reconfiguration_hidden_cmd
,
4352 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4353 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4354 "Per neighbor soft reconfiguration\n"
4355 "Allow inbound soft reconfiguration for this neighbor\n")
4357 DEFUN (no_neighbor_soft_reconfiguration
,
4358 no_neighbor_soft_reconfiguration_cmd
,
4359 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4363 "Per neighbor soft reconfiguration\n"
4364 "Allow inbound soft reconfiguration for this neighbor\n")
4367 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4368 bgp_node_afi(vty
), bgp_node_safi(vty
),
4369 PEER_FLAG_SOFT_RECONFIG
);
4372 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4373 no_neighbor_soft_reconfiguration_hidden_cmd
,
4374 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4375 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4376 "Per neighbor soft reconfiguration\n"
4377 "Allow inbound soft reconfiguration for this neighbor\n")
4379 DEFUN (neighbor_route_reflector_client
,
4380 neighbor_route_reflector_client_cmd
,
4381 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4384 "Configure a neighbor as Route Reflector client\n")
4390 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4392 return CMD_WARNING_CONFIG_FAILED
;
4394 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4396 PEER_FLAG_REFLECTOR_CLIENT
);
4399 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4400 neighbor_route_reflector_client_hidden_cmd
,
4401 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4402 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4403 "Configure a neighbor as Route Reflector client\n")
4405 DEFUN (no_neighbor_route_reflector_client
,
4406 no_neighbor_route_reflector_client_cmd
,
4407 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4411 "Configure a neighbor as Route Reflector client\n")
4414 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4415 bgp_node_afi(vty
), bgp_node_safi(vty
),
4416 PEER_FLAG_REFLECTOR_CLIENT
);
4419 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4420 no_neighbor_route_reflector_client_hidden_cmd
,
4421 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4422 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4423 "Configure a neighbor as Route Reflector client\n")
4425 /* neighbor route-server-client. */
4426 DEFUN (neighbor_route_server_client
,
4427 neighbor_route_server_client_cmd
,
4428 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4431 "Configure a neighbor as Route Server client\n")
4436 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4438 return CMD_WARNING_CONFIG_FAILED
;
4439 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4441 PEER_FLAG_RSERVER_CLIENT
);
4444 ALIAS_HIDDEN(neighbor_route_server_client
,
4445 neighbor_route_server_client_hidden_cmd
,
4446 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4447 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4448 "Configure a neighbor as Route Server client\n")
4450 DEFUN (no_neighbor_route_server_client
,
4451 no_neighbor_route_server_client_cmd
,
4452 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4456 "Configure a neighbor as Route Server client\n")
4459 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4460 bgp_node_afi(vty
), bgp_node_safi(vty
),
4461 PEER_FLAG_RSERVER_CLIENT
);
4464 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4465 no_neighbor_route_server_client_hidden_cmd
,
4466 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4467 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4468 "Configure a neighbor as Route Server client\n")
4470 DEFUN (neighbor_nexthop_local_unchanged
,
4471 neighbor_nexthop_local_unchanged_cmd
,
4472 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4475 "Configure treatment of outgoing link-local nexthop attribute\n"
4476 "Leave link-local nexthop unchanged for this peer\n")
4479 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4481 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4484 DEFUN (no_neighbor_nexthop_local_unchanged
,
4485 no_neighbor_nexthop_local_unchanged_cmd
,
4486 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4490 "Configure treatment of outgoing link-local-nexthop attribute\n"
4491 "Leave link-local nexthop unchanged for this peer\n")
4494 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4495 bgp_node_afi(vty
), bgp_node_safi(vty
),
4496 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4499 DEFUN (neighbor_attr_unchanged
,
4500 neighbor_attr_unchanged_cmd
,
4501 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4504 "BGP attribute is propagated unchanged to this neighbor\n"
4505 "As-path attribute\n"
4506 "Nexthop attribute\n"
4510 char *peer_str
= argv
[1]->arg
;
4513 afi_t afi
= bgp_node_afi(vty
);
4514 safi_t safi
= bgp_node_safi(vty
);
4516 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4518 return CMD_WARNING_CONFIG_FAILED
;
4520 if (argv_find(argv
, argc
, "as-path", &idx
))
4521 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4523 if (argv_find(argv
, argc
, "next-hop", &idx
))
4524 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4526 if (argv_find(argv
, argc
, "med", &idx
))
4527 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4529 /* no flags means all of them! */
4531 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4532 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4533 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4535 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4536 && peer_af_flag_check(peer
, afi
, safi
,
4537 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4538 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4539 PEER_FLAG_AS_PATH_UNCHANGED
);
4542 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4543 && peer_af_flag_check(peer
, afi
, safi
,
4544 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4545 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4546 PEER_FLAG_NEXTHOP_UNCHANGED
);
4549 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4550 && peer_af_flag_check(peer
, afi
, safi
,
4551 PEER_FLAG_MED_UNCHANGED
)) {
4552 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4553 PEER_FLAG_MED_UNCHANGED
);
4557 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4561 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4562 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4563 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4564 "BGP attribute is propagated unchanged to this neighbor\n"
4565 "As-path attribute\n"
4566 "Nexthop attribute\n"
4569 DEFUN (no_neighbor_attr_unchanged
,
4570 no_neighbor_attr_unchanged_cmd
,
4571 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4575 "BGP attribute is propagated unchanged to this neighbor\n"
4576 "As-path attribute\n"
4577 "Nexthop attribute\n"
4581 char *peer
= argv
[2]->arg
;
4584 if (argv_find(argv
, argc
, "as-path", &idx
))
4585 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4587 if (argv_find(argv
, argc
, "next-hop", &idx
))
4588 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4590 if (argv_find(argv
, argc
, "med", &idx
))
4591 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4593 if (!flags
) // no flags means all of them!
4595 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4596 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4597 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4600 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4601 bgp_node_safi(vty
), flags
);
4605 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4606 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4607 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4608 "BGP attribute is propagated unchanged to this neighbor\n"
4609 "As-path attribute\n"
4610 "Nexthop attribute\n"
4613 /* EBGP multihop configuration. */
4614 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4615 const char *ttl_str
)
4620 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4622 return CMD_WARNING_CONFIG_FAILED
;
4625 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4630 ttl
= strtoul(ttl_str
, NULL
, 10);
4632 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4635 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4639 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4641 return CMD_WARNING_CONFIG_FAILED
;
4643 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4646 /* neighbor ebgp-multihop. */
4647 DEFUN (neighbor_ebgp_multihop
,
4648 neighbor_ebgp_multihop_cmd
,
4649 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4652 "Allow EBGP neighbors not on directly connected networks\n")
4655 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4658 DEFUN (neighbor_ebgp_multihop_ttl
,
4659 neighbor_ebgp_multihop_ttl_cmd
,
4660 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4663 "Allow EBGP neighbors not on directly connected networks\n"
4664 "maximum hop count\n")
4668 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4669 argv
[idx_number
]->arg
);
4672 DEFUN (no_neighbor_ebgp_multihop
,
4673 no_neighbor_ebgp_multihop_cmd
,
4674 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4678 "Allow EBGP neighbors not on directly connected networks\n"
4679 "maximum hop count\n")
4682 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4686 /* disable-connected-check */
4687 DEFUN (neighbor_disable_connected_check
,
4688 neighbor_disable_connected_check_cmd
,
4689 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4692 "one-hop away EBGP peer using loopback address\n"
4693 "Enforce EBGP neighbors perform multihop\n")
4696 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4697 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4700 DEFUN (no_neighbor_disable_connected_check
,
4701 no_neighbor_disable_connected_check_cmd
,
4702 "no 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_unset_vty(vty
, argv
[idx_peer
]->arg
,
4711 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4715 /* enforce-first-as */
4716 DEFUN (neighbor_enforce_first_as
,
4717 neighbor_enforce_first_as_cmd
,
4718 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4721 "Enforce the first AS for EBGP routes\n")
4725 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4726 PEER_FLAG_ENFORCE_FIRST_AS
);
4729 DEFUN (no_neighbor_enforce_first_as
,
4730 no_neighbor_enforce_first_as_cmd
,
4731 "no 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_unset_vty(vty
, argv
[idx_peer
]->arg
,
4740 PEER_FLAG_ENFORCE_FIRST_AS
);
4744 DEFUN (neighbor_description
,
4745 neighbor_description_cmd
,
4746 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4749 "Neighbor specific description\n"
4750 "Up to 80 characters describing this neighbor\n")
4757 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4759 return CMD_WARNING_CONFIG_FAILED
;
4761 str
= argv_concat(argv
, argc
, idx_line
);
4763 peer_description_set(peer
, str
);
4765 XFREE(MTYPE_TMP
, str
);
4770 DEFUN (no_neighbor_description
,
4771 no_neighbor_description_cmd
,
4772 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4776 "Neighbor specific description\n")
4781 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4783 return CMD_WARNING_CONFIG_FAILED
;
4785 peer_description_unset(peer
);
4790 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4791 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4792 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4793 "Neighbor specific description\n"
4794 "Up to 80 characters describing this neighbor\n")
4796 /* Neighbor update-source. */
4797 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4798 const char *source_str
)
4804 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4806 return CMD_WARNING_CONFIG_FAILED
;
4812 if (str2sockunion(source_str
, &su
) == 0)
4813 peer_update_source_addr_set(peer
, &su
);
4815 if (str2prefix(source_str
, &p
)) {
4817 "%% Invalid update-source, remove prefix length \n");
4818 return CMD_WARNING_CONFIG_FAILED
;
4820 peer_update_source_if_set(peer
, source_str
);
4823 peer_update_source_unset(peer
);
4828 #define BGP_UPDATE_SOURCE_HELP_STR \
4831 "Interface name (requires zebra to be running)\n"
4833 DEFUN (neighbor_update_source
,
4834 neighbor_update_source_cmd
,
4835 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4838 "Source of routing updates\n"
4839 BGP_UPDATE_SOURCE_HELP_STR
)
4843 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4844 argv
[idx_peer_2
]->arg
);
4847 DEFUN (no_neighbor_update_source
,
4848 no_neighbor_update_source_cmd
,
4849 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4853 "Source of routing updates\n"
4854 BGP_UPDATE_SOURCE_HELP_STR
)
4857 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4860 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4861 afi_t afi
, safi_t safi
,
4862 const char *rmap
, int set
)
4866 struct route_map
*route_map
;
4868 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4870 return CMD_WARNING_CONFIG_FAILED
;
4873 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4874 ret
= peer_default_originate_set(peer
, afi
, safi
,
4877 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4879 return bgp_vty_return(vty
, ret
);
4882 /* neighbor default-originate. */
4883 DEFUN (neighbor_default_originate
,
4884 neighbor_default_originate_cmd
,
4885 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4888 "Originate default route to this neighbor\n")
4891 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4893 bgp_node_safi(vty
), NULL
, 1);
4896 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4897 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4898 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4899 "Originate default route to this neighbor\n")
4901 DEFUN (neighbor_default_originate_rmap
,
4902 neighbor_default_originate_rmap_cmd
,
4903 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4906 "Originate default route to this neighbor\n"
4907 "Route-map to specify criteria to originate default\n"
4912 return peer_default_originate_set_vty(
4913 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4914 argv
[idx_word
]->arg
, 1);
4918 neighbor_default_originate_rmap
,
4919 neighbor_default_originate_rmap_hidden_cmd
,
4920 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4921 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4922 "Originate default route to this neighbor\n"
4923 "Route-map to specify criteria to originate default\n"
4926 DEFUN (no_neighbor_default_originate
,
4927 no_neighbor_default_originate_cmd
,
4928 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4932 "Originate default route to this neighbor\n"
4933 "Route-map to specify criteria to originate default\n"
4937 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4939 bgp_node_safi(vty
), NULL
, 0);
4943 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4944 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4945 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4946 "Originate default route to this neighbor\n"
4947 "Route-map to specify criteria to originate default\n"
4951 /* Set neighbor's BGP port. */
4952 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4953 const char *port_str
)
4959 peer
= peer_lookup_vty(vty
, ip_str
);
4961 return CMD_WARNING_CONFIG_FAILED
;
4964 sp
= getservbyname("bgp", "tcp");
4965 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4967 port
= strtoul(port_str
, NULL
, 10);
4970 peer_port_set(peer
, port
);
4975 /* Set specified peer's BGP port. */
4976 DEFUN (neighbor_port
,
4978 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4981 "Neighbor's BGP port\n"
4982 "TCP port number\n")
4986 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4987 argv
[idx_number
]->arg
);
4990 DEFUN (no_neighbor_port
,
4991 no_neighbor_port_cmd
,
4992 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4996 "Neighbor's BGP port\n"
4997 "TCP port number\n")
5000 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5004 /* neighbor weight. */
5005 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5006 safi_t safi
, const char *weight_str
)
5010 unsigned long weight
;
5012 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5014 return CMD_WARNING_CONFIG_FAILED
;
5016 weight
= strtoul(weight_str
, NULL
, 10);
5018 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5019 return bgp_vty_return(vty
, ret
);
5022 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5028 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5030 return CMD_WARNING_CONFIG_FAILED
;
5032 ret
= peer_weight_unset(peer
, afi
, safi
);
5033 return bgp_vty_return(vty
, ret
);
5036 DEFUN (neighbor_weight
,
5037 neighbor_weight_cmd
,
5038 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5041 "Set default weight for routes from this neighbor\n"
5046 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5047 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5050 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5051 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5052 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5053 "Set default weight for routes from this neighbor\n"
5056 DEFUN (no_neighbor_weight
,
5057 no_neighbor_weight_cmd
,
5058 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5062 "Set default weight for routes from this neighbor\n"
5066 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5067 bgp_node_afi(vty
), bgp_node_safi(vty
));
5070 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5071 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5072 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5073 "Set default weight for routes from this neighbor\n"
5077 /* Override capability negotiation. */
5078 DEFUN (neighbor_override_capability
,
5079 neighbor_override_capability_cmd
,
5080 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5083 "Override capability negotiation result\n")
5086 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5087 PEER_FLAG_OVERRIDE_CAPABILITY
);
5090 DEFUN (no_neighbor_override_capability
,
5091 no_neighbor_override_capability_cmd
,
5092 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5096 "Override capability negotiation result\n")
5099 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5100 PEER_FLAG_OVERRIDE_CAPABILITY
);
5103 DEFUN (neighbor_strict_capability
,
5104 neighbor_strict_capability_cmd
,
5105 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5108 "Strict capability negotiation match\n")
5112 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5113 PEER_FLAG_STRICT_CAP_MATCH
);
5116 DEFUN (no_neighbor_strict_capability
,
5117 no_neighbor_strict_capability_cmd
,
5118 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5122 "Strict capability negotiation match\n")
5126 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5127 PEER_FLAG_STRICT_CAP_MATCH
);
5130 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5131 const char *keep_str
, const char *hold_str
)
5138 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5140 return CMD_WARNING_CONFIG_FAILED
;
5142 keepalive
= strtoul(keep_str
, NULL
, 10);
5143 holdtime
= strtoul(hold_str
, NULL
, 10);
5145 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5147 return bgp_vty_return(vty
, ret
);
5150 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5155 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5157 return CMD_WARNING_CONFIG_FAILED
;
5159 ret
= peer_timers_unset(peer
);
5161 return bgp_vty_return(vty
, ret
);
5164 DEFUN (neighbor_timers
,
5165 neighbor_timers_cmd
,
5166 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5169 "BGP per neighbor timers\n"
5170 "Keepalive interval\n"
5175 int idx_number_2
= 4;
5176 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5177 argv
[idx_number
]->arg
,
5178 argv
[idx_number_2
]->arg
);
5181 DEFUN (no_neighbor_timers
,
5182 no_neighbor_timers_cmd
,
5183 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5187 "BGP per neighbor timers\n"
5188 "Keepalive interval\n"
5192 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5196 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5197 const char *time_str
)
5203 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5205 return CMD_WARNING_CONFIG_FAILED
;
5207 connect
= strtoul(time_str
, NULL
, 10);
5209 ret
= peer_timers_connect_set(peer
, connect
);
5211 return bgp_vty_return(vty
, ret
);
5214 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5219 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5221 return CMD_WARNING_CONFIG_FAILED
;
5223 ret
= peer_timers_connect_unset(peer
);
5225 return bgp_vty_return(vty
, ret
);
5228 DEFUN (neighbor_timers_connect
,
5229 neighbor_timers_connect_cmd
,
5230 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5233 "BGP per neighbor timers\n"
5234 "BGP connect timer\n"
5239 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5240 argv
[idx_number
]->arg
);
5243 DEFUN (no_neighbor_timers_connect
,
5244 no_neighbor_timers_connect_cmd
,
5245 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5249 "BGP per neighbor timers\n"
5250 "BGP connect timer\n"
5254 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5258 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5259 const char *time_str
, int set
)
5263 uint32_t routeadv
= 0;
5265 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5267 return CMD_WARNING_CONFIG_FAILED
;
5270 routeadv
= strtoul(time_str
, NULL
, 10);
5273 ret
= peer_advertise_interval_set(peer
, routeadv
);
5275 ret
= peer_advertise_interval_unset(peer
);
5277 return bgp_vty_return(vty
, ret
);
5280 DEFUN (neighbor_advertise_interval
,
5281 neighbor_advertise_interval_cmd
,
5282 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5285 "Minimum interval between sending BGP routing updates\n"
5286 "time in seconds\n")
5290 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5291 argv
[idx_number
]->arg
, 1);
5294 DEFUN (no_neighbor_advertise_interval
,
5295 no_neighbor_advertise_interval_cmd
,
5296 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5300 "Minimum interval between sending BGP routing updates\n"
5301 "time in seconds\n")
5304 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5308 /* Time to wait before processing route-map updates */
5309 DEFUN (bgp_set_route_map_delay_timer
,
5310 bgp_set_route_map_delay_timer_cmd
,
5311 "bgp route-map delay-timer (0-600)",
5313 "BGP route-map delay timer\n"
5314 "Time in secs to wait before processing route-map changes\n"
5315 "0 disables the timer, no route updates happen when route-maps change\n")
5318 uint32_t rmap_delay_timer
;
5320 if (argv
[idx_number
]->arg
) {
5321 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5322 bm
->rmap_update_timer
= rmap_delay_timer
;
5324 /* if the dynamic update handling is being disabled, and a timer
5326 * running, stop the timer and act as if the timer has already
5329 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5330 BGP_TIMER_OFF(bm
->t_rmap_update
);
5331 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5336 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5337 return CMD_WARNING_CONFIG_FAILED
;
5341 DEFUN (no_bgp_set_route_map_delay_timer
,
5342 no_bgp_set_route_map_delay_timer_cmd
,
5343 "no bgp route-map delay-timer [(0-600)]",
5346 "Default BGP route-map delay timer\n"
5347 "Reset to default time to wait for processing route-map changes\n"
5348 "0 disables the timer, no route updates happen when route-maps change\n")
5351 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5357 /* neighbor interface */
5358 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5363 peer
= peer_lookup_vty(vty
, ip_str
);
5364 if (!peer
|| peer
->conf_if
) {
5365 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5366 return CMD_WARNING_CONFIG_FAILED
;
5370 peer_interface_set(peer
, str
);
5372 peer_interface_unset(peer
);
5377 DEFUN (neighbor_interface
,
5378 neighbor_interface_cmd
,
5379 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5387 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5390 DEFUN (no_neighbor_interface
,
5391 no_neighbor_interface_cmd
,
5392 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5400 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5403 DEFUN (neighbor_distribute_list
,
5404 neighbor_distribute_list_cmd
,
5405 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5408 "Filter updates to/from this neighbor\n"
5409 "IP access-list number\n"
5410 "IP access-list number (expanded range)\n"
5411 "IP Access-list name\n"
5412 "Filter incoming updates\n"
5413 "Filter outgoing updates\n")
5420 const char *pstr
= argv
[idx_peer
]->arg
;
5421 const char *acl
= argv
[idx_acl
]->arg
;
5422 const char *inout
= argv
[argc
- 1]->text
;
5424 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5426 return CMD_WARNING_CONFIG_FAILED
;
5428 /* Check filter direction. */
5429 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5430 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5433 return bgp_vty_return(vty
, ret
);
5437 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5438 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5439 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5440 "Filter updates to/from this neighbor\n"
5441 "IP access-list number\n"
5442 "IP access-list number (expanded range)\n"
5443 "IP Access-list name\n"
5444 "Filter incoming updates\n"
5445 "Filter outgoing updates\n")
5447 DEFUN (no_neighbor_distribute_list
,
5448 no_neighbor_distribute_list_cmd
,
5449 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5453 "Filter updates to/from this neighbor\n"
5454 "IP access-list number\n"
5455 "IP access-list number (expanded range)\n"
5456 "IP Access-list name\n"
5457 "Filter incoming updates\n"
5458 "Filter outgoing updates\n")
5464 const char *pstr
= argv
[idx_peer
]->arg
;
5465 const char *inout
= argv
[argc
- 1]->text
;
5467 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5469 return CMD_WARNING_CONFIG_FAILED
;
5471 /* Check filter direction. */
5472 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5473 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5476 return bgp_vty_return(vty
, ret
);
5480 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5481 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5482 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5483 "Filter updates to/from this neighbor\n"
5484 "IP access-list number\n"
5485 "IP access-list number (expanded range)\n"
5486 "IP Access-list name\n"
5487 "Filter incoming updates\n"
5488 "Filter outgoing updates\n")
5490 /* Set prefix list to the peer. */
5491 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5492 afi_t afi
, safi_t safi
,
5493 const char *name_str
,
5494 const char *direct_str
)
5497 int direct
= FILTER_IN
;
5500 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5502 return CMD_WARNING_CONFIG_FAILED
;
5504 /* Check filter direction. */
5505 if (strncmp(direct_str
, "i", 1) == 0)
5507 else if (strncmp(direct_str
, "o", 1) == 0)
5508 direct
= FILTER_OUT
;
5510 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5512 return bgp_vty_return(vty
, ret
);
5515 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5516 afi_t afi
, safi_t safi
,
5517 const char *direct_str
)
5521 int direct
= FILTER_IN
;
5523 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5525 return CMD_WARNING_CONFIG_FAILED
;
5527 /* Check filter direction. */
5528 if (strncmp(direct_str
, "i", 1) == 0)
5530 else if (strncmp(direct_str
, "o", 1) == 0)
5531 direct
= FILTER_OUT
;
5533 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5535 return bgp_vty_return(vty
, ret
);
5538 DEFUN (neighbor_prefix_list
,
5539 neighbor_prefix_list_cmd
,
5540 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5543 "Filter updates to/from this neighbor\n"
5544 "Name of a prefix list\n"
5545 "Filter incoming updates\n"
5546 "Filter outgoing updates\n")
5551 return peer_prefix_list_set_vty(
5552 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5553 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5556 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5557 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5558 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5559 "Filter updates to/from this neighbor\n"
5560 "Name of a prefix list\n"
5561 "Filter incoming updates\n"
5562 "Filter outgoing updates\n")
5564 DEFUN (no_neighbor_prefix_list
,
5565 no_neighbor_prefix_list_cmd
,
5566 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5570 "Filter updates to/from this neighbor\n"
5571 "Name of a prefix list\n"
5572 "Filter incoming updates\n"
5573 "Filter outgoing updates\n")
5577 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5578 bgp_node_afi(vty
), bgp_node_safi(vty
),
5579 argv
[idx_in_out
]->arg
);
5582 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5583 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5584 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5585 "Filter updates to/from this neighbor\n"
5586 "Name of a prefix list\n"
5587 "Filter incoming updates\n"
5588 "Filter outgoing updates\n")
5590 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5591 safi_t safi
, const char *name_str
,
5592 const char *direct_str
)
5596 int direct
= FILTER_IN
;
5598 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5600 return CMD_WARNING_CONFIG_FAILED
;
5602 /* Check filter direction. */
5603 if (strncmp(direct_str
, "i", 1) == 0)
5605 else if (strncmp(direct_str
, "o", 1) == 0)
5606 direct
= FILTER_OUT
;
5608 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5610 return bgp_vty_return(vty
, ret
);
5613 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5614 safi_t safi
, const char *direct_str
)
5618 int direct
= FILTER_IN
;
5620 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5622 return CMD_WARNING_CONFIG_FAILED
;
5624 /* Check filter direction. */
5625 if (strncmp(direct_str
, "i", 1) == 0)
5627 else if (strncmp(direct_str
, "o", 1) == 0)
5628 direct
= FILTER_OUT
;
5630 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5632 return bgp_vty_return(vty
, ret
);
5635 DEFUN (neighbor_filter_list
,
5636 neighbor_filter_list_cmd
,
5637 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5640 "Establish BGP filters\n"
5641 "AS path access-list name\n"
5642 "Filter incoming routes\n"
5643 "Filter outgoing routes\n")
5648 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5649 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5650 argv
[idx_in_out
]->arg
);
5653 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5654 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5655 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5656 "Establish BGP filters\n"
5657 "AS path access-list name\n"
5658 "Filter incoming routes\n"
5659 "Filter outgoing routes\n")
5661 DEFUN (no_neighbor_filter_list
,
5662 no_neighbor_filter_list_cmd
,
5663 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5667 "Establish BGP filters\n"
5668 "AS path access-list name\n"
5669 "Filter incoming routes\n"
5670 "Filter outgoing routes\n")
5674 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5675 bgp_node_afi(vty
), bgp_node_safi(vty
),
5676 argv
[idx_in_out
]->arg
);
5679 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5680 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5681 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5682 "Establish BGP filters\n"
5683 "AS path access-list name\n"
5684 "Filter incoming routes\n"
5685 "Filter outgoing routes\n")
5687 /* Set route-map to the peer. */
5688 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5689 afi_t afi
, safi_t safi
, const char *name_str
,
5690 const char *direct_str
)
5694 int direct
= RMAP_IN
;
5695 struct route_map
*route_map
;
5697 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5699 return CMD_WARNING_CONFIG_FAILED
;
5701 /* Check filter direction. */
5702 if (strncmp(direct_str
, "in", 2) == 0)
5704 else if (strncmp(direct_str
, "o", 1) == 0)
5707 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5708 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5710 return bgp_vty_return(vty
, ret
);
5713 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5714 afi_t afi
, safi_t safi
,
5715 const char *direct_str
)
5719 int direct
= RMAP_IN
;
5721 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5723 return CMD_WARNING_CONFIG_FAILED
;
5725 /* Check filter direction. */
5726 if (strncmp(direct_str
, "in", 2) == 0)
5728 else if (strncmp(direct_str
, "o", 1) == 0)
5731 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5733 return bgp_vty_return(vty
, ret
);
5736 DEFUN (neighbor_route_map
,
5737 neighbor_route_map_cmd
,
5738 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5741 "Apply route map to neighbor\n"
5742 "Name of route map\n"
5743 "Apply map to incoming routes\n"
5744 "Apply map to outbound routes\n")
5749 return peer_route_map_set_vty(
5750 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5751 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5754 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5755 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5756 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5757 "Apply route map to neighbor\n"
5758 "Name of route map\n"
5759 "Apply map to incoming routes\n"
5760 "Apply map to outbound routes\n")
5762 DEFUN (no_neighbor_route_map
,
5763 no_neighbor_route_map_cmd
,
5764 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5768 "Apply route map to neighbor\n"
5769 "Name of route map\n"
5770 "Apply map to incoming routes\n"
5771 "Apply map to outbound routes\n")
5775 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5776 bgp_node_afi(vty
), bgp_node_safi(vty
),
5777 argv
[idx_in_out
]->arg
);
5780 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5781 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5782 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5783 "Apply route map to neighbor\n"
5784 "Name of route map\n"
5785 "Apply map to incoming routes\n"
5786 "Apply map to outbound routes\n")
5788 /* Set unsuppress-map to the peer. */
5789 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5790 afi_t afi
, safi_t safi
,
5791 const char *name_str
)
5795 struct route_map
*route_map
;
5797 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5799 return CMD_WARNING_CONFIG_FAILED
;
5801 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5802 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5804 return bgp_vty_return(vty
, ret
);
5807 /* Unset route-map from the peer. */
5808 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5809 afi_t afi
, safi_t safi
)
5814 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5816 return CMD_WARNING_CONFIG_FAILED
;
5818 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5820 return bgp_vty_return(vty
, ret
);
5823 DEFUN (neighbor_unsuppress_map
,
5824 neighbor_unsuppress_map_cmd
,
5825 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5828 "Route-map to selectively unsuppress suppressed routes\n"
5829 "Name of route map\n")
5833 return peer_unsuppress_map_set_vty(
5834 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5835 argv
[idx_word
]->arg
);
5838 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5839 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5840 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5841 "Route-map to selectively unsuppress suppressed routes\n"
5842 "Name of route map\n")
5844 DEFUN (no_neighbor_unsuppress_map
,
5845 no_neighbor_unsuppress_map_cmd
,
5846 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5850 "Route-map to selectively unsuppress suppressed routes\n"
5851 "Name of route map\n")
5854 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5856 bgp_node_safi(vty
));
5859 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5860 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5861 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5862 "Route-map to selectively unsuppress suppressed routes\n"
5863 "Name of route map\n")
5865 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5866 afi_t afi
, safi_t safi
,
5867 const char *num_str
,
5868 const char *threshold_str
, int warning
,
5869 const char *restart_str
)
5877 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5879 return CMD_WARNING_CONFIG_FAILED
;
5881 max
= strtoul(num_str
, NULL
, 10);
5883 threshold
= atoi(threshold_str
);
5885 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5888 restart
= atoi(restart_str
);
5892 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5895 return bgp_vty_return(vty
, ret
);
5898 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5899 afi_t afi
, safi_t safi
)
5904 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5906 return CMD_WARNING_CONFIG_FAILED
;
5908 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5910 return bgp_vty_return(vty
, ret
);
5913 /* Maximum number of prefix configuration. prefix count is different
5914 for each peer configuration. So this configuration can be set for
5915 each peer configuration. */
5916 DEFUN (neighbor_maximum_prefix
,
5917 neighbor_maximum_prefix_cmd
,
5918 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5921 "Maximum number of prefix accept from this peer\n"
5922 "maximum no. of prefix limit\n")
5926 return peer_maximum_prefix_set_vty(
5927 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5928 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5931 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5932 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5933 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5934 "Maximum number of prefix accept from this peer\n"
5935 "maximum no. of prefix limit\n")
5937 DEFUN (neighbor_maximum_prefix_threshold
,
5938 neighbor_maximum_prefix_threshold_cmd
,
5939 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5942 "Maximum number of prefix accept from this peer\n"
5943 "maximum no. of prefix limit\n"
5944 "Threshold value (%) at which to generate a warning msg\n")
5948 int idx_number_2
= 4;
5949 return peer_maximum_prefix_set_vty(
5950 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5951 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5955 neighbor_maximum_prefix_threshold
,
5956 neighbor_maximum_prefix_threshold_hidden_cmd
,
5957 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5958 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5959 "Maximum number of prefix accept from this peer\n"
5960 "maximum no. of prefix limit\n"
5961 "Threshold value (%) at which to generate a warning msg\n")
5963 DEFUN (neighbor_maximum_prefix_warning
,
5964 neighbor_maximum_prefix_warning_cmd
,
5965 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5968 "Maximum number of prefix accept from this peer\n"
5969 "maximum no. of prefix limit\n"
5970 "Only give warning message when limit is exceeded\n")
5974 return peer_maximum_prefix_set_vty(
5975 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5976 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5980 neighbor_maximum_prefix_warning
,
5981 neighbor_maximum_prefix_warning_hidden_cmd
,
5982 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5983 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5984 "Maximum number of prefix accept from this peer\n"
5985 "maximum no. of prefix limit\n"
5986 "Only give warning message when limit is exceeded\n")
5988 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5989 neighbor_maximum_prefix_threshold_warning_cmd
,
5990 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5993 "Maximum number of prefix accept from this peer\n"
5994 "maximum no. of prefix limit\n"
5995 "Threshold value (%) at which to generate a warning msg\n"
5996 "Only give warning message when limit is exceeded\n")
6000 int idx_number_2
= 4;
6001 return peer_maximum_prefix_set_vty(
6002 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6003 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6007 neighbor_maximum_prefix_threshold_warning
,
6008 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6009 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6010 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6011 "Maximum number of prefix accept from this peer\n"
6012 "maximum no. of prefix limit\n"
6013 "Threshold value (%) at which to generate a warning msg\n"
6014 "Only give warning message when limit is exceeded\n")
6016 DEFUN (neighbor_maximum_prefix_restart
,
6017 neighbor_maximum_prefix_restart_cmd
,
6018 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6021 "Maximum number of prefix accept from this peer\n"
6022 "maximum no. of prefix limit\n"
6023 "Restart bgp connection after limit is exceeded\n"
6024 "Restart interval in minutes\n")
6028 int idx_number_2
= 5;
6029 return peer_maximum_prefix_set_vty(
6030 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6031 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6035 neighbor_maximum_prefix_restart
,
6036 neighbor_maximum_prefix_restart_hidden_cmd
,
6037 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6038 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6039 "Maximum number of prefix accept from this peer\n"
6040 "maximum no. of prefix limit\n"
6041 "Restart bgp connection after limit is exceeded\n"
6042 "Restart interval in minutes\n")
6044 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6045 neighbor_maximum_prefix_threshold_restart_cmd
,
6046 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6049 "Maximum number of prefixes to accept from this peer\n"
6050 "maximum no. of prefix limit\n"
6051 "Threshold value (%) at which to generate a warning msg\n"
6052 "Restart bgp connection after limit is exceeded\n"
6053 "Restart interval in minutes\n")
6057 int idx_number_2
= 4;
6058 int idx_number_3
= 6;
6059 return peer_maximum_prefix_set_vty(
6060 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6061 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6062 argv
[idx_number_3
]->arg
);
6066 neighbor_maximum_prefix_threshold_restart
,
6067 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6068 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6069 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6070 "Maximum number of prefixes to accept from this peer\n"
6071 "maximum no. of prefix limit\n"
6072 "Threshold value (%) at which to generate a warning msg\n"
6073 "Restart bgp connection after limit is exceeded\n"
6074 "Restart interval in minutes\n")
6076 DEFUN (no_neighbor_maximum_prefix
,
6077 no_neighbor_maximum_prefix_cmd
,
6078 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6082 "Maximum number of prefixes to accept from this peer\n"
6083 "maximum no. of prefix limit\n"
6084 "Threshold value (%) at which to generate a warning msg\n"
6085 "Restart bgp connection after limit is exceeded\n"
6086 "Restart interval in minutes\n"
6087 "Only give warning message when limit is exceeded\n")
6090 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6092 bgp_node_safi(vty
));
6096 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6097 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6098 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6099 "Maximum number of prefixes to accept from this peer\n"
6100 "maximum no. of prefix limit\n"
6101 "Threshold value (%) at which to generate a warning msg\n"
6102 "Restart bgp connection after limit is exceeded\n"
6103 "Restart interval in minutes\n"
6104 "Only give warning message when limit is exceeded\n")
6107 /* "neighbor allowas-in" */
6108 DEFUN (neighbor_allowas_in
,
6109 neighbor_allowas_in_cmd
,
6110 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6113 "Accept as-path with my AS present in it\n"
6114 "Number of occurences of AS number\n"
6115 "Only accept my AS in the as-path if the route was originated in my AS\n")
6118 int idx_number_origin
= 3;
6124 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6126 return CMD_WARNING_CONFIG_FAILED
;
6128 if (argc
<= idx_number_origin
)
6131 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6134 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6137 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6140 return bgp_vty_return(vty
, ret
);
6144 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6145 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6146 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6147 "Accept as-path with my AS present in it\n"
6148 "Number of occurences of AS number\n"
6149 "Only accept my AS in the as-path if the route was originated in my AS\n")
6151 DEFUN (no_neighbor_allowas_in
,
6152 no_neighbor_allowas_in_cmd
,
6153 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6157 "allow local ASN appears in aspath attribute\n"
6158 "Number of occurences of AS number\n"
6159 "Only accept my AS in the as-path if the route was originated in my AS\n")
6165 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6167 return CMD_WARNING_CONFIG_FAILED
;
6169 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6170 bgp_node_safi(vty
));
6172 return bgp_vty_return(vty
, ret
);
6176 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6177 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6178 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6179 "allow local ASN appears in aspath attribute\n"
6180 "Number of occurences of AS number\n"
6181 "Only accept my AS in the as-path if the route was originated in my AS\n")
6183 DEFUN (neighbor_ttl_security
,
6184 neighbor_ttl_security_cmd
,
6185 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6188 "BGP ttl-security parameters\n"
6189 "Specify the maximum number of hops to the BGP peer\n"
6190 "Number of hops to BGP peer\n")
6197 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6199 return CMD_WARNING_CONFIG_FAILED
;
6201 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6204 * If 'neighbor swpX', then this is for directly connected peers,
6205 * we should not accept a ttl-security hops value greater than 1.
6207 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6209 "%s is directly connected peer, hops cannot exceed 1\n",
6210 argv
[idx_peer
]->arg
);
6211 return CMD_WARNING_CONFIG_FAILED
;
6214 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6217 DEFUN (no_neighbor_ttl_security
,
6218 no_neighbor_ttl_security_cmd
,
6219 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6223 "BGP ttl-security parameters\n"
6224 "Specify the maximum number of hops to the BGP peer\n"
6225 "Number of hops to BGP peer\n")
6230 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6232 return CMD_WARNING_CONFIG_FAILED
;
6234 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6237 DEFUN (neighbor_addpath_tx_all_paths
,
6238 neighbor_addpath_tx_all_paths_cmd
,
6239 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6242 "Use addpath to advertise all paths to a neighbor\n")
6247 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6249 return CMD_WARNING_CONFIG_FAILED
;
6251 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6256 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6257 neighbor_addpath_tx_all_paths_hidden_cmd
,
6258 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6259 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6260 "Use addpath to advertise all paths to a neighbor\n")
6262 DEFUN (no_neighbor_addpath_tx_all_paths
,
6263 no_neighbor_addpath_tx_all_paths_cmd
,
6264 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6268 "Use addpath to advertise all paths to a neighbor\n")
6273 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6275 return CMD_WARNING_CONFIG_FAILED
;
6277 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6278 != BGP_ADDPATH_ALL
) {
6280 "%% Peer not currently configured to transmit all paths.");
6281 return CMD_WARNING_CONFIG_FAILED
;
6284 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6290 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6291 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6292 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6293 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6294 "Use addpath to advertise all paths to a neighbor\n")
6296 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6297 neighbor_addpath_tx_bestpath_per_as_cmd
,
6298 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6301 "Use addpath to advertise the bestpath per each neighboring AS\n")
6306 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6308 return CMD_WARNING_CONFIG_FAILED
;
6310 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6311 BGP_ADDPATH_BEST_PER_AS
);
6316 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6317 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6318 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6319 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6320 "Use addpath to advertise the bestpath per each neighboring AS\n")
6322 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6323 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6324 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6328 "Use addpath to advertise the bestpath per each neighboring AS\n")
6333 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6335 return CMD_WARNING_CONFIG_FAILED
;
6337 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6338 != BGP_ADDPATH_BEST_PER_AS
) {
6340 "%% Peer not currently configured to transmit all best path per as.");
6341 return CMD_WARNING_CONFIG_FAILED
;
6344 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6350 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6351 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6352 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6353 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6354 "Use addpath to advertise the bestpath per each neighboring AS\n")
6356 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6357 struct ecommunity
**list
)
6359 struct ecommunity
*ecom
= NULL
;
6360 struct ecommunity
*ecomadd
;
6362 for (; argc
; --argc
, ++argv
) {
6364 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6365 ECOMMUNITY_ROUTE_TARGET
, 0);
6367 vty_out(vty
, "Malformed community-list value\n");
6369 ecommunity_free(&ecom
);
6370 return CMD_WARNING_CONFIG_FAILED
;
6374 ecommunity_merge(ecom
, ecomadd
);
6375 ecommunity_free(&ecomadd
);
6382 ecommunity_free(&*list
);
6390 * v2vimport is true if we are handling a `import vrf ...` command
6392 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6396 switch (vty
->node
) {
6405 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6410 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6411 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6412 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6413 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6415 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6419 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6420 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6421 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6422 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6424 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6431 DEFPY (af_rd_vpn_export
,
6432 af_rd_vpn_export_cmd
,
6433 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6435 "Specify route distinguisher\n"
6436 "Between current address-family and vpn\n"
6437 "For routes leaked from current address-family to vpn\n"
6438 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6440 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6441 struct prefix_rd prd
;
6447 if (argv_find(argv
, argc
, "no", &idx
))
6451 ret
= str2prefix_rd(rd_str
, &prd
);
6453 vty_out(vty
, "%% Malformed rd\n");
6454 return CMD_WARNING_CONFIG_FAILED
;
6458 afi
= vpn_policy_getafi(vty
, bgp
, false);
6460 return CMD_WARNING_CONFIG_FAILED
;
6463 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6465 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6466 bgp_get_default(), bgp
);
6469 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6470 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6471 BGP_VPN_POLICY_TOVPN_RD_SET
);
6473 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6474 BGP_VPN_POLICY_TOVPN_RD_SET
);
6477 /* post-change: re-export vpn routes */
6478 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6479 bgp_get_default(), bgp
);
6484 ALIAS (af_rd_vpn_export
,
6485 af_no_rd_vpn_export_cmd
,
6488 "Specify route distinguisher\n"
6489 "Between current address-family and vpn\n"
6490 "For routes leaked from current address-family to vpn\n")
6492 DEFPY (af_label_vpn_export
,
6493 af_label_vpn_export_cmd
,
6494 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6496 "label value for VRF\n"
6497 "Between current address-family and vpn\n"
6498 "For routes leaked from current address-family to vpn\n"
6499 "Label Value <0-1048575>\n"
6500 "Automatically assign a label\n")
6502 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6503 mpls_label_t label
= MPLS_LABEL_NONE
;
6508 if (argv_find(argv
, argc
, "no", &idx
))
6511 /* If "no ...", squash trailing parameter */
6517 label
= label_val
; /* parser should force unsigned */
6520 afi
= vpn_policy_getafi(vty
, bgp
, false);
6522 return CMD_WARNING_CONFIG_FAILED
;
6525 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6526 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6531 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6533 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6534 bgp_get_default(), bgp
);
6536 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6537 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6539 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6542 * label has previously been automatically
6543 * assigned by labelpool: release it
6545 * NB if tovpn_label == MPLS_LABEL_NONE it
6546 * means the automatic assignment is in flight
6547 * and therefore the labelpool callback must
6548 * detect that the auto label is not needed.
6551 bgp_lp_release(LP_TYPE_VRF
,
6552 &bgp
->vpn_policy
[afi
],
6553 bgp
->vpn_policy
[afi
].tovpn_label
);
6555 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6556 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6559 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6561 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6562 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6563 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6564 vpn_leak_label_callback
);
6567 /* post-change: re-export vpn routes */
6568 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6569 bgp_get_default(), bgp
);
6574 ALIAS (af_label_vpn_export
,
6575 af_no_label_vpn_export_cmd
,
6576 "no label vpn export",
6578 "label value for VRF\n"
6579 "Between current address-family and vpn\n"
6580 "For routes leaked from current address-family to vpn\n")
6582 DEFPY (af_nexthop_vpn_export
,
6583 af_nexthop_vpn_export_cmd
,
6584 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6586 "Specify next hop to use for VRF advertised prefixes\n"
6587 "Between current address-family and vpn\n"
6588 "For routes leaked from current address-family to vpn\n"
6592 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6598 if (argv_find(argv
, argc
, "no", &idx
))
6602 if (!sockunion2hostprefix(nexthop_str
, &p
))
6603 return CMD_WARNING_CONFIG_FAILED
;
6606 afi
= vpn_policy_getafi(vty
, bgp
, false);
6608 return CMD_WARNING_CONFIG_FAILED
;
6611 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6613 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6614 bgp_get_default(), bgp
);
6617 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6618 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6619 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6621 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6622 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6625 /* post-change: re-export vpn routes */
6626 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6627 bgp_get_default(), bgp
);
6632 ALIAS (af_nexthop_vpn_export
,
6633 af_no_nexthop_vpn_export_cmd
,
6634 "no nexthop vpn export",
6636 "Specify next hop to use for VRF advertised prefixes\n"
6637 "Between current address-family and vpn\n"
6638 "For routes leaked from current address-family to vpn\n")
6640 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6642 if (!strcmp(dstr
, "import")) {
6643 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6644 } else if (!strcmp(dstr
, "export")) {
6645 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6646 } else if (!strcmp(dstr
, "both")) {
6647 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6648 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6650 vty_out(vty
, "%% direction parse error\n");
6651 return CMD_WARNING_CONFIG_FAILED
;
6656 DEFPY (af_rt_vpn_imexport
,
6657 af_rt_vpn_imexport_cmd
,
6658 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6660 "Specify route target list\n"
6661 "Specify route target list\n"
6662 "Between current address-family and vpn\n"
6663 "For routes leaked from vpn to current address-family: match any\n"
6664 "For routes leaked from current address-family to vpn: set\n"
6665 "both import: match any and export: set\n"
6666 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6668 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6670 struct ecommunity
*ecom
= NULL
;
6671 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6672 vpn_policy_direction_t dir
;
6677 if (argv_find(argv
, argc
, "no", &idx
))
6680 afi
= vpn_policy_getafi(vty
, bgp
, false);
6682 return CMD_WARNING_CONFIG_FAILED
;
6684 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6685 if (ret
!= CMD_SUCCESS
)
6689 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6690 vty_out(vty
, "%% Missing RTLIST\n");
6691 return CMD_WARNING_CONFIG_FAILED
;
6693 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6694 if (ret
!= CMD_SUCCESS
) {
6699 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6703 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6706 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6708 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6709 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6710 ecommunity_dup(ecom
);
6712 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6714 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6715 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6718 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6722 ecommunity_free(&ecom
);
6727 ALIAS (af_rt_vpn_imexport
,
6728 af_no_rt_vpn_imexport_cmd
,
6729 "no <rt|route-target> vpn <import|export|both>$direction_str",
6731 "Specify route target list\n"
6732 "Specify route target list\n"
6733 "Between current address-family and vpn\n"
6734 "For routes leaked from vpn to current address-family\n"
6735 "For routes leaked from current address-family to vpn\n"
6736 "both import and export\n")
6738 DEFPY (af_route_map_vpn_imexport
,
6739 af_route_map_vpn_imexport_cmd
,
6740 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6741 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6743 "Specify route map\n"
6744 "Between current address-family and vpn\n"
6745 "For routes leaked from vpn to current address-family\n"
6746 "For routes leaked from current address-family to vpn\n"
6747 "name of route-map\n")
6749 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6751 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6752 vpn_policy_direction_t dir
;
6757 if (argv_find(argv
, argc
, "no", &idx
))
6760 afi
= vpn_policy_getafi(vty
, bgp
, false);
6762 return CMD_WARNING_CONFIG_FAILED
;
6764 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6765 if (ret
!= CMD_SUCCESS
)
6768 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6772 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6775 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6776 XFREE(MTYPE_ROUTE_MAP_NAME
,
6777 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6778 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6779 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6780 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6781 route_map_lookup_warn_noexist(vty
, rmap_str
);
6782 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6785 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6786 XFREE(MTYPE_ROUTE_MAP_NAME
,
6787 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6788 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6789 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6792 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6798 ALIAS (af_route_map_vpn_imexport
,
6799 af_no_route_map_vpn_imexport_cmd
,
6800 "no route-map vpn <import|export>$direction_str",
6802 "Specify route map\n"
6803 "Between current address-family and vpn\n"
6804 "For routes leaked from vpn to current address-family\n"
6805 "For routes leaked from current address-family to vpn\n")
6807 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6808 "[no] import vrf route-map RMAP$rmap_str",
6810 "Import routes from another VRF\n"
6811 "Vrf routes being filtered\n"
6812 "Specify route map\n"
6813 "name of route-map\n")
6815 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6816 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6820 struct bgp
*bgp_default
;
6822 if (argv_find(argv
, argc
, "no", &idx
))
6825 afi
= vpn_policy_getafi(vty
, bgp
, true);
6827 return CMD_WARNING_CONFIG_FAILED
;
6829 bgp_default
= bgp_get_default();
6834 /* Auto-create assuming the same AS */
6835 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6836 BGP_INSTANCE_TYPE_DEFAULT
);
6840 "VRF default is not configured as a bgp instance\n");
6845 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6848 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6849 XFREE(MTYPE_ROUTE_MAP_NAME
,
6850 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6851 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6852 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6853 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6854 route_map_lookup_warn_noexist(vty
, rmap_str
);
6855 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6858 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6859 XFREE(MTYPE_ROUTE_MAP_NAME
,
6860 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6861 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6862 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6865 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6870 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6871 "no import vrf route-map",
6873 "Import routes from another VRF\n"
6874 "Vrf routes being filtered\n"
6875 "Specify route map\n")
6877 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6878 "[no] import vrf VIEWVRFNAME$import_name",
6880 "Import routes from another VRF\n"
6881 "VRF to import from\n"
6882 "The name of the VRF\n")
6884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6885 struct listnode
*node
;
6886 struct bgp
*vrf_bgp
, *bgp_default
;
6889 bool remove
= false;
6892 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6896 if (import_name
== NULL
) {
6897 vty_out(vty
, "%% Missing import name\n");
6901 if (argv_find(argv
, argc
, "no", &idx
))
6904 afi
= vpn_policy_getafi(vty
, bgp
, true);
6906 return CMD_WARNING_CONFIG_FAILED
;
6908 safi
= bgp_node_safi(vty
);
6910 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6911 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6912 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6913 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6914 remove
? "unimport" : "import", import_name
);
6918 bgp_default
= bgp_get_default();
6920 /* Auto-create assuming the same AS */
6921 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6922 BGP_INSTANCE_TYPE_DEFAULT
);
6926 "VRF default is not configured as a bgp instance\n");
6931 vrf_bgp
= bgp_lookup_by_name(import_name
);
6933 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6934 vrf_bgp
= bgp_default
;
6936 /* Auto-create assuming the same AS */
6937 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6941 "VRF %s is not configured as a bgp instance\n",
6948 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6950 /* Already importing from "import_vrf"? */
6951 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6953 if (strcmp(vname
, import_name
) == 0)
6957 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6963 /* This command is valid only in a bgp vrf instance or the default instance */
6964 DEFPY (bgp_imexport_vpn
,
6965 bgp_imexport_vpn_cmd
,
6966 "[no] <import|export>$direction_str vpn",
6968 "Import routes to this address-family\n"
6969 "Export routes from this address-family\n"
6970 "to/from default instance VPN RIB\n")
6972 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6979 vpn_policy_direction_t dir
;
6981 if (argv_find(argv
, argc
, "no", &idx
))
6984 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6985 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6987 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6988 return CMD_WARNING_CONFIG_FAILED
;
6991 afi
= bgp_node_afi(vty
);
6992 safi
= bgp_node_safi(vty
);
6993 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6994 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6995 return CMD_WARNING_CONFIG_FAILED
;
6998 if (!strcmp(direction_str
, "import")) {
6999 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7000 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7001 } else if (!strcmp(direction_str
, "export")) {
7002 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7003 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7005 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7006 return CMD_WARNING_CONFIG_FAILED
;
7009 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7012 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7013 if (!previous_state
) {
7014 /* trigger export current vrf */
7015 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7018 if (previous_state
) {
7019 /* trigger un-export current vrf */
7020 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7022 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7028 DEFPY (af_routetarget_import
,
7029 af_routetarget_import_cmd
,
7030 "[no] <rt|route-target> redirect import RTLIST...",
7032 "Specify route target list\n"
7033 "Specify route target list\n"
7034 "Flow-spec redirect type route target\n"
7035 "Import routes to this address-family\n"
7036 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7038 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7040 struct ecommunity
*ecom
= NULL
;
7045 if (argv_find(argv
, argc
, "no", &idx
))
7048 afi
= vpn_policy_getafi(vty
, bgp
, false);
7050 return CMD_WARNING_CONFIG_FAILED
;
7053 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7054 vty_out(vty
, "%% Missing RTLIST\n");
7055 return CMD_WARNING_CONFIG_FAILED
;
7057 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7058 if (ret
!= CMD_SUCCESS
)
7063 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7064 ecommunity_free(&bgp
->vpn_policy
[afi
]
7065 .import_redirect_rtlist
);
7066 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7067 ecommunity_dup(ecom
);
7069 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7070 ecommunity_free(&bgp
->vpn_policy
[afi
]
7071 .import_redirect_rtlist
);
7072 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7076 ecommunity_free(&ecom
);
7081 DEFUN_NOSH (address_family_ipv4_safi
,
7082 address_family_ipv4_safi_cmd
,
7083 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7084 "Enter Address Family command mode\n"
7086 BGP_SAFI_WITH_LABEL_HELP_STR
)
7090 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7091 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7092 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7093 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7094 && safi
!= SAFI_EVPN
) {
7096 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7097 return CMD_WARNING_CONFIG_FAILED
;
7099 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7101 vty
->node
= BGP_IPV4_NODE
;
7106 DEFUN_NOSH (address_family_ipv6_safi
,
7107 address_family_ipv6_safi_cmd
,
7108 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7109 "Enter Address Family command mode\n"
7111 BGP_SAFI_WITH_LABEL_HELP_STR
)
7114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7115 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7116 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7117 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7118 && safi
!= SAFI_EVPN
) {
7120 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7121 return CMD_WARNING_CONFIG_FAILED
;
7123 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7125 vty
->node
= BGP_IPV6_NODE
;
7130 #ifdef KEEP_OLD_VPN_COMMANDS
7131 DEFUN_NOSH (address_family_vpnv4
,
7132 address_family_vpnv4_cmd
,
7133 "address-family vpnv4 [unicast]",
7134 "Enter Address Family command mode\n"
7136 "Address Family modifier\n")
7138 vty
->node
= BGP_VPNV4_NODE
;
7142 DEFUN_NOSH (address_family_vpnv6
,
7143 address_family_vpnv6_cmd
,
7144 "address-family vpnv6 [unicast]",
7145 "Enter Address Family command mode\n"
7147 "Address Family modifier\n")
7149 vty
->node
= BGP_VPNV6_NODE
;
7152 #endif /* KEEP_OLD_VPN_COMMANDS */
7154 DEFUN_NOSH (address_family_evpn
,
7155 address_family_evpn_cmd
,
7156 "address-family l2vpn evpn",
7157 "Enter Address Family command mode\n"
7159 "Address Family modifier\n")
7161 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7162 vty
->node
= BGP_EVPN_NODE
;
7166 DEFUN_NOSH (exit_address_family
,
7167 exit_address_family_cmd
,
7168 "exit-address-family",
7169 "Exit from Address Family configuration mode\n")
7171 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7172 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7173 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7174 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7175 || vty
->node
== BGP_EVPN_NODE
7176 || vty
->node
== BGP_FLOWSPECV4_NODE
7177 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7178 vty
->node
= BGP_NODE
;
7182 /* Recalculate bestpath and re-advertise a prefix */
7183 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7184 const char *ip_str
, afi_t afi
, safi_t safi
,
7185 struct prefix_rd
*prd
)
7188 struct prefix match
;
7189 struct bgp_node
*rn
;
7190 struct bgp_node
*rm
;
7192 struct bgp_table
*table
;
7193 struct bgp_table
*rib
;
7195 /* BGP structure lookup. */
7197 bgp
= bgp_lookup_by_name(view_name
);
7199 vty_out(vty
, "%% Can't find BGP instance %s\n",
7204 bgp
= bgp_get_default();
7206 vty_out(vty
, "%% No BGP process is configured\n");
7211 /* Check IP address argument. */
7212 ret
= str2prefix(ip_str
, &match
);
7214 vty_out(vty
, "%% address is malformed\n");
7218 match
.family
= afi2family(afi
);
7219 rib
= bgp
->rib
[afi
][safi
];
7221 if (safi
== SAFI_MPLS_VPN
) {
7222 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7223 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7226 table
= bgp_node_get_bgp_table_info(rn
);
7227 if (table
!= NULL
) {
7229 if ((rm
= bgp_node_match(table
, &match
))
7232 == match
.prefixlen
) {
7234 BGP_NODE_USER_CLEAR
);
7235 bgp_process(bgp
, rm
, afi
, safi
);
7237 bgp_unlock_node(rm
);
7242 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7243 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7244 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7245 bgp_process(bgp
, rn
, afi
, safi
);
7247 bgp_unlock_node(rn
);
7254 /* one clear bgp command to rule them all */
7255 DEFUN (clear_ip_bgp_all
,
7256 clear_ip_bgp_all_cmd
,
7257 "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>]",
7261 BGP_INSTANCE_HELP_STR
7264 BGP_SAFI_WITH_LABEL_HELP_STR
7265 "Address Family modifier\n"
7267 "BGP neighbor address to clear\n"
7268 "BGP IPv6 neighbor to clear\n"
7269 "BGP neighbor on interface to clear\n"
7270 "Clear peers with the AS number\n"
7271 "Clear all external peers\n"
7272 "Clear all members of peer-group\n"
7273 "BGP peer-group name\n"
7278 "Push out prefix-list ORF and do inbound soft reconfig\n"
7283 afi_t afi
= AFI_IP6
;
7284 safi_t safi
= SAFI_UNICAST
;
7285 enum clear_sort clr_sort
= clear_peer
;
7286 enum bgp_clear_type clr_type
;
7287 char *clr_arg
= NULL
;
7291 /* clear [ip] bgp */
7292 if (argv_find(argv
, argc
, "ip", &idx
))
7295 /* [<vrf> VIEWVRFNAME] */
7296 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7297 vrf
= argv
[idx
+ 1]->arg
;
7299 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7301 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7302 /* [<view> VIEWVRFNAME] */
7303 vrf
= argv
[idx
+ 1]->arg
;
7306 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7307 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7308 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7310 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7311 if (argv_find(argv
, argc
, "*", &idx
)) {
7312 clr_sort
= clear_all
;
7313 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7314 clr_sort
= clear_peer
;
7315 clr_arg
= argv
[idx
]->arg
;
7316 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7317 clr_sort
= clear_peer
;
7318 clr_arg
= argv
[idx
]->arg
;
7319 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7320 clr_sort
= clear_group
;
7322 clr_arg
= argv
[idx
]->arg
;
7323 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7324 clr_sort
= clear_peer
;
7325 clr_arg
= argv
[idx
]->arg
;
7326 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7327 clr_sort
= clear_as
;
7328 clr_arg
= argv
[idx
]->arg
;
7329 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7330 clr_sort
= clear_external
;
7333 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7334 if (argv_find(argv
, argc
, "soft", &idx
)) {
7335 if (argv_find(argv
, argc
, "in", &idx
)
7336 || argv_find(argv
, argc
, "out", &idx
))
7337 clr_type
= strmatch(argv
[idx
]->text
, "in")
7339 : BGP_CLEAR_SOFT_OUT
;
7341 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7342 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7343 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7344 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7345 : BGP_CLEAR_SOFT_IN
;
7346 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7347 clr_type
= BGP_CLEAR_SOFT_OUT
;
7349 clr_type
= BGP_CLEAR_SOFT_NONE
;
7351 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7354 DEFUN (clear_ip_bgp_prefix
,
7355 clear_ip_bgp_prefix_cmd
,
7356 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7360 BGP_INSTANCE_HELP_STR
7361 "Clear bestpath and re-advertise\n"
7365 char *prefix
= NULL
;
7369 /* [<view|vrf> VIEWVRFNAME] */
7370 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7371 vrf
= argv
[idx
+ 1]->arg
;
7373 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7375 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7376 /* [<view> VIEWVRFNAME] */
7377 vrf
= argv
[idx
+ 1]->arg
;
7381 prefix
= argv
[argc
- 1]->arg
;
7383 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7386 DEFUN (clear_bgp_ipv6_safi_prefix
,
7387 clear_bgp_ipv6_safi_prefix_cmd
,
7388 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7394 "Clear bestpath and re-advertise\n"
7398 int idx_ipv6_prefix
= 0;
7399 safi_t safi
= SAFI_UNICAST
;
7400 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7401 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7403 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7404 return bgp_clear_prefix(
7405 vty
, NULL
, prefix
, AFI_IP6
,
7409 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7410 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7411 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7415 BGP_INSTANCE_HELP_STR
7418 "Clear bestpath and re-advertise\n"
7422 int idx_vrfview
= 0;
7423 int idx_ipv6_prefix
= 0;
7424 safi_t safi
= SAFI_UNICAST
;
7425 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7426 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7427 char *vrfview
= NULL
;
7429 /* [<view|vrf> VIEWVRFNAME] */
7430 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7431 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7432 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7434 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7435 /* [<view> VIEWVRFNAME] */
7436 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7438 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7440 return bgp_clear_prefix(
7441 vty
, vrfview
, prefix
,
7442 AFI_IP6
, safi
, NULL
);
7445 DEFUN (show_bgp_views
,
7447 "show [ip] bgp views",
7451 "Show the defined BGP views\n")
7453 struct list
*inst
= bm
->bgp
;
7454 struct listnode
*node
;
7457 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7458 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7462 vty_out(vty
, "Defined BGP views:\n");
7463 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7465 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7467 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7474 DEFUN (show_bgp_vrfs
,
7476 "show [ip] bgp vrfs [json]",
7483 char buf
[ETHER_ADDR_STRLEN
];
7484 struct list
*inst
= bm
->bgp
;
7485 struct listnode
*node
;
7487 bool uj
= use_json(argc
, argv
);
7488 json_object
*json
= NULL
;
7489 json_object
*json_vrfs
= NULL
;
7492 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7493 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7498 json
= json_object_new_object();
7499 json_vrfs
= json_object_new_object();
7502 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7503 const char *name
, *type
;
7505 struct listnode
*node2
, *nnode2
;
7506 int peers_cfg
, peers_estb
;
7507 json_object
*json_vrf
= NULL
;
7510 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7514 if (!uj
&& count
== 1)
7516 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7517 "Type", "Id", "routerId", "#PeersVfg",
7518 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7520 peers_cfg
= peers_estb
= 0;
7522 json_vrf
= json_object_new_object();
7525 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7526 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7529 if (peer
->status
== Established
)
7533 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7534 name
= VRF_DEFAULT_NAME
;
7543 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7545 : (int64_t)bgp
->vrf_id
;
7546 json_object_string_add(json_vrf
, "type", type
);
7547 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7548 json_object_string_add(json_vrf
, "routerId",
7549 inet_ntoa(bgp
->router_id
));
7550 json_object_int_add(json_vrf
, "numConfiguredPeers",
7552 json_object_int_add(json_vrf
, "numEstablishedPeers",
7555 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7556 json_object_string_add(
7558 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7559 json_object_object_add(json_vrfs
, name
, json_vrf
);
7562 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7564 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7566 inet_ntoa(bgp
->router_id
), peers_cfg
,
7567 peers_estb
, name
, bgp
->l3vni
,
7568 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7572 json_object_object_add(json
, "vrfs", json_vrfs
);
7574 json_object_int_add(json
, "totalVrfs", count
);
7576 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7577 json
, JSON_C_TO_STRING_PRETTY
));
7578 json_object_free(json
);
7582 "\nTotal number of VRFs (including default): %d\n",
7589 DEFUN (show_bgp_mac_hash
,
7590 show_bgp_mac_hash_cmd
,
7591 "show bgp mac hash",
7595 "Mac Address database\n")
7597 bgp_mac_dump_table(vty
);
7602 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7604 struct vty
*vty
= (struct vty
*)args
;
7605 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7607 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7611 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7613 vty_out(vty
, "self nexthop database:\n");
7614 bgp_nexthop_show_address_hash(vty
, bgp
);
7616 vty_out(vty
, "Tunnel-ip database:\n");
7617 hash_iterate(bgp
->tip_hash
,
7618 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7622 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7623 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7624 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7625 "martian next-hops\n"
7626 "martian next-hop database\n")
7628 struct bgp
*bgp
= NULL
;
7632 /* [<vrf> VIEWVRFNAME] */
7633 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7634 name
= argv
[idx
+ 1]->arg
;
7635 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7637 } else if (argv_find(argv
, argc
, "view", &idx
))
7638 /* [<view> VIEWVRFNAME] */
7639 name
= argv
[idx
+ 1]->arg
;
7641 bgp
= bgp_lookup_by_name(name
);
7643 bgp
= bgp_get_default();
7646 vty_out(vty
, "%% No BGP process is configured\n");
7649 bgp_show_martian_nexthops(vty
, bgp
);
7654 DEFUN (show_bgp_memory
,
7655 show_bgp_memory_cmd
,
7656 "show [ip] bgp memory",
7660 "Global BGP memory statistics\n")
7662 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7663 unsigned long count
;
7665 /* RIB related usage stats */
7666 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7667 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7668 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7669 count
* sizeof(struct bgp_node
)));
7671 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7672 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7673 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7674 count
* sizeof(struct bgp_path_info
)));
7675 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7676 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7679 memstrbuf
, sizeof(memstrbuf
),
7680 count
* sizeof(struct bgp_path_info_extra
)));
7682 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7683 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7684 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7685 count
* sizeof(struct bgp_static
)));
7687 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7688 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7689 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7690 count
* sizeof(struct bpacket
)));
7693 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7694 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7695 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7696 count
* sizeof(struct bgp_adj_in
)));
7697 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7698 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7699 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7700 count
* sizeof(struct bgp_adj_out
)));
7702 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7703 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7705 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7706 count
* sizeof(struct bgp_nexthop_cache
)));
7708 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7709 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7711 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7712 count
* sizeof(struct bgp_damp_info
)));
7715 count
= attr_count();
7716 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7717 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7718 count
* sizeof(struct attr
)));
7720 if ((count
= attr_unknown_count()))
7721 vty_out(vty
, "%ld unknown attributes\n", count
);
7723 /* AS_PATH attributes */
7724 count
= aspath_count();
7725 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7726 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7727 count
* sizeof(struct aspath
)));
7729 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7730 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7731 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7732 count
* sizeof(struct assegment
)));
7734 /* Other attributes */
7735 if ((count
= community_count()))
7736 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7737 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7738 count
* sizeof(struct community
)));
7739 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7740 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7741 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7742 count
* sizeof(struct ecommunity
)));
7743 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7745 "%ld BGP large-community entries, using %s of memory\n",
7746 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7747 count
* sizeof(struct lcommunity
)));
7749 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7750 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7751 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7752 count
* sizeof(struct cluster_list
)));
7754 /* Peer related usage */
7755 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7756 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7757 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7758 count
* sizeof(struct peer
)));
7760 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7761 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7762 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7763 count
* sizeof(struct peer_group
)));
7766 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7767 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7768 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7769 count
* sizeof(struct hash
)));
7770 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7771 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7772 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7773 count
* sizeof(struct hash_bucket
)));
7774 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7775 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7776 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7777 count
* sizeof(regex_t
)));
7781 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7783 json_object
*bestpath
= json_object_new_object();
7785 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7786 json_object_string_add(bestpath
, "asPath", "ignore");
7788 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7789 json_object_string_add(bestpath
, "asPath", "confed");
7791 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7792 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7793 json_object_string_add(bestpath
, "multiPathRelax",
7796 json_object_string_add(bestpath
, "multiPathRelax",
7799 json_object_string_add(bestpath
, "multiPathRelax", "false");
7801 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7802 json_object_string_add(bestpath
, "compareRouterId", "true");
7803 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7804 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7805 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7806 json_object_string_add(bestpath
, "med", "confed");
7807 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7808 json_object_string_add(bestpath
, "med",
7809 "missing-as-worst");
7811 json_object_string_add(bestpath
, "med", "true");
7814 json_object_object_add(json
, "bestPath", bestpath
);
7817 /* Show BGP peer's summary information. */
7818 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7819 bool use_json
, json_object
*json
)
7822 struct listnode
*node
, *nnode
;
7823 unsigned int count
= 0, dn_count
= 0;
7824 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7825 char neighbor_buf
[VTY_BUFSIZ
];
7826 int neighbor_col_default_width
= 16;
7828 int max_neighbor_width
= 0;
7830 json_object
*json_peer
= NULL
;
7831 json_object
*json_peers
= NULL
;
7832 struct peer_af
*paf
;
7834 /* labeled-unicast routes are installed in the unicast table so in order
7836 * display the correct PfxRcd value we must look at SAFI_UNICAST
7838 if (safi
== SAFI_LABELED_UNICAST
)
7839 pfx_rcd_safi
= SAFI_UNICAST
;
7841 pfx_rcd_safi
= safi
;
7845 json
= json_object_new_object();
7847 json_peers
= json_object_new_object();
7849 /* Loop over all neighbors that will be displayed to determine
7851 * characters are needed for the Neighbor column
7853 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7854 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7857 if (peer
->afc
[afi
][safi
]) {
7858 memset(dn_flag
, '\0', sizeof(dn_flag
));
7859 if (peer_dynamic_neighbor(peer
))
7863 && bgp_flag_check(bgp
,
7864 BGP_FLAG_SHOW_HOSTNAME
))
7865 sprintf(neighbor_buf
, "%s%s(%s) ",
7866 dn_flag
, peer
->hostname
,
7869 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7872 len
= strlen(neighbor_buf
);
7874 if (len
> max_neighbor_width
)
7875 max_neighbor_width
= len
;
7879 /* Originally we displayed the Neighbor column as 16
7880 * characters wide so make that the default
7882 if (max_neighbor_width
< neighbor_col_default_width
)
7883 max_neighbor_width
= neighbor_col_default_width
;
7886 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7887 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7890 if (!peer
->afc
[afi
][safi
])
7895 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7898 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7900 : (int64_t)bgp
->vrf_id
;
7902 /* Usage summary and header */
7904 json_object_string_add(
7906 inet_ntoa(bgp
->router_id
));
7907 json_object_int_add(json
, "as", bgp
->as
);
7908 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7909 json_object_string_add(
7912 == BGP_INSTANCE_TYPE_DEFAULT
)
7917 "BGP router identifier %s, local AS number %u vrf-id %d",
7918 inet_ntoa(bgp
->router_id
), bgp
->as
,
7919 bgp
->vrf_id
== VRF_UNKNOWN
7921 : (int)bgp
->vrf_id
);
7925 if (bgp_update_delay_configured(bgp
)) {
7927 json_object_int_add(
7928 json
, "updateDelayLimit",
7929 bgp
->v_update_delay
);
7931 if (bgp
->v_update_delay
7932 != bgp
->v_establish_wait
)
7933 json_object_int_add(
7935 "updateDelayEstablishWait",
7936 bgp
->v_establish_wait
);
7938 if (bgp_update_delay_active(bgp
)) {
7939 json_object_string_add(
7941 "updateDelayFirstNeighbor",
7942 bgp
->update_delay_begin_time
);
7943 json_object_boolean_true_add(
7945 "updateDelayInProgress");
7947 if (bgp
->update_delay_over
) {
7948 json_object_string_add(
7950 "updateDelayFirstNeighbor",
7951 bgp
->update_delay_begin_time
);
7952 json_object_string_add(
7954 "updateDelayBestpathResumed",
7955 bgp
->update_delay_end_time
);
7956 json_object_string_add(
7958 "updateDelayZebraUpdateResume",
7959 bgp
->update_delay_zebra_resume_time
);
7960 json_object_string_add(
7962 "updateDelayPeerUpdateResume",
7963 bgp
->update_delay_peers_resume_time
);
7968 "Read-only mode update-delay limit: %d seconds\n",
7969 bgp
->v_update_delay
);
7970 if (bgp
->v_update_delay
7971 != bgp
->v_establish_wait
)
7973 " Establish wait: %d seconds\n",
7974 bgp
->v_establish_wait
);
7976 if (bgp_update_delay_active(bgp
)) {
7978 " First neighbor established: %s\n",
7979 bgp
->update_delay_begin_time
);
7981 " Delay in progress\n");
7983 if (bgp
->update_delay_over
) {
7985 " First neighbor established: %s\n",
7986 bgp
->update_delay_begin_time
);
7988 " Best-paths resumed: %s\n",
7989 bgp
->update_delay_end_time
);
7991 " zebra update resumed: %s\n",
7992 bgp
->update_delay_zebra_resume_time
);
7994 " peers update resumed: %s\n",
7995 bgp
->update_delay_peers_resume_time
);
8002 if (bgp_maxmed_onstartup_configured(bgp
)
8003 && bgp
->maxmed_active
)
8004 json_object_boolean_true_add(
8005 json
, "maxMedOnStartup");
8006 if (bgp
->v_maxmed_admin
)
8007 json_object_boolean_true_add(
8008 json
, "maxMedAdministrative");
8010 json_object_int_add(
8011 json
, "tableVersion",
8012 bgp_table_version(bgp
->rib
[afi
][safi
]));
8014 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8015 json_object_int_add(json
, "ribCount", ents
);
8016 json_object_int_add(
8018 ents
* sizeof(struct bgp_node
));
8020 ents
= bgp
->af_peer_count
[afi
][safi
];
8021 json_object_int_add(json
, "peerCount", ents
);
8022 json_object_int_add(json
, "peerMemory",
8023 ents
* sizeof(struct peer
));
8025 if ((ents
= listcount(bgp
->group
))) {
8026 json_object_int_add(
8027 json
, "peerGroupCount", ents
);
8028 json_object_int_add(
8029 json
, "peerGroupMemory",
8030 ents
* sizeof(struct
8034 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8035 BGP_CONFIG_DAMPENING
))
8036 json_object_boolean_true_add(
8037 json
, "dampeningEnabled");
8039 if (bgp_maxmed_onstartup_configured(bgp
)
8040 && bgp
->maxmed_active
)
8042 "Max-med on-startup active\n");
8043 if (bgp
->v_maxmed_admin
)
8045 "Max-med administrative active\n");
8047 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8048 bgp_table_version(bgp
->rib
[afi
][safi
]));
8050 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8052 "RIB entries %ld, using %s of memory\n",
8054 mtype_memstr(memstrbuf
,
8056 ents
* sizeof(struct
8059 /* Peer related usage */
8060 ents
= bgp
->af_peer_count
[afi
][safi
];
8061 vty_out(vty
, "Peers %ld, using %s of memory\n",
8064 memstrbuf
, sizeof(memstrbuf
),
8065 ents
* sizeof(struct peer
)));
8067 if ((ents
= listcount(bgp
->group
)))
8069 "Peer groups %ld, using %s of memory\n",
8074 ents
* sizeof(struct
8077 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8078 BGP_CONFIG_DAMPENING
))
8079 vty_out(vty
, "Dampening enabled.\n");
8082 /* Subtract 8 here because 'Neighbor' is
8084 vty_out(vty
, "Neighbor");
8085 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8088 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8095 json_peer
= json_object_new_object();
8097 if (peer_dynamic_neighbor(peer
)) {
8099 json_object_boolean_true_add(json_peer
,
8104 json_object_string_add(json_peer
, "hostname",
8107 if (peer
->domainname
)
8108 json_object_string_add(json_peer
, "domainname",
8111 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8112 json_object_int_add(json_peer
, "version", 4);
8113 json_object_int_add(json_peer
, "msgRcvd",
8114 PEER_TOTAL_RX(peer
));
8115 json_object_int_add(json_peer
, "msgSent",
8116 PEER_TOTAL_TX(peer
));
8118 json_object_int_add(json_peer
, "tableVersion",
8119 peer
->version
[afi
][safi
]);
8120 json_object_int_add(json_peer
, "outq",
8122 json_object_int_add(json_peer
, "inq", 0);
8123 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8124 use_json
, json_peer
);
8127 * Adding "pfxRcd" field to match with the corresponding
8128 * CLI. "prefixReceivedCount" will be deprecated in
8131 json_object_int_add(json_peer
, "prefixReceivedCount",
8132 peer
->pcount
[afi
][pfx_rcd_safi
]);
8133 json_object_int_add(json_peer
, "pfxRcd",
8134 peer
->pcount
[afi
][pfx_rcd_safi
]);
8136 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8137 if (paf
&& PAF_SUBGRP(paf
))
8138 json_object_int_add(json_peer
,
8140 (PAF_SUBGRP(paf
))->scount
);
8142 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8143 json_object_string_add(json_peer
, "state",
8145 else if (peer
->afc_recv
[afi
][safi
])
8146 json_object_string_add(
8148 lookup_msg(bgp_status_msg
, peer
->status
,
8150 else if (CHECK_FLAG(peer
->sflags
,
8151 PEER_STATUS_PREFIX_OVERFLOW
))
8152 json_object_string_add(json_peer
, "state",
8155 json_object_string_add(
8157 lookup_msg(bgp_status_msg
, peer
->status
,
8161 json_object_string_add(json_peer
, "idType",
8163 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8164 json_object_string_add(json_peer
, "idType",
8166 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8167 json_object_string_add(json_peer
, "idType",
8170 json_object_object_add(json_peers
, peer
->host
,
8173 memset(dn_flag
, '\0', sizeof(dn_flag
));
8174 if (peer_dynamic_neighbor(peer
)) {
8180 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8181 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8182 peer
->hostname
, peer
->host
);
8184 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8186 /* pad the neighbor column with spaces */
8187 if (len
< max_neighbor_width
)
8188 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8191 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8192 peer
->as
, PEER_TOTAL_RX(peer
),
8193 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8194 0, peer
->obuf
->count
,
8195 peer_uptime(peer
->uptime
, timebuf
,
8196 BGP_UPTIME_LEN
, 0, NULL
));
8198 if (peer
->status
== Established
)
8199 if (peer
->afc_recv
[afi
][safi
])
8200 vty_out(vty
, " %12ld",
8204 vty_out(vty
, " NoNeg");
8206 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8207 vty_out(vty
, " Idle (Admin)");
8208 else if (CHECK_FLAG(
8210 PEER_STATUS_PREFIX_OVERFLOW
))
8211 vty_out(vty
, " Idle (PfxCt)");
8213 vty_out(vty
, " %12s",
8214 lookup_msg(bgp_status_msg
,
8215 peer
->status
, NULL
));
8222 json_object_object_add(json
, "peers", json_peers
);
8224 json_object_int_add(json
, "totalPeers", count
);
8225 json_object_int_add(json
, "dynamicPeers", dn_count
);
8227 bgp_show_bestpath_json(bgp
, json
);
8229 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8230 json
, JSON_C_TO_STRING_PRETTY
));
8231 json_object_free(json
);
8234 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8236 vty_out(vty
, "No %s neighbor is configured\n",
8237 afi_safi_print(afi
, safi
));
8241 vty_out(vty
, "* - dynamic neighbor\n");
8242 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8243 dn_count
, bgp
->dynamic_neighbors_limit
);
8250 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8251 int safi
, bool use_json
,
8255 int afi_wildcard
= (afi
== AFI_MAX
);
8256 int safi_wildcard
= (safi
== SAFI_MAX
);
8257 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8258 bool nbr_output
= false;
8260 if (use_json
&& is_wildcard
)
8261 vty_out(vty
, "{\n");
8263 afi
= 1; /* AFI_IP */
8264 while (afi
< AFI_MAX
) {
8266 safi
= 1; /* SAFI_UNICAST */
8267 while (safi
< SAFI_MAX
) {
8268 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8272 * So limit output to those afi/safi
8274 * actualy have something interesting in
8278 json
= json_object_new_object();
8281 vty_out(vty
, ",\n");
8285 vty_out(vty
, "\"%s\":",
8289 vty_out(vty
, "\n%s Summary:\n",
8294 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8306 if (use_json
&& is_wildcard
)
8307 vty_out(vty
, "}\n");
8308 else if (!nbr_output
) {
8310 vty_out(vty
, "{}\n");
8312 vty_out(vty
, "%% No BGP neighbors found\n");
8316 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8317 safi_t safi
, bool use_json
)
8319 struct listnode
*node
, *nnode
;
8321 json_object
*json
= NULL
;
8323 bool nbr_output
= false;
8326 vty_out(vty
, "{\n");
8328 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8331 json
= json_object_new_object();
8334 vty_out(vty
, ",\n");
8338 vty_out(vty
, "\"%s\":",
8339 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8343 vty_out(vty
, "\nInstance %s:\n",
8344 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8348 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8352 vty_out(vty
, "}\n");
8353 else if (!nbr_output
)
8354 vty_out(vty
, "%% BGP instance not found\n");
8357 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8358 safi_t safi
, bool use_json
)
8363 if (strmatch(name
, "all")) {
8364 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8368 bgp
= bgp_lookup_by_name(name
);
8372 vty_out(vty
, "{}\n");
8375 "%% BGP instance not found\n");
8379 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8385 bgp
= bgp_get_default();
8388 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8391 vty_out(vty
, "{}\n");
8393 vty_out(vty
, "%% BGP instance not found\n");
8400 /* `show [ip] bgp summary' commands. */
8401 DEFUN (show_ip_bgp_summary
,
8402 show_ip_bgp_summary_cmd
,
8403 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8407 BGP_INSTANCE_HELP_STR
8409 BGP_SAFI_WITH_LABEL_HELP_STR
8410 "Summary of BGP neighbor status\n"
8414 afi_t afi
= AFI_MAX
;
8415 safi_t safi
= SAFI_MAX
;
8420 if (argv_find(argv
, argc
, "ip", &idx
))
8422 /* [<vrf> VIEWVRFNAME] */
8423 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8424 vrf
= argv
[idx
+ 1]->arg
;
8425 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8427 } else if (argv_find(argv
, argc
, "view", &idx
))
8428 /* [<view> VIEWVRFNAME] */
8429 vrf
= argv
[idx
+ 1]->arg
;
8430 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8431 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8432 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8435 bool uj
= use_json(argc
, argv
);
8437 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8440 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8442 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8443 return "IPv4 Unicast";
8444 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8445 return "IPv4 Multicast";
8446 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8447 return "IPv4 Labeled Unicast";
8448 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8450 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8451 return "IPv4 Encap";
8452 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8453 return "IPv4 Flowspec";
8454 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8455 return "IPv6 Unicast";
8456 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8457 return "IPv6 Multicast";
8458 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8459 return "IPv6 Labeled Unicast";
8460 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8462 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8463 return "IPv6 Encap";
8464 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8465 return "IPv6 Flowspec";
8466 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8467 return "L2VPN EVPN";
8473 * Please note that we have intentionally camelCased
8474 * the return strings here. So if you want
8475 * to use this function, please ensure you
8476 * are doing this within json output
8478 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8480 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8481 return "ipv4Unicast";
8482 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8483 return "ipv4Multicast";
8484 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8485 return "ipv4LabeledUnicast";
8486 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8488 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8490 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8491 return "ipv4Flowspec";
8492 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8493 return "ipv6Unicast";
8494 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8495 return "ipv6Multicast";
8496 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8497 return "ipv6LabeledUnicast";
8498 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8500 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8502 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8503 return "ipv6Flowspec";
8504 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8510 /* Show BGP peer's information. */
8511 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8513 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8514 afi_t afi
, safi_t safi
,
8515 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8516 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8517 bool use_json
, json_object
*json_pref
)
8520 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8521 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8523 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8524 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8525 json_object_string_add(json_pref
, "sendMode",
8526 "advertisedAndReceived");
8527 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8528 json_object_string_add(json_pref
, "sendMode",
8530 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8531 json_object_string_add(json_pref
, "sendMode",
8534 vty_out(vty
, " Send-mode: ");
8535 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8536 vty_out(vty
, "advertised");
8537 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8538 vty_out(vty
, "%sreceived",
8539 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8548 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8549 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8551 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8552 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8553 json_object_string_add(json_pref
, "recvMode",
8554 "advertisedAndReceived");
8555 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8556 json_object_string_add(json_pref
, "recvMode",
8558 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8559 json_object_string_add(json_pref
, "recvMode",
8562 vty_out(vty
, " Receive-mode: ");
8563 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8564 vty_out(vty
, "advertised");
8565 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8566 vty_out(vty
, "%sreceived",
8567 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8576 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8577 safi_t safi
, bool use_json
,
8578 json_object
*json_neigh
)
8580 struct bgp_filter
*filter
;
8581 struct peer_af
*paf
;
8582 char orf_pfx_name
[BUFSIZ
];
8584 json_object
*json_af
= NULL
;
8585 json_object
*json_prefA
= NULL
;
8586 json_object
*json_prefB
= NULL
;
8587 json_object
*json_addr
= NULL
;
8590 json_addr
= json_object_new_object();
8591 json_af
= json_object_new_object();
8592 filter
= &p
->filter
[afi
][safi
];
8594 if (peer_group_active(p
))
8595 json_object_string_add(json_addr
, "peerGroupMember",
8598 paf
= peer_af_find(p
, afi
, safi
);
8599 if (paf
&& PAF_SUBGRP(paf
)) {
8600 json_object_int_add(json_addr
, "updateGroupId",
8601 PAF_UPDGRP(paf
)->id
);
8602 json_object_int_add(json_addr
, "subGroupId",
8603 PAF_SUBGRP(paf
)->id
);
8604 json_object_int_add(json_addr
, "packetQueueLength",
8605 bpacket_queue_virtual_length(paf
));
8608 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8609 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8610 PEER_CAP_ORF_PREFIX_SM_RCV
)
8611 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8612 PEER_CAP_ORF_PREFIX_RM_ADV
)
8613 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8614 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8615 json_object_int_add(json_af
, "orfType",
8617 json_prefA
= json_object_new_object();
8618 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8619 PEER_CAP_ORF_PREFIX_SM_ADV
,
8620 PEER_CAP_ORF_PREFIX_RM_ADV
,
8621 PEER_CAP_ORF_PREFIX_SM_RCV
,
8622 PEER_CAP_ORF_PREFIX_RM_RCV
,
8623 use_json
, json_prefA
);
8624 json_object_object_add(json_af
, "orfPrefixList",
8628 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8629 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8630 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8631 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8632 PEER_CAP_ORF_PREFIX_RM_ADV
)
8633 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8634 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8635 json_object_int_add(json_af
, "orfOldType",
8636 ORF_TYPE_PREFIX_OLD
);
8637 json_prefB
= json_object_new_object();
8638 bgp_show_peer_afi_orf_cap(
8639 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8640 PEER_CAP_ORF_PREFIX_RM_ADV
,
8641 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8642 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8644 json_object_object_add(json_af
, "orfOldPrefixList",
8648 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8649 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8650 PEER_CAP_ORF_PREFIX_SM_RCV
)
8651 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8652 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8653 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8654 PEER_CAP_ORF_PREFIX_RM_ADV
)
8655 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8656 PEER_CAP_ORF_PREFIX_RM_RCV
)
8657 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8658 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8659 json_object_object_add(json_addr
, "afDependentCap",
8662 json_object_free(json_af
);
8664 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8665 orf_pfx_count
= prefix_bgp_show_prefix_list(
8666 NULL
, afi
, orf_pfx_name
, use_json
);
8668 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8669 PEER_STATUS_ORF_PREFIX_SEND
)
8671 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8672 PEER_STATUS_ORF_PREFIX_SEND
))
8673 json_object_boolean_true_add(json_neigh
,
8676 json_object_int_add(json_addr
, "orfRecvCounter",
8679 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8680 PEER_STATUS_ORF_WAIT_REFRESH
))
8681 json_object_string_add(
8682 json_addr
, "orfFirstUpdate",
8683 "deferredUntilORFOrRouteRefreshRecvd");
8685 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8686 PEER_FLAG_REFLECTOR_CLIENT
))
8687 json_object_boolean_true_add(json_addr
,
8688 "routeReflectorClient");
8689 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8690 PEER_FLAG_RSERVER_CLIENT
))
8691 json_object_boolean_true_add(json_addr
,
8692 "routeServerClient");
8693 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8694 json_object_boolean_true_add(json_addr
,
8695 "inboundSoftConfigPermit");
8697 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8698 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8699 json_object_boolean_true_add(
8701 "privateAsNumsAllReplacedInUpdatesToNbr");
8702 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8703 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8704 json_object_boolean_true_add(
8706 "privateAsNumsReplacedInUpdatesToNbr");
8707 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8708 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8709 json_object_boolean_true_add(
8711 "privateAsNumsAllRemovedInUpdatesToNbr");
8712 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8713 PEER_FLAG_REMOVE_PRIVATE_AS
))
8714 json_object_boolean_true_add(
8716 "privateAsNumsRemovedInUpdatesToNbr");
8718 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8719 json_object_boolean_true_add(
8721 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8724 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8725 json_object_string_add(json_addr
,
8726 "overrideASNsInOutboundUpdates",
8727 "ifAspathEqualRemoteAs");
8729 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8730 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8731 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8732 json_object_boolean_true_add(json_addr
,
8733 "routerAlwaysNextHop");
8734 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8735 PEER_FLAG_AS_PATH_UNCHANGED
))
8736 json_object_boolean_true_add(
8737 json_addr
, "unchangedAsPathPropogatedToNbr");
8738 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8739 PEER_FLAG_NEXTHOP_UNCHANGED
))
8740 json_object_boolean_true_add(
8741 json_addr
, "unchangedNextHopPropogatedToNbr");
8742 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8743 json_object_boolean_true_add(
8744 json_addr
, "unchangedMedPropogatedToNbr");
8745 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8746 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8747 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8748 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8749 PEER_FLAG_SEND_COMMUNITY
)
8750 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8751 PEER_FLAG_SEND_EXT_COMMUNITY
))
8752 json_object_string_add(json_addr
,
8753 "commAttriSentToNbr",
8754 "extendedAndStandard");
8755 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8756 PEER_FLAG_SEND_EXT_COMMUNITY
))
8757 json_object_string_add(json_addr
,
8758 "commAttriSentToNbr",
8761 json_object_string_add(json_addr
,
8762 "commAttriSentToNbr",
8765 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8766 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8767 if (p
->default_rmap
[afi
][safi
].name
)
8768 json_object_string_add(
8769 json_addr
, "defaultRouteMap",
8770 p
->default_rmap
[afi
][safi
].name
);
8772 if (paf
&& PAF_SUBGRP(paf
)
8773 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8774 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8775 json_object_boolean_true_add(json_addr
,
8778 json_object_boolean_true_add(json_addr
,
8782 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8783 if (is_evpn_enabled())
8784 json_object_boolean_true_add(
8785 json_addr
, "advertiseAllVnis");
8788 if (filter
->plist
[FILTER_IN
].name
8789 || filter
->dlist
[FILTER_IN
].name
8790 || filter
->aslist
[FILTER_IN
].name
8791 || filter
->map
[RMAP_IN
].name
)
8792 json_object_boolean_true_add(json_addr
,
8793 "inboundPathPolicyConfig");
8794 if (filter
->plist
[FILTER_OUT
].name
8795 || filter
->dlist
[FILTER_OUT
].name
8796 || filter
->aslist
[FILTER_OUT
].name
8797 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8798 json_object_boolean_true_add(
8799 json_addr
, "outboundPathPolicyConfig");
8802 if (filter
->plist
[FILTER_IN
].name
)
8803 json_object_string_add(json_addr
,
8804 "incomingUpdatePrefixFilterList",
8805 filter
->plist
[FILTER_IN
].name
);
8806 if (filter
->plist
[FILTER_OUT
].name
)
8807 json_object_string_add(json_addr
,
8808 "outgoingUpdatePrefixFilterList",
8809 filter
->plist
[FILTER_OUT
].name
);
8811 /* distribute-list */
8812 if (filter
->dlist
[FILTER_IN
].name
)
8813 json_object_string_add(
8814 json_addr
, "incomingUpdateNetworkFilterList",
8815 filter
->dlist
[FILTER_IN
].name
);
8816 if (filter
->dlist
[FILTER_OUT
].name
)
8817 json_object_string_add(
8818 json_addr
, "outgoingUpdateNetworkFilterList",
8819 filter
->dlist
[FILTER_OUT
].name
);
8822 if (filter
->aslist
[FILTER_IN
].name
)
8823 json_object_string_add(json_addr
,
8824 "incomingUpdateAsPathFilterList",
8825 filter
->aslist
[FILTER_IN
].name
);
8826 if (filter
->aslist
[FILTER_OUT
].name
)
8827 json_object_string_add(json_addr
,
8828 "outgoingUpdateAsPathFilterList",
8829 filter
->aslist
[FILTER_OUT
].name
);
8832 if (filter
->map
[RMAP_IN
].name
)
8833 json_object_string_add(
8834 json_addr
, "routeMapForIncomingAdvertisements",
8835 filter
->map
[RMAP_IN
].name
);
8836 if (filter
->map
[RMAP_OUT
].name
)
8837 json_object_string_add(
8838 json_addr
, "routeMapForOutgoingAdvertisements",
8839 filter
->map
[RMAP_OUT
].name
);
8841 /* ebgp-requires-policy (inbound) */
8842 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8843 && !bgp_inbound_policy_exists(p
, filter
))
8844 json_object_string_add(
8845 json_addr
, "inboundEbgpRequiresPolicy",
8846 "Inbound updates discarded due to missing policy");
8848 /* ebgp-requires-policy (outbound) */
8849 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8850 && (!bgp_outbound_policy_exists(p
, filter
)))
8851 json_object_string_add(
8852 json_addr
, "outboundEbgpRequiresPolicy",
8853 "Outbound updates discarded due to missing policy");
8855 /* unsuppress-map */
8856 if (filter
->usmap
.name
)
8857 json_object_string_add(json_addr
,
8858 "selectiveUnsuppressRouteMap",
8859 filter
->usmap
.name
);
8861 /* Receive prefix count */
8862 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8863 p
->pcount
[afi
][safi
]);
8864 if (paf
&& PAF_SUBGRP(paf
))
8865 json_object_int_add(json_addr
, "sentPrefixCounter",
8866 (PAF_SUBGRP(paf
))->scount
);
8868 /* Maximum prefix */
8869 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8870 json_object_int_add(json_addr
, "prefixAllowedMax",
8871 p
->pmax
[afi
][safi
]);
8872 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8873 PEER_FLAG_MAX_PREFIX_WARNING
))
8874 json_object_boolean_true_add(
8875 json_addr
, "prefixAllowedMaxWarning");
8876 json_object_int_add(json_addr
,
8877 "prefixAllowedWarningThresh",
8878 p
->pmax_threshold
[afi
][safi
]);
8879 if (p
->pmax_restart
[afi
][safi
])
8880 json_object_int_add(
8882 "prefixAllowedRestartIntervalMsecs",
8883 p
->pmax_restart
[afi
][safi
] * 60000);
8885 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8889 filter
= &p
->filter
[afi
][safi
];
8891 vty_out(vty
, " For address family: %s\n",
8892 afi_safi_print(afi
, safi
));
8894 if (peer_group_active(p
))
8895 vty_out(vty
, " %s peer-group member\n",
8898 paf
= peer_af_find(p
, afi
, safi
);
8899 if (paf
&& PAF_SUBGRP(paf
)) {
8900 vty_out(vty
, " Update group %" PRIu64
8901 ", subgroup %" PRIu64
"\n",
8902 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8903 vty_out(vty
, " Packet Queue length %d\n",
8904 bpacket_queue_virtual_length(paf
));
8906 vty_out(vty
, " Not part of any update group\n");
8908 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8909 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8910 PEER_CAP_ORF_PREFIX_SM_RCV
)
8911 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8912 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8913 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8914 PEER_CAP_ORF_PREFIX_RM_ADV
)
8915 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8916 PEER_CAP_ORF_PREFIX_RM_RCV
)
8917 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8918 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8919 vty_out(vty
, " AF-dependant capabilities:\n");
8921 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8922 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8923 PEER_CAP_ORF_PREFIX_SM_RCV
)
8924 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8925 PEER_CAP_ORF_PREFIX_RM_ADV
)
8926 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8927 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8929 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8931 bgp_show_peer_afi_orf_cap(
8932 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8933 PEER_CAP_ORF_PREFIX_RM_ADV
,
8934 PEER_CAP_ORF_PREFIX_SM_RCV
,
8935 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8937 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8938 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8939 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8940 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8941 PEER_CAP_ORF_PREFIX_RM_ADV
)
8942 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8943 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8945 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8946 ORF_TYPE_PREFIX_OLD
);
8947 bgp_show_peer_afi_orf_cap(
8948 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8949 PEER_CAP_ORF_PREFIX_RM_ADV
,
8950 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8951 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8954 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8955 orf_pfx_count
= prefix_bgp_show_prefix_list(
8956 NULL
, afi
, orf_pfx_name
, use_json
);
8958 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8959 PEER_STATUS_ORF_PREFIX_SEND
)
8961 vty_out(vty
, " Outbound Route Filter (ORF):");
8962 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8963 PEER_STATUS_ORF_PREFIX_SEND
))
8964 vty_out(vty
, " sent;");
8966 vty_out(vty
, " received (%d entries)",
8970 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8971 PEER_STATUS_ORF_WAIT_REFRESH
))
8973 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8975 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8976 PEER_FLAG_REFLECTOR_CLIENT
))
8977 vty_out(vty
, " Route-Reflector Client\n");
8978 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8979 PEER_FLAG_RSERVER_CLIENT
))
8980 vty_out(vty
, " Route-Server Client\n");
8981 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8983 " Inbound soft reconfiguration allowed\n");
8985 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8986 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8988 " Private AS numbers (all) replaced in updates to this neighbor\n");
8989 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8990 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8992 " Private AS numbers replaced in updates to this neighbor\n");
8993 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8994 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8996 " Private AS numbers (all) removed in updates to this neighbor\n");
8997 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8998 PEER_FLAG_REMOVE_PRIVATE_AS
))
9000 " Private AS numbers removed in updates to this neighbor\n");
9002 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9003 vty_out(vty
, " %s\n",
9004 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9005 ->human_description
);
9007 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9009 " Override ASNs in outbound updates if aspath equals remote-as\n");
9011 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9012 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9013 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9014 vty_out(vty
, " NEXT_HOP is always this router\n");
9015 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9016 PEER_FLAG_AS_PATH_UNCHANGED
))
9018 " AS_PATH is propagated unchanged to this neighbor\n");
9019 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9020 PEER_FLAG_NEXTHOP_UNCHANGED
))
9022 " NEXT_HOP is propagated unchanged to this neighbor\n");
9023 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9025 " MED is propagated unchanged to this neighbor\n");
9026 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9027 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9028 PEER_FLAG_SEND_EXT_COMMUNITY
)
9029 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9030 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9032 " Community attribute sent to this neighbor");
9033 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9034 PEER_FLAG_SEND_COMMUNITY
)
9035 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9036 PEER_FLAG_SEND_EXT_COMMUNITY
)
9037 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9038 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9039 vty_out(vty
, "(all)\n");
9040 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9041 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9042 vty_out(vty
, "(large)\n");
9043 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9044 PEER_FLAG_SEND_EXT_COMMUNITY
))
9045 vty_out(vty
, "(extended)\n");
9047 vty_out(vty
, "(standard)\n");
9049 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9050 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9051 vty_out(vty
, " Default information originate,");
9053 if (p
->default_rmap
[afi
][safi
].name
)
9054 vty_out(vty
, " default route-map %s%s,",
9055 p
->default_rmap
[afi
][safi
].map
? "*"
9057 p
->default_rmap
[afi
][safi
].name
);
9058 if (paf
&& PAF_SUBGRP(paf
)
9059 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9060 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9061 vty_out(vty
, " default sent\n");
9063 vty_out(vty
, " default not sent\n");
9066 /* advertise-vni-all */
9067 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9068 if (is_evpn_enabled())
9069 vty_out(vty
, " advertise-all-vni\n");
9072 if (filter
->plist
[FILTER_IN
].name
9073 || filter
->dlist
[FILTER_IN
].name
9074 || filter
->aslist
[FILTER_IN
].name
9075 || filter
->map
[RMAP_IN
].name
)
9076 vty_out(vty
, " Inbound path policy configured\n");
9077 if (filter
->plist
[FILTER_OUT
].name
9078 || filter
->dlist
[FILTER_OUT
].name
9079 || filter
->aslist
[FILTER_OUT
].name
9080 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9081 vty_out(vty
, " Outbound path policy configured\n");
9084 if (filter
->plist
[FILTER_IN
].name
)
9086 " Incoming update prefix filter list is %s%s\n",
9087 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9088 filter
->plist
[FILTER_IN
].name
);
9089 if (filter
->plist
[FILTER_OUT
].name
)
9091 " Outgoing update prefix filter list is %s%s\n",
9092 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9093 filter
->plist
[FILTER_OUT
].name
);
9095 /* distribute-list */
9096 if (filter
->dlist
[FILTER_IN
].name
)
9098 " Incoming update network filter list is %s%s\n",
9099 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9100 filter
->dlist
[FILTER_IN
].name
);
9101 if (filter
->dlist
[FILTER_OUT
].name
)
9103 " Outgoing update network filter list is %s%s\n",
9104 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9105 filter
->dlist
[FILTER_OUT
].name
);
9108 if (filter
->aslist
[FILTER_IN
].name
)
9110 " Incoming update AS path filter list is %s%s\n",
9111 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9112 filter
->aslist
[FILTER_IN
].name
);
9113 if (filter
->aslist
[FILTER_OUT
].name
)
9115 " Outgoing update AS path filter list is %s%s\n",
9116 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9117 filter
->aslist
[FILTER_OUT
].name
);
9120 if (filter
->map
[RMAP_IN
].name
)
9122 " Route map for incoming advertisements is %s%s\n",
9123 filter
->map
[RMAP_IN
].map
? "*" : "",
9124 filter
->map
[RMAP_IN
].name
);
9125 if (filter
->map
[RMAP_OUT
].name
)
9127 " Route map for outgoing advertisements is %s%s\n",
9128 filter
->map
[RMAP_OUT
].map
? "*" : "",
9129 filter
->map
[RMAP_OUT
].name
);
9131 /* ebgp-requires-policy (inbound) */
9132 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9133 && !bgp_inbound_policy_exists(p
, filter
))
9135 " Inbound updates discarded due to missing policy\n");
9137 /* ebgp-requires-policy (outbound) */
9138 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9139 && !bgp_outbound_policy_exists(p
, filter
))
9141 " Outbound updates discarded due to missing policy\n");
9143 /* unsuppress-map */
9144 if (filter
->usmap
.name
)
9146 " Route map for selective unsuppress is %s%s\n",
9147 filter
->usmap
.map
? "*" : "",
9148 filter
->usmap
.name
);
9150 /* Receive prefix count */
9151 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9153 /* Maximum prefix */
9154 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9155 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9157 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9158 PEER_FLAG_MAX_PREFIX_WARNING
)
9161 vty_out(vty
, " Threshold for warning message %d%%",
9162 p
->pmax_threshold
[afi
][safi
]);
9163 if (p
->pmax_restart
[afi
][safi
])
9164 vty_out(vty
, ", restart interval %d min",
9165 p
->pmax_restart
[afi
][safi
]);
9173 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9177 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9178 char timebuf
[BGP_UPTIME_LEN
];
9180 const char *subcode_str
;
9181 const char *code_str
;
9186 json_object
*json_neigh
= NULL
;
9192 json_neigh
= json_object_new_object();
9194 memset(dn_flag
, '\0', sizeof(dn_flag
));
9195 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9199 if (p
->conf_if
) /* Configured interface name. */
9200 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9201 BGP_PEER_SU_UNSPEC(p
)
9203 : sockunion2str(&p
->su
, buf
,
9205 else /* Configured IP address. */
9206 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9211 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9212 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9214 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9215 json_object_string_add(
9216 json_neigh
, "bgpNeighborAddr",
9217 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9219 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9221 if (p
->change_local_as
)
9222 json_object_int_add(json_neigh
, "localAs",
9223 p
->change_local_as
);
9225 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9227 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9228 json_object_boolean_true_add(json_neigh
,
9229 "localAsNoPrepend");
9231 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9232 json_object_boolean_true_add(json_neigh
,
9233 "localAsReplaceAs");
9235 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9236 || (p
->as_type
== AS_INTERNAL
))
9237 vty_out(vty
, "remote AS %u, ", p
->as
);
9239 vty_out(vty
, "remote AS Unspecified, ");
9240 vty_out(vty
, "local AS %u%s%s, ",
9241 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9242 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9245 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9249 /* peer type internal or confed-internal */
9250 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9252 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9253 json_object_boolean_true_add(
9254 json_neigh
, "nbrConfedInternalLink");
9256 json_object_boolean_true_add(json_neigh
,
9259 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9260 vty_out(vty
, "confed-internal link\n");
9262 vty_out(vty
, "internal link\n");
9264 /* peer type external or confed-external */
9265 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9267 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9268 json_object_boolean_true_add(
9269 json_neigh
, "nbrConfedExternalLink");
9271 json_object_boolean_true_add(json_neigh
,
9274 if (bgp_confederation_peers_check(bgp
, p
->as
))
9275 vty_out(vty
, "confed-external link\n");
9277 vty_out(vty
, "external link\n");
9281 json_object_boolean_true_add(json_neigh
,
9282 "nbrUnspecifiedLink");
9284 vty_out(vty
, "unspecified link\n");
9290 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9292 vty_out(vty
, " Description: %s\n", p
->desc
);
9298 json_object_string_add(json_neigh
, "hostname",
9302 json_object_string_add(json_neigh
, "domainname",
9305 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9306 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9309 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9316 json_object_string_add(json_neigh
, "peerGroup",
9320 struct prefix prefix
, *range
= NULL
;
9322 sockunion2hostprefix(&(p
->su
), &prefix
);
9323 range
= peer_group_lookup_dynamic_neighbor_range(
9327 prefix2str(range
, buf1
, sizeof(buf1
));
9328 json_object_string_add(
9330 "peerSubnetRangeGroup", buf1
);
9335 " Member of peer-group %s for session parameters\n",
9339 struct prefix prefix
, *range
= NULL
;
9341 sockunion2hostprefix(&(p
->su
), &prefix
);
9342 range
= peer_group_lookup_dynamic_neighbor_range(
9346 prefix2str(range
, buf1
, sizeof(buf1
));
9348 " Belongs to the subnet range group: %s\n",
9356 /* Administrative shutdown. */
9357 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9358 json_object_boolean_true_add(json_neigh
,
9362 json_object_int_add(json_neigh
, "bgpVersion", 4);
9363 json_object_string_add(
9364 json_neigh
, "remoteRouterId",
9365 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9366 json_object_string_add(
9367 json_neigh
, "localRouterId",
9368 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9372 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9373 && bgp_confederation_peers_check(bgp
, p
->as
))
9374 json_object_boolean_true_add(json_neigh
,
9378 json_object_string_add(
9379 json_neigh
, "bgpState",
9380 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9382 if (p
->status
== Established
) {
9385 uptime
= bgp_clock();
9386 uptime
-= p
->uptime
;
9387 epoch_tbuf
= time(NULL
) - uptime
;
9389 #if CONFDATE > 20200101
9391 "bgpTimerUp should be deprecated and can be removed now");
9394 * bgpTimerUp was miliseconds that was accurate
9395 * up to 1 day, then the value returned
9396 * became garbage. So in order to provide
9397 * some level of backwards compatability,
9398 * we still provde the data, but now
9399 * we are returning the correct value
9400 * and also adding a new bgpTimerUpMsec
9401 * which will allow us to deprecate
9404 json_object_int_add(json_neigh
, "bgpTimerUp",
9406 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9408 json_object_string_add(json_neigh
, "bgpTimerUpString",
9409 peer_uptime(p
->uptime
, timebuf
,
9412 json_object_int_add(json_neigh
,
9413 "bgpTimerUpEstablishedEpoch",
9417 else if (p
->status
== Active
) {
9418 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9419 json_object_string_add(json_neigh
, "bgpStateIs",
9421 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9422 json_object_string_add(json_neigh
, "bgpStateIs",
9430 uptime
= bgp_clock();
9431 uptime
-= p
->readtime
;
9432 tm
= gmtime(&uptime
);
9433 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9434 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9435 + (tm
->tm_hour
* 3600000));
9437 uptime
= bgp_clock();
9438 uptime
-= p
->last_write
;
9439 tm
= gmtime(&uptime
);
9440 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9441 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9442 + (tm
->tm_hour
* 3600000));
9444 uptime
= bgp_clock();
9445 uptime
-= p
->update_time
;
9446 tm
= gmtime(&uptime
);
9447 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9448 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9449 + (tm
->tm_hour
* 3600000));
9451 /* Configured timer values. */
9452 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9453 p
->v_holdtime
* 1000);
9454 json_object_int_add(json_neigh
,
9455 "bgpTimerKeepAliveIntervalMsecs",
9456 p
->v_keepalive
* 1000);
9457 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9458 json_object_int_add(json_neigh
,
9459 "bgpTimerConfiguredHoldTimeMsecs",
9460 p
->holdtime
* 1000);
9461 json_object_int_add(
9463 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9464 p
->keepalive
* 1000);
9465 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9466 || (bgp
->default_keepalive
9467 != BGP_DEFAULT_KEEPALIVE
)) {
9468 json_object_int_add(json_neigh
,
9469 "bgpTimerConfiguredHoldTimeMsecs",
9470 bgp
->default_holdtime
);
9471 json_object_int_add(
9473 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9474 bgp
->default_keepalive
);
9477 /* Administrative shutdown. */
9478 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9479 vty_out(vty
, " Administratively shut down\n");
9482 vty_out(vty
, " BGP version 4");
9483 vty_out(vty
, ", remote router ID %s",
9484 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9485 vty_out(vty
, ", local router ID %s\n",
9486 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9490 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9491 && bgp_confederation_peers_check(bgp
, p
->as
))
9493 " Neighbor under common administration\n");
9496 vty_out(vty
, " BGP state = %s",
9497 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9499 if (p
->status
== Established
)
9500 vty_out(vty
, ", up for %8s",
9501 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9504 else if (p
->status
== Active
) {
9505 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9506 vty_out(vty
, " (passive)");
9507 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9508 vty_out(vty
, " (NSF passive)");
9513 vty_out(vty
, " Last read %s",
9514 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9516 vty_out(vty
, ", Last write %s\n",
9517 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9520 /* Configured timer values. */
9522 " Hold time is %d, keepalive interval is %d seconds\n",
9523 p
->v_holdtime
, p
->v_keepalive
);
9524 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9525 vty_out(vty
, " Configured hold time is %d",
9527 vty_out(vty
, ", keepalive interval is %d seconds\n",
9529 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9530 || (bgp
->default_keepalive
9531 != BGP_DEFAULT_KEEPALIVE
)) {
9532 vty_out(vty
, " Configured hold time is %d",
9533 bgp
->default_holdtime
);
9534 vty_out(vty
, ", keepalive interval is %d seconds\n",
9535 bgp
->default_keepalive
);
9539 if (p
->status
== Established
) {
9540 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9541 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9542 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9543 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9544 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9545 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9546 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9547 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9548 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9549 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9550 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9551 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9552 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9553 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9554 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9555 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9556 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9557 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9558 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9559 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9561 json_object
*json_cap
= NULL
;
9563 json_cap
= json_object_new_object();
9566 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9567 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9568 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9569 && CHECK_FLAG(p
->cap
,
9571 json_object_string_add(
9572 json_cap
, "4byteAs",
9573 "advertisedAndReceived");
9574 else if (CHECK_FLAG(p
->cap
,
9576 json_object_string_add(
9577 json_cap
, "4byteAs",
9579 else if (CHECK_FLAG(p
->cap
,
9581 json_object_string_add(
9582 json_cap
, "4byteAs",
9587 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9588 || CHECK_FLAG(p
->cap
,
9589 PEER_CAP_ADDPATH_ADV
)) {
9590 json_object
*json_add
= NULL
;
9591 const char *print_store
;
9593 json_add
= json_object_new_object();
9595 FOREACH_AFI_SAFI (afi
, safi
) {
9596 json_object
*json_sub
= NULL
;
9598 json_object_new_object();
9599 print_store
= afi_safi_print(
9605 PEER_CAP_ADDPATH_AF_TX_ADV
)
9609 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9614 PEER_CAP_ADDPATH_AF_TX_ADV
)
9619 PEER_CAP_ADDPATH_AF_TX_RCV
))
9620 json_object_boolean_true_add(
9622 "txAdvertisedAndReceived");
9628 PEER_CAP_ADDPATH_AF_TX_ADV
))
9629 json_object_boolean_true_add(
9637 PEER_CAP_ADDPATH_AF_TX_RCV
))
9638 json_object_boolean_true_add(
9646 PEER_CAP_ADDPATH_AF_RX_ADV
)
9650 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9655 PEER_CAP_ADDPATH_AF_RX_ADV
)
9660 PEER_CAP_ADDPATH_AF_RX_RCV
))
9661 json_object_boolean_true_add(
9663 "rxAdvertisedAndReceived");
9669 PEER_CAP_ADDPATH_AF_RX_ADV
))
9670 json_object_boolean_true_add(
9678 PEER_CAP_ADDPATH_AF_RX_RCV
))
9679 json_object_boolean_true_add(
9687 PEER_CAP_ADDPATH_AF_TX_ADV
)
9691 PEER_CAP_ADDPATH_AF_TX_RCV
)
9695 PEER_CAP_ADDPATH_AF_RX_ADV
)
9699 PEER_CAP_ADDPATH_AF_RX_RCV
))
9700 json_object_object_add(
9709 json_object_object_add(
9710 json_cap
, "addPath", json_add
);
9714 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9715 || CHECK_FLAG(p
->cap
,
9716 PEER_CAP_DYNAMIC_ADV
)) {
9717 if (CHECK_FLAG(p
->cap
,
9718 PEER_CAP_DYNAMIC_ADV
)
9719 && CHECK_FLAG(p
->cap
,
9720 PEER_CAP_DYNAMIC_RCV
))
9721 json_object_string_add(
9722 json_cap
, "dynamic",
9723 "advertisedAndReceived");
9724 else if (CHECK_FLAG(
9726 PEER_CAP_DYNAMIC_ADV
))
9727 json_object_string_add(
9728 json_cap
, "dynamic",
9730 else if (CHECK_FLAG(
9732 PEER_CAP_DYNAMIC_RCV
))
9733 json_object_string_add(
9734 json_cap
, "dynamic",
9738 /* Extended nexthop */
9739 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9740 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9741 json_object
*json_nxt
= NULL
;
9742 const char *print_store
;
9745 if (CHECK_FLAG(p
->cap
,
9747 && CHECK_FLAG(p
->cap
,
9749 json_object_string_add(
9752 "advertisedAndReceived");
9753 else if (CHECK_FLAG(p
->cap
,
9755 json_object_string_add(
9759 else if (CHECK_FLAG(p
->cap
,
9761 json_object_string_add(
9766 if (CHECK_FLAG(p
->cap
,
9767 PEER_CAP_ENHE_RCV
)) {
9769 json_object_new_object();
9771 for (safi
= SAFI_UNICAST
;
9772 safi
< SAFI_MAX
; safi
++) {
9777 PEER_CAP_ENHE_AF_RCV
)) {
9778 print_store
= afi_safi_print(
9781 json_object_string_add(
9784 "recieved"); /* misspelled for compatibility */
9787 json_object_object_add(
9789 "extendedNexthopFamililesByPeer",
9795 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9796 || CHECK_FLAG(p
->cap
,
9797 PEER_CAP_REFRESH_NEW_RCV
)
9798 || CHECK_FLAG(p
->cap
,
9799 PEER_CAP_REFRESH_OLD_RCV
)) {
9800 if (CHECK_FLAG(p
->cap
,
9801 PEER_CAP_REFRESH_ADV
)
9804 PEER_CAP_REFRESH_NEW_RCV
)
9807 PEER_CAP_REFRESH_OLD_RCV
))) {
9810 PEER_CAP_REFRESH_OLD_RCV
)
9813 PEER_CAP_REFRESH_NEW_RCV
))
9814 json_object_string_add(
9817 "advertisedAndReceivedOldNew");
9821 PEER_CAP_REFRESH_OLD_RCV
))
9822 json_object_string_add(
9825 "advertisedAndReceivedOld");
9827 json_object_string_add(
9830 "advertisedAndReceivedNew");
9835 PEER_CAP_REFRESH_ADV
))
9836 json_object_string_add(
9843 PEER_CAP_REFRESH_NEW_RCV
)
9846 PEER_CAP_REFRESH_OLD_RCV
))
9847 json_object_string_add(
9853 /* Multiprotocol Extensions */
9854 json_object
*json_multi
= NULL
;
9855 json_multi
= json_object_new_object();
9857 FOREACH_AFI_SAFI (afi
, safi
) {
9858 if (p
->afc_adv
[afi
][safi
]
9859 || p
->afc_recv
[afi
][safi
]) {
9860 json_object
*json_exten
= NULL
;
9862 json_object_new_object();
9864 if (p
->afc_adv
[afi
][safi
]
9865 && p
->afc_recv
[afi
][safi
])
9866 json_object_boolean_true_add(
9868 "advertisedAndReceived");
9869 else if (p
->afc_adv
[afi
][safi
])
9870 json_object_boolean_true_add(
9873 else if (p
->afc_recv
[afi
][safi
])
9874 json_object_boolean_true_add(
9878 json_object_object_add(
9885 json_object_object_add(
9886 json_cap
, "multiprotocolExtensions",
9889 /* Hostname capabilities */
9890 json_object
*json_hname
= NULL
;
9892 json_hname
= json_object_new_object();
9894 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9895 json_object_string_add(
9896 json_hname
, "advHostName",
9897 bgp
->peer_self
->hostname
9901 json_object_string_add(
9902 json_hname
, "advDomainName",
9903 bgp
->peer_self
->domainname
9910 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9911 json_object_string_add(
9912 json_hname
, "rcvHostName",
9913 p
->hostname
? p
->hostname
9915 json_object_string_add(
9916 json_hname
, "rcvDomainName",
9917 p
->domainname
? p
->domainname
9921 json_object_object_add(json_cap
, "hostName",
9924 /* Gracefull Restart */
9925 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9926 || CHECK_FLAG(p
->cap
,
9927 PEER_CAP_RESTART_ADV
)) {
9928 if (CHECK_FLAG(p
->cap
,
9929 PEER_CAP_RESTART_ADV
)
9930 && CHECK_FLAG(p
->cap
,
9931 PEER_CAP_RESTART_RCV
))
9932 json_object_string_add(
9935 "advertisedAndReceived");
9936 else if (CHECK_FLAG(
9938 PEER_CAP_RESTART_ADV
))
9939 json_object_string_add(
9941 "gracefulRestartCapability",
9943 else if (CHECK_FLAG(
9945 PEER_CAP_RESTART_RCV
))
9946 json_object_string_add(
9948 "gracefulRestartCapability",
9951 if (CHECK_FLAG(p
->cap
,
9952 PEER_CAP_RESTART_RCV
)) {
9953 int restart_af_count
= 0;
9954 json_object
*json_restart
=
9957 json_object_new_object();
9959 json_object_int_add(
9961 "gracefulRestartRemoteTimerMsecs",
9962 p
->v_gr_restart
* 1000);
9964 FOREACH_AFI_SAFI (afi
, safi
) {
9969 PEER_CAP_RESTART_AF_RCV
)) {
9974 json_object_new_object();
9980 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9981 json_object_boolean_true_add(
9985 json_object_object_add(
9993 if (!restart_af_count
) {
9994 json_object_string_add(
9996 "addressFamiliesByPeer",
10001 json_object_object_add(
10003 "addressFamiliesByPeer",
10007 json_object_object_add(json_neigh
,
10008 "neighborCapabilities",
10011 vty_out(vty
, " Neighbor capabilities:\n");
10014 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10015 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10016 vty_out(vty
, " 4 Byte AS:");
10017 if (CHECK_FLAG(p
->cap
,
10019 vty_out(vty
, " advertised");
10020 if (CHECK_FLAG(p
->cap
,
10022 vty_out(vty
, " %sreceived",
10028 vty_out(vty
, "\n");
10032 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10033 || CHECK_FLAG(p
->cap
,
10034 PEER_CAP_ADDPATH_ADV
)) {
10035 vty_out(vty
, " AddPath:\n");
10037 FOREACH_AFI_SAFI (afi
, safi
) {
10041 PEER_CAP_ADDPATH_AF_TX_ADV
)
10045 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10056 PEER_CAP_ADDPATH_AF_TX_ADV
))
10067 PEER_CAP_ADDPATH_AF_TX_RCV
))
10074 PEER_CAP_ADDPATH_AF_TX_ADV
)
10078 vty_out(vty
, "\n");
10084 PEER_CAP_ADDPATH_AF_RX_ADV
)
10088 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10099 PEER_CAP_ADDPATH_AF_RX_ADV
))
10110 PEER_CAP_ADDPATH_AF_RX_RCV
))
10117 PEER_CAP_ADDPATH_AF_RX_ADV
)
10121 vty_out(vty
, "\n");
10127 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10128 || CHECK_FLAG(p
->cap
,
10129 PEER_CAP_DYNAMIC_ADV
)) {
10130 vty_out(vty
, " Dynamic:");
10131 if (CHECK_FLAG(p
->cap
,
10132 PEER_CAP_DYNAMIC_ADV
))
10133 vty_out(vty
, " advertised");
10134 if (CHECK_FLAG(p
->cap
,
10135 PEER_CAP_DYNAMIC_RCV
))
10136 vty_out(vty
, " %sreceived",
10139 PEER_CAP_DYNAMIC_ADV
)
10142 vty_out(vty
, "\n");
10145 /* Extended nexthop */
10146 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10147 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10148 vty_out(vty
, " Extended nexthop:");
10149 if (CHECK_FLAG(p
->cap
,
10150 PEER_CAP_ENHE_ADV
))
10151 vty_out(vty
, " advertised");
10152 if (CHECK_FLAG(p
->cap
,
10153 PEER_CAP_ENHE_RCV
))
10154 vty_out(vty
, " %sreceived",
10160 vty_out(vty
, "\n");
10162 if (CHECK_FLAG(p
->cap
,
10163 PEER_CAP_ENHE_RCV
)) {
10165 " Address families by peer:\n ");
10166 for (safi
= SAFI_UNICAST
;
10167 safi
< SAFI_MAX
; safi
++)
10172 PEER_CAP_ENHE_AF_RCV
))
10181 /* Route Refresh */
10182 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10183 || CHECK_FLAG(p
->cap
,
10184 PEER_CAP_REFRESH_NEW_RCV
)
10185 || CHECK_FLAG(p
->cap
,
10186 PEER_CAP_REFRESH_OLD_RCV
)) {
10187 vty_out(vty
, " Route refresh:");
10188 if (CHECK_FLAG(p
->cap
,
10189 PEER_CAP_REFRESH_ADV
))
10190 vty_out(vty
, " advertised");
10191 if (CHECK_FLAG(p
->cap
,
10192 PEER_CAP_REFRESH_NEW_RCV
)
10195 PEER_CAP_REFRESH_OLD_RCV
))
10196 vty_out(vty
, " %sreceived(%s)",
10199 PEER_CAP_REFRESH_ADV
)
10204 PEER_CAP_REFRESH_OLD_RCV
)
10207 PEER_CAP_REFRESH_NEW_RCV
))
10211 PEER_CAP_REFRESH_OLD_RCV
)
10215 vty_out(vty
, "\n");
10218 /* Multiprotocol Extensions */
10219 FOREACH_AFI_SAFI (afi
, safi
)
10220 if (p
->afc_adv
[afi
][safi
]
10221 || p
->afc_recv
[afi
][safi
]) {
10223 " Address Family %s:",
10224 afi_safi_print(afi
,
10226 if (p
->afc_adv
[afi
][safi
])
10229 if (p
->afc_recv
[afi
][safi
])
10236 vty_out(vty
, "\n");
10239 /* Hostname capability */
10240 vty_out(vty
, " Hostname Capability:");
10242 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10244 " advertised (name: %s,domain name: %s)",
10245 bgp
->peer_self
->hostname
10249 bgp
->peer_self
->domainname
10254 vty_out(vty
, " not advertised");
10257 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10259 " received (name: %s,domain name: %s)",
10260 p
->hostname
? p
->hostname
10262 p
->domainname
? p
->domainname
10265 vty_out(vty
, " not received");
10268 vty_out(vty
, "\n");
10270 /* Gracefull Restart */
10271 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10272 || CHECK_FLAG(p
->cap
,
10273 PEER_CAP_RESTART_ADV
)) {
10275 " Graceful Restart Capabilty:");
10276 if (CHECK_FLAG(p
->cap
,
10277 PEER_CAP_RESTART_ADV
))
10278 vty_out(vty
, " advertised");
10279 if (CHECK_FLAG(p
->cap
,
10280 PEER_CAP_RESTART_RCV
))
10281 vty_out(vty
, " %sreceived",
10284 PEER_CAP_RESTART_ADV
)
10287 vty_out(vty
, "\n");
10289 if (CHECK_FLAG(p
->cap
,
10290 PEER_CAP_RESTART_RCV
)) {
10291 int restart_af_count
= 0;
10294 " Remote Restart timer is %d seconds\n",
10297 " Address families by peer:\n ");
10299 FOREACH_AFI_SAFI (afi
, safi
)
10304 PEER_CAP_RESTART_AF_RCV
)) {
10317 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10319 : "not preserved");
10320 restart_af_count
++;
10322 if (!restart_af_count
)
10323 vty_out(vty
, "none");
10324 vty_out(vty
, "\n");
10331 /* graceful restart information */
10332 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10333 || p
->t_gr_stale
) {
10334 json_object
*json_grace
= NULL
;
10335 json_object
*json_grace_send
= NULL
;
10336 json_object
*json_grace_recv
= NULL
;
10337 int eor_send_af_count
= 0;
10338 int eor_receive_af_count
= 0;
10341 json_grace
= json_object_new_object();
10342 json_grace_send
= json_object_new_object();
10343 json_grace_recv
= json_object_new_object();
10345 if (p
->status
== Established
) {
10346 FOREACH_AFI_SAFI (afi
, safi
) {
10347 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10348 PEER_STATUS_EOR_SEND
)) {
10349 json_object_boolean_true_add(
10351 afi_safi_print(afi
,
10353 eor_send_af_count
++;
10356 FOREACH_AFI_SAFI (afi
, safi
) {
10358 p
->af_sflags
[afi
][safi
],
10359 PEER_STATUS_EOR_RECEIVED
)) {
10360 json_object_boolean_true_add(
10362 afi_safi_print(afi
,
10364 eor_receive_af_count
++;
10369 json_object_object_add(json_grace
, "endOfRibSend",
10371 json_object_object_add(json_grace
, "endOfRibRecv",
10374 if (p
->t_gr_restart
)
10375 json_object_int_add(json_grace
,
10376 "gracefulRestartTimerMsecs",
10377 thread_timer_remain_second(
10382 json_object_int_add(
10384 "gracefulStalepathTimerMsecs",
10385 thread_timer_remain_second(
10389 json_object_object_add(
10390 json_neigh
, "gracefulRestartInfo", json_grace
);
10392 vty_out(vty
, " Graceful restart information:\n");
10393 if (p
->status
== Established
) {
10394 vty_out(vty
, " End-of-RIB send: ");
10395 FOREACH_AFI_SAFI (afi
, safi
) {
10396 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10397 PEER_STATUS_EOR_SEND
)) {
10398 vty_out(vty
, "%s%s",
10399 eor_send_af_count
? ", "
10401 afi_safi_print(afi
,
10403 eor_send_af_count
++;
10406 vty_out(vty
, "\n");
10407 vty_out(vty
, " End-of-RIB received: ");
10408 FOREACH_AFI_SAFI (afi
, safi
) {
10410 p
->af_sflags
[afi
][safi
],
10411 PEER_STATUS_EOR_RECEIVED
)) {
10412 vty_out(vty
, "%s%s",
10413 eor_receive_af_count
10416 afi_safi_print(afi
,
10418 eor_receive_af_count
++;
10421 vty_out(vty
, "\n");
10424 if (p
->t_gr_restart
)
10426 " The remaining time of restart timer is %ld\n",
10427 thread_timer_remain_second(
10432 " The remaining time of stalepath timer is %ld\n",
10433 thread_timer_remain_second(
10438 json_object
*json_stat
= NULL
;
10439 json_stat
= json_object_new_object();
10440 /* Packet counts. */
10441 json_object_int_add(json_stat
, "depthInq", 0);
10442 json_object_int_add(json_stat
, "depthOutq",
10443 (unsigned long)p
->obuf
->count
);
10444 json_object_int_add(json_stat
, "opensSent",
10445 atomic_load_explicit(&p
->open_out
,
10446 memory_order_relaxed
));
10447 json_object_int_add(json_stat
, "opensRecv",
10448 atomic_load_explicit(&p
->open_in
,
10449 memory_order_relaxed
));
10450 json_object_int_add(json_stat
, "notificationsSent",
10451 atomic_load_explicit(&p
->notify_out
,
10452 memory_order_relaxed
));
10453 json_object_int_add(json_stat
, "notificationsRecv",
10454 atomic_load_explicit(&p
->notify_in
,
10455 memory_order_relaxed
));
10456 json_object_int_add(json_stat
, "updatesSent",
10457 atomic_load_explicit(&p
->update_out
,
10458 memory_order_relaxed
));
10459 json_object_int_add(json_stat
, "updatesRecv",
10460 atomic_load_explicit(&p
->update_in
,
10461 memory_order_relaxed
));
10462 json_object_int_add(json_stat
, "keepalivesSent",
10463 atomic_load_explicit(&p
->keepalive_out
,
10464 memory_order_relaxed
));
10465 json_object_int_add(json_stat
, "keepalivesRecv",
10466 atomic_load_explicit(&p
->keepalive_in
,
10467 memory_order_relaxed
));
10468 json_object_int_add(json_stat
, "routeRefreshSent",
10469 atomic_load_explicit(&p
->refresh_out
,
10470 memory_order_relaxed
));
10471 json_object_int_add(json_stat
, "routeRefreshRecv",
10472 atomic_load_explicit(&p
->refresh_in
,
10473 memory_order_relaxed
));
10474 json_object_int_add(json_stat
, "capabilitySent",
10475 atomic_load_explicit(&p
->dynamic_cap_out
,
10476 memory_order_relaxed
));
10477 json_object_int_add(json_stat
, "capabilityRecv",
10478 atomic_load_explicit(&p
->dynamic_cap_in
,
10479 memory_order_relaxed
));
10480 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10481 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10482 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10484 /* Packet counts. */
10485 vty_out(vty
, " Message statistics:\n");
10486 vty_out(vty
, " Inq depth is 0\n");
10487 vty_out(vty
, " Outq depth is %lu\n",
10488 (unsigned long)p
->obuf
->count
);
10489 vty_out(vty
, " Sent Rcvd\n");
10490 vty_out(vty
, " Opens: %10d %10d\n",
10491 atomic_load_explicit(&p
->open_out
,
10492 memory_order_relaxed
),
10493 atomic_load_explicit(&p
->open_in
,
10494 memory_order_relaxed
));
10495 vty_out(vty
, " Notifications: %10d %10d\n",
10496 atomic_load_explicit(&p
->notify_out
,
10497 memory_order_relaxed
),
10498 atomic_load_explicit(&p
->notify_in
,
10499 memory_order_relaxed
));
10500 vty_out(vty
, " Updates: %10d %10d\n",
10501 atomic_load_explicit(&p
->update_out
,
10502 memory_order_relaxed
),
10503 atomic_load_explicit(&p
->update_in
,
10504 memory_order_relaxed
));
10505 vty_out(vty
, " Keepalives: %10d %10d\n",
10506 atomic_load_explicit(&p
->keepalive_out
,
10507 memory_order_relaxed
),
10508 atomic_load_explicit(&p
->keepalive_in
,
10509 memory_order_relaxed
));
10510 vty_out(vty
, " Route Refresh: %10d %10d\n",
10511 atomic_load_explicit(&p
->refresh_out
,
10512 memory_order_relaxed
),
10513 atomic_load_explicit(&p
->refresh_in
,
10514 memory_order_relaxed
));
10515 vty_out(vty
, " Capability: %10d %10d\n",
10516 atomic_load_explicit(&p
->dynamic_cap_out
,
10517 memory_order_relaxed
),
10518 atomic_load_explicit(&p
->dynamic_cap_in
,
10519 memory_order_relaxed
));
10520 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10525 /* advertisement-interval */
10526 json_object_int_add(json_neigh
,
10527 "minBtwnAdvertisementRunsTimerMsecs",
10528 p
->v_routeadv
* 1000);
10530 /* Update-source. */
10531 if (p
->update_if
|| p
->update_source
) {
10533 json_object_string_add(json_neigh
,
10536 else if (p
->update_source
)
10537 json_object_string_add(
10538 json_neigh
, "updateSource",
10539 sockunion2str(p
->update_source
, buf1
,
10543 /* advertisement-interval */
10545 " Minimum time between advertisement runs is %d seconds\n",
10548 /* Update-source. */
10549 if (p
->update_if
|| p
->update_source
) {
10550 vty_out(vty
, " Update source is ");
10552 vty_out(vty
, "%s", p
->update_if
);
10553 else if (p
->update_source
)
10555 sockunion2str(p
->update_source
, buf1
,
10557 vty_out(vty
, "\n");
10560 vty_out(vty
, "\n");
10563 /* Address Family Information */
10564 json_object
*json_hold
= NULL
;
10567 json_hold
= json_object_new_object();
10569 FOREACH_AFI_SAFI (afi
, safi
)
10570 if (p
->afc
[afi
][safi
])
10571 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10575 json_object_object_add(json_neigh
, "addressFamilyInfo",
10577 json_object_int_add(json_neigh
, "connectionsEstablished",
10579 json_object_int_add(json_neigh
, "connectionsDropped",
10582 vty_out(vty
, " Connections established %d; dropped %d\n",
10583 p
->established
, p
->dropped
);
10585 if (!p
->last_reset
) {
10587 json_object_string_add(json_neigh
, "lastReset",
10590 vty_out(vty
, " Last reset never\n");
10596 uptime
= bgp_clock();
10597 uptime
-= p
->resettime
;
10598 tm
= gmtime(&uptime
);
10599 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10600 (tm
->tm_sec
* 1000)
10601 + (tm
->tm_min
* 60000)
10602 + (tm
->tm_hour
* 3600000));
10603 json_object_string_add(
10604 json_neigh
, "lastResetDueTo",
10605 peer_down_str
[(int)p
->last_reset
]);
10606 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10607 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10608 char errorcodesubcode_hexstr
[5];
10609 char errorcodesubcode_str
[256];
10611 code_str
= bgp_notify_code_str(p
->notify
.code
);
10612 subcode_str
= bgp_notify_subcode_str(
10613 p
->notify
.code
, p
->notify
.subcode
);
10615 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10616 p
->notify
.code
, p
->notify
.subcode
);
10617 json_object_string_add(json_neigh
,
10618 "lastErrorCodeSubcode",
10619 errorcodesubcode_hexstr
);
10620 snprintf(errorcodesubcode_str
, 255, "%s%s",
10621 code_str
, subcode_str
);
10622 json_object_string_add(json_neigh
,
10623 "lastNotificationReason",
10624 errorcodesubcode_str
);
10625 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10626 && p
->notify
.code
== BGP_NOTIFY_CEASE
10627 && (p
->notify
.subcode
10628 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10629 || p
->notify
.subcode
10630 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10631 && p
->notify
.length
) {
10633 const char *msg_str
;
10635 msg_str
= bgp_notify_admin_message(
10636 msgbuf
, sizeof(msgbuf
),
10637 (uint8_t *)p
->notify
.data
,
10640 json_object_string_add(
10642 "lastShutdownDescription",
10647 vty_out(vty
, " Last reset %s, ",
10648 peer_uptime(p
->resettime
, timebuf
,
10649 BGP_UPTIME_LEN
, 0, NULL
));
10651 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10652 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10653 code_str
= bgp_notify_code_str(p
->notify
.code
);
10654 subcode_str
= bgp_notify_subcode_str(
10655 p
->notify
.code
, p
->notify
.subcode
);
10656 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10657 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10660 code_str
, subcode_str
);
10661 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10662 && p
->notify
.code
== BGP_NOTIFY_CEASE
10663 && (p
->notify
.subcode
10664 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10665 || p
->notify
.subcode
10666 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10667 && p
->notify
.length
) {
10669 const char *msg_str
;
10671 msg_str
= bgp_notify_admin_message(
10672 msgbuf
, sizeof(msgbuf
),
10673 (uint8_t *)p
->notify
.data
,
10677 " Message: \"%s\"\n",
10681 vty_out(vty
, "due to %s\n",
10682 peer_down_str
[(int)p
->last_reset
]);
10685 if (p
->last_reset_cause_size
) {
10686 msg
= p
->last_reset_cause
;
10688 " Message received that caused BGP to send a NOTIFICATION:\n ");
10689 for (i
= 1; i
<= p
->last_reset_cause_size
;
10691 vty_out(vty
, "%02X", *msg
++);
10693 if (i
!= p
->last_reset_cause_size
) {
10695 vty_out(vty
, "\n ");
10696 } else if (i
% 4 == 0) {
10701 vty_out(vty
, "\n");
10706 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10708 json_object_boolean_true_add(json_neigh
,
10709 "prefixesConfigExceedMax");
10712 " Peer had exceeded the max. no. of prefixes configured.\n");
10714 if (p
->t_pmax_restart
) {
10716 json_object_boolean_true_add(
10717 json_neigh
, "reducePrefixNumFrom");
10718 json_object_int_add(json_neigh
,
10719 "restartInTimerMsec",
10720 thread_timer_remain_second(
10725 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10726 p
->host
, thread_timer_remain_second(
10727 p
->t_pmax_restart
));
10730 json_object_boolean_true_add(
10732 "reducePrefixNumAndClearIpBgp");
10735 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10740 /* EBGP Multihop and GTSM */
10741 if (p
->sort
!= BGP_PEER_IBGP
) {
10743 if (p
->gtsm_hops
> 0)
10744 json_object_int_add(json_neigh
,
10745 "externalBgpNbrMaxHopsAway",
10747 else if (p
->ttl
> 1)
10748 json_object_int_add(json_neigh
,
10749 "externalBgpNbrMaxHopsAway",
10752 if (p
->gtsm_hops
> 0)
10754 " External BGP neighbor may be up to %d hops away.\n",
10756 else if (p
->ttl
> 1)
10758 " External BGP neighbor may be up to %d hops away.\n",
10762 if (p
->gtsm_hops
> 0) {
10764 json_object_int_add(json_neigh
,
10765 "internalBgpNbrMaxHopsAway",
10769 " Internal BGP neighbor may be up to %d hops away.\n",
10774 /* Local address. */
10777 json_object_string_add(json_neigh
, "hostLocal",
10778 sockunion2str(p
->su_local
, buf1
,
10780 json_object_int_add(json_neigh
, "portLocal",
10781 ntohs(p
->su_local
->sin
.sin_port
));
10783 vty_out(vty
, "Local host: %s, Local port: %d\n",
10784 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10785 ntohs(p
->su_local
->sin
.sin_port
));
10788 /* Remote address. */
10789 if (p
->su_remote
) {
10791 json_object_string_add(json_neigh
, "hostForeign",
10792 sockunion2str(p
->su_remote
, buf1
,
10794 json_object_int_add(json_neigh
, "portForeign",
10795 ntohs(p
->su_remote
->sin
.sin_port
));
10797 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10798 sockunion2str(p
->su_remote
, buf1
,
10800 ntohs(p
->su_remote
->sin
.sin_port
));
10803 /* Nexthop display. */
10806 json_object_string_add(json_neigh
, "nexthop",
10808 &p
->nexthop
.v4
, buf1
,
10810 json_object_string_add(json_neigh
, "nexthopGlobal",
10811 inet_ntop(AF_INET6
,
10812 &p
->nexthop
.v6_global
,
10813 buf1
, sizeof(buf1
)));
10814 json_object_string_add(json_neigh
, "nexthopLocal",
10815 inet_ntop(AF_INET6
,
10816 &p
->nexthop
.v6_local
,
10817 buf1
, sizeof(buf1
)));
10818 if (p
->shared_network
)
10819 json_object_string_add(json_neigh
,
10823 json_object_string_add(json_neigh
,
10825 "nonSharedNetwork");
10827 vty_out(vty
, "Nexthop: %s\n",
10828 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10830 vty_out(vty
, "Nexthop global: %s\n",
10831 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10833 vty_out(vty
, "Nexthop local: %s\n",
10834 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10836 vty_out(vty
, "BGP connection: %s\n",
10837 p
->shared_network
? "shared network"
10838 : "non shared network");
10842 /* Timer information. */
10844 json_object_int_add(json_neigh
, "connectRetryTimer",
10846 if (p
->status
== Established
&& p
->rtt
)
10847 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10850 json_object_int_add(
10851 json_neigh
, "nextStartTimerDueInMsecs",
10852 thread_timer_remain_second(p
->t_start
) * 1000);
10854 json_object_int_add(
10855 json_neigh
, "nextConnectTimerDueInMsecs",
10856 thread_timer_remain_second(p
->t_connect
)
10858 if (p
->t_routeadv
) {
10859 json_object_int_add(json_neigh
, "mraiInterval",
10861 json_object_int_add(
10862 json_neigh
, "mraiTimerExpireInMsecs",
10863 thread_timer_remain_second(p
->t_routeadv
)
10867 json_object_int_add(json_neigh
, "authenticationEnabled",
10871 json_object_string_add(json_neigh
, "readThread", "on");
10873 json_object_string_add(json_neigh
, "readThread", "off");
10875 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10876 json_object_string_add(json_neigh
, "writeThread", "on");
10878 json_object_string_add(json_neigh
, "writeThread",
10881 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10883 if (p
->status
== Established
&& p
->rtt
)
10884 vty_out(vty
, "Estimated round trip time: %d ms\n",
10887 vty_out(vty
, "Next start timer due in %ld seconds\n",
10888 thread_timer_remain_second(p
->t_start
));
10890 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10891 thread_timer_remain_second(p
->t_connect
));
10894 "MRAI (interval %u) timer expires in %ld seconds\n",
10896 thread_timer_remain_second(p
->t_routeadv
));
10898 vty_out(vty
, "Peer Authentication Enabled\n");
10900 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10901 p
->t_read
? "on" : "off",
10902 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10907 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10908 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10909 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10912 vty_out(vty
, "\n");
10914 /* BFD information. */
10915 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10918 if (p
->conf_if
) /* Configured interface name. */
10919 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10920 else /* Configured IP address. */
10921 json_object_object_add(json
, p
->host
, json_neigh
);
10925 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10926 enum show_type type
, union sockunion
*su
,
10927 const char *conf_if
, bool use_json
,
10930 struct listnode
*node
, *nnode
;
10933 bool nbr_output
= false;
10934 afi_t afi
= AFI_MAX
;
10935 safi_t safi
= SAFI_MAX
;
10937 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10939 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10943 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10944 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10949 bgp_show_peer(vty
, peer
, use_json
, json
);
10955 && !strcmp(peer
->conf_if
, conf_if
))
10957 && !strcmp(peer
->hostname
, conf_if
))) {
10959 bgp_show_peer(vty
, peer
, use_json
,
10963 if (sockunion_same(&peer
->su
, su
)) {
10965 bgp_show_peer(vty
, peer
, use_json
,
10970 case show_ipv4_peer
:
10971 case show_ipv6_peer
:
10972 FOREACH_SAFI (safi
) {
10973 if (peer
->afc
[afi
][safi
]) {
10976 && !strcmp(peer
->conf_if
, conf_if
))
10978 && !strcmp(peer
->hostname
, conf_if
))) {
10980 bgp_show_peer(vty
, peer
, use_json
,
10985 if (sockunion_same(&peer
->su
, su
)) {
10987 bgp_show_peer(vty
, peer
, use_json
,
10995 case show_ipv4_all
:
10996 case show_ipv6_all
:
10997 FOREACH_SAFI (safi
) {
10998 if (peer
->afc
[afi
][safi
]) {
10999 bgp_show_peer(vty
, peer
, use_json
, json
);
11008 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11009 type
== show_ipv6_peer
) && !find
) {
11011 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11013 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11016 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11017 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11018 vty_out(vty
, "%% No BGP neighbors found\n");
11021 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11022 json
, JSON_C_TO_STRING_PRETTY
));
11024 vty_out(vty
, "\n");
11027 return CMD_SUCCESS
;
11030 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11031 enum show_type type
,
11032 const char *ip_str
,
11035 struct listnode
*node
, *nnode
;
11037 union sockunion su
;
11038 json_object
*json
= NULL
;
11039 int ret
, is_first
= 1;
11040 bool nbr_output
= false;
11043 vty_out(vty
, "{\n");
11045 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11048 if (!(json
= json_object_new_object())) {
11050 EC_BGP_JSON_MEM_ERROR
,
11051 "Unable to allocate memory for JSON object");
11053 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11057 json_object_int_add(json
, "vrfId",
11058 (bgp
->vrf_id
== VRF_UNKNOWN
)
11060 : (int64_t)bgp
->vrf_id
);
11061 json_object_string_add(
11063 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11068 vty_out(vty
, ",\n");
11072 vty_out(vty
, "\"%s\":",
11073 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11077 vty_out(vty
, "\nInstance %s:\n",
11078 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11083 if (type
== show_peer
|| type
== show_ipv4_peer
||
11084 type
== show_ipv6_peer
) {
11085 ret
= str2sockunion(ip_str
, &su
);
11087 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11090 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11093 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11096 json_object_free(json
);
11100 vty_out(vty
, "}\n");
11101 json_object_free(json
);
11103 else if (!nbr_output
)
11104 vty_out(vty
, "%% BGP instance not found\n");
11107 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11108 enum show_type type
, const char *ip_str
,
11113 union sockunion su
;
11114 json_object
*json
= NULL
;
11117 if (strmatch(name
, "all")) {
11118 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11120 return CMD_SUCCESS
;
11122 bgp
= bgp_lookup_by_name(name
);
11125 json
= json_object_new_object();
11126 vty_out(vty
, "%s\n",
11127 json_object_to_json_string_ext(
11129 JSON_C_TO_STRING_PRETTY
));
11130 json_object_free(json
);
11133 "%% BGP instance not found\n");
11135 return CMD_WARNING
;
11139 bgp
= bgp_get_default();
11143 json
= json_object_new_object();
11145 ret
= str2sockunion(ip_str
, &su
);
11147 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11150 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11153 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11156 json_object_free(json
);
11159 vty_out(vty
, "{}\n");
11161 vty_out(vty
, "%% BGP instance not found\n");
11164 return CMD_SUCCESS
;
11167 /* "show [ip] bgp neighbors" commands. */
11168 DEFUN (show_ip_bgp_neighbors
,
11169 show_ip_bgp_neighbors_cmd
,
11170 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11174 BGP_INSTANCE_HELP_STR
11177 "Detailed information on TCP and BGP neighbor connections\n"
11178 "Neighbor to display information about\n"
11179 "Neighbor to display information about\n"
11180 "Neighbor on BGP configured interface\n"
11184 char *sh_arg
= NULL
;
11185 enum show_type sh_type
;
11186 afi_t afi
= AFI_MAX
;
11188 bool uj
= use_json(argc
, argv
);
11192 /* [<vrf> VIEWVRFNAME] */
11193 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11194 vrf
= argv
[idx
+ 1]->arg
;
11195 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11197 } else if (argv_find(argv
, argc
, "view", &idx
))
11198 /* [<view> VIEWVRFNAME] */
11199 vrf
= argv
[idx
+ 1]->arg
;
11203 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11204 sh_type
= show_ipv4_all
;
11206 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11207 sh_type
= show_ipv6_all
;
11210 sh_type
= show_all
;
11213 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11214 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11215 || argv_find(argv
, argc
, "WORD", &idx
)) {
11216 sh_type
= show_peer
;
11217 sh_arg
= argv
[idx
]->arg
;
11220 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11221 sh_type
= show_ipv4_peer
;
11222 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11223 sh_type
= show_ipv6_peer
;
11226 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11229 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11230 paths' and `show ip mbgp paths'. Those functions results are the
11232 DEFUN (show_ip_bgp_paths
,
11233 show_ip_bgp_paths_cmd
,
11234 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11239 "Path information\n")
11241 vty_out(vty
, "Address Refcnt Path\n");
11242 aspath_print_all_vty(vty
);
11243 return CMD_SUCCESS
;
11248 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11251 struct community
*com
;
11253 com
= (struct community
*)bucket
->data
;
11254 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11255 community_str(com
, false));
11258 /* Show BGP's community internal data. */
11259 DEFUN (show_ip_bgp_community_info
,
11260 show_ip_bgp_community_info_cmd
,
11261 "show [ip] bgp community-info",
11265 "List all bgp community information\n")
11267 vty_out(vty
, "Address Refcnt Community\n");
11269 hash_iterate(community_hash(),
11270 (void (*)(struct hash_bucket
*,
11271 void *))community_show_all_iterator
,
11274 return CMD_SUCCESS
;
11277 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11280 struct lcommunity
*lcom
;
11282 lcom
= (struct lcommunity
*)bucket
->data
;
11283 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11284 lcommunity_str(lcom
, false));
11287 /* Show BGP's community internal data. */
11288 DEFUN (show_ip_bgp_lcommunity_info
,
11289 show_ip_bgp_lcommunity_info_cmd
,
11290 "show ip bgp large-community-info",
11294 "List all bgp large-community information\n")
11296 vty_out(vty
, "Address Refcnt Large-community\n");
11298 hash_iterate(lcommunity_hash(),
11299 (void (*)(struct hash_bucket
*,
11300 void *))lcommunity_show_all_iterator
,
11303 return CMD_SUCCESS
;
11307 DEFUN (show_ip_bgp_attr_info
,
11308 show_ip_bgp_attr_info_cmd
,
11309 "show [ip] bgp attribute-info",
11313 "List all bgp attribute information\n")
11315 attr_show_all(vty
);
11316 return CMD_SUCCESS
;
11319 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11320 afi_t afi
, safi_t safi
,
11321 bool use_json
, json_object
*json
)
11324 struct listnode
*node
;
11326 char buf1
[INET6_ADDRSTRLEN
];
11328 vpn_policy_direction_t dir
;
11331 json_object
*json_import_vrfs
= NULL
;
11332 json_object
*json_export_vrfs
= NULL
;
11334 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11337 vty_out(vty
, "%s\n",
11338 json_object_to_json_string_ext(
11340 JSON_C_TO_STRING_PRETTY
));
11341 json_object_free(json
);
11343 return CMD_WARNING
;
11346 /* Provide context for the block */
11347 json_object_string_add(json
, "vrf", name
? name
: "default");
11348 json_object_string_add(json
, "afiSafi",
11349 afi_safi_print(afi
, safi
));
11351 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11352 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11353 json_object_string_add(json
, "importFromVrfs", "none");
11354 json_object_string_add(json
, "importRts", "none");
11356 json_import_vrfs
= json_object_new_array();
11358 for (ALL_LIST_ELEMENTS_RO(
11359 bgp
->vpn_policy
[afi
].import_vrf
,
11361 json_object_array_add(json_import_vrfs
,
11362 json_object_new_string(vname
));
11364 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11365 ecom_str
= ecommunity_ecom2str(
11366 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11367 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11368 json_object_object_add(json
, "importFromVrfs",
11370 json_object_string_add(json
, "importRts", ecom_str
);
11372 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11375 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11376 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11377 json_object_string_add(json
, "exportToVrfs", "none");
11378 json_object_string_add(json
, "routeDistinguisher",
11380 json_object_string_add(json
, "exportRts", "none");
11382 json_export_vrfs
= json_object_new_array();
11384 for (ALL_LIST_ELEMENTS_RO(
11385 bgp
->vpn_policy
[afi
].export_vrf
,
11387 json_object_array_add(json_export_vrfs
,
11388 json_object_new_string(vname
));
11389 json_object_object_add(json
, "exportToVrfs",
11391 json_object_string_add(json
, "routeDistinguisher",
11392 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11393 buf1
, RD_ADDRSTRLEN
));
11395 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11396 ecom_str
= ecommunity_ecom2str(
11397 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11398 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11399 json_object_string_add(json
, "exportRts", ecom_str
);
11401 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11405 vty_out(vty
, "%s\n",
11406 json_object_to_json_string_ext(json
,
11407 JSON_C_TO_STRING_PRETTY
));
11408 json_object_free(json
);
11411 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11414 vty_out(vty
, "%% No such BGP instance exist\n");
11415 return CMD_WARNING
;
11418 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11419 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11421 "This VRF is not importing %s routes from any other VRF\n",
11422 afi_safi_print(afi
, safi
));
11425 "This VRF is importing %s routes from the following VRFs:\n",
11426 afi_safi_print(afi
, safi
));
11428 for (ALL_LIST_ELEMENTS_RO(
11429 bgp
->vpn_policy
[afi
].import_vrf
,
11431 vty_out(vty
, " %s\n", vname
);
11433 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11434 ecom_str
= ecommunity_ecom2str(
11435 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11436 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11437 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11439 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11442 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11443 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11445 "This VRF is not exporting %s routes to any other VRF\n",
11446 afi_safi_print(afi
, safi
));
11449 "This VRF is exporting %s routes to the following VRFs:\n",
11450 afi_safi_print(afi
, safi
));
11452 for (ALL_LIST_ELEMENTS_RO(
11453 bgp
->vpn_policy
[afi
].export_vrf
,
11455 vty_out(vty
, " %s\n", vname
);
11457 vty_out(vty
, "RD: %s\n",
11458 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11459 buf1
, RD_ADDRSTRLEN
));
11461 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11462 ecom_str
= ecommunity_ecom2str(
11463 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11464 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11465 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11466 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11470 return CMD_SUCCESS
;
11473 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11474 safi_t safi
, bool use_json
)
11476 struct listnode
*node
, *nnode
;
11478 char *vrf_name
= NULL
;
11479 json_object
*json
= NULL
;
11480 json_object
*json_vrf
= NULL
;
11481 json_object
*json_vrfs
= NULL
;
11484 json
= json_object_new_object();
11485 json_vrfs
= json_object_new_object();
11488 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11490 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11491 vrf_name
= bgp
->name
;
11494 json_vrf
= json_object_new_object();
11496 vty_out(vty
, "\nInstance %s:\n",
11497 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11498 ? VRF_DEFAULT_NAME
: bgp
->name
);
11500 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11502 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11503 json_object_object_add(json_vrfs
,
11504 VRF_DEFAULT_NAME
, json_vrf
);
11506 json_object_object_add(json_vrfs
, vrf_name
,
11512 json_object_object_add(json
, "vrfs", json_vrfs
);
11513 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11514 JSON_C_TO_STRING_PRETTY
));
11515 json_object_free(json
);
11518 return CMD_SUCCESS
;
11521 /* "show [ip] bgp route-leak" command. */
11522 DEFUN (show_ip_bgp_route_leak
,
11523 show_ip_bgp_route_leak_cmd
,
11524 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11528 BGP_INSTANCE_HELP_STR
11531 "Route leaking information\n"
11535 afi_t afi
= AFI_MAX
;
11536 safi_t safi
= SAFI_MAX
;
11538 bool uj
= use_json(argc
, argv
);
11540 json_object
*json
= NULL
;
11542 /* show [ip] bgp */
11543 if (argv_find(argv
, argc
, "ip", &idx
)) {
11545 safi
= SAFI_UNICAST
;
11547 /* [vrf VIEWVRFNAME] */
11548 if (argv_find(argv
, argc
, "view", &idx
)) {
11550 "%% This command is not applicable to BGP views\n");
11551 return CMD_WARNING
;
11554 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11555 vrf
= argv
[idx
+ 1]->arg
;
11556 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11559 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11560 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11561 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11564 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11566 "%% This command is applicable only for unicast ipv4|ipv6\n");
11567 return CMD_WARNING
;
11570 if (vrf
&& strmatch(vrf
, "all"))
11571 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11574 json
= json_object_new_object();
11576 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11579 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11582 struct listnode
*node
, *nnode
;
11585 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11586 vty_out(vty
, "\nInstance %s:\n",
11587 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11590 update_group_show(bgp
, afi
, safi
, vty
, 0);
11594 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11595 int safi
, uint64_t subgrp_id
)
11600 if (strmatch(name
, "all")) {
11601 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11602 return CMD_SUCCESS
;
11604 bgp
= bgp_lookup_by_name(name
);
11607 bgp
= bgp_get_default();
11611 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11612 return CMD_SUCCESS
;
11615 DEFUN (show_ip_bgp_updgrps
,
11616 show_ip_bgp_updgrps_cmd
,
11617 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11621 BGP_INSTANCE_HELP_STR
11623 BGP_SAFI_WITH_LABEL_HELP_STR
11624 "Detailed info about dynamic update groups\n"
11625 "Specific subgroup to display detailed info for\n")
11628 afi_t afi
= AFI_IP6
;
11629 safi_t safi
= SAFI_UNICAST
;
11630 uint64_t subgrp_id
= 0;
11634 /* show [ip] bgp */
11635 if (argv_find(argv
, argc
, "ip", &idx
))
11637 /* [<vrf> VIEWVRFNAME] */
11638 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11639 vrf
= argv
[idx
+ 1]->arg
;
11640 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11642 } else if (argv_find(argv
, argc
, "view", &idx
))
11643 /* [<view> VIEWVRFNAME] */
11644 vrf
= argv
[idx
+ 1]->arg
;
11645 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11646 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11647 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11650 /* get subgroup id, if provided */
11652 if (argv
[idx
]->type
== VARIABLE_TKN
)
11653 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11655 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11658 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11659 show_bgp_instance_all_ipv6_updgrps_cmd
,
11660 "show [ip] bgp <view|vrf> all update-groups",
11664 BGP_INSTANCE_ALL_HELP_STR
11665 "Detailed info about dynamic update groups\n")
11667 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11668 return CMD_SUCCESS
;
11671 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11672 show_bgp_l2vpn_evpn_updgrps_cmd
,
11673 "show [ip] bgp l2vpn evpn update-groups",
11677 "l2vpn address family\n"
11678 "evpn sub-address family\n"
11679 "Detailed info about dynamic update groups\n")
11682 uint64_t subgrp_id
= 0;
11684 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11685 return CMD_SUCCESS
;
11688 DEFUN (show_bgp_updgrps_stats
,
11689 show_bgp_updgrps_stats_cmd
,
11690 "show [ip] bgp update-groups statistics",
11694 "Detailed info about dynamic update groups\n"
11699 bgp
= bgp_get_default();
11701 update_group_show_stats(bgp
, vty
);
11703 return CMD_SUCCESS
;
11706 DEFUN (show_bgp_instance_updgrps_stats
,
11707 show_bgp_instance_updgrps_stats_cmd
,
11708 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11712 BGP_INSTANCE_HELP_STR
11713 "Detailed info about dynamic update groups\n"
11719 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11721 update_group_show_stats(bgp
, vty
);
11723 return CMD_SUCCESS
;
11726 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11727 afi_t afi
, safi_t safi
,
11728 const char *what
, uint64_t subgrp_id
)
11733 bgp
= bgp_lookup_by_name(name
);
11735 bgp
= bgp_get_default();
11738 if (!strcmp(what
, "advertise-queue"))
11739 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11741 else if (!strcmp(what
, "advertised-routes"))
11742 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11744 else if (!strcmp(what
, "packet-queue"))
11745 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11750 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11751 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11752 "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",
11753 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11755 "Detailed info about dynamic update groups\n"
11756 "Specific subgroup to display info for\n"
11757 "Advertisement queue\n"
11758 "Announced routes\n"
11761 uint64_t subgrp_id
= 0;
11765 subgrp_id
= strtoull(sgid
, NULL
, 10);
11770 afiz
= bgp_vty_afi_from_str(afi
);
11774 afiz
= bgp_vty_afi_from_str(afi
);
11775 if (afiz
!= AFI_IP
)
11777 "%% Cannot specify both 'ip' and 'ipv6'\n");
11778 return CMD_WARNING
;
11781 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11783 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11784 return CMD_SUCCESS
;
11787 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11789 struct listnode
*node
, *nnode
;
11790 struct prefix
*range
;
11793 char buf
[PREFIX2STR_BUFFER
];
11796 const char *peer_status
;
11797 const char *af_str
;
11802 conf
= group
->conf
;
11804 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11805 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11806 group
->name
, conf
->as
);
11807 } else if (conf
->as_type
== AS_INTERNAL
) {
11808 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11809 group
->name
, group
->bgp
->as
);
11811 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11814 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11815 vty_out(vty
, " Peer-group type is internal\n");
11817 vty_out(vty
, " Peer-group type is external\n");
11819 /* Display AFs configured. */
11820 vty_out(vty
, " Configured address-families:");
11821 FOREACH_AFI_SAFI (afi
, safi
) {
11822 if (conf
->afc
[afi
][safi
]) {
11824 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11828 vty_out(vty
, " none\n");
11830 vty_out(vty
, "\n");
11832 /* Display listen ranges (for dynamic neighbors), if any */
11833 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11836 else if (afi
== AFI_IP6
)
11840 lr_count
= listcount(group
->listen_range
[afi
]);
11842 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11846 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11848 prefix2str(range
, buf
, sizeof(buf
));
11849 vty_out(vty
, " %s\n", buf
);
11854 /* Display group members and their status */
11855 if (listcount(group
->peer
)) {
11856 vty_out(vty
, " Peer-group members:\n");
11857 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11858 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11859 peer_status
= "Idle (Admin)";
11860 else if (CHECK_FLAG(peer
->sflags
,
11861 PEER_STATUS_PREFIX_OVERFLOW
))
11862 peer_status
= "Idle (PfxCt)";
11864 peer_status
= lookup_msg(bgp_status_msg
,
11865 peer
->status
, NULL
);
11867 dynamic
= peer_dynamic_neighbor(peer
);
11868 vty_out(vty
, " %s %s %s \n", peer
->host
,
11869 dynamic
? "(dynamic)" : "", peer_status
);
11873 return CMD_SUCCESS
;
11876 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11877 const char *group_name
)
11880 struct listnode
*node
, *nnode
;
11881 struct peer_group
*group
;
11882 bool found
= false;
11884 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11887 vty_out(vty
, "%% BGP instance not found\n");
11888 return CMD_WARNING
;
11891 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11893 if (strmatch(group
->name
, group_name
)) {
11894 bgp_show_one_peer_group(vty
, group
);
11899 bgp_show_one_peer_group(vty
, group
);
11903 if (group_name
&& !found
)
11904 vty_out(vty
, "%% No such peer-group\n");
11906 return CMD_SUCCESS
;
11909 DEFUN (show_ip_bgp_peer_groups
,
11910 show_ip_bgp_peer_groups_cmd
,
11911 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11915 BGP_INSTANCE_HELP_STR
11916 "Detailed information on BGP peer groups\n"
11917 "Peer group name\n")
11922 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11924 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11926 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11930 /* Redistribute VTY commands. */
11932 DEFUN (bgp_redistribute_ipv4
,
11933 bgp_redistribute_ipv4_cmd
,
11934 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11935 "Redistribute information from another routing protocol\n"
11936 FRR_IP_REDIST_HELP_STR_BGPD
)
11938 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11939 int idx_protocol
= 1;
11942 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11944 vty_out(vty
, "%% Invalid route type\n");
11945 return CMD_WARNING_CONFIG_FAILED
;
11948 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11949 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11953 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11954 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11955 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11957 DEFUN (bgp_redistribute_ipv4_rmap
,
11958 bgp_redistribute_ipv4_rmap_cmd
,
11959 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11960 "Redistribute information from another routing protocol\n"
11961 FRR_IP_REDIST_HELP_STR_BGPD
11962 "Route map reference\n"
11963 "Pointer to route-map entries\n")
11965 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11966 int idx_protocol
= 1;
11969 struct bgp_redist
*red
;
11971 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11972 vty
, argv
[idx_word
]->arg
);
11974 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11976 vty_out(vty
, "%% Invalid route type\n");
11977 return CMD_WARNING_CONFIG_FAILED
;
11980 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11982 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11983 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11987 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11988 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11989 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11990 "Route map reference\n"
11991 "Pointer to route-map entries\n")
11993 DEFUN (bgp_redistribute_ipv4_metric
,
11994 bgp_redistribute_ipv4_metric_cmd
,
11995 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11996 "Redistribute information from another routing protocol\n"
11997 FRR_IP_REDIST_HELP_STR_BGPD
11998 "Metric for redistributed routes\n"
11999 "Default metric\n")
12001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12002 int idx_protocol
= 1;
12003 int idx_number
= 3;
12006 struct bgp_redist
*red
;
12009 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12011 vty_out(vty
, "%% Invalid route type\n");
12012 return CMD_WARNING_CONFIG_FAILED
;
12014 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12016 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12017 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12018 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12022 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12023 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12024 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12025 "Metric for redistributed routes\n"
12026 "Default metric\n")
12028 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12029 bgp_redistribute_ipv4_rmap_metric_cmd
,
12030 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12031 "Redistribute information from another routing protocol\n"
12032 FRR_IP_REDIST_HELP_STR_BGPD
12033 "Route map reference\n"
12034 "Pointer to route-map entries\n"
12035 "Metric for redistributed routes\n"
12036 "Default metric\n")
12038 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12039 int idx_protocol
= 1;
12041 int idx_number
= 5;
12044 struct bgp_redist
*red
;
12046 struct route_map
*route_map
=
12047 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12049 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12051 vty_out(vty
, "%% Invalid route type\n");
12052 return CMD_WARNING_CONFIG_FAILED
;
12054 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12056 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12058 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12059 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12060 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12064 bgp_redistribute_ipv4_rmap_metric
,
12065 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12066 "redistribute " FRR_IP_REDIST_STR_BGPD
12067 " route-map WORD metric (0-4294967295)",
12068 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12069 "Route map reference\n"
12070 "Pointer to route-map entries\n"
12071 "Metric for redistributed routes\n"
12072 "Default metric\n")
12074 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12075 bgp_redistribute_ipv4_metric_rmap_cmd
,
12076 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12077 "Redistribute information from another routing protocol\n"
12078 FRR_IP_REDIST_HELP_STR_BGPD
12079 "Metric for redistributed routes\n"
12081 "Route map reference\n"
12082 "Pointer to route-map entries\n")
12084 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12085 int idx_protocol
= 1;
12086 int idx_number
= 3;
12090 struct bgp_redist
*red
;
12092 struct route_map
*route_map
=
12093 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12095 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12097 vty_out(vty
, "%% Invalid route type\n");
12098 return CMD_WARNING_CONFIG_FAILED
;
12100 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12102 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12103 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12105 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12106 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12110 bgp_redistribute_ipv4_metric_rmap
,
12111 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12112 "redistribute " FRR_IP_REDIST_STR_BGPD
12113 " metric (0-4294967295) route-map WORD",
12114 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12115 "Metric for redistributed routes\n"
12117 "Route map reference\n"
12118 "Pointer to route-map entries\n")
12120 DEFUN (bgp_redistribute_ipv4_ospf
,
12121 bgp_redistribute_ipv4_ospf_cmd
,
12122 "redistribute <ospf|table> (1-65535)",
12123 "Redistribute information from another routing protocol\n"
12124 "Open Shortest Path First (OSPFv2)\n"
12125 "Non-main Kernel Routing Table\n"
12126 "Instance ID/Table ID\n")
12128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12129 int idx_ospf_table
= 1;
12130 int idx_number
= 2;
12131 unsigned short instance
;
12132 unsigned short protocol
;
12134 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12136 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12137 protocol
= ZEBRA_ROUTE_OSPF
;
12139 protocol
= ZEBRA_ROUTE_TABLE
;
12141 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12142 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12145 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12146 "redistribute <ospf|table> (1-65535)",
12147 "Redistribute information from another routing protocol\n"
12148 "Open Shortest Path First (OSPFv2)\n"
12149 "Non-main Kernel Routing Table\n"
12150 "Instance ID/Table ID\n")
12152 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12153 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12154 "redistribute <ospf|table> (1-65535) route-map WORD",
12155 "Redistribute information from another routing protocol\n"
12156 "Open Shortest Path First (OSPFv2)\n"
12157 "Non-main Kernel Routing Table\n"
12158 "Instance ID/Table ID\n"
12159 "Route map reference\n"
12160 "Pointer to route-map entries\n")
12162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12163 int idx_ospf_table
= 1;
12164 int idx_number
= 2;
12166 struct bgp_redist
*red
;
12167 unsigned short instance
;
12170 struct route_map
*route_map
=
12171 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12173 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12174 protocol
= ZEBRA_ROUTE_OSPF
;
12176 protocol
= ZEBRA_ROUTE_TABLE
;
12178 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12179 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12181 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12182 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12185 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12186 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12187 "redistribute <ospf|table> (1-65535) route-map WORD",
12188 "Redistribute information from another routing protocol\n"
12189 "Open Shortest Path First (OSPFv2)\n"
12190 "Non-main Kernel Routing Table\n"
12191 "Instance ID/Table ID\n"
12192 "Route map reference\n"
12193 "Pointer to route-map entries\n")
12195 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12196 bgp_redistribute_ipv4_ospf_metric_cmd
,
12197 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12198 "Redistribute information from another routing protocol\n"
12199 "Open Shortest Path First (OSPFv2)\n"
12200 "Non-main Kernel Routing Table\n"
12201 "Instance ID/Table ID\n"
12202 "Metric for redistributed routes\n"
12203 "Default metric\n")
12205 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12206 int idx_ospf_table
= 1;
12207 int idx_number
= 2;
12208 int idx_number_2
= 4;
12210 struct bgp_redist
*red
;
12211 unsigned short instance
;
12215 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12216 protocol
= ZEBRA_ROUTE_OSPF
;
12218 protocol
= ZEBRA_ROUTE_TABLE
;
12220 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12221 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12223 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12224 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12226 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12229 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12230 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12231 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12232 "Redistribute information from another routing protocol\n"
12233 "Open Shortest Path First (OSPFv2)\n"
12234 "Non-main Kernel Routing Table\n"
12235 "Instance ID/Table ID\n"
12236 "Metric for redistributed routes\n"
12237 "Default metric\n")
12239 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12240 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12241 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12242 "Redistribute information from another routing protocol\n"
12243 "Open Shortest Path First (OSPFv2)\n"
12244 "Non-main Kernel Routing Table\n"
12245 "Instance ID/Table ID\n"
12246 "Route map reference\n"
12247 "Pointer to route-map entries\n"
12248 "Metric for redistributed routes\n"
12249 "Default metric\n")
12251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12252 int idx_ospf_table
= 1;
12253 int idx_number
= 2;
12255 int idx_number_2
= 6;
12257 struct bgp_redist
*red
;
12258 unsigned short instance
;
12261 struct route_map
*route_map
=
12262 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12264 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12265 protocol
= ZEBRA_ROUTE_OSPF
;
12267 protocol
= ZEBRA_ROUTE_TABLE
;
12269 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12270 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12272 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12274 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12275 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12277 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12281 bgp_redistribute_ipv4_ospf_rmap_metric
,
12282 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12283 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12284 "Redistribute information from another routing protocol\n"
12285 "Open Shortest Path First (OSPFv2)\n"
12286 "Non-main Kernel Routing Table\n"
12287 "Instance ID/Table ID\n"
12288 "Route map reference\n"
12289 "Pointer to route-map entries\n"
12290 "Metric for redistributed routes\n"
12291 "Default metric\n")
12293 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12294 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12295 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12296 "Redistribute information from another routing protocol\n"
12297 "Open Shortest Path First (OSPFv2)\n"
12298 "Non-main Kernel Routing Table\n"
12299 "Instance ID/Table ID\n"
12300 "Metric for redistributed routes\n"
12302 "Route map reference\n"
12303 "Pointer to route-map entries\n")
12305 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12306 int idx_ospf_table
= 1;
12307 int idx_number
= 2;
12308 int idx_number_2
= 4;
12311 struct bgp_redist
*red
;
12312 unsigned short instance
;
12315 struct route_map
*route_map
=
12316 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12318 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12319 protocol
= ZEBRA_ROUTE_OSPF
;
12321 protocol
= ZEBRA_ROUTE_TABLE
;
12323 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12324 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12326 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12327 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12330 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12331 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12335 bgp_redistribute_ipv4_ospf_metric_rmap
,
12336 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12337 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12338 "Redistribute information from another routing protocol\n"
12339 "Open Shortest Path First (OSPFv2)\n"
12340 "Non-main Kernel Routing Table\n"
12341 "Instance ID/Table ID\n"
12342 "Metric for redistributed routes\n"
12344 "Route map reference\n"
12345 "Pointer to route-map entries\n")
12347 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12348 no_bgp_redistribute_ipv4_ospf_cmd
,
12349 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12351 "Redistribute information from another routing protocol\n"
12352 "Open Shortest Path First (OSPFv2)\n"
12353 "Non-main Kernel Routing Table\n"
12354 "Instance ID/Table ID\n"
12355 "Metric for redistributed routes\n"
12357 "Route map reference\n"
12358 "Pointer to route-map entries\n")
12360 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12361 int idx_ospf_table
= 2;
12362 int idx_number
= 3;
12363 unsigned short instance
;
12366 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12367 protocol
= ZEBRA_ROUTE_OSPF
;
12369 protocol
= ZEBRA_ROUTE_TABLE
;
12371 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12372 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12376 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12377 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12379 "Redistribute information from another routing protocol\n"
12380 "Open Shortest Path First (OSPFv2)\n"
12381 "Non-main Kernel Routing Table\n"
12382 "Instance ID/Table ID\n"
12383 "Metric for redistributed routes\n"
12385 "Route map reference\n"
12386 "Pointer to route-map entries\n")
12388 DEFUN (no_bgp_redistribute_ipv4
,
12389 no_bgp_redistribute_ipv4_cmd
,
12390 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12392 "Redistribute information from another routing protocol\n"
12393 FRR_IP_REDIST_HELP_STR_BGPD
12394 "Metric for redistributed routes\n"
12396 "Route map reference\n"
12397 "Pointer to route-map entries\n")
12399 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12400 int idx_protocol
= 2;
12403 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12405 vty_out(vty
, "%% Invalid route type\n");
12406 return CMD_WARNING_CONFIG_FAILED
;
12408 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12412 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12413 "no redistribute " FRR_IP_REDIST_STR_BGPD
12414 " [metric (0-4294967295)] [route-map WORD]",
12416 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12417 "Metric for redistributed routes\n"
12419 "Route map reference\n"
12420 "Pointer to route-map entries\n")
12422 DEFUN (bgp_redistribute_ipv6
,
12423 bgp_redistribute_ipv6_cmd
,
12424 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12425 "Redistribute information from another routing protocol\n"
12426 FRR_IP6_REDIST_HELP_STR_BGPD
)
12428 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12429 int idx_protocol
= 1;
12432 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12434 vty_out(vty
, "%% Invalid route type\n");
12435 return CMD_WARNING_CONFIG_FAILED
;
12438 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12439 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12442 DEFUN (bgp_redistribute_ipv6_rmap
,
12443 bgp_redistribute_ipv6_rmap_cmd
,
12444 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12445 "Redistribute information from another routing protocol\n"
12446 FRR_IP6_REDIST_HELP_STR_BGPD
12447 "Route map reference\n"
12448 "Pointer to route-map entries\n")
12450 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12451 int idx_protocol
= 1;
12454 struct bgp_redist
*red
;
12456 struct route_map
*route_map
=
12457 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12459 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12461 vty_out(vty
, "%% Invalid route type\n");
12462 return CMD_WARNING_CONFIG_FAILED
;
12465 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12467 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12468 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12471 DEFUN (bgp_redistribute_ipv6_metric
,
12472 bgp_redistribute_ipv6_metric_cmd
,
12473 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12474 "Redistribute information from another routing protocol\n"
12475 FRR_IP6_REDIST_HELP_STR_BGPD
12476 "Metric for redistributed routes\n"
12477 "Default metric\n")
12479 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12480 int idx_protocol
= 1;
12481 int idx_number
= 3;
12484 struct bgp_redist
*red
;
12487 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12489 vty_out(vty
, "%% Invalid route type\n");
12490 return CMD_WARNING_CONFIG_FAILED
;
12492 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12494 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12495 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12496 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12499 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12500 bgp_redistribute_ipv6_rmap_metric_cmd
,
12501 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12502 "Redistribute information from another routing protocol\n"
12503 FRR_IP6_REDIST_HELP_STR_BGPD
12504 "Route map reference\n"
12505 "Pointer to route-map entries\n"
12506 "Metric for redistributed routes\n"
12507 "Default metric\n")
12509 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12510 int idx_protocol
= 1;
12512 int idx_number
= 5;
12515 struct bgp_redist
*red
;
12517 struct route_map
*route_map
=
12518 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12520 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12522 vty_out(vty
, "%% Invalid route type\n");
12523 return CMD_WARNING_CONFIG_FAILED
;
12525 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12527 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12529 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12530 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12532 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12535 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12536 bgp_redistribute_ipv6_metric_rmap_cmd
,
12537 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12538 "Redistribute information from another routing protocol\n"
12539 FRR_IP6_REDIST_HELP_STR_BGPD
12540 "Metric for redistributed routes\n"
12542 "Route map reference\n"
12543 "Pointer to route-map entries\n")
12545 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12546 int idx_protocol
= 1;
12547 int idx_number
= 3;
12551 struct bgp_redist
*red
;
12553 struct route_map
*route_map
=
12554 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12556 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12558 vty_out(vty
, "%% Invalid route type\n");
12559 return CMD_WARNING_CONFIG_FAILED
;
12561 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12563 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12564 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12567 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12568 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12571 DEFUN (no_bgp_redistribute_ipv6
,
12572 no_bgp_redistribute_ipv6_cmd
,
12573 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12575 "Redistribute information from another routing protocol\n"
12576 FRR_IP6_REDIST_HELP_STR_BGPD
12577 "Metric for redistributed routes\n"
12579 "Route map reference\n"
12580 "Pointer to route-map entries\n")
12582 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12583 int idx_protocol
= 2;
12586 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12588 vty_out(vty
, "%% Invalid route type\n");
12589 return CMD_WARNING_CONFIG_FAILED
;
12592 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12595 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12600 /* Unicast redistribution only. */
12601 if (safi
!= SAFI_UNICAST
)
12604 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12605 /* Redistribute BGP does not make sense. */
12606 if (i
!= ZEBRA_ROUTE_BGP
) {
12607 struct list
*red_list
;
12608 struct listnode
*node
;
12609 struct bgp_redist
*red
;
12611 red_list
= bgp
->redist
[afi
][i
];
12615 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12616 /* "redistribute" configuration. */
12617 vty_out(vty
, " redistribute %s",
12618 zebra_route_string(i
));
12620 vty_out(vty
, " %d", red
->instance
);
12621 if (red
->redist_metric_flag
)
12622 vty_out(vty
, " metric %u",
12623 red
->redist_metric
);
12624 if (red
->rmap
.name
)
12625 vty_out(vty
, " route-map %s",
12627 vty_out(vty
, "\n");
12633 /* This is part of the address-family block (unicast only) */
12634 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12639 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12640 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12641 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12642 bgp
->vpn_policy
[afi
]
12643 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12645 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12646 bgp
->vpn_policy
[afi
]
12647 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12649 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12650 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12651 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12652 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12655 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12656 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12658 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12661 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12662 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12663 bgp
->vpn_policy
[afi
].tovpn_label
);
12666 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12667 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12668 char buf
[RD_ADDRSTRLEN
];
12669 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12670 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12673 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12674 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12676 char buf
[PREFIX_STRLEN
];
12677 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12678 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12681 vty_out(vty
, "%*snexthop vpn export %s\n",
12685 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12686 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12688 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12689 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12691 char *b
= ecommunity_ecom2str(
12692 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12693 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12694 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12695 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12697 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12698 char *b
= ecommunity_ecom2str(
12699 bgp
->vpn_policy
[afi
]
12700 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12701 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12702 ECOMMUNITY_ROUTE_TARGET
);
12703 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12704 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12706 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12707 char *b
= ecommunity_ecom2str(
12708 bgp
->vpn_policy
[afi
]
12709 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12710 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12711 ECOMMUNITY_ROUTE_TARGET
);
12712 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12713 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12717 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12718 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12719 bgp
->vpn_policy
[afi
]
12720 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12722 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12723 char *b
= ecommunity_ecom2str(
12724 bgp
->vpn_policy
[afi
]
12725 .import_redirect_rtlist
,
12726 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12727 ECOMMUNITY_ROUTE_TARGET
);
12729 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12730 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12735 /* BGP node structure. */
12736 static struct cmd_node bgp_node
= {
12737 BGP_NODE
, "%s(config-router)# ", 1,
12740 static struct cmd_node bgp_ipv4_unicast_node
= {
12741 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12744 static struct cmd_node bgp_ipv4_multicast_node
= {
12745 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12748 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12749 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12752 static struct cmd_node bgp_ipv6_unicast_node
= {
12753 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12756 static struct cmd_node bgp_ipv6_multicast_node
= {
12757 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12760 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12761 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12764 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12765 "%s(config-router-af)# ", 1};
12767 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12768 "%s(config-router-af-vpnv6)# ", 1};
12770 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12771 "%s(config-router-evpn)# ", 1};
12773 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12774 "%s(config-router-af-vni)# ", 1};
12776 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12777 "%s(config-router-af)# ", 1};
12779 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12780 "%s(config-router-af-vpnv6)# ", 1};
12782 static void community_list_vty(void);
12784 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12788 struct listnode
*lnbgp
, *lnpeer
;
12790 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12791 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12792 /* only provide suggestions on the appropriate input
12794 * they'll otherwise show up multiple times */
12795 enum cmd_token_type match_type
;
12796 char *name
= peer
->host
;
12798 if (peer
->conf_if
) {
12799 match_type
= VARIABLE_TKN
;
12800 name
= peer
->conf_if
;
12801 } else if (strchr(peer
->host
, ':'))
12802 match_type
= IPV6_TKN
;
12804 match_type
= IPV4_TKN
;
12806 if (token
->type
!= match_type
)
12809 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12814 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12815 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12816 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12817 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12818 {.completions
= NULL
}};
12820 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12823 struct peer_group
*group
;
12824 struct listnode
*lnbgp
, *lnpeer
;
12826 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12827 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12828 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12833 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12834 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12835 {.completions
= NULL
} };
12837 void bgp_vty_init(void)
12839 cmd_variable_handler_register(bgp_var_neighbor
);
12840 cmd_variable_handler_register(bgp_var_peergroup
);
12842 /* Install bgp top node. */
12843 install_node(&bgp_node
, bgp_config_write
);
12844 install_node(&bgp_ipv4_unicast_node
, NULL
);
12845 install_node(&bgp_ipv4_multicast_node
, NULL
);
12846 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12847 install_node(&bgp_ipv6_unicast_node
, NULL
);
12848 install_node(&bgp_ipv6_multicast_node
, NULL
);
12849 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12850 install_node(&bgp_vpnv4_node
, NULL
);
12851 install_node(&bgp_vpnv6_node
, NULL
);
12852 install_node(&bgp_evpn_node
, NULL
);
12853 install_node(&bgp_evpn_vni_node
, NULL
);
12854 install_node(&bgp_flowspecv4_node
, NULL
);
12855 install_node(&bgp_flowspecv6_node
, NULL
);
12857 /* Install default VTY commands to new nodes. */
12858 install_default(BGP_NODE
);
12859 install_default(BGP_IPV4_NODE
);
12860 install_default(BGP_IPV4M_NODE
);
12861 install_default(BGP_IPV4L_NODE
);
12862 install_default(BGP_IPV6_NODE
);
12863 install_default(BGP_IPV6M_NODE
);
12864 install_default(BGP_IPV6L_NODE
);
12865 install_default(BGP_VPNV4_NODE
);
12866 install_default(BGP_VPNV6_NODE
);
12867 install_default(BGP_FLOWSPECV4_NODE
);
12868 install_default(BGP_FLOWSPECV6_NODE
);
12869 install_default(BGP_EVPN_NODE
);
12870 install_default(BGP_EVPN_VNI_NODE
);
12872 /* "bgp multiple-instance" commands. */
12873 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12874 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12876 /* "bgp config-type" commands. */
12877 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12878 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12880 /* "bgp local-mac" hidden commands. */
12881 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12882 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12884 /* bgp route-map delay-timer commands. */
12885 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12886 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12888 /* Dummy commands (Currently not supported) */
12889 install_element(BGP_NODE
, &no_synchronization_cmd
);
12890 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12892 /* "router bgp" commands. */
12893 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12895 /* "no router bgp" commands. */
12896 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12898 /* "bgp router-id" commands. */
12899 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12900 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12902 /* "bgp cluster-id" commands. */
12903 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12904 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12906 /* "bgp confederation" commands. */
12907 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12908 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12910 /* "bgp confederation peers" commands. */
12911 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12912 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12914 /* bgp max-med command */
12915 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12916 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12917 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12918 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12919 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12921 /* bgp disable-ebgp-connected-nh-check */
12922 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12923 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12925 /* bgp update-delay command */
12926 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12927 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12928 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12930 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12931 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12932 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12933 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12935 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12936 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12938 /* "maximum-paths" commands. */
12939 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12940 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12941 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12942 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12943 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12944 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12945 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12946 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12947 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12948 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12949 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12950 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12951 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12952 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12953 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12955 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12956 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12957 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12958 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12959 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12961 /* "timers bgp" commands. */
12962 install_element(BGP_NODE
, &bgp_timers_cmd
);
12963 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12965 /* route-map delay-timer commands - per instance for backwards compat.
12967 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12968 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12970 /* "bgp client-to-client reflection" commands */
12971 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12972 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12974 /* "bgp always-compare-med" commands */
12975 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12976 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12978 /* bgp ebgp-requires-policy */
12979 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12980 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
12982 /* "bgp deterministic-med" commands */
12983 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12984 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12986 /* "bgp graceful-restart" commands */
12987 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12988 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12989 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12990 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12991 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12992 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12994 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12995 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12997 /* "bgp graceful-shutdown" commands */
12998 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12999 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13001 /* "bgp fast-external-failover" commands */
13002 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13003 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13005 /* "bgp enforce-first-as" commands */
13006 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
13008 /* "bgp bestpath compare-routerid" commands */
13009 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13010 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13012 /* "bgp bestpath as-path ignore" commands */
13013 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13014 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13016 /* "bgp bestpath as-path confed" commands */
13017 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13018 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13020 /* "bgp bestpath as-path multipath-relax" commands */
13021 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13022 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13024 /* "bgp log-neighbor-changes" commands */
13025 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13026 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13028 /* "bgp bestpath med" commands */
13029 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13030 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13032 /* "no bgp default ipv4-unicast" commands. */
13033 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13034 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13036 /* "bgp network import-check" commands. */
13037 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13038 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13039 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13041 /* "bgp default local-preference" commands. */
13042 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13043 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13045 /* bgp default show-hostname */
13046 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13047 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13049 /* "bgp default subgroup-pkt-queue-max" commands. */
13050 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13051 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13053 /* bgp ibgp-allow-policy-mods command */
13054 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13055 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13057 /* "bgp listen limit" commands. */
13058 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13059 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13061 /* "bgp listen range" commands. */
13062 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13063 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13065 /* "bgp default shutdown" command */
13066 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13068 /* "neighbor remote-as" commands. */
13069 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13070 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13071 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13072 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13073 install_element(BGP_NODE
,
13074 &neighbor_interface_v6only_config_remote_as_cmd
);
13075 install_element(BGP_NODE
, &no_neighbor_cmd
);
13076 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13078 /* "neighbor peer-group" commands. */
13079 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13080 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13081 install_element(BGP_NODE
,
13082 &no_neighbor_interface_peer_group_remote_as_cmd
);
13084 /* "neighbor local-as" commands. */
13085 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13086 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13087 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13088 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13090 /* "neighbor solo" commands. */
13091 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13092 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13094 /* "neighbor password" commands. */
13095 install_element(BGP_NODE
, &neighbor_password_cmd
);
13096 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13098 /* "neighbor activate" commands. */
13099 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13100 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13101 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13102 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13103 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13104 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13105 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13106 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13107 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13108 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13109 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13110 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13112 /* "no neighbor activate" commands. */
13113 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13114 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13115 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13116 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13117 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13118 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13119 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13120 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13121 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13122 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13123 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13124 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13126 /* "neighbor peer-group" set commands. */
13127 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13128 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13129 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13130 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13131 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13132 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13133 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13134 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13135 install_element(BGP_FLOWSPECV4_NODE
,
13136 &neighbor_set_peer_group_hidden_cmd
);
13137 install_element(BGP_FLOWSPECV6_NODE
,
13138 &neighbor_set_peer_group_hidden_cmd
);
13140 /* "no neighbor peer-group unset" commands. */
13141 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13142 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13143 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13144 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13145 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13146 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13147 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13148 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13149 install_element(BGP_FLOWSPECV4_NODE
,
13150 &no_neighbor_set_peer_group_hidden_cmd
);
13151 install_element(BGP_FLOWSPECV6_NODE
,
13152 &no_neighbor_set_peer_group_hidden_cmd
);
13154 /* "neighbor softreconfiguration inbound" commands.*/
13155 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13156 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13157 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13158 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13159 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13160 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13161 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13162 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13163 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13164 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13165 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13166 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13167 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13168 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13169 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13170 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13171 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13172 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13173 install_element(BGP_FLOWSPECV4_NODE
,
13174 &neighbor_soft_reconfiguration_cmd
);
13175 install_element(BGP_FLOWSPECV4_NODE
,
13176 &no_neighbor_soft_reconfiguration_cmd
);
13177 install_element(BGP_FLOWSPECV6_NODE
,
13178 &neighbor_soft_reconfiguration_cmd
);
13179 install_element(BGP_FLOWSPECV6_NODE
,
13180 &no_neighbor_soft_reconfiguration_cmd
);
13181 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13182 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13184 /* "neighbor attribute-unchanged" commands. */
13185 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13186 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13187 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13188 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13189 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13190 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13191 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13192 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13193 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13194 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13195 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13196 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13197 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13198 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13199 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13200 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13201 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13202 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13204 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13205 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13207 /* "nexthop-local unchanged" commands */
13208 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13209 install_element(BGP_IPV6_NODE
,
13210 &no_neighbor_nexthop_local_unchanged_cmd
);
13212 /* "neighbor next-hop-self" commands. */
13213 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13214 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13215 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13216 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13217 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13218 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13219 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13220 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13221 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13222 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13223 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13224 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13225 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13226 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13227 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13228 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13229 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13230 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13231 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13232 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13234 /* "neighbor next-hop-self force" commands. */
13235 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13236 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13237 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13238 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13239 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13240 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13241 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13242 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13243 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13244 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13245 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13246 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13247 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13248 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13249 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13250 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13251 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13252 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13254 /* "neighbor as-override" commands. */
13255 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13256 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13257 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13258 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13259 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13260 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13261 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13262 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13263 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13264 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13265 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13266 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13267 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13268 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13269 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13270 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13271 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13272 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13274 /* "neighbor remove-private-AS" commands. */
13275 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13276 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13277 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13278 install_element(BGP_NODE
,
13279 &no_neighbor_remove_private_as_all_hidden_cmd
);
13280 install_element(BGP_NODE
,
13281 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13282 install_element(BGP_NODE
,
13283 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13284 install_element(BGP_NODE
,
13285 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13288 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13289 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13290 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13291 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13292 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13293 install_element(BGP_IPV4_NODE
,
13294 &neighbor_remove_private_as_replace_as_cmd
);
13295 install_element(BGP_IPV4_NODE
,
13296 &no_neighbor_remove_private_as_replace_as_cmd
);
13297 install_element(BGP_IPV4_NODE
,
13298 &neighbor_remove_private_as_all_replace_as_cmd
);
13299 install_element(BGP_IPV4_NODE
,
13300 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13301 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13302 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13303 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13304 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13305 install_element(BGP_IPV4M_NODE
,
13306 &neighbor_remove_private_as_replace_as_cmd
);
13307 install_element(BGP_IPV4M_NODE
,
13308 &no_neighbor_remove_private_as_replace_as_cmd
);
13309 install_element(BGP_IPV4M_NODE
,
13310 &neighbor_remove_private_as_all_replace_as_cmd
);
13311 install_element(BGP_IPV4M_NODE
,
13312 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13313 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13314 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13315 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13316 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13317 install_element(BGP_IPV4L_NODE
,
13318 &neighbor_remove_private_as_replace_as_cmd
);
13319 install_element(BGP_IPV4L_NODE
,
13320 &no_neighbor_remove_private_as_replace_as_cmd
);
13321 install_element(BGP_IPV4L_NODE
,
13322 &neighbor_remove_private_as_all_replace_as_cmd
);
13323 install_element(BGP_IPV4L_NODE
,
13324 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13325 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13326 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13327 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13328 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13329 install_element(BGP_IPV6_NODE
,
13330 &neighbor_remove_private_as_replace_as_cmd
);
13331 install_element(BGP_IPV6_NODE
,
13332 &no_neighbor_remove_private_as_replace_as_cmd
);
13333 install_element(BGP_IPV6_NODE
,
13334 &neighbor_remove_private_as_all_replace_as_cmd
);
13335 install_element(BGP_IPV6_NODE
,
13336 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13337 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13338 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13339 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13340 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13341 install_element(BGP_IPV6M_NODE
,
13342 &neighbor_remove_private_as_replace_as_cmd
);
13343 install_element(BGP_IPV6M_NODE
,
13344 &no_neighbor_remove_private_as_replace_as_cmd
);
13345 install_element(BGP_IPV6M_NODE
,
13346 &neighbor_remove_private_as_all_replace_as_cmd
);
13347 install_element(BGP_IPV6M_NODE
,
13348 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13349 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13350 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13351 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13352 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13353 install_element(BGP_IPV6L_NODE
,
13354 &neighbor_remove_private_as_replace_as_cmd
);
13355 install_element(BGP_IPV6L_NODE
,
13356 &no_neighbor_remove_private_as_replace_as_cmd
);
13357 install_element(BGP_IPV6L_NODE
,
13358 &neighbor_remove_private_as_all_replace_as_cmd
);
13359 install_element(BGP_IPV6L_NODE
,
13360 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13361 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13362 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13363 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13364 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13365 install_element(BGP_VPNV4_NODE
,
13366 &neighbor_remove_private_as_replace_as_cmd
);
13367 install_element(BGP_VPNV4_NODE
,
13368 &no_neighbor_remove_private_as_replace_as_cmd
);
13369 install_element(BGP_VPNV4_NODE
,
13370 &neighbor_remove_private_as_all_replace_as_cmd
);
13371 install_element(BGP_VPNV4_NODE
,
13372 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13373 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13374 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13375 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13376 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13377 install_element(BGP_VPNV6_NODE
,
13378 &neighbor_remove_private_as_replace_as_cmd
);
13379 install_element(BGP_VPNV6_NODE
,
13380 &no_neighbor_remove_private_as_replace_as_cmd
);
13381 install_element(BGP_VPNV6_NODE
,
13382 &neighbor_remove_private_as_all_replace_as_cmd
);
13383 install_element(BGP_VPNV6_NODE
,
13384 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13386 /* "neighbor send-community" commands.*/
13387 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13388 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13389 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13390 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13391 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13392 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13393 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13394 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13395 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13396 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13397 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13398 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13399 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13400 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13401 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13402 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13403 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13404 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13405 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13406 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13407 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13408 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13409 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13410 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13411 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13412 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13413 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13414 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13415 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13416 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13417 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13418 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13419 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13420 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13421 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13422 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13424 /* "neighbor route-reflector" commands.*/
13425 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13426 install_element(BGP_NODE
,
13427 &no_neighbor_route_reflector_client_hidden_cmd
);
13428 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13429 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13430 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13431 install_element(BGP_IPV4M_NODE
,
13432 &no_neighbor_route_reflector_client_cmd
);
13433 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13434 install_element(BGP_IPV4L_NODE
,
13435 &no_neighbor_route_reflector_client_cmd
);
13436 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13437 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13438 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13439 install_element(BGP_IPV6M_NODE
,
13440 &no_neighbor_route_reflector_client_cmd
);
13441 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13442 install_element(BGP_IPV6L_NODE
,
13443 &no_neighbor_route_reflector_client_cmd
);
13444 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13445 install_element(BGP_VPNV4_NODE
,
13446 &no_neighbor_route_reflector_client_cmd
);
13447 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13448 install_element(BGP_VPNV6_NODE
,
13449 &no_neighbor_route_reflector_client_cmd
);
13450 install_element(BGP_FLOWSPECV4_NODE
,
13451 &neighbor_route_reflector_client_cmd
);
13452 install_element(BGP_FLOWSPECV4_NODE
,
13453 &no_neighbor_route_reflector_client_cmd
);
13454 install_element(BGP_FLOWSPECV6_NODE
,
13455 &neighbor_route_reflector_client_cmd
);
13456 install_element(BGP_FLOWSPECV6_NODE
,
13457 &no_neighbor_route_reflector_client_cmd
);
13458 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13459 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13461 /* "neighbor route-server" commands.*/
13462 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13463 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13464 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13465 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13466 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13467 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13468 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13469 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13470 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13471 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13472 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13473 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13474 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13475 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13476 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13477 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13478 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13479 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13480 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13481 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13482 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13483 install_element(BGP_FLOWSPECV4_NODE
,
13484 &no_neighbor_route_server_client_cmd
);
13485 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13486 install_element(BGP_FLOWSPECV6_NODE
,
13487 &no_neighbor_route_server_client_cmd
);
13489 /* "neighbor addpath-tx-all-paths" commands.*/
13490 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13491 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13492 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13493 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13494 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13495 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13496 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13497 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13498 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13499 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13500 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13501 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13502 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13503 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13504 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13505 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13506 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13507 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13509 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13510 install_element(BGP_NODE
,
13511 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13512 install_element(BGP_NODE
,
13513 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13514 install_element(BGP_IPV4_NODE
,
13515 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13516 install_element(BGP_IPV4_NODE
,
13517 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13518 install_element(BGP_IPV4M_NODE
,
13519 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13520 install_element(BGP_IPV4M_NODE
,
13521 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13522 install_element(BGP_IPV4L_NODE
,
13523 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13524 install_element(BGP_IPV4L_NODE
,
13525 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13526 install_element(BGP_IPV6_NODE
,
13527 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13528 install_element(BGP_IPV6_NODE
,
13529 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13530 install_element(BGP_IPV6M_NODE
,
13531 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13532 install_element(BGP_IPV6M_NODE
,
13533 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13534 install_element(BGP_IPV6L_NODE
,
13535 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13536 install_element(BGP_IPV6L_NODE
,
13537 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13538 install_element(BGP_VPNV4_NODE
,
13539 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13540 install_element(BGP_VPNV4_NODE
,
13541 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13542 install_element(BGP_VPNV6_NODE
,
13543 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13544 install_element(BGP_VPNV6_NODE
,
13545 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13547 /* "neighbor passive" commands. */
13548 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13549 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13552 /* "neighbor shutdown" commands. */
13553 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13554 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13555 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13556 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13558 /* "neighbor capability extended-nexthop" commands.*/
13559 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13560 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13562 /* "neighbor capability orf prefix-list" commands.*/
13563 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13564 install_element(BGP_NODE
,
13565 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13566 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13567 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13568 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13569 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13570 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13571 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13572 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13573 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13574 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13575 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13576 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13577 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13579 /* "neighbor capability dynamic" commands.*/
13580 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13581 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13583 /* "neighbor dont-capability-negotiate" commands. */
13584 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13585 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13587 /* "neighbor ebgp-multihop" commands. */
13588 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13589 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13590 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13592 /* "neighbor disable-connected-check" commands. */
13593 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13594 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13596 /* "neighbor enforce-first-as" commands. */
13597 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13598 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13600 /* "neighbor description" commands. */
13601 install_element(BGP_NODE
, &neighbor_description_cmd
);
13602 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13603 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13605 /* "neighbor update-source" commands. "*/
13606 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13607 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13609 /* "neighbor default-originate" commands. */
13610 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13611 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13612 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13613 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13614 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13615 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13616 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13617 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13618 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13619 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13620 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13621 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13622 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13623 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13624 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13625 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13626 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13627 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13628 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13629 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13630 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13632 /* "neighbor port" commands. */
13633 install_element(BGP_NODE
, &neighbor_port_cmd
);
13634 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13636 /* "neighbor weight" commands. */
13637 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13638 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13640 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13641 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13642 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13643 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13644 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13645 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13646 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13647 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13648 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13649 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13650 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13651 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13652 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13653 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13654 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13655 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13657 /* "neighbor override-capability" commands. */
13658 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13659 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13661 /* "neighbor strict-capability-match" commands. */
13662 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13663 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13665 /* "neighbor timers" commands. */
13666 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13667 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13669 /* "neighbor timers connect" commands. */
13670 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13671 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13673 /* "neighbor advertisement-interval" commands. */
13674 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13675 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13677 /* "neighbor interface" commands. */
13678 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13679 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13681 /* "neighbor distribute" commands. */
13682 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13683 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13684 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13685 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13686 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13687 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13688 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13689 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13690 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13691 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13692 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13693 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13694 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13695 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13696 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13697 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13698 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13699 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13701 /* "neighbor prefix-list" commands. */
13702 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13703 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13704 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13705 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13706 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13707 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13708 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13709 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13710 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13711 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13712 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13713 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13714 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13715 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13716 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13717 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13718 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13719 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13720 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13721 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13722 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13723 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13725 /* "neighbor filter-list" commands. */
13726 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13727 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13728 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13729 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13730 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13731 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13732 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13733 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13734 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13735 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13736 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13737 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13738 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13739 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13740 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13741 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13742 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13743 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13744 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13745 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13746 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13747 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13749 /* "neighbor route-map" commands. */
13750 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13751 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13752 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13753 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13754 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13755 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13756 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13757 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13758 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13759 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13760 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13761 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13762 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13763 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13764 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13765 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13766 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13767 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13768 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13769 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13770 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13771 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13772 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13773 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13775 /* "neighbor unsuppress-map" commands. */
13776 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13777 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13778 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13779 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13780 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13781 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13782 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13783 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13784 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13785 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13786 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13787 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13788 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13789 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13790 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13791 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13792 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13793 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13795 /* "neighbor maximum-prefix" commands. */
13796 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13797 install_element(BGP_NODE
,
13798 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13799 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13800 install_element(BGP_NODE
,
13801 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13802 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13803 install_element(BGP_NODE
,
13804 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13805 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13806 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13807 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13808 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13809 install_element(BGP_IPV4_NODE
,
13810 &neighbor_maximum_prefix_threshold_warning_cmd
);
13811 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13812 install_element(BGP_IPV4_NODE
,
13813 &neighbor_maximum_prefix_threshold_restart_cmd
);
13814 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13815 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13816 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13817 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13818 install_element(BGP_IPV4M_NODE
,
13819 &neighbor_maximum_prefix_threshold_warning_cmd
);
13820 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13821 install_element(BGP_IPV4M_NODE
,
13822 &neighbor_maximum_prefix_threshold_restart_cmd
);
13823 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13824 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13825 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13826 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13827 install_element(BGP_IPV4L_NODE
,
13828 &neighbor_maximum_prefix_threshold_warning_cmd
);
13829 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13830 install_element(BGP_IPV4L_NODE
,
13831 &neighbor_maximum_prefix_threshold_restart_cmd
);
13832 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13833 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13834 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13835 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13836 install_element(BGP_IPV6_NODE
,
13837 &neighbor_maximum_prefix_threshold_warning_cmd
);
13838 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13839 install_element(BGP_IPV6_NODE
,
13840 &neighbor_maximum_prefix_threshold_restart_cmd
);
13841 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13842 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13843 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13844 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13845 install_element(BGP_IPV6M_NODE
,
13846 &neighbor_maximum_prefix_threshold_warning_cmd
);
13847 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13848 install_element(BGP_IPV6M_NODE
,
13849 &neighbor_maximum_prefix_threshold_restart_cmd
);
13850 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13851 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13852 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13853 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13854 install_element(BGP_IPV6L_NODE
,
13855 &neighbor_maximum_prefix_threshold_warning_cmd
);
13856 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13857 install_element(BGP_IPV6L_NODE
,
13858 &neighbor_maximum_prefix_threshold_restart_cmd
);
13859 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13860 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13861 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13862 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13863 install_element(BGP_VPNV4_NODE
,
13864 &neighbor_maximum_prefix_threshold_warning_cmd
);
13865 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13866 install_element(BGP_VPNV4_NODE
,
13867 &neighbor_maximum_prefix_threshold_restart_cmd
);
13868 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13869 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13870 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13871 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13872 install_element(BGP_VPNV6_NODE
,
13873 &neighbor_maximum_prefix_threshold_warning_cmd
);
13874 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13875 install_element(BGP_VPNV6_NODE
,
13876 &neighbor_maximum_prefix_threshold_restart_cmd
);
13877 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13879 /* "neighbor allowas-in" */
13880 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13881 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13882 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13883 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13884 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13885 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13886 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13887 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13888 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13889 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13890 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13891 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13892 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13893 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13894 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13895 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13896 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13897 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13898 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13899 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13901 /* address-family commands. */
13902 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13903 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13904 #ifdef KEEP_OLD_VPN_COMMANDS
13905 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13906 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13907 #endif /* KEEP_OLD_VPN_COMMANDS */
13909 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13911 /* "exit-address-family" command. */
13912 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13913 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13914 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13915 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13916 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13917 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13918 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13919 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13920 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13921 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13922 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13924 /* "clear ip bgp commands" */
13925 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13927 /* clear ip bgp prefix */
13928 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13929 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13930 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13932 /* "show [ip] bgp summary" commands. */
13933 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13934 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13935 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13936 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13937 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13938 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13939 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13941 /* "show [ip] bgp neighbors" commands. */
13942 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13944 /* "show [ip] bgp peer-group" commands. */
13945 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13947 /* "show [ip] bgp paths" commands. */
13948 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13950 /* "show [ip] bgp community" commands. */
13951 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13953 /* "show ip bgp large-community" commands. */
13954 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13955 /* "show [ip] bgp attribute-info" commands. */
13956 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13957 /* "show [ip] bgp route-leak" command */
13958 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13960 /* "redistribute" commands. */
13961 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13962 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13963 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13964 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13965 install_element(BGP_NODE
,
13966 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13967 install_element(BGP_NODE
,
13968 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13969 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13970 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13971 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13972 install_element(BGP_NODE
,
13973 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13974 install_element(BGP_NODE
,
13975 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13976 install_element(BGP_NODE
,
13977 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13978 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13979 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13980 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13981 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13982 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13983 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13984 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13985 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13986 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13987 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13988 install_element(BGP_IPV4_NODE
,
13989 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13990 install_element(BGP_IPV4_NODE
,
13991 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13992 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13993 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13994 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13995 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13996 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13997 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13999 /* import|export vpn [route-map WORD] */
14000 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14001 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14003 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14004 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14006 /* ttl_security commands */
14007 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14008 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14010 /* "show [ip] bgp memory" commands. */
14011 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14013 /* "show bgp martian next-hop" */
14014 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14016 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14018 /* "show [ip] bgp views" commands. */
14019 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14021 /* "show [ip] bgp vrfs" commands. */
14022 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14024 /* Community-list. */
14025 community_list_vty();
14027 /* vpn-policy commands */
14028 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14029 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14030 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14031 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14032 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14033 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14034 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14035 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14036 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14037 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14038 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14039 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14041 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14042 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14044 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14045 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14046 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14047 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14048 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14049 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14050 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14051 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14052 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14053 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14054 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14055 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14058 #include "memory.h"
14059 #include "bgp_regex.h"
14060 #include "bgp_clist.h"
14061 #include "bgp_ecommunity.h"
14063 /* VTY functions. */
14065 /* Direction value to string conversion. */
14066 static const char *community_direct_str(int direct
)
14069 case COMMUNITY_DENY
:
14071 case COMMUNITY_PERMIT
:
14078 /* Display error string. */
14079 static void community_list_perror(struct vty
*vty
, int ret
)
14082 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14083 vty_out(vty
, "%% Can't find community-list\n");
14085 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14086 vty_out(vty
, "%% Malformed community-list value\n");
14088 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14090 "%% Community name conflict, previously defined as standard community\n");
14092 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14094 "%% Community name conflict, previously defined as expanded community\n");
14099 /* "community-list" keyword help string. */
14100 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14102 /*community-list standard */
14103 DEFUN (community_list_standard
,
14104 bgp_community_list_standard_cmd
,
14105 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14108 "Community list number (standard)\n"
14109 "Add an standard community-list entry\n"
14110 "Community list name\n"
14111 "Specify community to reject\n"
14112 "Specify community to accept\n"
14115 char *cl_name_or_number
= NULL
;
14117 int style
= COMMUNITY_LIST_STANDARD
;
14121 if (argv_find(argv
, argc
, "ip", &idx
)) {
14122 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14123 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14124 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14125 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14128 argv_find(argv
, argc
, "(1-99)", &idx
);
14129 argv_find(argv
, argc
, "WORD", &idx
);
14130 cl_name_or_number
= argv
[idx
]->arg
;
14131 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14133 argv_find(argv
, argc
, "AA:NN", &idx
);
14134 char *str
= argv_concat(argv
, argc
, idx
);
14136 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14139 XFREE(MTYPE_TMP
, str
);
14142 /* Display error string. */
14143 community_list_perror(vty
, ret
);
14144 return CMD_WARNING_CONFIG_FAILED
;
14147 return CMD_SUCCESS
;
14150 #if CONFDATE > 20191005
14151 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14153 ALIAS (community_list_standard
,
14154 ip_community_list_standard_cmd
,
14155 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14158 "Community list number (standard)\n"
14159 "Add an standard community-list entry\n"
14160 "Community list name\n"
14161 "Specify community to reject\n"
14162 "Specify community to accept\n"
14165 DEFUN (no_community_list_standard_all
,
14166 no_bgp_community_list_standard_all_cmd
,
14167 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14171 "Community list number (standard)\n"
14172 "Add an standard community-list entry\n"
14173 "Community list name\n"
14174 "Specify community to reject\n"
14175 "Specify community to accept\n"
14178 char *cl_name_or_number
= NULL
;
14181 int style
= COMMUNITY_LIST_STANDARD
;
14185 if (argv_find(argv
, argc
, "ip", &idx
)) {
14186 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14187 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14188 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14189 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14192 argv_find(argv
, argc
, "permit", &idx
);
14193 argv_find(argv
, argc
, "deny", &idx
);
14196 direct
= argv_find(argv
, argc
, "permit", &idx
)
14201 argv_find(argv
, argc
, "AA:NN", &idx
);
14202 str
= argv_concat(argv
, argc
, idx
);
14206 argv_find(argv
, argc
, "(1-99)", &idx
);
14207 argv_find(argv
, argc
, "WORD", &idx
);
14208 cl_name_or_number
= argv
[idx
]->arg
;
14210 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14213 XFREE(MTYPE_TMP
, str
);
14216 community_list_perror(vty
, ret
);
14217 return CMD_WARNING_CONFIG_FAILED
;
14220 return CMD_SUCCESS
;
14222 ALIAS (no_community_list_standard_all
,
14223 no_ip_community_list_standard_all_cmd
,
14224 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14228 "Community list number (standard)\n"
14229 "Add an standard community-list entry\n"
14230 "Community list name\n"
14231 "Specify community to reject\n"
14232 "Specify community to accept\n"
14235 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14236 "no bgp community-list <(1-99)|standard WORD>",
14237 NO_STR BGP_STR COMMUNITY_LIST_STR
14238 "Community list number (standard)\n"
14239 "Add an standard community-list entry\n"
14240 "Community list name\n")
14242 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14243 "no ip community-list <(1-99)|standard WORD>",
14244 NO_STR BGP_STR COMMUNITY_LIST_STR
14245 "Community list number (standard)\n"
14246 "Add an standard community-list entry\n"
14247 "Community list name\n")
14249 /*community-list expanded */
14250 DEFUN (community_list_expanded_all
,
14251 bgp_community_list_expanded_all_cmd
,
14252 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14255 "Community list number (expanded)\n"
14256 "Add an expanded community-list entry\n"
14257 "Community list name\n"
14258 "Specify community to reject\n"
14259 "Specify community to accept\n"
14262 char *cl_name_or_number
= NULL
;
14264 int style
= COMMUNITY_LIST_EXPANDED
;
14267 if (argv_find(argv
, argc
, "ip", &idx
)) {
14268 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14269 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14270 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14271 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14273 argv_find(argv
, argc
, "(100-500)", &idx
);
14274 argv_find(argv
, argc
, "WORD", &idx
);
14275 cl_name_or_number
= argv
[idx
]->arg
;
14276 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14278 argv_find(argv
, argc
, "AA:NN", &idx
);
14279 char *str
= argv_concat(argv
, argc
, idx
);
14281 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14284 XFREE(MTYPE_TMP
, str
);
14287 /* Display error string. */
14288 community_list_perror(vty
, ret
);
14289 return CMD_WARNING_CONFIG_FAILED
;
14292 return CMD_SUCCESS
;
14295 ALIAS (community_list_expanded_all
,
14296 ip_community_list_expanded_all_cmd
,
14297 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14300 "Community list number (expanded)\n"
14301 "Add an expanded community-list entry\n"
14302 "Community list name\n"
14303 "Specify community to reject\n"
14304 "Specify community to accept\n"
14307 DEFUN (no_community_list_expanded_all
,
14308 no_bgp_community_list_expanded_all_cmd
,
14309 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14313 "Community list number (expanded)\n"
14314 "Add an expanded community-list entry\n"
14315 "Community list name\n"
14316 "Specify community to reject\n"
14317 "Specify community to accept\n"
14320 char *cl_name_or_number
= NULL
;
14323 int style
= COMMUNITY_LIST_EXPANDED
;
14326 if (argv_find(argv
, argc
, "ip", &idx
)) {
14327 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14328 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14329 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14330 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14334 argv_find(argv
, argc
, "permit", &idx
);
14335 argv_find(argv
, argc
, "deny", &idx
);
14338 direct
= argv_find(argv
, argc
, "permit", &idx
)
14343 argv_find(argv
, argc
, "AA:NN", &idx
);
14344 str
= argv_concat(argv
, argc
, idx
);
14348 argv_find(argv
, argc
, "(100-500)", &idx
);
14349 argv_find(argv
, argc
, "WORD", &idx
);
14350 cl_name_or_number
= argv
[idx
]->arg
;
14352 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14355 XFREE(MTYPE_TMP
, str
);
14358 community_list_perror(vty
, ret
);
14359 return CMD_WARNING_CONFIG_FAILED
;
14362 return CMD_SUCCESS
;
14365 ALIAS (no_community_list_expanded_all
,
14366 no_ip_community_list_expanded_all_cmd
,
14367 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14371 "Community list number (expanded)\n"
14372 "Add an expanded community-list entry\n"
14373 "Community list name\n"
14374 "Specify community to reject\n"
14375 "Specify community to accept\n"
14378 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14379 "no bgp community-list <(100-500)|expanded WORD>",
14380 NO_STR IP_STR COMMUNITY_LIST_STR
14381 "Community list number (expanded)\n"
14382 "Add an expanded community-list entry\n"
14383 "Community list name\n")
14385 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14386 "no ip community-list <(100-500)|expanded WORD>",
14387 NO_STR IP_STR COMMUNITY_LIST_STR
14388 "Community list number (expanded)\n"
14389 "Add an expanded community-list entry\n"
14390 "Community list name\n")
14392 /* Return configuration string of community-list entry. */
14393 static const char *community_list_config_str(struct community_entry
*entry
)
14400 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14401 str
= community_str(entry
->u
.com
, false);
14402 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14403 str
= lcommunity_str(entry
->u
.lcom
, false);
14405 str
= entry
->config
;
14410 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14412 struct community_entry
*entry
;
14414 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14415 if (entry
== list
->head
) {
14416 if (all_digit(list
->name
))
14417 vty_out(vty
, "Community %s list %s\n",
14418 entry
->style
== COMMUNITY_LIST_STANDARD
14420 : "(expanded) access",
14423 vty_out(vty
, "Named Community %s list %s\n",
14424 entry
->style
== COMMUNITY_LIST_STANDARD
14430 vty_out(vty
, " %s\n",
14431 community_direct_str(entry
->direct
));
14433 vty_out(vty
, " %s %s\n",
14434 community_direct_str(entry
->direct
),
14435 community_list_config_str(entry
));
14439 DEFUN (show_community_list
,
14440 show_bgp_community_list_cmd
,
14441 "show bgp community-list",
14444 "List community-list\n")
14446 struct community_list
*list
;
14447 struct community_list_master
*cm
;
14450 if (argv_find(argv
, argc
, "ip", &idx
)) {
14451 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14452 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14453 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14454 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14456 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14458 return CMD_SUCCESS
;
14460 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14461 community_list_show(vty
, list
);
14463 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14464 community_list_show(vty
, list
);
14466 return CMD_SUCCESS
;
14469 ALIAS (show_community_list
,
14470 show_ip_community_list_cmd
,
14471 "show ip community-list",
14474 "List community-list\n")
14476 DEFUN (show_community_list_arg
,
14477 show_bgp_community_list_arg_cmd
,
14478 "show bgp community-list <(1-500)|WORD>",
14481 "List community-list\n"
14482 "Community-list number\n"
14483 "Community-list name\n")
14485 int idx_comm_list
= 3;
14486 struct community_list
*list
;
14489 if (argv_find(argv
, argc
, "ip", &idx
)) {
14490 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14491 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14492 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14493 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14495 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14496 COMMUNITY_LIST_MASTER
);
14498 vty_out(vty
, "%% Can't find community-list\n");
14499 return CMD_WARNING
;
14502 community_list_show(vty
, list
);
14504 return CMD_SUCCESS
;
14507 ALIAS (show_community_list_arg
,
14508 show_ip_community_list_arg_cmd
,
14509 "show ip community-list <(1-500)|WORD>",
14512 "List community-list\n"
14513 "Community-list number\n"
14514 "Community-list name\n")
14517 * Large Community code.
14519 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14520 struct cmd_token
**argv
, int style
,
14521 int reject_all_digit_name
)
14529 if (argv_find(argv
, argc
, "ip", &idx
)) {
14530 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14531 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14532 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14533 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14535 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14538 /* All digit name check. */
14540 argv_find(argv
, argc
, "WORD", &idx
);
14541 argv_find(argv
, argc
, "(1-99)", &idx
);
14542 argv_find(argv
, argc
, "(100-500)", &idx
);
14543 cl_name
= argv
[idx
]->arg
;
14544 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14545 vty_out(vty
, "%% Community name cannot have all digits\n");
14546 return CMD_WARNING_CONFIG_FAILED
;
14550 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14551 argv_find(argv
, argc
, "LINE", &idx
);
14552 /* Concat community string argument. */
14554 str
= argv_concat(argv
, argc
, idx
);
14558 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14560 /* Free temporary community list string allocated by
14562 XFREE(MTYPE_TMP
, str
);
14565 community_list_perror(vty
, ret
);
14566 return CMD_WARNING_CONFIG_FAILED
;
14568 return CMD_SUCCESS
;
14571 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14572 struct cmd_token
**argv
, int style
)
14579 if (argv_find(argv
, argc
, "ip", &idx
)) {
14580 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14581 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14582 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14583 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14585 argv_find(argv
, argc
, "permit", &idx
);
14586 argv_find(argv
, argc
, "deny", &idx
);
14589 /* Check the list direct. */
14590 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14591 direct
= COMMUNITY_PERMIT
;
14593 direct
= COMMUNITY_DENY
;
14596 argv_find(argv
, argc
, "LINE", &idx
);
14597 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14598 /* Concat community string argument. */
14599 str
= argv_concat(argv
, argc
, idx
);
14603 argv_find(argv
, argc
, "(1-99)", &idx
);
14604 argv_find(argv
, argc
, "(100-500)", &idx
);
14605 argv_find(argv
, argc
, "WORD", &idx
);
14607 /* Unset community list. */
14608 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14611 /* Free temporary community list string allocated by
14613 XFREE(MTYPE_TMP
, str
);
14616 community_list_perror(vty
, ret
);
14617 return CMD_WARNING_CONFIG_FAILED
;
14620 return CMD_SUCCESS
;
14623 /* "large-community-list" keyword help string. */
14624 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14625 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14627 #if CONFDATE > 20191005
14628 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14630 DEFUN (lcommunity_list_standard
,
14631 bgp_lcommunity_list_standard_cmd
,
14632 "bgp large-community-list (1-99) <deny|permit>",
14634 LCOMMUNITY_LIST_STR
14635 "Large Community list number (standard)\n"
14636 "Specify large community to reject\n"
14637 "Specify large community to accept\n")
14639 return lcommunity_list_set_vty(vty
, argc
, argv
,
14640 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14643 ALIAS (lcommunity_list_standard
,
14644 ip_lcommunity_list_standard_cmd
,
14645 "ip large-community-list (1-99) <deny|permit>",
14647 LCOMMUNITY_LIST_STR
14648 "Large Community list number (standard)\n"
14649 "Specify large community to reject\n"
14650 "Specify large community to accept\n")
14652 DEFUN (lcommunity_list_standard1
,
14653 bgp_lcommunity_list_standard1_cmd
,
14654 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14656 LCOMMUNITY_LIST_STR
14657 "Large Community list number (standard)\n"
14658 "Specify large community to reject\n"
14659 "Specify large community to accept\n"
14660 LCOMMUNITY_VAL_STR
)
14662 return lcommunity_list_set_vty(vty
, argc
, argv
,
14663 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14666 ALIAS (lcommunity_list_standard1
,
14667 ip_lcommunity_list_standard1_cmd
,
14668 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14670 LCOMMUNITY_LIST_STR
14671 "Large Community list number (standard)\n"
14672 "Specify large community to reject\n"
14673 "Specify large community to accept\n"
14674 LCOMMUNITY_VAL_STR
)
14676 DEFUN (lcommunity_list_expanded
,
14677 bgp_lcommunity_list_expanded_cmd
,
14678 "bgp large-community-list (100-500) <deny|permit> LINE...",
14680 LCOMMUNITY_LIST_STR
14681 "Large Community list number (expanded)\n"
14682 "Specify large community to reject\n"
14683 "Specify large community to accept\n"
14684 "An ordered list as a regular-expression\n")
14686 return lcommunity_list_set_vty(vty
, argc
, argv
,
14687 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14690 ALIAS (lcommunity_list_expanded
,
14691 ip_lcommunity_list_expanded_cmd
,
14692 "ip large-community-list (100-500) <deny|permit> LINE...",
14694 LCOMMUNITY_LIST_STR
14695 "Large Community list number (expanded)\n"
14696 "Specify large community to reject\n"
14697 "Specify large community to accept\n"
14698 "An ordered list as a regular-expression\n")
14700 DEFUN (lcommunity_list_name_standard
,
14701 bgp_lcommunity_list_name_standard_cmd
,
14702 "bgp large-community-list standard WORD <deny|permit>",
14704 LCOMMUNITY_LIST_STR
14705 "Specify standard large-community-list\n"
14706 "Large Community list name\n"
14707 "Specify large community to reject\n"
14708 "Specify large community to accept\n")
14710 return lcommunity_list_set_vty(vty
, argc
, argv
,
14711 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14714 ALIAS (lcommunity_list_name_standard
,
14715 ip_lcommunity_list_name_standard_cmd
,
14716 "ip large-community-list standard WORD <deny|permit>",
14718 LCOMMUNITY_LIST_STR
14719 "Specify standard large-community-list\n"
14720 "Large Community list name\n"
14721 "Specify large community to reject\n"
14722 "Specify large community to accept\n")
14724 DEFUN (lcommunity_list_name_standard1
,
14725 bgp_lcommunity_list_name_standard1_cmd
,
14726 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14728 LCOMMUNITY_LIST_STR
14729 "Specify standard large-community-list\n"
14730 "Large Community list name\n"
14731 "Specify large community to reject\n"
14732 "Specify large community to accept\n"
14733 LCOMMUNITY_VAL_STR
)
14735 return lcommunity_list_set_vty(vty
, argc
, argv
,
14736 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14739 ALIAS (lcommunity_list_name_standard1
,
14740 ip_lcommunity_list_name_standard1_cmd
,
14741 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14743 LCOMMUNITY_LIST_STR
14744 "Specify standard large-community-list\n"
14745 "Large Community list name\n"
14746 "Specify large community to reject\n"
14747 "Specify large community to accept\n"
14748 LCOMMUNITY_VAL_STR
)
14750 DEFUN (lcommunity_list_name_expanded
,
14751 bgp_lcommunity_list_name_expanded_cmd
,
14752 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14754 LCOMMUNITY_LIST_STR
14755 "Specify expanded large-community-list\n"
14756 "Large Community list name\n"
14757 "Specify large community to reject\n"
14758 "Specify large community to accept\n"
14759 "An ordered list as a regular-expression\n")
14761 return lcommunity_list_set_vty(vty
, argc
, argv
,
14762 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14765 ALIAS (lcommunity_list_name_expanded
,
14766 ip_lcommunity_list_name_expanded_cmd
,
14767 "ip large-community-list expanded WORD <deny|permit> LINE...",
14769 LCOMMUNITY_LIST_STR
14770 "Specify expanded large-community-list\n"
14771 "Large Community list name\n"
14772 "Specify large community to reject\n"
14773 "Specify large community to accept\n"
14774 "An ordered list as a regular-expression\n")
14776 DEFUN (no_lcommunity_list_standard_all
,
14777 no_bgp_lcommunity_list_standard_all_cmd
,
14778 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14781 LCOMMUNITY_LIST_STR
14782 "Large Community list number (standard)\n"
14783 "Large Community list number (expanded)\n"
14784 "Large Community list name\n")
14786 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14787 LARGE_COMMUNITY_LIST_STANDARD
);
14790 ALIAS (no_lcommunity_list_standard_all
,
14791 no_ip_lcommunity_list_standard_all_cmd
,
14792 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14795 LCOMMUNITY_LIST_STR
14796 "Large Community list number (standard)\n"
14797 "Large Community list number (expanded)\n"
14798 "Large Community list name\n")
14800 DEFUN (no_lcommunity_list_name_expanded_all
,
14801 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14802 "no bgp large-community-list expanded WORD",
14805 LCOMMUNITY_LIST_STR
14806 "Specify expanded large-community-list\n"
14807 "Large Community list name\n")
14809 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14810 LARGE_COMMUNITY_LIST_EXPANDED
);
14813 ALIAS (no_lcommunity_list_name_expanded_all
,
14814 no_ip_lcommunity_list_name_expanded_all_cmd
,
14815 "no ip large-community-list expanded WORD",
14818 LCOMMUNITY_LIST_STR
14819 "Specify expanded large-community-list\n"
14820 "Large Community list name\n")
14822 DEFUN (no_lcommunity_list_standard
,
14823 no_bgp_lcommunity_list_standard_cmd
,
14824 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14827 LCOMMUNITY_LIST_STR
14828 "Large Community list number (standard)\n"
14829 "Specify large community to reject\n"
14830 "Specify large community to accept\n"
14831 LCOMMUNITY_VAL_STR
)
14833 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14834 LARGE_COMMUNITY_LIST_STANDARD
);
14837 ALIAS (no_lcommunity_list_standard
,
14838 no_ip_lcommunity_list_standard_cmd
,
14839 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14842 LCOMMUNITY_LIST_STR
14843 "Large Community list number (standard)\n"
14844 "Specify large community to reject\n"
14845 "Specify large community to accept\n"
14846 LCOMMUNITY_VAL_STR
)
14848 DEFUN (no_lcommunity_list_expanded
,
14849 no_bgp_lcommunity_list_expanded_cmd
,
14850 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14853 LCOMMUNITY_LIST_STR
14854 "Large Community list number (expanded)\n"
14855 "Specify large community to reject\n"
14856 "Specify large community to accept\n"
14857 "An ordered list as a regular-expression\n")
14859 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14860 LARGE_COMMUNITY_LIST_EXPANDED
);
14863 ALIAS (no_lcommunity_list_expanded
,
14864 no_ip_lcommunity_list_expanded_cmd
,
14865 "no ip large-community-list (100-500) <deny|permit> LINE...",
14868 LCOMMUNITY_LIST_STR
14869 "Large Community list number (expanded)\n"
14870 "Specify large community to reject\n"
14871 "Specify large community to accept\n"
14872 "An ordered list as a regular-expression\n")
14874 DEFUN (no_lcommunity_list_name_standard
,
14875 no_bgp_lcommunity_list_name_standard_cmd
,
14876 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14879 LCOMMUNITY_LIST_STR
14880 "Specify standard large-community-list\n"
14881 "Large Community list name\n"
14882 "Specify large community to reject\n"
14883 "Specify large community to accept\n"
14884 LCOMMUNITY_VAL_STR
)
14886 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14887 LARGE_COMMUNITY_LIST_STANDARD
);
14890 ALIAS (no_lcommunity_list_name_standard
,
14891 no_ip_lcommunity_list_name_standard_cmd
,
14892 "no ip 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 DEFUN (no_lcommunity_list_name_expanded
,
14903 no_bgp_lcommunity_list_name_expanded_cmd
,
14904 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14907 LCOMMUNITY_LIST_STR
14908 "Specify expanded large-community-list\n"
14909 "Large community list name\n"
14910 "Specify large community to reject\n"
14911 "Specify large community to accept\n"
14912 "An ordered list as a regular-expression\n")
14914 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14915 LARGE_COMMUNITY_LIST_EXPANDED
);
14918 ALIAS (no_lcommunity_list_name_expanded
,
14919 no_ip_lcommunity_list_name_expanded_cmd
,
14920 "no ip 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 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14932 struct community_entry
*entry
;
14934 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14935 if (entry
== list
->head
) {
14936 if (all_digit(list
->name
))
14937 vty_out(vty
, "Large community %s list %s\n",
14938 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14940 : "(expanded) access",
14944 "Named large community %s list %s\n",
14945 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14951 vty_out(vty
, " %s\n",
14952 community_direct_str(entry
->direct
));
14954 vty_out(vty
, " %s %s\n",
14955 community_direct_str(entry
->direct
),
14956 community_list_config_str(entry
));
14960 DEFUN (show_lcommunity_list
,
14961 show_bgp_lcommunity_list_cmd
,
14962 "show bgp large-community-list",
14965 "List large-community list\n")
14967 struct community_list
*list
;
14968 struct community_list_master
*cm
;
14971 if (argv_find(argv
, argc
, "ip", &idx
)) {
14972 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14973 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14974 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14975 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14978 cm
= community_list_master_lookup(bgp_clist
,
14979 LARGE_COMMUNITY_LIST_MASTER
);
14981 return CMD_SUCCESS
;
14983 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14984 lcommunity_list_show(vty
, list
);
14986 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14987 lcommunity_list_show(vty
, list
);
14989 return CMD_SUCCESS
;
14992 ALIAS (show_lcommunity_list
,
14993 show_ip_lcommunity_list_cmd
,
14994 "show ip large-community-list",
14997 "List large-community list\n")
14999 DEFUN (show_lcommunity_list_arg
,
15000 show_bgp_lcommunity_list_arg_cmd
,
15001 "show bgp large-community-list <(1-500)|WORD>",
15004 "List large-community list\n"
15005 "large-community-list number\n"
15006 "large-community-list name\n")
15008 struct community_list
*list
;
15011 if (argv_find(argv
, argc
, "ip", &idx
)) {
15012 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15013 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15014 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15015 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15018 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
15019 LARGE_COMMUNITY_LIST_MASTER
);
15021 vty_out(vty
, "%% Can't find extcommunity-list\n");
15022 return CMD_WARNING
;
15025 lcommunity_list_show(vty
, list
);
15027 return CMD_SUCCESS
;
15030 ALIAS (show_lcommunity_list_arg
,
15031 show_ip_lcommunity_list_arg_cmd
,
15032 "show ip large-community-list <(1-500)|WORD>",
15035 "List large-community list\n"
15036 "large-community-list number\n"
15037 "large-community-list name\n")
15039 /* "extcommunity-list" keyword help string. */
15040 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15041 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15043 DEFUN (extcommunity_list_standard
,
15044 bgp_extcommunity_list_standard_cmd
,
15045 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15047 EXTCOMMUNITY_LIST_STR
15048 "Extended Community list number (standard)\n"
15049 "Specify standard extcommunity-list\n"
15050 "Community list name\n"
15051 "Specify community to reject\n"
15052 "Specify community to accept\n"
15053 EXTCOMMUNITY_VAL_STR
)
15055 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15057 char *cl_number_or_name
= NULL
;
15060 if (argv_find(argv
, argc
, "ip", &idx
)) {
15061 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15062 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15063 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15064 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15066 argv_find(argv
, argc
, "(1-99)", &idx
);
15067 argv_find(argv
, argc
, "WORD", &idx
);
15068 cl_number_or_name
= argv
[idx
]->arg
;
15069 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15071 argv_find(argv
, argc
, "AA:NN", &idx
);
15072 char *str
= argv_concat(argv
, argc
, idx
);
15074 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15077 XFREE(MTYPE_TMP
, str
);
15080 community_list_perror(vty
, ret
);
15081 return CMD_WARNING_CONFIG_FAILED
;
15084 return CMD_SUCCESS
;
15087 #if CONFDATE > 20191005
15088 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15090 ALIAS (extcommunity_list_standard
,
15091 ip_extcommunity_list_standard_cmd
,
15092 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15094 EXTCOMMUNITY_LIST_STR
15095 "Extended Community list number (standard)\n"
15096 "Specify standard extcommunity-list\n"
15097 "Community list name\n"
15098 "Specify community to reject\n"
15099 "Specify community to accept\n"
15100 EXTCOMMUNITY_VAL_STR
)
15102 DEFUN (extcommunity_list_name_expanded
,
15103 bgp_extcommunity_list_name_expanded_cmd
,
15104 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15106 EXTCOMMUNITY_LIST_STR
15107 "Extended Community list number (expanded)\n"
15108 "Specify expanded extcommunity-list\n"
15109 "Extended Community list name\n"
15110 "Specify community to reject\n"
15111 "Specify community to accept\n"
15112 "An ordered list as a regular-expression\n")
15114 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15116 char *cl_number_or_name
= NULL
;
15119 if (argv_find(argv
, argc
, "ip", &idx
)) {
15120 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15121 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15122 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15123 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15126 argv_find(argv
, argc
, "(100-500)", &idx
);
15127 argv_find(argv
, argc
, "WORD", &idx
);
15128 cl_number_or_name
= argv
[idx
]->arg
;
15129 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15131 argv_find(argv
, argc
, "LINE", &idx
);
15132 char *str
= argv_concat(argv
, argc
, idx
);
15134 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15137 XFREE(MTYPE_TMP
, str
);
15140 community_list_perror(vty
, ret
);
15141 return CMD_WARNING_CONFIG_FAILED
;
15144 return CMD_SUCCESS
;
15147 ALIAS (extcommunity_list_name_expanded
,
15148 ip_extcommunity_list_name_expanded_cmd
,
15149 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15151 EXTCOMMUNITY_LIST_STR
15152 "Extended Community list number (expanded)\n"
15153 "Specify expanded extcommunity-list\n"
15154 "Extended Community list name\n"
15155 "Specify community to reject\n"
15156 "Specify community to accept\n"
15157 "An ordered list as a regular-expression\n")
15159 DEFUN (no_extcommunity_list_standard_all
,
15160 no_bgp_extcommunity_list_standard_all_cmd
,
15161 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15164 EXTCOMMUNITY_LIST_STR
15165 "Extended Community list number (standard)\n"
15166 "Specify standard extcommunity-list\n"
15167 "Community list name\n"
15168 "Specify community to reject\n"
15169 "Specify community to accept\n"
15170 EXTCOMMUNITY_VAL_STR
)
15172 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15174 char *cl_number_or_name
= NULL
;
15178 if (argv_find(argv
, argc
, "ip", &idx
)) {
15179 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15180 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15181 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15182 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15186 argv_find(argv
, argc
, "permit", &idx
);
15187 argv_find(argv
, argc
, "deny", &idx
);
15190 direct
= argv_find(argv
, argc
, "permit", &idx
)
15195 argv_find(argv
, argc
, "AA:NN", &idx
);
15196 str
= argv_concat(argv
, argc
, idx
);
15200 argv_find(argv
, argc
, "(1-99)", &idx
);
15201 argv_find(argv
, argc
, "WORD", &idx
);
15202 cl_number_or_name
= argv
[idx
]->arg
;
15204 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15207 XFREE(MTYPE_TMP
, str
);
15210 community_list_perror(vty
, ret
);
15211 return CMD_WARNING_CONFIG_FAILED
;
15214 return CMD_SUCCESS
;
15217 ALIAS (no_extcommunity_list_standard_all
,
15218 no_ip_extcommunity_list_standard_all_cmd
,
15219 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15222 EXTCOMMUNITY_LIST_STR
15223 "Extended Community list number (standard)\n"
15224 "Specify standard extcommunity-list\n"
15225 "Community list name\n"
15226 "Specify community to reject\n"
15227 "Specify community to accept\n"
15228 EXTCOMMUNITY_VAL_STR
)
15230 ALIAS(no_extcommunity_list_standard_all
,
15231 no_bgp_extcommunity_list_standard_all_list_cmd
,
15232 "no bgp extcommunity-list <(1-99)|standard WORD>",
15233 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15234 "Extended Community list number (standard)\n"
15235 "Specify standard extcommunity-list\n"
15236 "Community list name\n")
15238 ALIAS(no_extcommunity_list_standard_all
,
15239 no_ip_extcommunity_list_standard_all_list_cmd
,
15240 "no ip extcommunity-list <(1-99)|standard WORD>",
15241 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15242 "Extended Community list number (standard)\n"
15243 "Specify standard extcommunity-list\n"
15244 "Community list name\n")
15246 DEFUN (no_extcommunity_list_expanded_all
,
15247 no_bgp_extcommunity_list_expanded_all_cmd
,
15248 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15251 EXTCOMMUNITY_LIST_STR
15252 "Extended Community list number (expanded)\n"
15253 "Specify expanded extcommunity-list\n"
15254 "Extended Community list name\n"
15255 "Specify community to reject\n"
15256 "Specify community to accept\n"
15257 "An ordered list as a regular-expression\n")
15259 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15261 char *cl_number_or_name
= NULL
;
15265 if (argv_find(argv
, argc
, "ip", &idx
)) {
15266 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15267 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15268 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15269 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15273 argv_find(argv
, argc
, "permit", &idx
);
15274 argv_find(argv
, argc
, "deny", &idx
);
15277 direct
= argv_find(argv
, argc
, "permit", &idx
)
15282 argv_find(argv
, argc
, "LINE", &idx
);
15283 str
= argv_concat(argv
, argc
, idx
);
15287 argv_find(argv
, argc
, "(100-500)", &idx
);
15288 argv_find(argv
, argc
, "WORD", &idx
);
15289 cl_number_or_name
= argv
[idx
]->arg
;
15291 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15294 XFREE(MTYPE_TMP
, str
);
15297 community_list_perror(vty
, ret
);
15298 return CMD_WARNING_CONFIG_FAILED
;
15301 return CMD_SUCCESS
;
15304 ALIAS (no_extcommunity_list_expanded_all
,
15305 no_ip_extcommunity_list_expanded_all_cmd
,
15306 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15309 EXTCOMMUNITY_LIST_STR
15310 "Extended Community list number (expanded)\n"
15311 "Specify expanded extcommunity-list\n"
15312 "Extended Community list name\n"
15313 "Specify community to reject\n"
15314 "Specify community to accept\n"
15315 "An ordered list as a regular-expression\n")
15317 ALIAS(no_extcommunity_list_expanded_all
,
15318 no_ip_extcommunity_list_expanded_all_list_cmd
,
15319 "no ip extcommunity-list <(100-500)|expanded WORD>",
15320 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15321 "Extended Community list number (expanded)\n"
15322 "Specify expanded extcommunity-list\n"
15323 "Extended Community list name\n")
15325 ALIAS(no_extcommunity_list_expanded_all
,
15326 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15327 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15328 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15329 "Extended Community list number (expanded)\n"
15330 "Specify expanded extcommunity-list\n"
15331 "Extended Community list name\n")
15333 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15335 struct community_entry
*entry
;
15337 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15338 if (entry
== list
->head
) {
15339 if (all_digit(list
->name
))
15340 vty_out(vty
, "Extended community %s list %s\n",
15341 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15343 : "(expanded) access",
15347 "Named extended community %s list %s\n",
15348 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15354 vty_out(vty
, " %s\n",
15355 community_direct_str(entry
->direct
));
15357 vty_out(vty
, " %s %s\n",
15358 community_direct_str(entry
->direct
),
15359 community_list_config_str(entry
));
15363 DEFUN (show_extcommunity_list
,
15364 show_bgp_extcommunity_list_cmd
,
15365 "show bgp extcommunity-list",
15368 "List extended-community list\n")
15370 struct community_list
*list
;
15371 struct community_list_master
*cm
;
15374 if (argv_find(argv
, argc
, "ip", &idx
)) {
15375 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15376 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15377 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15378 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15380 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15382 return CMD_SUCCESS
;
15384 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15385 extcommunity_list_show(vty
, list
);
15387 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15388 extcommunity_list_show(vty
, list
);
15390 return CMD_SUCCESS
;
15393 ALIAS (show_extcommunity_list
,
15394 show_ip_extcommunity_list_cmd
,
15395 "show ip extcommunity-list",
15398 "List extended-community list\n")
15400 DEFUN (show_extcommunity_list_arg
,
15401 show_bgp_extcommunity_list_arg_cmd
,
15402 "show bgp extcommunity-list <(1-500)|WORD>",
15405 "List extended-community list\n"
15406 "Extcommunity-list number\n"
15407 "Extcommunity-list name\n")
15409 int idx_comm_list
= 3;
15410 struct community_list
*list
;
15413 if (argv_find(argv
, argc
, "ip", &idx
)) {
15414 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15415 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15416 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15417 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15419 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15420 EXTCOMMUNITY_LIST_MASTER
);
15422 vty_out(vty
, "%% Can't find extcommunity-list\n");
15423 return CMD_WARNING
;
15426 extcommunity_list_show(vty
, list
);
15428 return CMD_SUCCESS
;
15431 ALIAS (show_extcommunity_list_arg
,
15432 show_ip_extcommunity_list_arg_cmd
,
15433 "show ip extcommunity-list <(1-500)|WORD>",
15436 "List extended-community list\n"
15437 "Extcommunity-list number\n"
15438 "Extcommunity-list name\n")
15440 /* Display community-list and extcommunity-list configuration. */
15441 static int community_list_config_write(struct vty
*vty
)
15443 struct community_list
*list
;
15444 struct community_entry
*entry
;
15445 struct community_list_master
*cm
;
15448 /* Community-list. */
15449 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15451 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15452 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15453 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15454 community_direct_str(entry
->direct
),
15455 community_list_config_str(entry
));
15458 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15459 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15460 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15461 entry
->style
== COMMUNITY_LIST_STANDARD
15464 list
->name
, community_direct_str(entry
->direct
),
15465 community_list_config_str(entry
));
15469 /* Extcommunity-list. */
15470 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15472 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15473 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15474 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15475 list
->name
, community_direct_str(entry
->direct
),
15476 community_list_config_str(entry
));
15479 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15480 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15481 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15482 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15485 list
->name
, community_direct_str(entry
->direct
),
15486 community_list_config_str(entry
));
15491 /* lcommunity-list. */
15492 cm
= community_list_master_lookup(bgp_clist
,
15493 LARGE_COMMUNITY_LIST_MASTER
);
15495 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15496 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15497 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15498 list
->name
, community_direct_str(entry
->direct
),
15499 community_list_config_str(entry
));
15502 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15503 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15504 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15505 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15508 list
->name
, community_direct_str(entry
->direct
),
15509 community_list_config_str(entry
));
15516 static struct cmd_node community_list_node
= {
15517 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15520 static void community_list_vty(void)
15522 install_node(&community_list_node
, community_list_config_write
);
15524 /* Community-list. */
15525 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15526 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15527 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15528 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15529 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15530 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15531 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15532 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15533 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15534 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15535 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15536 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15537 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15538 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15539 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15540 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15542 /* Extcommunity-list. */
15543 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15544 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15545 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15546 install_element(CONFIG_NODE
,
15547 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15548 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15549 install_element(CONFIG_NODE
,
15550 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15551 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15552 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15553 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15554 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15555 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15556 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15557 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15558 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15559 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15560 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15562 /* Large Community List */
15563 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15564 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15565 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15566 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15567 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15568 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15569 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15570 install_element(CONFIG_NODE
,
15571 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15572 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15573 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15574 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15575 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15576 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15577 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15578 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15579 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15580 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15581 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15582 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15583 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15584 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15585 install_element(CONFIG_NODE
,
15586 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15587 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15588 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15589 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15590 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15591 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15592 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);