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
)
774 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
775 BGP_CLEAR_SOFT_IN
, NULL
);
776 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
777 BGP_CLEAR_SOFT_IN
, NULL
);
780 /* clear soft outbound */
781 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
783 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
784 BGP_CLEAR_SOFT_OUT
, NULL
);
785 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
786 BGP_CLEAR_SOFT_OUT
, NULL
);
790 #ifndef VTYSH_EXTRACT_PL
791 #include "bgpd/bgp_vty_clippy.c"
794 /* BGP global configuration. */
795 #if (CONFDATE > 20190601)
796 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
797 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
799 DEFUN_HIDDEN (bgp_multiple_instance_func
,
800 bgp_multiple_instance_cmd
,
801 "bgp multiple-instance",
803 "Enable bgp multiple instance\n")
805 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
809 DEFUN_HIDDEN (no_bgp_multiple_instance
,
810 no_bgp_multiple_instance_cmd
,
811 "no bgp multiple-instance",
814 "BGP multiple instance\n")
818 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
819 vty_out(vty
, "if you are using this please let the developers know\n");
820 zlog_info("Deprecated option: `bgp multiple-instance` being used");
821 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
823 vty_out(vty
, "%% There are more than two BGP instances\n");
824 return CMD_WARNING_CONFIG_FAILED
;
829 DEFUN_HIDDEN (bgp_local_mac
,
831 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
834 "VxLAN Network Identifier\n"
838 "mac-mobility sequence\n"
848 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
849 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
850 vty_out(vty
, "%% Malformed MAC address\n");
853 memset(&ip
, 0, sizeof(ip
));
854 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
856 bgp
= bgp_get_default();
858 vty_out(vty
, "Default BGP instance is not there\n");
862 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
864 vty_out(vty
, "Internal error\n");
871 DEFUN_HIDDEN (no_bgp_local_mac
,
872 no_bgp_local_mac_cmd
,
873 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
877 "VxLAN Network Identifier\n"
888 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
889 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
890 vty_out(vty
, "%% Malformed MAC address\n");
893 memset(&ip
, 0, sizeof(ip
));
895 bgp
= bgp_get_default();
897 vty_out(vty
, "Default BGP instance is not there\n");
901 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
903 vty_out(vty
, "Internal error\n");
910 #if (CONFDATE > 20190601)
911 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
912 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
914 DEFUN_HIDDEN (bgp_config_type
,
916 "bgp config-type <cisco|zebra>",
918 "Configuration type\n"
923 if (argv_find(argv
, argc
, "cisco", &idx
)) {
924 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
925 vty_out(vty
, "if you are using this please let the developers know!\n");
926 zlog_info("Deprecated option: `bgp config-type cisco` being used");
927 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
929 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
934 DEFUN_HIDDEN (no_bgp_config_type
,
935 no_bgp_config_type_cmd
,
936 "no bgp config-type [<cisco|zebra>]",
939 "Display configuration type\n"
943 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
948 DEFUN (no_synchronization
,
949 no_synchronization_cmd
,
950 "no synchronization",
952 "Perform IGP synchronization\n")
957 DEFUN (no_auto_summary
,
961 "Enable automatic network number summarization\n")
966 /* "router bgp" commands. */
967 DEFUN_NOSH (router_bgp
,
969 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
973 BGP_INSTANCE_HELP_STR
)
976 int idx_view_vrf
= 3;
982 const char *name
= NULL
;
983 enum bgp_instance_type inst_type
;
985 // "router bgp" without an ASN
987 // Pending: Make VRF option available for ASN less config
988 bgp
= bgp_get_default();
991 vty_out(vty
, "%% No BGP process is configured\n");
992 return CMD_WARNING_CONFIG_FAILED
;
995 if (listcount(bm
->bgp
) > 1) {
996 vty_out(vty
, "%% Please specify ASN and VRF\n");
997 return CMD_WARNING_CONFIG_FAILED
;
1003 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1005 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1007 name
= argv
[idx_vrf
]->arg
;
1009 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1010 if (strmatch(name
, VRF_DEFAULT_NAME
))
1013 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1014 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1015 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1018 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1019 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1021 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
1023 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
1025 "Please specify 'bgp multiple-instance' first\n");
1026 return CMD_WARNING_CONFIG_FAILED
;
1027 case BGP_ERR_AS_MISMATCH
:
1028 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1029 return CMD_WARNING_CONFIG_FAILED
;
1030 case BGP_ERR_INSTANCE_MISMATCH
:
1032 "BGP instance name and AS number mismatch\n");
1034 "BGP instance is already running; AS is %u\n",
1036 return CMD_WARNING_CONFIG_FAILED
;
1040 * If we just instantiated the default instance, complete
1041 * any pending VRF-VPN leaking that was configured via
1042 * earlier "router bgp X vrf FOO" blocks.
1044 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1045 vpn_leak_postchange_all();
1047 /* Pending: handle when user tries to change a view to vrf n vv.
1051 /* unset the auto created flag as the user config is now present */
1052 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1053 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1058 /* "no router bgp" commands. */
1059 DEFUN (no_router_bgp
,
1061 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
1066 BGP_INSTANCE_HELP_STR
)
1072 const char *name
= NULL
;
1074 // "no router bgp" without an ASN
1076 // Pending: Make VRF option available for ASN less config
1077 bgp
= bgp_get_default();
1080 vty_out(vty
, "%% No BGP process is configured\n");
1081 return CMD_WARNING_CONFIG_FAILED
;
1084 if (listcount(bm
->bgp
) > 1) {
1085 vty_out(vty
, "%% Please specify ASN and VRF\n");
1086 return CMD_WARNING_CONFIG_FAILED
;
1090 vty_out(vty
, "%% Please unconfigure l3vni %u",
1092 return CMD_WARNING_CONFIG_FAILED
;
1095 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1098 name
= argv
[idx_vrf
]->arg
;
1100 /* Lookup bgp structure. */
1101 bgp
= bgp_lookup(as
, name
);
1103 vty_out(vty
, "%% Can't find BGP instance\n");
1104 return CMD_WARNING_CONFIG_FAILED
;
1108 vty_out(vty
, "%% Please unconfigure l3vni %u",
1110 return CMD_WARNING_CONFIG_FAILED
;
1120 /* BGP router-id. */
1122 DEFPY (bgp_router_id
,
1124 "bgp router-id A.B.C.D",
1126 "Override configured router identifier\n"
1127 "Manually configured router identifier\n")
1129 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1130 bgp_router_id_static_set(bgp
, router_id
);
1134 DEFPY (no_bgp_router_id
,
1135 no_bgp_router_id_cmd
,
1136 "no bgp router-id [A.B.C.D]",
1139 "Override configured router identifier\n"
1140 "Manually configured router identifier\n")
1142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1144 if (router_id_str
) {
1145 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1146 vty_out(vty
, "%% BGP router-id doesn't match\n");
1147 return CMD_WARNING_CONFIG_FAILED
;
1151 router_id
.s_addr
= 0;
1152 bgp_router_id_static_set(bgp
, router_id
);
1158 /* BGP Cluster ID. */
1159 DEFUN (bgp_cluster_id
,
1161 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1163 "Configure Route-Reflector Cluster-id\n"
1164 "Route-Reflector Cluster-id in IP address format\n"
1165 "Route-Reflector Cluster-id as 32 bit quantity\n")
1167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1170 struct in_addr cluster
;
1172 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1174 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1175 return CMD_WARNING_CONFIG_FAILED
;
1178 bgp_cluster_id_set(bgp
, &cluster
);
1179 bgp_clear_star_soft_out(vty
, bgp
->name
);
1184 DEFUN (no_bgp_cluster_id
,
1185 no_bgp_cluster_id_cmd
,
1186 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1189 "Configure Route-Reflector Cluster-id\n"
1190 "Route-Reflector Cluster-id in IP address format\n"
1191 "Route-Reflector Cluster-id as 32 bit quantity\n")
1193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1194 bgp_cluster_id_unset(bgp
);
1195 bgp_clear_star_soft_out(vty
, bgp
->name
);
1200 DEFUN (bgp_confederation_identifier
,
1201 bgp_confederation_identifier_cmd
,
1202 "bgp confederation identifier (1-4294967295)",
1203 "BGP specific commands\n"
1204 "AS confederation parameters\n"
1206 "Set routing domain confederation AS\n")
1208 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1212 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1214 bgp_confederation_id_set(bgp
, as
);
1219 DEFUN (no_bgp_confederation_identifier
,
1220 no_bgp_confederation_identifier_cmd
,
1221 "no bgp confederation identifier [(1-4294967295)]",
1223 "BGP specific commands\n"
1224 "AS confederation parameters\n"
1226 "Set routing domain confederation AS\n")
1228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1229 bgp_confederation_id_unset(bgp
);
1234 DEFUN (bgp_confederation_peers
,
1235 bgp_confederation_peers_cmd
,
1236 "bgp confederation peers (1-4294967295)...",
1237 "BGP specific commands\n"
1238 "AS confederation parameters\n"
1239 "Peer ASs in BGP confederation\n"
1242 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1247 for (i
= idx_asn
; i
< argc
; i
++) {
1248 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1250 if (bgp
->as
== as
) {
1252 "%% Local member-AS not allowed in confed peer list\n");
1256 bgp_confederation_peers_add(bgp
, as
);
1261 DEFUN (no_bgp_confederation_peers
,
1262 no_bgp_confederation_peers_cmd
,
1263 "no bgp confederation peers (1-4294967295)...",
1265 "BGP specific commands\n"
1266 "AS confederation parameters\n"
1267 "Peer ASs in BGP confederation\n"
1270 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1275 for (i
= idx_asn
; i
< argc
; i
++) {
1276 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1278 bgp_confederation_peers_remove(bgp
, as
);
1284 * Central routine for maximum-paths configuration.
1285 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1286 * @set: 1 for setting values, 0 for removing the max-paths config.
1288 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1289 const char *mpaths
, uint16_t options
,
1292 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1293 uint16_t maxpaths
= 0;
1298 afi
= bgp_node_afi(vty
);
1299 safi
= bgp_node_safi(vty
);
1302 maxpaths
= strtol(mpaths
, NULL
, 10);
1303 if (maxpaths
> multipath_num
) {
1305 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1306 maxpaths
, multipath_num
);
1307 return CMD_WARNING_CONFIG_FAILED
;
1309 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1312 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1316 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1317 (set
== 1) ? "" : "un",
1318 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1319 maxpaths
, afi
, safi
);
1320 return CMD_WARNING_CONFIG_FAILED
;
1323 bgp_recalculate_all_bestpaths(bgp
);
1328 DEFUN (bgp_maxmed_admin
,
1329 bgp_maxmed_admin_cmd
,
1330 "bgp max-med administrative ",
1332 "Advertise routes with max-med\n"
1333 "Administratively applied, for an indefinite period\n")
1335 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1337 bgp
->v_maxmed_admin
= 1;
1338 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1340 bgp_maxmed_update(bgp
);
1345 DEFUN (bgp_maxmed_admin_medv
,
1346 bgp_maxmed_admin_medv_cmd
,
1347 "bgp max-med administrative (0-4294967295)",
1349 "Advertise routes with max-med\n"
1350 "Administratively applied, for an indefinite period\n"
1351 "Max MED value to be used\n")
1353 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1356 bgp
->v_maxmed_admin
= 1;
1357 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1359 bgp_maxmed_update(bgp
);
1364 DEFUN (no_bgp_maxmed_admin
,
1365 no_bgp_maxmed_admin_cmd
,
1366 "no bgp max-med administrative [(0-4294967295)]",
1369 "Advertise routes with max-med\n"
1370 "Administratively applied, for an indefinite period\n"
1371 "Max MED value to be used\n")
1373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1374 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1375 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1376 bgp_maxmed_update(bgp
);
1381 DEFUN (bgp_maxmed_onstartup
,
1382 bgp_maxmed_onstartup_cmd
,
1383 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1385 "Advertise routes with max-med\n"
1386 "Effective on a startup\n"
1387 "Time (seconds) period for max-med\n"
1388 "Max MED value to be used\n")
1390 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1393 argv_find(argv
, argc
, "(5-86400)", &idx
);
1394 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1395 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1396 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1398 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1400 bgp_maxmed_update(bgp
);
1405 DEFUN (no_bgp_maxmed_onstartup
,
1406 no_bgp_maxmed_onstartup_cmd
,
1407 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1410 "Advertise routes with max-med\n"
1411 "Effective on a startup\n"
1412 "Time (seconds) period for max-med\n"
1413 "Max MED value to be used\n")
1415 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1417 /* Cancel max-med onstartup if its on */
1418 if (bgp
->t_maxmed_onstartup
) {
1419 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1420 bgp
->maxmed_onstartup_over
= 1;
1423 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1424 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1426 bgp_maxmed_update(bgp
);
1431 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1434 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1435 uint16_t update_delay
;
1436 uint16_t establish_wait
;
1438 update_delay
= strtoul(delay
, NULL
, 10);
1440 if (!wait
) /* update-delay <delay> */
1442 bgp
->v_update_delay
= update_delay
;
1443 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1447 /* update-delay <delay> <establish-wait> */
1448 establish_wait
= atoi(wait
);
1449 if (update_delay
< establish_wait
) {
1451 "%%Failed: update-delay less than the establish-wait!\n");
1452 return CMD_WARNING_CONFIG_FAILED
;
1455 bgp
->v_update_delay
= update_delay
;
1456 bgp
->v_establish_wait
= establish_wait
;
1461 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1463 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1465 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1466 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1471 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1473 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1474 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1475 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1476 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1482 /* Update-delay configuration */
1483 DEFUN (bgp_update_delay
,
1484 bgp_update_delay_cmd
,
1485 "update-delay (0-3600)",
1486 "Force initial delay for best-path and updates\n"
1490 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1493 DEFUN (bgp_update_delay_establish_wait
,
1494 bgp_update_delay_establish_wait_cmd
,
1495 "update-delay (0-3600) (1-3600)",
1496 "Force initial delay for best-path and updates\n"
1501 int idx_number_2
= 2;
1502 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1503 argv
[idx_number_2
]->arg
);
1506 /* Update-delay deconfiguration */
1507 DEFUN (no_bgp_update_delay
,
1508 no_bgp_update_delay_cmd
,
1509 "no update-delay [(0-3600) [(1-3600)]]",
1511 "Force initial delay for best-path and updates\n"
1515 return bgp_update_delay_deconfig_vty(vty
);
1519 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1525 uint32_t quanta
= strtoul(num
, NULL
, 10);
1526 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1527 memory_order_relaxed
);
1529 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1530 memory_order_relaxed
);
1536 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1539 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1542 uint32_t quanta
= strtoul(num
, NULL
, 10);
1543 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1544 memory_order_relaxed
);
1546 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1547 memory_order_relaxed
);
1553 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1556 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1557 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1558 vty_out(vty
, " write-quanta %d\n", quanta
);
1561 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1564 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1565 if (quanta
!= BGP_READ_PACKET_MAX
)
1566 vty_out(vty
, " read-quanta %d\n", quanta
);
1569 /* Packet quanta configuration */
1570 DEFUN (bgp_wpkt_quanta
,
1571 bgp_wpkt_quanta_cmd
,
1572 "write-quanta (1-10)",
1573 "How many packets to write to peer socket per run\n"
1574 "Number of packets\n")
1577 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1580 DEFUN (no_bgp_wpkt_quanta
,
1581 no_bgp_wpkt_quanta_cmd
,
1582 "no write-quanta (1-10)",
1584 "How many packets to write to peer socket per I/O cycle\n"
1585 "Number of packets\n")
1588 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1591 DEFUN (bgp_rpkt_quanta
,
1592 bgp_rpkt_quanta_cmd
,
1593 "read-quanta (1-10)",
1594 "How many packets to read from peer socket per I/O cycle\n"
1595 "Number of packets\n")
1598 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1601 DEFUN (no_bgp_rpkt_quanta
,
1602 no_bgp_rpkt_quanta_cmd
,
1603 "no read-quanta (1-10)",
1605 "How many packets to read from peer socket per I/O cycle\n"
1606 "Number of packets\n")
1609 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1612 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1614 if (!bgp
->heuristic_coalesce
)
1615 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1619 DEFUN (bgp_coalesce_time
,
1620 bgp_coalesce_time_cmd
,
1621 "coalesce-time (0-4294967295)",
1622 "Subgroup coalesce timer\n"
1623 "Subgroup coalesce timer value (in ms)\n")
1625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1628 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1629 bgp
->heuristic_coalesce
= false;
1630 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1634 DEFUN (no_bgp_coalesce_time
,
1635 no_bgp_coalesce_time_cmd
,
1636 "no coalesce-time (0-4294967295)",
1638 "Subgroup coalesce timer\n"
1639 "Subgroup coalesce timer value (in ms)\n")
1641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1643 bgp
->heuristic_coalesce
= true;
1644 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1648 /* Maximum-paths configuration */
1649 DEFUN (bgp_maxpaths
,
1651 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1652 "Forward packets over multiple paths\n"
1653 "Number of paths\n")
1656 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1657 argv
[idx_number
]->arg
, 0, 1);
1660 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1661 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1662 "Forward packets over multiple paths\n"
1663 "Number of paths\n")
1665 DEFUN (bgp_maxpaths_ibgp
,
1666 bgp_maxpaths_ibgp_cmd
,
1667 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1668 "Forward packets over multiple paths\n"
1670 "Number of paths\n")
1673 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1674 argv
[idx_number
]->arg
, 0, 1);
1677 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1678 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1679 "Forward packets over multiple paths\n"
1681 "Number of paths\n")
1683 DEFUN (bgp_maxpaths_ibgp_cluster
,
1684 bgp_maxpaths_ibgp_cluster_cmd
,
1685 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1686 "Forward packets over multiple paths\n"
1689 "Match the cluster length\n")
1692 return bgp_maxpaths_config_vty(
1693 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1694 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1697 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1698 "maximum-paths ibgp " CMD_RANGE_STR(
1699 1, MULTIPATH_NUM
) " equal-cluster-length",
1700 "Forward packets over multiple paths\n"
1703 "Match the cluster length\n")
1705 DEFUN (no_bgp_maxpaths
,
1706 no_bgp_maxpaths_cmd
,
1707 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1709 "Forward packets over multiple paths\n"
1710 "Number of paths\n")
1712 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1715 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1716 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1717 "Forward packets over multiple paths\n"
1718 "Number of paths\n")
1720 DEFUN (no_bgp_maxpaths_ibgp
,
1721 no_bgp_maxpaths_ibgp_cmd
,
1722 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1724 "Forward packets over multiple paths\n"
1727 "Match the cluster length\n")
1729 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1732 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1733 "no maximum-paths ibgp [" CMD_RANGE_STR(
1734 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1736 "Forward packets over multiple paths\n"
1739 "Match the cluster length\n")
1741 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1744 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1745 vty_out(vty
, " maximum-paths %d\n",
1746 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1749 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1750 vty_out(vty
, " maximum-paths ibgp %d",
1751 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1752 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1753 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1754 vty_out(vty
, " equal-cluster-length");
1763 "timers bgp (0-65535) (0-65535)",
1764 "Adjust routing timers\n"
1766 "Keepalive interval\n"
1769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1771 int idx_number_2
= 3;
1772 unsigned long keepalive
= 0;
1773 unsigned long holdtime
= 0;
1775 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1776 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1778 /* Holdtime value check. */
1779 if (holdtime
< 3 && holdtime
!= 0) {
1781 "%% hold time value must be either 0 or greater than 3\n");
1782 return CMD_WARNING_CONFIG_FAILED
;
1785 bgp_timers_set(bgp
, keepalive
, holdtime
);
1790 DEFUN (no_bgp_timers
,
1792 "no timers bgp [(0-65535) (0-65535)]",
1794 "Adjust routing timers\n"
1796 "Keepalive interval\n"
1799 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1800 bgp_timers_unset(bgp
);
1806 DEFUN (bgp_client_to_client_reflection
,
1807 bgp_client_to_client_reflection_cmd
,
1808 "bgp client-to-client reflection",
1809 "BGP specific commands\n"
1810 "Configure client to client route reflection\n"
1811 "reflection of routes allowed\n")
1813 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1814 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1815 bgp_clear_star_soft_out(vty
, bgp
->name
);
1820 DEFUN (no_bgp_client_to_client_reflection
,
1821 no_bgp_client_to_client_reflection_cmd
,
1822 "no bgp client-to-client reflection",
1824 "BGP specific commands\n"
1825 "Configure client to client route reflection\n"
1826 "reflection of routes allowed\n")
1828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1829 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1830 bgp_clear_star_soft_out(vty
, bgp
->name
);
1835 /* "bgp always-compare-med" configuration. */
1836 DEFUN (bgp_always_compare_med
,
1837 bgp_always_compare_med_cmd
,
1838 "bgp always-compare-med",
1839 "BGP specific commands\n"
1840 "Allow comparing MED from different neighbors\n")
1842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1843 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1844 bgp_recalculate_all_bestpaths(bgp
);
1849 DEFUN (no_bgp_always_compare_med
,
1850 no_bgp_always_compare_med_cmd
,
1851 "no bgp always-compare-med",
1853 "BGP specific commands\n"
1854 "Allow comparing MED from different neighbors\n")
1856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1857 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1858 bgp_recalculate_all_bestpaths(bgp
);
1864 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1865 "bgp ebgp-requires-policy",
1866 "BGP specific commands\n"
1867 "Require in and out policy for eBGP peers (RFC8212)\n")
1869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1870 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1874 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1875 "no bgp ebgp-requires-policy",
1877 "BGP specific commands\n"
1878 "Require in and out policy for eBGP peers (RFC8212)\n")
1880 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1881 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1886 /* "bgp deterministic-med" configuration. */
1887 DEFUN (bgp_deterministic_med
,
1888 bgp_deterministic_med_cmd
,
1889 "bgp deterministic-med",
1890 "BGP specific commands\n"
1891 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1893 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1895 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1896 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1897 bgp_recalculate_all_bestpaths(bgp
);
1903 DEFUN (no_bgp_deterministic_med
,
1904 no_bgp_deterministic_med_cmd
,
1905 "no bgp deterministic-med",
1907 "BGP specific commands\n"
1908 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1910 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1911 int bestpath_per_as_used
;
1915 struct listnode
*node
, *nnode
;
1917 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1918 bestpath_per_as_used
= 0;
1920 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1921 FOREACH_AFI_SAFI (afi
, safi
)
1922 if (bgp_addpath_dmed_required(
1923 peer
->addpath_type
[afi
][safi
])) {
1924 bestpath_per_as_used
= 1;
1928 if (bestpath_per_as_used
)
1932 if (bestpath_per_as_used
) {
1934 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1935 return CMD_WARNING_CONFIG_FAILED
;
1937 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1938 bgp_recalculate_all_bestpaths(bgp
);
1945 /* "bgp graceful-restart" configuration. */
1946 DEFUN (bgp_graceful_restart
,
1947 bgp_graceful_restart_cmd
,
1948 "bgp graceful-restart",
1949 "BGP specific commands\n"
1950 "Graceful restart capability parameters\n")
1952 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1953 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1957 DEFUN (no_bgp_graceful_restart
,
1958 no_bgp_graceful_restart_cmd
,
1959 "no bgp graceful-restart",
1961 "BGP specific commands\n"
1962 "Graceful restart capability parameters\n")
1964 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1965 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1969 DEFUN (bgp_graceful_restart_stalepath_time
,
1970 bgp_graceful_restart_stalepath_time_cmd
,
1971 "bgp graceful-restart stalepath-time (1-4095)",
1972 "BGP specific commands\n"
1973 "Graceful restart capability parameters\n"
1974 "Set the max time to hold onto restarting peer's stale paths\n"
1975 "Delay value (seconds)\n")
1977 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1981 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1982 bgp
->stalepath_time
= stalepath
;
1986 DEFUN (bgp_graceful_restart_restart_time
,
1987 bgp_graceful_restart_restart_time_cmd
,
1988 "bgp graceful-restart restart-time (1-4095)",
1989 "BGP specific commands\n"
1990 "Graceful restart capability parameters\n"
1991 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1992 "Delay value (seconds)\n")
1994 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1998 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1999 bgp
->restart_time
= restart
;
2003 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2004 no_bgp_graceful_restart_stalepath_time_cmd
,
2005 "no bgp graceful-restart stalepath-time [(1-4095)]",
2007 "BGP specific commands\n"
2008 "Graceful restart capability parameters\n"
2009 "Set the max time to hold onto restarting peer's stale paths\n"
2010 "Delay value (seconds)\n")
2012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2014 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2018 DEFUN (no_bgp_graceful_restart_restart_time
,
2019 no_bgp_graceful_restart_restart_time_cmd
,
2020 "no bgp graceful-restart restart-time [(1-4095)]",
2022 "BGP specific commands\n"
2023 "Graceful restart capability parameters\n"
2024 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2025 "Delay value (seconds)\n")
2027 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2029 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2033 DEFUN (bgp_graceful_restart_preserve_fw
,
2034 bgp_graceful_restart_preserve_fw_cmd
,
2035 "bgp graceful-restart preserve-fw-state",
2036 "BGP specific commands\n"
2037 "Graceful restart capability parameters\n"
2038 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2040 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2041 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2045 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2046 no_bgp_graceful_restart_preserve_fw_cmd
,
2047 "no bgp graceful-restart preserve-fw-state",
2049 "BGP specific commands\n"
2050 "Graceful restart capability parameters\n"
2051 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2054 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2058 /* "bgp graceful-shutdown" configuration */
2059 DEFUN (bgp_graceful_shutdown
,
2060 bgp_graceful_shutdown_cmd
,
2061 "bgp graceful-shutdown",
2063 "Graceful shutdown parameters\n")
2065 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2067 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2068 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2069 bgp_static_redo_import_check(bgp
);
2070 bgp_redistribute_redo(bgp
);
2071 bgp_clear_star_soft_out(vty
, bgp
->name
);
2072 bgp_clear_star_soft_in(vty
, bgp
->name
);
2078 DEFUN (no_bgp_graceful_shutdown
,
2079 no_bgp_graceful_shutdown_cmd
,
2080 "no bgp graceful-shutdown",
2083 "Graceful shutdown parameters\n")
2085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2087 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2088 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2089 bgp_static_redo_import_check(bgp
);
2090 bgp_redistribute_redo(bgp
);
2091 bgp_clear_star_soft_out(vty
, bgp
->name
);
2092 bgp_clear_star_soft_in(vty
, bgp
->name
);
2098 /* "bgp fast-external-failover" configuration. */
2099 DEFUN (bgp_fast_external_failover
,
2100 bgp_fast_external_failover_cmd
,
2101 "bgp fast-external-failover",
2103 "Immediately reset session if a link to a directly connected external peer goes down\n")
2105 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2106 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2110 DEFUN (no_bgp_fast_external_failover
,
2111 no_bgp_fast_external_failover_cmd
,
2112 "no bgp fast-external-failover",
2115 "Immediately reset session if a link to a directly connected external peer goes down\n")
2117 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2118 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2122 /* "bgp enforce-first-as" configuration. */
2123 #if CONFDATE > 20190517
2124 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2127 DEFUN_HIDDEN (bgp_enforce_first_as
,
2128 bgp_enforce_first_as_cmd
,
2129 "[no] bgp enforce-first-as",
2132 "Enforce the first AS for EBGP routes\n")
2134 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2136 if (strmatch(argv
[0]->text
, "no"))
2137 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2139 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2144 /* "bgp bestpath compare-routerid" configuration. */
2145 DEFUN (bgp_bestpath_compare_router_id
,
2146 bgp_bestpath_compare_router_id_cmd
,
2147 "bgp bestpath compare-routerid",
2148 "BGP specific commands\n"
2149 "Change the default bestpath selection\n"
2150 "Compare router-id for identical EBGP paths\n")
2152 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2153 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2154 bgp_recalculate_all_bestpaths(bgp
);
2159 DEFUN (no_bgp_bestpath_compare_router_id
,
2160 no_bgp_bestpath_compare_router_id_cmd
,
2161 "no bgp bestpath compare-routerid",
2163 "BGP specific commands\n"
2164 "Change the default bestpath selection\n"
2165 "Compare router-id for identical EBGP paths\n")
2167 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2168 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2169 bgp_recalculate_all_bestpaths(bgp
);
2174 /* "bgp bestpath as-path ignore" configuration. */
2175 DEFUN (bgp_bestpath_aspath_ignore
,
2176 bgp_bestpath_aspath_ignore_cmd
,
2177 "bgp bestpath as-path ignore",
2178 "BGP specific commands\n"
2179 "Change the default bestpath selection\n"
2180 "AS-path attribute\n"
2181 "Ignore as-path length in selecting a route\n")
2183 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2184 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2185 bgp_recalculate_all_bestpaths(bgp
);
2190 DEFUN (no_bgp_bestpath_aspath_ignore
,
2191 no_bgp_bestpath_aspath_ignore_cmd
,
2192 "no bgp bestpath as-path ignore",
2194 "BGP specific commands\n"
2195 "Change the default bestpath selection\n"
2196 "AS-path attribute\n"
2197 "Ignore as-path length in selecting a route\n")
2199 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2200 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2201 bgp_recalculate_all_bestpaths(bgp
);
2206 /* "bgp bestpath as-path confed" configuration. */
2207 DEFUN (bgp_bestpath_aspath_confed
,
2208 bgp_bestpath_aspath_confed_cmd
,
2209 "bgp bestpath as-path confed",
2210 "BGP specific commands\n"
2211 "Change the default bestpath selection\n"
2212 "AS-path attribute\n"
2213 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2215 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2216 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2217 bgp_recalculate_all_bestpaths(bgp
);
2222 DEFUN (no_bgp_bestpath_aspath_confed
,
2223 no_bgp_bestpath_aspath_confed_cmd
,
2224 "no bgp bestpath as-path confed",
2226 "BGP specific commands\n"
2227 "Change the default bestpath selection\n"
2228 "AS-path attribute\n"
2229 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2231 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2232 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2233 bgp_recalculate_all_bestpaths(bgp
);
2238 /* "bgp bestpath as-path multipath-relax" configuration. */
2239 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2240 bgp_bestpath_aspath_multipath_relax_cmd
,
2241 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2242 "BGP specific commands\n"
2243 "Change the default bestpath selection\n"
2244 "AS-path attribute\n"
2245 "Allow load sharing across routes that have different AS paths (but same length)\n"
2246 "Generate an AS_SET\n"
2247 "Do not generate an AS_SET\n")
2249 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2251 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2253 /* no-as-set is now the default behavior so we can silently
2255 if (argv_find(argv
, argc
, "as-set", &idx
))
2256 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2258 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2260 bgp_recalculate_all_bestpaths(bgp
);
2265 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2266 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2267 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2269 "BGP specific commands\n"
2270 "Change the default bestpath selection\n"
2271 "AS-path attribute\n"
2272 "Allow load sharing across routes that have different AS paths (but same length)\n"
2273 "Generate an AS_SET\n"
2274 "Do not generate an AS_SET\n")
2276 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2277 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2278 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2279 bgp_recalculate_all_bestpaths(bgp
);
2284 /* "bgp log-neighbor-changes" configuration. */
2285 DEFUN (bgp_log_neighbor_changes
,
2286 bgp_log_neighbor_changes_cmd
,
2287 "bgp log-neighbor-changes",
2288 "BGP specific commands\n"
2289 "Log neighbor up/down and reset reason\n")
2291 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2292 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2296 DEFUN (no_bgp_log_neighbor_changes
,
2297 no_bgp_log_neighbor_changes_cmd
,
2298 "no bgp log-neighbor-changes",
2300 "BGP specific commands\n"
2301 "Log neighbor up/down and reset reason\n")
2303 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2304 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2308 /* "bgp bestpath med" configuration. */
2309 DEFUN (bgp_bestpath_med
,
2310 bgp_bestpath_med_cmd
,
2311 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2312 "BGP specific commands\n"
2313 "Change the default bestpath selection\n"
2315 "Compare MED among confederation paths\n"
2316 "Treat missing MED as the least preferred one\n"
2317 "Treat missing MED as the least preferred one\n"
2318 "Compare MED among confederation paths\n")
2320 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2323 if (argv_find(argv
, argc
, "confed", &idx
))
2324 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2326 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2327 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2329 bgp_recalculate_all_bestpaths(bgp
);
2334 DEFUN (no_bgp_bestpath_med
,
2335 no_bgp_bestpath_med_cmd
,
2336 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2338 "BGP specific commands\n"
2339 "Change the default bestpath selection\n"
2341 "Compare MED among confederation paths\n"
2342 "Treat missing MED as the least preferred one\n"
2343 "Treat missing MED as the least preferred one\n"
2344 "Compare MED among confederation paths\n")
2346 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2349 if (argv_find(argv
, argc
, "confed", &idx
))
2350 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2352 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2353 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2355 bgp_recalculate_all_bestpaths(bgp
);
2360 /* "no bgp default ipv4-unicast". */
2361 DEFUN (no_bgp_default_ipv4_unicast
,
2362 no_bgp_default_ipv4_unicast_cmd
,
2363 "no bgp default ipv4-unicast",
2365 "BGP specific commands\n"
2366 "Configure BGP defaults\n"
2367 "Activate ipv4-unicast for a peer by default\n")
2369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2370 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2374 DEFUN (bgp_default_ipv4_unicast
,
2375 bgp_default_ipv4_unicast_cmd
,
2376 "bgp default ipv4-unicast",
2377 "BGP specific commands\n"
2378 "Configure BGP defaults\n"
2379 "Activate ipv4-unicast for a peer by default\n")
2381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2382 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2386 /* Display hostname in certain command outputs */
2387 DEFUN (bgp_default_show_hostname
,
2388 bgp_default_show_hostname_cmd
,
2389 "bgp default show-hostname",
2390 "BGP specific commands\n"
2391 "Configure BGP defaults\n"
2392 "Show hostname in certain command outputs\n")
2394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2395 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2399 DEFUN (no_bgp_default_show_hostname
,
2400 no_bgp_default_show_hostname_cmd
,
2401 "no bgp default show-hostname",
2403 "BGP specific commands\n"
2404 "Configure BGP defaults\n"
2405 "Show hostname in certain command outputs\n")
2407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2408 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2412 /* "bgp network import-check" configuration. */
2413 DEFUN (bgp_network_import_check
,
2414 bgp_network_import_check_cmd
,
2415 "bgp network import-check",
2416 "BGP specific commands\n"
2417 "BGP network command\n"
2418 "Check BGP network route exists in IGP\n")
2420 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2421 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2422 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2423 bgp_static_redo_import_check(bgp
);
2429 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2430 "bgp network import-check exact",
2431 "BGP specific commands\n"
2432 "BGP network command\n"
2433 "Check BGP network route exists in IGP\n"
2434 "Match route precisely\n")
2436 DEFUN (no_bgp_network_import_check
,
2437 no_bgp_network_import_check_cmd
,
2438 "no bgp network import-check",
2440 "BGP specific commands\n"
2441 "BGP network command\n"
2442 "Check BGP network route exists in IGP\n")
2444 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2445 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2446 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2447 bgp_static_redo_import_check(bgp
);
2453 DEFUN (bgp_default_local_preference
,
2454 bgp_default_local_preference_cmd
,
2455 "bgp default local-preference (0-4294967295)",
2456 "BGP specific commands\n"
2457 "Configure BGP defaults\n"
2458 "local preference (higher=more preferred)\n"
2459 "Configure default local preference value\n")
2461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2463 uint32_t local_pref
;
2465 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2467 bgp_default_local_preference_set(bgp
, local_pref
);
2468 bgp_clear_star_soft_in(vty
, bgp
->name
);
2473 DEFUN (no_bgp_default_local_preference
,
2474 no_bgp_default_local_preference_cmd
,
2475 "no bgp default local-preference [(0-4294967295)]",
2477 "BGP specific commands\n"
2478 "Configure BGP defaults\n"
2479 "local preference (higher=more preferred)\n"
2480 "Configure default local preference value\n")
2482 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2483 bgp_default_local_preference_unset(bgp
);
2484 bgp_clear_star_soft_in(vty
, bgp
->name
);
2490 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2491 bgp_default_subgroup_pkt_queue_max_cmd
,
2492 "bgp default subgroup-pkt-queue-max (20-100)",
2493 "BGP specific commands\n"
2494 "Configure BGP defaults\n"
2495 "subgroup-pkt-queue-max\n"
2496 "Configure subgroup packet queue max\n")
2498 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2502 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2504 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2509 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2510 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2511 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2513 "BGP specific commands\n"
2514 "Configure BGP defaults\n"
2515 "subgroup-pkt-queue-max\n"
2516 "Configure subgroup packet queue max\n")
2518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2519 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2524 DEFUN (bgp_rr_allow_outbound_policy
,
2525 bgp_rr_allow_outbound_policy_cmd
,
2526 "bgp route-reflector allow-outbound-policy",
2527 "BGP specific commands\n"
2528 "Allow modifications made by out route-map\n"
2529 "on ibgp neighbors\n")
2531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2533 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2534 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2535 update_group_announce_rrclients(bgp
);
2536 bgp_clear_star_soft_out(vty
, bgp
->name
);
2542 DEFUN (no_bgp_rr_allow_outbound_policy
,
2543 no_bgp_rr_allow_outbound_policy_cmd
,
2544 "no bgp route-reflector allow-outbound-policy",
2546 "BGP specific commands\n"
2547 "Allow modifications made by out route-map\n"
2548 "on ibgp neighbors\n")
2550 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2552 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2553 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2554 update_group_announce_rrclients(bgp
);
2555 bgp_clear_star_soft_out(vty
, bgp
->name
);
2561 DEFUN (bgp_listen_limit
,
2562 bgp_listen_limit_cmd
,
2563 "bgp listen limit (1-5000)",
2564 "BGP specific commands\n"
2565 "Configure BGP defaults\n"
2566 "maximum number of BGP Dynamic Neighbors that can be created\n"
2567 "Configure Dynamic Neighbors listen limit value\n")
2569 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2573 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2575 bgp_listen_limit_set(bgp
, listen_limit
);
2580 DEFUN (no_bgp_listen_limit
,
2581 no_bgp_listen_limit_cmd
,
2582 "no bgp listen limit [(1-5000)]",
2583 "BGP specific commands\n"
2584 "Configure BGP defaults\n"
2585 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2586 "Configure Dynamic Neighbors listen limit value to default\n"
2587 "Configure Dynamic Neighbors listen limit value\n")
2589 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2590 bgp_listen_limit_unset(bgp
);
2596 * Check if this listen range is already configured. Check for exact
2597 * match or overlap based on input.
2599 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2600 struct prefix
*range
, int exact
)
2602 struct listnode
*node
, *nnode
;
2603 struct listnode
*node1
, *nnode1
;
2604 struct peer_group
*group
;
2609 afi
= family2afi(range
->family
);
2610 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2611 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2614 match
= prefix_same(range
, lr
);
2616 match
= (prefix_match(range
, lr
)
2617 || prefix_match(lr
, range
));
2626 DEFUN (bgp_listen_range
,
2627 bgp_listen_range_cmd
,
2628 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2629 "BGP specific commands\n"
2630 "Configure BGP dynamic neighbors listen range\n"
2631 "Configure BGP dynamic neighbors listen range\n"
2633 "Member of the peer-group\n"
2634 "Peer-group name\n")
2636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2637 struct prefix range
;
2638 struct peer_group
*group
, *existing_group
;
2643 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2644 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2645 char *prefix
= argv
[idx
]->arg
;
2646 argv_find(argv
, argc
, "WORD", &idx
);
2647 char *peergroup
= argv
[idx
]->arg
;
2649 /* Convert IP prefix string to struct prefix. */
2650 ret
= str2prefix(prefix
, &range
);
2652 vty_out(vty
, "%% Malformed listen range\n");
2653 return CMD_WARNING_CONFIG_FAILED
;
2656 afi
= family2afi(range
.family
);
2658 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2660 "%% Malformed listen range (link-local address)\n");
2661 return CMD_WARNING_CONFIG_FAILED
;
2666 /* Check if same listen range is already configured. */
2667 existing_group
= listen_range_exists(bgp
, &range
, 1);
2668 if (existing_group
) {
2669 if (strcmp(existing_group
->name
, peergroup
) == 0)
2673 "%% Same listen range is attached to peer-group %s\n",
2674 existing_group
->name
);
2675 return CMD_WARNING_CONFIG_FAILED
;
2679 /* Check if an overlapping listen range exists. */
2680 if (listen_range_exists(bgp
, &range
, 0)) {
2682 "%% Listen range overlaps with existing listen range\n");
2683 return CMD_WARNING_CONFIG_FAILED
;
2686 group
= peer_group_lookup(bgp
, peergroup
);
2688 vty_out(vty
, "%% Configure the peer-group first\n");
2689 return CMD_WARNING_CONFIG_FAILED
;
2692 ret
= peer_group_listen_range_add(group
, &range
);
2693 return bgp_vty_return(vty
, ret
);
2696 DEFUN (no_bgp_listen_range
,
2697 no_bgp_listen_range_cmd
,
2698 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2700 "BGP specific commands\n"
2701 "Unconfigure BGP dynamic neighbors listen range\n"
2702 "Unconfigure BGP dynamic neighbors listen range\n"
2704 "Member of the peer-group\n"
2705 "Peer-group name\n")
2707 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2708 struct prefix range
;
2709 struct peer_group
*group
;
2714 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2715 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2716 char *prefix
= argv
[idx
]->arg
;
2717 argv_find(argv
, argc
, "WORD", &idx
);
2718 char *peergroup
= argv
[idx
]->arg
;
2720 /* Convert IP prefix string to struct prefix. */
2721 ret
= str2prefix(prefix
, &range
);
2723 vty_out(vty
, "%% Malformed listen range\n");
2724 return CMD_WARNING_CONFIG_FAILED
;
2727 afi
= family2afi(range
.family
);
2729 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2731 "%% Malformed listen range (link-local address)\n");
2732 return CMD_WARNING_CONFIG_FAILED
;
2737 group
= peer_group_lookup(bgp
, peergroup
);
2739 vty_out(vty
, "%% Peer-group does not exist\n");
2740 return CMD_WARNING_CONFIG_FAILED
;
2743 ret
= peer_group_listen_range_del(group
, &range
);
2744 return bgp_vty_return(vty
, ret
);
2747 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2749 struct peer_group
*group
;
2750 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2751 struct prefix
*range
;
2753 char buf
[PREFIX2STR_BUFFER
];
2755 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2756 vty_out(vty
, " bgp listen limit %d\n",
2757 bgp
->dynamic_neighbors_limit
);
2759 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2760 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2761 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2763 prefix2str(range
, buf
, sizeof(buf
));
2765 " bgp listen range %s peer-group %s\n",
2773 DEFUN (bgp_disable_connected_route_check
,
2774 bgp_disable_connected_route_check_cmd
,
2775 "bgp disable-ebgp-connected-route-check",
2776 "BGP specific commands\n"
2777 "Disable checking if nexthop is connected on ebgp sessions\n")
2779 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2780 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2781 bgp_clear_star_soft_in(vty
, bgp
->name
);
2786 DEFUN (no_bgp_disable_connected_route_check
,
2787 no_bgp_disable_connected_route_check_cmd
,
2788 "no bgp disable-ebgp-connected-route-check",
2790 "BGP specific commands\n"
2791 "Disable checking if nexthop is connected on ebgp sessions\n")
2793 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2794 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2795 bgp_clear_star_soft_in(vty
, bgp
->name
);
2801 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2802 const char *as_str
, afi_t afi
, safi_t safi
)
2804 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2807 int as_type
= AS_SPECIFIED
;
2810 if (as_str
[0] == 'i') {
2812 as_type
= AS_INTERNAL
;
2813 } else if (as_str
[0] == 'e') {
2815 as_type
= AS_EXTERNAL
;
2817 /* Get AS number. */
2818 as
= strtoul(as_str
, NULL
, 10);
2821 /* If peer is peer group or interface peer, call proper function. */
2822 ret
= str2sockunion(peer_str
, &su
);
2826 /* Check if existing interface peer */
2827 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2829 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2832 /* if not interface peer, check peer-group settings */
2833 if (ret
< 0 && !peer
) {
2834 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2837 "%% Create the peer-group or interface first\n");
2838 return CMD_WARNING_CONFIG_FAILED
;
2843 if (peer_address_self_check(bgp
, &su
)) {
2845 "%% Can not configure the local system as neighbor\n");
2846 return CMD_WARNING_CONFIG_FAILED
;
2848 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2851 /* This peer belongs to peer group. */
2853 case BGP_ERR_PEER_GROUP_MEMBER
:
2855 "%% Peer-group member cannot override remote-as of peer-group\n");
2856 return CMD_WARNING_CONFIG_FAILED
;
2857 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2859 "%% Peer-group members must be all internal or all external\n");
2860 return CMD_WARNING_CONFIG_FAILED
;
2862 return bgp_vty_return(vty
, ret
);
2865 DEFUN (bgp_default_shutdown
,
2866 bgp_default_shutdown_cmd
,
2867 "[no] bgp default shutdown",
2870 "Configure BGP defaults\n"
2871 "Apply administrative shutdown to newly configured peers\n")
2873 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2874 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2878 DEFUN (neighbor_remote_as
,
2879 neighbor_remote_as_cmd
,
2880 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2883 "Specify a BGP neighbor\n"
2885 "Internal BGP peer\n"
2886 "External BGP peer\n")
2889 int idx_remote_as
= 3;
2890 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2891 argv
[idx_remote_as
]->arg
, AFI_IP
,
2895 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2896 afi_t afi
, safi_t safi
, int v6only
,
2897 const char *peer_group_name
,
2900 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2902 int as_type
= AS_UNSPECIFIED
;
2904 struct peer_group
*group
;
2908 group
= peer_group_lookup(bgp
, conf_if
);
2911 vty_out(vty
, "%% Name conflict with peer-group \n");
2912 return CMD_WARNING_CONFIG_FAILED
;
2916 if (as_str
[0] == 'i') {
2917 as_type
= AS_INTERNAL
;
2918 } else if (as_str
[0] == 'e') {
2919 as_type
= AS_EXTERNAL
;
2921 /* Get AS number. */
2922 as
= strtoul(as_str
, NULL
, 10);
2923 as_type
= AS_SPECIFIED
;
2927 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2930 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2933 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2934 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2935 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2936 as_type
, 0, 0, NULL
);
2938 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2939 as_type
, afi
, safi
, NULL
);
2942 vty_out(vty
, "%% BGP failed to create peer\n");
2943 return CMD_WARNING_CONFIG_FAILED
;
2947 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2949 /* Request zebra to initiate IPv6 RAs on this interface. We do
2951 * any unnumbered peer in order to not worry about run-time
2953 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2955 * gets deleted later etc.)
2958 bgp_zebra_initiate_radv(bgp
, peer
);
2961 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2962 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2964 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2966 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2968 /* v6only flag changed. Reset bgp seesion */
2969 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2970 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2971 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2972 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2974 bgp_session_reset(peer
);
2977 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2978 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2979 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2980 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
2983 if (peer_group_name
) {
2984 group
= peer_group_lookup(bgp
, peer_group_name
);
2986 vty_out(vty
, "%% Configure the peer-group first\n");
2987 return CMD_WARNING_CONFIG_FAILED
;
2990 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2993 return bgp_vty_return(vty
, ret
);
2996 DEFUN (neighbor_interface_config
,
2997 neighbor_interface_config_cmd
,
2998 "neighbor WORD interface [peer-group WORD]",
3000 "Interface name or neighbor tag\n"
3001 "Enable BGP on interface\n"
3002 "Member of the peer-group\n"
3003 "Peer-group name\n")
3006 int idx_peer_group_word
= 4;
3008 if (argc
> idx_peer_group_word
)
3009 return peer_conf_interface_get(
3010 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3011 argv
[idx_peer_group_word
]->arg
, NULL
);
3013 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3014 SAFI_UNICAST
, 0, NULL
, NULL
);
3017 DEFUN (neighbor_interface_config_v6only
,
3018 neighbor_interface_config_v6only_cmd
,
3019 "neighbor WORD interface v6only [peer-group WORD]",
3021 "Interface name or neighbor tag\n"
3022 "Enable BGP on interface\n"
3023 "Enable BGP with v6 link-local only\n"
3024 "Member of the peer-group\n"
3025 "Peer-group name\n")
3028 int idx_peer_group_word
= 5;
3030 if (argc
> idx_peer_group_word
)
3031 return peer_conf_interface_get(
3032 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3033 argv
[idx_peer_group_word
]->arg
, NULL
);
3035 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3036 SAFI_UNICAST
, 1, NULL
, NULL
);
3040 DEFUN (neighbor_interface_config_remote_as
,
3041 neighbor_interface_config_remote_as_cmd
,
3042 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3044 "Interface name or neighbor tag\n"
3045 "Enable BGP on interface\n"
3046 "Specify a BGP neighbor\n"
3048 "Internal BGP peer\n"
3049 "External BGP peer\n")
3052 int idx_remote_as
= 4;
3053 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3054 SAFI_UNICAST
, 0, NULL
,
3055 argv
[idx_remote_as
]->arg
);
3058 DEFUN (neighbor_interface_v6only_config_remote_as
,
3059 neighbor_interface_v6only_config_remote_as_cmd
,
3060 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3062 "Interface name or neighbor tag\n"
3063 "Enable BGP with v6 link-local only\n"
3064 "Enable BGP on interface\n"
3065 "Specify a BGP neighbor\n"
3067 "Internal BGP peer\n"
3068 "External BGP peer\n")
3071 int idx_remote_as
= 5;
3072 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3073 SAFI_UNICAST
, 1, NULL
,
3074 argv
[idx_remote_as
]->arg
);
3077 DEFUN (neighbor_peer_group
,
3078 neighbor_peer_group_cmd
,
3079 "neighbor WORD peer-group",
3081 "Interface name or neighbor tag\n"
3082 "Configure peer-group\n")
3084 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3087 struct peer_group
*group
;
3089 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3091 vty_out(vty
, "%% Name conflict with interface: \n");
3092 return CMD_WARNING_CONFIG_FAILED
;
3095 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3097 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3098 return CMD_WARNING_CONFIG_FAILED
;
3106 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3110 "Specify a BGP neighbor\n"
3112 "Internal BGP peer\n"
3113 "External BGP peer\n")
3115 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3119 struct peer_group
*group
;
3123 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3125 /* look up for neighbor by interface name config. */
3126 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3128 /* Request zebra to terminate IPv6 RAs on this
3131 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3136 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3138 peer_group_delete(group
);
3140 vty_out(vty
, "%% Create the peer-group first\n");
3141 return CMD_WARNING_CONFIG_FAILED
;
3144 peer
= peer_lookup(bgp
, &su
);
3146 if (peer_dynamic_neighbor(peer
)) {
3148 "%% Operation not allowed on a dynamic neighbor\n");
3149 return CMD_WARNING_CONFIG_FAILED
;
3152 other
= peer
->doppelganger
;
3154 if (other
&& other
->status
!= Deleted
)
3162 DEFUN (no_neighbor_interface_config
,
3163 no_neighbor_interface_config_cmd
,
3164 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3168 "Configure BGP on interface\n"
3169 "Enable BGP with v6 link-local only\n"
3170 "Member of the peer-group\n"
3172 "Specify a BGP neighbor\n"
3174 "Internal BGP peer\n"
3175 "External BGP peer\n")
3177 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3181 /* look up for neighbor by interface name config. */
3182 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3184 /* Request zebra to terminate IPv6 RAs on this interface. */
3186 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3189 vty_out(vty
, "%% Create the bgp interface first\n");
3190 return CMD_WARNING_CONFIG_FAILED
;
3195 DEFUN (no_neighbor_peer_group
,
3196 no_neighbor_peer_group_cmd
,
3197 "no neighbor WORD peer-group",
3201 "Configure peer-group\n")
3203 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3205 struct peer_group
*group
;
3207 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3209 peer_group_delete(group
);
3211 vty_out(vty
, "%% Create the peer-group first\n");
3212 return CMD_WARNING_CONFIG_FAILED
;
3217 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3218 no_neighbor_interface_peer_group_remote_as_cmd
,
3219 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3222 "Interface name or neighbor tag\n"
3223 "Specify a BGP neighbor\n"
3225 "Internal BGP peer\n"
3226 "External BGP peer\n")
3228 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3230 struct peer_group
*group
;
3233 /* look up for neighbor by interface name config. */
3234 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3236 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3240 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3242 peer_group_remote_as_delete(group
);
3244 vty_out(vty
, "%% Create the peer-group or interface first\n");
3245 return CMD_WARNING_CONFIG_FAILED
;
3250 DEFUN (neighbor_local_as
,
3251 neighbor_local_as_cmd
,
3252 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3255 "Specify a local-as number\n"
3256 "AS number used as local AS\n")
3264 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3266 return CMD_WARNING_CONFIG_FAILED
;
3268 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3269 ret
= peer_local_as_set(peer
, as
, 0, 0);
3270 return bgp_vty_return(vty
, ret
);
3273 DEFUN (neighbor_local_as_no_prepend
,
3274 neighbor_local_as_no_prepend_cmd
,
3275 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3278 "Specify a local-as number\n"
3279 "AS number used as local AS\n"
3280 "Do not prepend local-as to updates from ebgp peers\n")
3288 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3290 return CMD_WARNING_CONFIG_FAILED
;
3292 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3293 ret
= peer_local_as_set(peer
, as
, 1, 0);
3294 return bgp_vty_return(vty
, ret
);
3297 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3298 neighbor_local_as_no_prepend_replace_as_cmd
,
3299 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3302 "Specify a local-as number\n"
3303 "AS number used as local AS\n"
3304 "Do not prepend local-as to updates from ebgp peers\n"
3305 "Do not prepend local-as to updates from ibgp peers\n")
3313 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3315 return CMD_WARNING_CONFIG_FAILED
;
3317 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3318 ret
= peer_local_as_set(peer
, as
, 1, 1);
3319 return bgp_vty_return(vty
, ret
);
3322 DEFUN (no_neighbor_local_as
,
3323 no_neighbor_local_as_cmd
,
3324 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3328 "Specify a local-as number\n"
3329 "AS number used as local AS\n"
3330 "Do not prepend local-as to updates from ebgp peers\n"
3331 "Do not prepend local-as to updates from ibgp peers\n")
3337 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3339 return CMD_WARNING_CONFIG_FAILED
;
3341 ret
= peer_local_as_unset(peer
);
3342 return bgp_vty_return(vty
, ret
);
3346 DEFUN (neighbor_solo
,
3348 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3351 "Solo peer - part of its own update group\n")
3357 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3359 return CMD_WARNING_CONFIG_FAILED
;
3361 ret
= update_group_adjust_soloness(peer
, 1);
3362 return bgp_vty_return(vty
, ret
);
3365 DEFUN (no_neighbor_solo
,
3366 no_neighbor_solo_cmd
,
3367 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3371 "Solo peer - part of its own update group\n")
3377 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3379 return CMD_WARNING_CONFIG_FAILED
;
3381 ret
= update_group_adjust_soloness(peer
, 0);
3382 return bgp_vty_return(vty
, ret
);
3385 DEFUN (neighbor_password
,
3386 neighbor_password_cmd
,
3387 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3398 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3400 return CMD_WARNING_CONFIG_FAILED
;
3402 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3403 return bgp_vty_return(vty
, ret
);
3406 DEFUN (no_neighbor_password
,
3407 no_neighbor_password_cmd
,
3408 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3419 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3421 return CMD_WARNING_CONFIG_FAILED
;
3423 ret
= peer_password_unset(peer
);
3424 return bgp_vty_return(vty
, ret
);
3427 DEFUN (neighbor_activate
,
3428 neighbor_activate_cmd
,
3429 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3432 "Enable the Address Family for this Neighbor\n")
3438 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3440 return CMD_WARNING_CONFIG_FAILED
;
3442 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3443 return bgp_vty_return(vty
, ret
);
3446 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3447 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3448 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3449 "Enable the Address Family for this Neighbor\n")
3451 DEFUN (no_neighbor_activate
,
3452 no_neighbor_activate_cmd
,
3453 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3457 "Enable the Address Family for this Neighbor\n")
3464 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3466 return CMD_WARNING_CONFIG_FAILED
;
3468 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3469 return bgp_vty_return(vty
, ret
);
3472 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3473 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3474 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3475 "Enable the Address Family for this Neighbor\n")
3477 DEFUN (neighbor_set_peer_group
,
3478 neighbor_set_peer_group_cmd
,
3479 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3482 "Member of the peer-group\n"
3483 "Peer-group name\n")
3485 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3492 struct peer_group
*group
;
3494 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3496 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3498 vty_out(vty
, "%% Malformed address or name: %s\n",
3499 argv
[idx_peer
]->arg
);
3500 return CMD_WARNING_CONFIG_FAILED
;
3503 if (peer_address_self_check(bgp
, &su
)) {
3505 "%% Can not configure the local system as neighbor\n");
3506 return CMD_WARNING_CONFIG_FAILED
;
3509 /* Disallow for dynamic neighbor. */
3510 peer
= peer_lookup(bgp
, &su
);
3511 if (peer
&& peer_dynamic_neighbor(peer
)) {
3513 "%% Operation not allowed on a dynamic neighbor\n");
3514 return CMD_WARNING_CONFIG_FAILED
;
3518 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3520 vty_out(vty
, "%% Configure the peer-group first\n");
3521 return CMD_WARNING_CONFIG_FAILED
;
3524 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3526 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3528 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3530 return CMD_WARNING_CONFIG_FAILED
;
3533 return bgp_vty_return(vty
, ret
);
3536 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3537 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3538 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3539 "Member of the peer-group\n"
3540 "Peer-group name\n")
3542 DEFUN (no_neighbor_set_peer_group
,
3543 no_neighbor_set_peer_group_cmd
,
3544 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3548 "Member of the peer-group\n"
3549 "Peer-group name\n")
3551 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3556 struct peer_group
*group
;
3558 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3560 return CMD_WARNING_CONFIG_FAILED
;
3562 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3564 vty_out(vty
, "%% Configure the peer-group first\n");
3565 return CMD_WARNING_CONFIG_FAILED
;
3568 ret
= peer_delete(peer
);
3570 return bgp_vty_return(vty
, ret
);
3573 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3574 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3575 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3576 "Member of the peer-group\n"
3577 "Peer-group name\n")
3579 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3580 uint32_t flag
, int set
)
3585 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3587 return CMD_WARNING_CONFIG_FAILED
;
3590 * If 'neighbor <interface>', then this is for directly connected peers,
3591 * we should not accept disable-connected-check.
3593 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3595 "%s is directly connected peer, cannot accept disable-"
3596 "connected-check\n",
3598 return CMD_WARNING_CONFIG_FAILED
;
3601 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3602 peer_tx_shutdown_message_unset(peer
);
3605 ret
= peer_flag_set(peer
, flag
);
3607 ret
= peer_flag_unset(peer
, flag
);
3609 return bgp_vty_return(vty
, ret
);
3612 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3614 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3617 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3620 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3623 /* neighbor passive. */
3624 DEFUN (neighbor_passive
,
3625 neighbor_passive_cmd
,
3626 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3629 "Don't send open messages to this neighbor\n")
3632 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3635 DEFUN (no_neighbor_passive
,
3636 no_neighbor_passive_cmd
,
3637 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3641 "Don't send open messages to this neighbor\n")
3644 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3647 /* neighbor shutdown. */
3648 DEFUN (neighbor_shutdown_msg
,
3649 neighbor_shutdown_msg_cmd
,
3650 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3653 "Administratively shut down this neighbor\n"
3654 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3655 "Shutdown message\n")
3661 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3665 return CMD_WARNING_CONFIG_FAILED
;
3666 message
= argv_concat(argv
, argc
, 4);
3667 peer_tx_shutdown_message_set(peer
, message
);
3668 XFREE(MTYPE_TMP
, message
);
3671 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3674 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3675 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3676 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3677 "Administratively shut down this neighbor\n")
3679 DEFUN (no_neighbor_shutdown_msg
,
3680 no_neighbor_shutdown_msg_cmd
,
3681 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3685 "Administratively shut down this neighbor\n"
3686 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3687 "Shutdown message\n")
3691 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3692 PEER_FLAG_SHUTDOWN
);
3695 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3696 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3697 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3698 "Administratively shut down this neighbor\n")
3700 /* neighbor capability dynamic. */
3701 DEFUN (neighbor_capability_dynamic
,
3702 neighbor_capability_dynamic_cmd
,
3703 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3706 "Advertise capability to the peer\n"
3707 "Advertise dynamic capability to this neighbor\n")
3710 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3711 PEER_FLAG_DYNAMIC_CAPABILITY
);
3714 DEFUN (no_neighbor_capability_dynamic
,
3715 no_neighbor_capability_dynamic_cmd
,
3716 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3720 "Advertise capability to the peer\n"
3721 "Advertise dynamic capability to this neighbor\n")
3724 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3725 PEER_FLAG_DYNAMIC_CAPABILITY
);
3728 /* neighbor dont-capability-negotiate */
3729 DEFUN (neighbor_dont_capability_negotiate
,
3730 neighbor_dont_capability_negotiate_cmd
,
3731 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3734 "Do not perform capability negotiation\n")
3737 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3738 PEER_FLAG_DONT_CAPABILITY
);
3741 DEFUN (no_neighbor_dont_capability_negotiate
,
3742 no_neighbor_dont_capability_negotiate_cmd
,
3743 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3747 "Do not perform capability negotiation\n")
3750 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3751 PEER_FLAG_DONT_CAPABILITY
);
3754 /* neighbor capability extended next hop encoding */
3755 DEFUN (neighbor_capability_enhe
,
3756 neighbor_capability_enhe_cmd
,
3757 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3760 "Advertise capability to the peer\n"
3761 "Advertise extended next-hop capability to the peer\n")
3764 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3765 PEER_FLAG_CAPABILITY_ENHE
);
3768 DEFUN (no_neighbor_capability_enhe
,
3769 no_neighbor_capability_enhe_cmd
,
3770 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3774 "Advertise capability to the peer\n"
3775 "Advertise extended next-hop capability to the peer\n")
3778 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3779 PEER_FLAG_CAPABILITY_ENHE
);
3782 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3783 afi_t afi
, safi_t safi
, uint32_t flag
,
3789 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3791 return CMD_WARNING_CONFIG_FAILED
;
3794 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3796 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3798 return bgp_vty_return(vty
, ret
);
3801 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3802 afi_t afi
, safi_t safi
, uint32_t flag
)
3804 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3807 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3808 afi_t afi
, safi_t safi
, uint32_t flag
)
3810 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3813 /* neighbor capability orf prefix-list. */
3814 DEFUN (neighbor_capability_orf_prefix
,
3815 neighbor_capability_orf_prefix_cmd
,
3816 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3819 "Advertise capability to the peer\n"
3820 "Advertise ORF capability to the peer\n"
3821 "Advertise prefixlist ORF capability to this neighbor\n"
3822 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3823 "Capability to RECEIVE the ORF from this neighbor\n"
3824 "Capability to SEND the ORF to this neighbor\n")
3827 int idx_send_recv
= 5;
3830 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3831 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3832 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3833 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3834 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3835 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3837 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3838 return CMD_WARNING_CONFIG_FAILED
;
3841 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3842 bgp_node_safi(vty
), flag
);
3846 neighbor_capability_orf_prefix
,
3847 neighbor_capability_orf_prefix_hidden_cmd
,
3848 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3849 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3850 "Advertise capability to the peer\n"
3851 "Advertise ORF capability to the peer\n"
3852 "Advertise prefixlist ORF capability to this neighbor\n"
3853 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3854 "Capability to RECEIVE the ORF from this neighbor\n"
3855 "Capability to SEND the ORF to this neighbor\n")
3857 DEFUN (no_neighbor_capability_orf_prefix
,
3858 no_neighbor_capability_orf_prefix_cmd
,
3859 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3863 "Advertise capability to the peer\n"
3864 "Advertise ORF capability to the peer\n"
3865 "Advertise prefixlist ORF capability to this neighbor\n"
3866 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3867 "Capability to RECEIVE the ORF from this neighbor\n"
3868 "Capability to SEND the ORF to this neighbor\n")
3871 int idx_send_recv
= 6;
3874 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3875 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3876 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3877 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3878 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3879 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3881 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3882 return CMD_WARNING_CONFIG_FAILED
;
3885 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3886 bgp_node_afi(vty
), bgp_node_safi(vty
),
3891 no_neighbor_capability_orf_prefix
,
3892 no_neighbor_capability_orf_prefix_hidden_cmd
,
3893 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3894 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3895 "Advertise capability to the peer\n"
3896 "Advertise ORF capability to the peer\n"
3897 "Advertise prefixlist ORF capability to this neighbor\n"
3898 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3899 "Capability to RECEIVE the ORF from this neighbor\n"
3900 "Capability to SEND the ORF to this neighbor\n")
3902 /* neighbor next-hop-self. */
3903 DEFUN (neighbor_nexthop_self
,
3904 neighbor_nexthop_self_cmd
,
3905 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3908 "Disable the next hop calculation for this neighbor\n")
3911 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3912 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3915 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3916 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3917 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3918 "Disable the next hop calculation for this neighbor\n")
3920 /* neighbor next-hop-self. */
3921 DEFUN (neighbor_nexthop_self_force
,
3922 neighbor_nexthop_self_force_cmd
,
3923 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3926 "Disable the next hop calculation for this neighbor\n"
3927 "Set the next hop to self for reflected routes\n")
3930 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3932 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3935 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3936 neighbor_nexthop_self_force_hidden_cmd
,
3937 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3938 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3939 "Disable the next hop calculation for this neighbor\n"
3940 "Set the next hop to self for reflected routes\n")
3942 DEFUN (no_neighbor_nexthop_self
,
3943 no_neighbor_nexthop_self_cmd
,
3944 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3948 "Disable the next hop calculation for this neighbor\n")
3951 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3952 bgp_node_afi(vty
), bgp_node_safi(vty
),
3953 PEER_FLAG_NEXTHOP_SELF
);
3956 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3957 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3958 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3959 "Disable the next hop calculation for this neighbor\n")
3961 DEFUN (no_neighbor_nexthop_self_force
,
3962 no_neighbor_nexthop_self_force_cmd
,
3963 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3967 "Disable the next hop calculation for this neighbor\n"
3968 "Set the next hop to self for reflected routes\n")
3971 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3972 bgp_node_afi(vty
), bgp_node_safi(vty
),
3973 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3976 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3977 no_neighbor_nexthop_self_force_hidden_cmd
,
3978 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3979 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3980 "Disable the next hop calculation for this neighbor\n"
3981 "Set the next hop to self for reflected routes\n")
3983 /* neighbor as-override */
3984 DEFUN (neighbor_as_override
,
3985 neighbor_as_override_cmd
,
3986 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3989 "Override ASNs in outbound updates if aspath equals remote-as\n")
3992 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3993 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3996 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3997 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3998 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3999 "Override ASNs in outbound updates if aspath equals remote-as\n")
4001 DEFUN (no_neighbor_as_override
,
4002 no_neighbor_as_override_cmd
,
4003 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4007 "Override ASNs in outbound updates if aspath equals remote-as\n")
4010 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4011 bgp_node_afi(vty
), bgp_node_safi(vty
),
4012 PEER_FLAG_AS_OVERRIDE
);
4015 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4016 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4017 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4018 "Override ASNs in outbound updates if aspath equals remote-as\n")
4020 /* neighbor remove-private-AS. */
4021 DEFUN (neighbor_remove_private_as
,
4022 neighbor_remove_private_as_cmd
,
4023 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4026 "Remove private ASNs in outbound updates\n")
4029 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4031 PEER_FLAG_REMOVE_PRIVATE_AS
);
4034 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4035 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4036 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4037 "Remove private ASNs in outbound updates\n")
4039 DEFUN (neighbor_remove_private_as_all
,
4040 neighbor_remove_private_as_all_cmd
,
4041 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4044 "Remove private ASNs in outbound updates\n"
4045 "Apply to all AS numbers\n")
4048 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4050 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4053 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4054 neighbor_remove_private_as_all_hidden_cmd
,
4055 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4056 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4057 "Remove private ASNs in outbound updates\n"
4058 "Apply to all AS numbers")
4060 DEFUN (neighbor_remove_private_as_replace_as
,
4061 neighbor_remove_private_as_replace_as_cmd
,
4062 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4065 "Remove private ASNs in outbound updates\n"
4066 "Replace private ASNs with our ASN in outbound updates\n")
4069 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4071 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4074 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4075 neighbor_remove_private_as_replace_as_hidden_cmd
,
4076 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4077 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4078 "Remove private ASNs in outbound updates\n"
4079 "Replace private ASNs with our ASN in outbound updates\n")
4081 DEFUN (neighbor_remove_private_as_all_replace_as
,
4082 neighbor_remove_private_as_all_replace_as_cmd
,
4083 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4086 "Remove private ASNs in outbound updates\n"
4087 "Apply to all AS numbers\n"
4088 "Replace private ASNs with our ASN in outbound updates\n")
4091 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4093 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4097 neighbor_remove_private_as_all_replace_as
,
4098 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4099 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4100 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4101 "Remove private ASNs in outbound updates\n"
4102 "Apply to all AS numbers\n"
4103 "Replace private ASNs with our ASN in outbound updates\n")
4105 DEFUN (no_neighbor_remove_private_as
,
4106 no_neighbor_remove_private_as_cmd
,
4107 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4111 "Remove private ASNs in outbound updates\n")
4114 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4115 bgp_node_afi(vty
), bgp_node_safi(vty
),
4116 PEER_FLAG_REMOVE_PRIVATE_AS
);
4119 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4120 no_neighbor_remove_private_as_hidden_cmd
,
4121 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4122 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4123 "Remove private ASNs in outbound updates\n")
4125 DEFUN (no_neighbor_remove_private_as_all
,
4126 no_neighbor_remove_private_as_all_cmd
,
4127 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4131 "Remove private ASNs in outbound updates\n"
4132 "Apply to all AS numbers\n")
4135 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4136 bgp_node_afi(vty
), bgp_node_safi(vty
),
4137 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4140 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4141 no_neighbor_remove_private_as_all_hidden_cmd
,
4142 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4143 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4144 "Remove private ASNs in outbound updates\n"
4145 "Apply to all AS numbers\n")
4147 DEFUN (no_neighbor_remove_private_as_replace_as
,
4148 no_neighbor_remove_private_as_replace_as_cmd
,
4149 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4153 "Remove private ASNs in outbound updates\n"
4154 "Replace private ASNs with our ASN in outbound updates\n")
4157 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4158 bgp_node_afi(vty
), bgp_node_safi(vty
),
4159 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4162 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4163 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4164 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4165 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4166 "Remove private ASNs in outbound updates\n"
4167 "Replace private ASNs with our ASN in outbound updates\n")
4169 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4170 no_neighbor_remove_private_as_all_replace_as_cmd
,
4171 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4175 "Remove private ASNs in outbound updates\n"
4176 "Apply to all AS numbers\n"
4177 "Replace private ASNs with our ASN in outbound updates\n")
4180 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4181 bgp_node_afi(vty
), bgp_node_safi(vty
),
4182 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4186 no_neighbor_remove_private_as_all_replace_as
,
4187 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4188 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4189 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4190 "Remove private ASNs in outbound updates\n"
4191 "Apply to all AS numbers\n"
4192 "Replace private ASNs with our ASN in outbound updates\n")
4195 /* neighbor send-community. */
4196 DEFUN (neighbor_send_community
,
4197 neighbor_send_community_cmd
,
4198 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4201 "Send Community attribute to this neighbor\n")
4205 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4207 PEER_FLAG_SEND_COMMUNITY
);
4210 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4211 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4212 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4213 "Send Community attribute to this neighbor\n")
4215 DEFUN (no_neighbor_send_community
,
4216 no_neighbor_send_community_cmd
,
4217 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4221 "Send Community attribute to this neighbor\n")
4225 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4226 bgp_node_afi(vty
), bgp_node_safi(vty
),
4227 PEER_FLAG_SEND_COMMUNITY
);
4230 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4231 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4232 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4233 "Send Community attribute to this neighbor\n")
4235 /* neighbor send-community extended. */
4236 DEFUN (neighbor_send_community_type
,
4237 neighbor_send_community_type_cmd
,
4238 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4241 "Send Community attribute to this neighbor\n"
4242 "Send Standard and Extended Community attributes\n"
4243 "Send Standard, Large and Extended Community attributes\n"
4244 "Send Extended Community attributes\n"
4245 "Send Standard Community attributes\n"
4246 "Send Large Community attributes\n")
4250 const char *type
= argv
[argc
- 1]->text
;
4252 if (strmatch(type
, "standard")) {
4253 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4254 } else if (strmatch(type
, "extended")) {
4255 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4256 } else if (strmatch(type
, "large")) {
4257 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4258 } else if (strmatch(type
, "both")) {
4259 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4260 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4261 } else { /* if (strmatch(type, "all")) */
4262 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4263 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4264 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4267 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4268 bgp_node_safi(vty
), flag
);
4272 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4273 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4274 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4275 "Send Community attribute to this neighbor\n"
4276 "Send Standard and Extended Community attributes\n"
4277 "Send Standard, Large and Extended Community attributes\n"
4278 "Send Extended Community attributes\n"
4279 "Send Standard Community attributes\n"
4280 "Send Large Community attributes\n")
4282 DEFUN (no_neighbor_send_community_type
,
4283 no_neighbor_send_community_type_cmd
,
4284 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4288 "Send Community attribute to this neighbor\n"
4289 "Send Standard and Extended Community attributes\n"
4290 "Send Standard, Large and Extended Community attributes\n"
4291 "Send Extended Community attributes\n"
4292 "Send Standard Community attributes\n"
4293 "Send Large Community attributes\n")
4297 const char *type
= argv
[argc
- 1]->text
;
4299 if (strmatch(type
, "standard")) {
4300 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4301 } else if (strmatch(type
, "extended")) {
4302 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4303 } else if (strmatch(type
, "large")) {
4304 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4305 } else if (strmatch(type
, "both")) {
4306 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4307 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4308 } else { /* if (strmatch(type, "all")) */
4309 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4310 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4311 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4314 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4315 bgp_node_afi(vty
), bgp_node_safi(vty
),
4320 no_neighbor_send_community_type
,
4321 no_neighbor_send_community_type_hidden_cmd
,
4322 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4323 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4324 "Send Community attribute to this neighbor\n"
4325 "Send Standard and Extended Community attributes\n"
4326 "Send Standard, Large and Extended Community attributes\n"
4327 "Send Extended Community attributes\n"
4328 "Send Standard Community attributes\n"
4329 "Send Large Community attributes\n")
4331 /* neighbor soft-reconfig. */
4332 DEFUN (neighbor_soft_reconfiguration
,
4333 neighbor_soft_reconfiguration_cmd
,
4334 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4337 "Per neighbor soft reconfiguration\n"
4338 "Allow inbound soft reconfiguration for this neighbor\n")
4341 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4343 PEER_FLAG_SOFT_RECONFIG
);
4346 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4347 neighbor_soft_reconfiguration_hidden_cmd
,
4348 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4349 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4350 "Per neighbor soft reconfiguration\n"
4351 "Allow inbound soft reconfiguration for this neighbor\n")
4353 DEFUN (no_neighbor_soft_reconfiguration
,
4354 no_neighbor_soft_reconfiguration_cmd
,
4355 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4359 "Per neighbor soft reconfiguration\n"
4360 "Allow inbound soft reconfiguration for this neighbor\n")
4363 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4364 bgp_node_afi(vty
), bgp_node_safi(vty
),
4365 PEER_FLAG_SOFT_RECONFIG
);
4368 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4369 no_neighbor_soft_reconfiguration_hidden_cmd
,
4370 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4371 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4372 "Per neighbor soft reconfiguration\n"
4373 "Allow inbound soft reconfiguration for this neighbor\n")
4375 DEFUN (neighbor_route_reflector_client
,
4376 neighbor_route_reflector_client_cmd
,
4377 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4380 "Configure a neighbor as Route Reflector client\n")
4386 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4388 return CMD_WARNING_CONFIG_FAILED
;
4390 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4392 PEER_FLAG_REFLECTOR_CLIENT
);
4395 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4396 neighbor_route_reflector_client_hidden_cmd
,
4397 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4398 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4399 "Configure a neighbor as Route Reflector client\n")
4401 DEFUN (no_neighbor_route_reflector_client
,
4402 no_neighbor_route_reflector_client_cmd
,
4403 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4407 "Configure a neighbor as Route Reflector client\n")
4410 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4411 bgp_node_afi(vty
), bgp_node_safi(vty
),
4412 PEER_FLAG_REFLECTOR_CLIENT
);
4415 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4416 no_neighbor_route_reflector_client_hidden_cmd
,
4417 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4418 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4419 "Configure a neighbor as Route Reflector client\n")
4421 /* neighbor route-server-client. */
4422 DEFUN (neighbor_route_server_client
,
4423 neighbor_route_server_client_cmd
,
4424 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4427 "Configure a neighbor as Route Server client\n")
4432 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4434 return CMD_WARNING_CONFIG_FAILED
;
4435 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4437 PEER_FLAG_RSERVER_CLIENT
);
4440 ALIAS_HIDDEN(neighbor_route_server_client
,
4441 neighbor_route_server_client_hidden_cmd
,
4442 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4443 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4444 "Configure a neighbor as Route Server client\n")
4446 DEFUN (no_neighbor_route_server_client
,
4447 no_neighbor_route_server_client_cmd
,
4448 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4452 "Configure a neighbor as Route Server client\n")
4455 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4456 bgp_node_afi(vty
), bgp_node_safi(vty
),
4457 PEER_FLAG_RSERVER_CLIENT
);
4460 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4461 no_neighbor_route_server_client_hidden_cmd
,
4462 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4463 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4464 "Configure a neighbor as Route Server client\n")
4466 DEFUN (neighbor_nexthop_local_unchanged
,
4467 neighbor_nexthop_local_unchanged_cmd
,
4468 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4471 "Configure treatment of outgoing link-local nexthop attribute\n"
4472 "Leave link-local nexthop unchanged for this peer\n")
4475 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4477 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4480 DEFUN (no_neighbor_nexthop_local_unchanged
,
4481 no_neighbor_nexthop_local_unchanged_cmd
,
4482 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4486 "Configure treatment of outgoing link-local-nexthop attribute\n"
4487 "Leave link-local nexthop unchanged for this peer\n")
4490 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4491 bgp_node_afi(vty
), bgp_node_safi(vty
),
4492 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4495 DEFUN (neighbor_attr_unchanged
,
4496 neighbor_attr_unchanged_cmd
,
4497 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4500 "BGP attribute is propagated unchanged to this neighbor\n"
4501 "As-path attribute\n"
4502 "Nexthop attribute\n"
4506 char *peer_str
= argv
[1]->arg
;
4509 afi_t afi
= bgp_node_afi(vty
);
4510 safi_t safi
= bgp_node_safi(vty
);
4512 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4514 return CMD_WARNING_CONFIG_FAILED
;
4516 if (argv_find(argv
, argc
, "as-path", &idx
))
4517 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4519 if (argv_find(argv
, argc
, "next-hop", &idx
))
4520 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4522 if (argv_find(argv
, argc
, "med", &idx
))
4523 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4525 /* no flags means all of them! */
4527 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4528 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4529 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4531 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4532 && peer_af_flag_check(peer
, afi
, safi
,
4533 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4534 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4535 PEER_FLAG_AS_PATH_UNCHANGED
);
4538 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4539 && peer_af_flag_check(peer
, afi
, safi
,
4540 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4541 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4542 PEER_FLAG_NEXTHOP_UNCHANGED
);
4545 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4546 && peer_af_flag_check(peer
, afi
, safi
,
4547 PEER_FLAG_MED_UNCHANGED
)) {
4548 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4549 PEER_FLAG_MED_UNCHANGED
);
4553 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4557 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4558 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4559 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4560 "BGP attribute is propagated unchanged to this neighbor\n"
4561 "As-path attribute\n"
4562 "Nexthop attribute\n"
4565 DEFUN (no_neighbor_attr_unchanged
,
4566 no_neighbor_attr_unchanged_cmd
,
4567 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4571 "BGP attribute is propagated unchanged to this neighbor\n"
4572 "As-path attribute\n"
4573 "Nexthop attribute\n"
4577 char *peer
= argv
[2]->arg
;
4580 if (argv_find(argv
, argc
, "as-path", &idx
))
4581 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4583 if (argv_find(argv
, argc
, "next-hop", &idx
))
4584 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4586 if (argv_find(argv
, argc
, "med", &idx
))
4587 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4589 if (!flags
) // no flags means all of them!
4591 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4592 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4593 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4596 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4597 bgp_node_safi(vty
), flags
);
4601 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4602 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4603 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4604 "BGP attribute is propagated unchanged to this neighbor\n"
4605 "As-path attribute\n"
4606 "Nexthop attribute\n"
4609 /* EBGP multihop configuration. */
4610 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4611 const char *ttl_str
)
4616 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4618 return CMD_WARNING_CONFIG_FAILED
;
4621 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4626 ttl
= strtoul(ttl_str
, NULL
, 10);
4628 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4631 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4635 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4637 return CMD_WARNING_CONFIG_FAILED
;
4639 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4642 /* neighbor ebgp-multihop. */
4643 DEFUN (neighbor_ebgp_multihop
,
4644 neighbor_ebgp_multihop_cmd
,
4645 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4648 "Allow EBGP neighbors not on directly connected networks\n")
4651 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4654 DEFUN (neighbor_ebgp_multihop_ttl
,
4655 neighbor_ebgp_multihop_ttl_cmd
,
4656 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4659 "Allow EBGP neighbors not on directly connected networks\n"
4660 "maximum hop count\n")
4664 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4665 argv
[idx_number
]->arg
);
4668 DEFUN (no_neighbor_ebgp_multihop
,
4669 no_neighbor_ebgp_multihop_cmd
,
4670 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4674 "Allow EBGP neighbors not on directly connected networks\n"
4675 "maximum hop count\n")
4678 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4682 /* disable-connected-check */
4683 DEFUN (neighbor_disable_connected_check
,
4684 neighbor_disable_connected_check_cmd
,
4685 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4688 "one-hop away EBGP peer using loopback address\n"
4689 "Enforce EBGP neighbors perform multihop\n")
4692 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4693 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4696 DEFUN (no_neighbor_disable_connected_check
,
4697 no_neighbor_disable_connected_check_cmd
,
4698 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4702 "one-hop away EBGP peer using loopback address\n"
4703 "Enforce EBGP neighbors perform multihop\n")
4706 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4707 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4711 /* enforce-first-as */
4712 DEFUN (neighbor_enforce_first_as
,
4713 neighbor_enforce_first_as_cmd
,
4714 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4717 "Enforce the first AS for EBGP routes\n")
4721 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4722 PEER_FLAG_ENFORCE_FIRST_AS
);
4725 DEFUN (no_neighbor_enforce_first_as
,
4726 no_neighbor_enforce_first_as_cmd
,
4727 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4731 "Enforce the first AS for EBGP routes\n")
4735 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4736 PEER_FLAG_ENFORCE_FIRST_AS
);
4740 DEFUN (neighbor_description
,
4741 neighbor_description_cmd
,
4742 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4745 "Neighbor specific description\n"
4746 "Up to 80 characters describing this neighbor\n")
4753 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4755 return CMD_WARNING_CONFIG_FAILED
;
4757 str
= argv_concat(argv
, argc
, idx_line
);
4759 peer_description_set(peer
, str
);
4761 XFREE(MTYPE_TMP
, str
);
4766 DEFUN (no_neighbor_description
,
4767 no_neighbor_description_cmd
,
4768 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4772 "Neighbor specific description\n")
4777 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4779 return CMD_WARNING_CONFIG_FAILED
;
4781 peer_description_unset(peer
);
4786 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4787 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4788 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4789 "Neighbor specific description\n"
4790 "Up to 80 characters describing this neighbor\n")
4792 /* Neighbor update-source. */
4793 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4794 const char *source_str
)
4800 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4802 return CMD_WARNING_CONFIG_FAILED
;
4808 if (str2sockunion(source_str
, &su
) == 0)
4809 peer_update_source_addr_set(peer
, &su
);
4811 if (str2prefix(source_str
, &p
)) {
4813 "%% Invalid update-source, remove prefix length \n");
4814 return CMD_WARNING_CONFIG_FAILED
;
4816 peer_update_source_if_set(peer
, source_str
);
4819 peer_update_source_unset(peer
);
4824 #define BGP_UPDATE_SOURCE_HELP_STR \
4827 "Interface name (requires zebra to be running)\n"
4829 DEFUN (neighbor_update_source
,
4830 neighbor_update_source_cmd
,
4831 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4834 "Source of routing updates\n"
4835 BGP_UPDATE_SOURCE_HELP_STR
)
4839 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4840 argv
[idx_peer_2
]->arg
);
4843 DEFUN (no_neighbor_update_source
,
4844 no_neighbor_update_source_cmd
,
4845 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4849 "Source of routing updates\n"
4850 BGP_UPDATE_SOURCE_HELP_STR
)
4853 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4856 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4857 afi_t afi
, safi_t safi
,
4858 const char *rmap
, int set
)
4862 struct route_map
*route_map
;
4864 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4866 return CMD_WARNING_CONFIG_FAILED
;
4869 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4870 ret
= peer_default_originate_set(peer
, afi
, safi
,
4873 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4875 return bgp_vty_return(vty
, ret
);
4878 /* neighbor default-originate. */
4879 DEFUN (neighbor_default_originate
,
4880 neighbor_default_originate_cmd
,
4881 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4884 "Originate default route to this neighbor\n")
4887 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4889 bgp_node_safi(vty
), NULL
, 1);
4892 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4893 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4894 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4895 "Originate default route to this neighbor\n")
4897 DEFUN (neighbor_default_originate_rmap
,
4898 neighbor_default_originate_rmap_cmd
,
4899 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4902 "Originate default route to this neighbor\n"
4903 "Route-map to specify criteria to originate default\n"
4908 return peer_default_originate_set_vty(
4909 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4910 argv
[idx_word
]->arg
, 1);
4914 neighbor_default_originate_rmap
,
4915 neighbor_default_originate_rmap_hidden_cmd
,
4916 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4917 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4918 "Originate default route to this neighbor\n"
4919 "Route-map to specify criteria to originate default\n"
4922 DEFUN (no_neighbor_default_originate
,
4923 no_neighbor_default_originate_cmd
,
4924 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4928 "Originate default route to this neighbor\n"
4929 "Route-map to specify criteria to originate default\n"
4933 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4935 bgp_node_safi(vty
), NULL
, 0);
4939 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4940 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4941 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4942 "Originate default route to this neighbor\n"
4943 "Route-map to specify criteria to originate default\n"
4947 /* Set neighbor's BGP port. */
4948 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4949 const char *port_str
)
4955 peer
= peer_lookup_vty(vty
, ip_str
);
4957 return CMD_WARNING_CONFIG_FAILED
;
4960 sp
= getservbyname("bgp", "tcp");
4961 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4963 port
= strtoul(port_str
, NULL
, 10);
4966 peer_port_set(peer
, port
);
4971 /* Set specified peer's BGP port. */
4972 DEFUN (neighbor_port
,
4974 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4977 "Neighbor's BGP port\n"
4978 "TCP port number\n")
4982 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4983 argv
[idx_number
]->arg
);
4986 DEFUN (no_neighbor_port
,
4987 no_neighbor_port_cmd
,
4988 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4992 "Neighbor's BGP port\n"
4993 "TCP port number\n")
4996 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5000 /* neighbor weight. */
5001 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5002 safi_t safi
, const char *weight_str
)
5006 unsigned long weight
;
5008 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5010 return CMD_WARNING_CONFIG_FAILED
;
5012 weight
= strtoul(weight_str
, NULL
, 10);
5014 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5015 return bgp_vty_return(vty
, ret
);
5018 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5024 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5026 return CMD_WARNING_CONFIG_FAILED
;
5028 ret
= peer_weight_unset(peer
, afi
, safi
);
5029 return bgp_vty_return(vty
, ret
);
5032 DEFUN (neighbor_weight
,
5033 neighbor_weight_cmd
,
5034 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5037 "Set default weight for routes from this neighbor\n"
5042 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5043 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5046 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5047 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5048 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5049 "Set default weight for routes from this neighbor\n"
5052 DEFUN (no_neighbor_weight
,
5053 no_neighbor_weight_cmd
,
5054 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5058 "Set default weight for routes from this neighbor\n"
5062 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5063 bgp_node_afi(vty
), bgp_node_safi(vty
));
5066 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5067 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5068 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5069 "Set default weight for routes from this neighbor\n"
5073 /* Override capability negotiation. */
5074 DEFUN (neighbor_override_capability
,
5075 neighbor_override_capability_cmd
,
5076 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5079 "Override capability negotiation result\n")
5082 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5083 PEER_FLAG_OVERRIDE_CAPABILITY
);
5086 DEFUN (no_neighbor_override_capability
,
5087 no_neighbor_override_capability_cmd
,
5088 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5092 "Override capability negotiation result\n")
5095 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5096 PEER_FLAG_OVERRIDE_CAPABILITY
);
5099 DEFUN (neighbor_strict_capability
,
5100 neighbor_strict_capability_cmd
,
5101 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5104 "Strict capability negotiation match\n")
5108 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5109 PEER_FLAG_STRICT_CAP_MATCH
);
5112 DEFUN (no_neighbor_strict_capability
,
5113 no_neighbor_strict_capability_cmd
,
5114 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5118 "Strict capability negotiation match\n")
5122 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5123 PEER_FLAG_STRICT_CAP_MATCH
);
5126 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5127 const char *keep_str
, const char *hold_str
)
5134 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5136 return CMD_WARNING_CONFIG_FAILED
;
5138 keepalive
= strtoul(keep_str
, NULL
, 10);
5139 holdtime
= strtoul(hold_str
, NULL
, 10);
5141 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5143 return bgp_vty_return(vty
, ret
);
5146 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5151 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5153 return CMD_WARNING_CONFIG_FAILED
;
5155 ret
= peer_timers_unset(peer
);
5157 return bgp_vty_return(vty
, ret
);
5160 DEFUN (neighbor_timers
,
5161 neighbor_timers_cmd
,
5162 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5165 "BGP per neighbor timers\n"
5166 "Keepalive interval\n"
5171 int idx_number_2
= 4;
5172 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5173 argv
[idx_number
]->arg
,
5174 argv
[idx_number_2
]->arg
);
5177 DEFUN (no_neighbor_timers
,
5178 no_neighbor_timers_cmd
,
5179 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5183 "BGP per neighbor timers\n"
5184 "Keepalive interval\n"
5188 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5192 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5193 const char *time_str
)
5199 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5201 return CMD_WARNING_CONFIG_FAILED
;
5203 connect
= strtoul(time_str
, NULL
, 10);
5205 ret
= peer_timers_connect_set(peer
, connect
);
5207 return bgp_vty_return(vty
, ret
);
5210 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5215 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5217 return CMD_WARNING_CONFIG_FAILED
;
5219 ret
= peer_timers_connect_unset(peer
);
5221 return bgp_vty_return(vty
, ret
);
5224 DEFUN (neighbor_timers_connect
,
5225 neighbor_timers_connect_cmd
,
5226 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5229 "BGP per neighbor timers\n"
5230 "BGP connect timer\n"
5235 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5236 argv
[idx_number
]->arg
);
5239 DEFUN (no_neighbor_timers_connect
,
5240 no_neighbor_timers_connect_cmd
,
5241 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5245 "BGP per neighbor timers\n"
5246 "BGP connect timer\n"
5250 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5254 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5255 const char *time_str
, int set
)
5259 uint32_t routeadv
= 0;
5261 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5263 return CMD_WARNING_CONFIG_FAILED
;
5266 routeadv
= strtoul(time_str
, NULL
, 10);
5269 ret
= peer_advertise_interval_set(peer
, routeadv
);
5271 ret
= peer_advertise_interval_unset(peer
);
5273 return bgp_vty_return(vty
, ret
);
5276 DEFUN (neighbor_advertise_interval
,
5277 neighbor_advertise_interval_cmd
,
5278 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5281 "Minimum interval between sending BGP routing updates\n"
5282 "time in seconds\n")
5286 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5287 argv
[idx_number
]->arg
, 1);
5290 DEFUN (no_neighbor_advertise_interval
,
5291 no_neighbor_advertise_interval_cmd
,
5292 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5296 "Minimum interval between sending BGP routing updates\n"
5297 "time in seconds\n")
5300 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5304 /* Time to wait before processing route-map updates */
5305 DEFUN (bgp_set_route_map_delay_timer
,
5306 bgp_set_route_map_delay_timer_cmd
,
5307 "bgp route-map delay-timer (0-600)",
5309 "BGP route-map delay timer\n"
5310 "Time in secs to wait before processing route-map changes\n"
5311 "0 disables the timer, no route updates happen when route-maps change\n")
5314 uint32_t rmap_delay_timer
;
5316 if (argv
[idx_number
]->arg
) {
5317 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5318 bm
->rmap_update_timer
= rmap_delay_timer
;
5320 /* if the dynamic update handling is being disabled, and a timer
5322 * running, stop the timer and act as if the timer has already
5325 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5326 BGP_TIMER_OFF(bm
->t_rmap_update
);
5327 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5332 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5333 return CMD_WARNING_CONFIG_FAILED
;
5337 DEFUN (no_bgp_set_route_map_delay_timer
,
5338 no_bgp_set_route_map_delay_timer_cmd
,
5339 "no bgp route-map delay-timer [(0-600)]",
5342 "Default BGP route-map delay timer\n"
5343 "Reset to default time to wait for processing route-map changes\n"
5344 "0 disables the timer, no route updates happen when route-maps change\n")
5347 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5353 /* neighbor interface */
5354 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5359 peer
= peer_lookup_vty(vty
, ip_str
);
5360 if (!peer
|| peer
->conf_if
) {
5361 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5362 return CMD_WARNING_CONFIG_FAILED
;
5366 peer_interface_set(peer
, str
);
5368 peer_interface_unset(peer
);
5373 DEFUN (neighbor_interface
,
5374 neighbor_interface_cmd
,
5375 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5383 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5386 DEFUN (no_neighbor_interface
,
5387 no_neighbor_interface_cmd
,
5388 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5396 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5399 DEFUN (neighbor_distribute_list
,
5400 neighbor_distribute_list_cmd
,
5401 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5404 "Filter updates to/from this neighbor\n"
5405 "IP access-list number\n"
5406 "IP access-list number (expanded range)\n"
5407 "IP Access-list name\n"
5408 "Filter incoming updates\n"
5409 "Filter outgoing updates\n")
5416 const char *pstr
= argv
[idx_peer
]->arg
;
5417 const char *acl
= argv
[idx_acl
]->arg
;
5418 const char *inout
= argv
[argc
- 1]->text
;
5420 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5422 return CMD_WARNING_CONFIG_FAILED
;
5424 /* Check filter direction. */
5425 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5426 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5429 return bgp_vty_return(vty
, ret
);
5433 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5434 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5435 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5436 "Filter updates to/from this neighbor\n"
5437 "IP access-list number\n"
5438 "IP access-list number (expanded range)\n"
5439 "IP Access-list name\n"
5440 "Filter incoming updates\n"
5441 "Filter outgoing updates\n")
5443 DEFUN (no_neighbor_distribute_list
,
5444 no_neighbor_distribute_list_cmd
,
5445 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5449 "Filter updates to/from this neighbor\n"
5450 "IP access-list number\n"
5451 "IP access-list number (expanded range)\n"
5452 "IP Access-list name\n"
5453 "Filter incoming updates\n"
5454 "Filter outgoing updates\n")
5460 const char *pstr
= argv
[idx_peer
]->arg
;
5461 const char *inout
= argv
[argc
- 1]->text
;
5463 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5465 return CMD_WARNING_CONFIG_FAILED
;
5467 /* Check filter direction. */
5468 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5469 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5472 return bgp_vty_return(vty
, ret
);
5476 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5477 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5478 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5479 "Filter updates to/from this neighbor\n"
5480 "IP access-list number\n"
5481 "IP access-list number (expanded range)\n"
5482 "IP Access-list name\n"
5483 "Filter incoming updates\n"
5484 "Filter outgoing updates\n")
5486 /* Set prefix list to the peer. */
5487 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5488 afi_t afi
, safi_t safi
,
5489 const char *name_str
,
5490 const char *direct_str
)
5493 int direct
= FILTER_IN
;
5496 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5498 return CMD_WARNING_CONFIG_FAILED
;
5500 /* Check filter direction. */
5501 if (strncmp(direct_str
, "i", 1) == 0)
5503 else if (strncmp(direct_str
, "o", 1) == 0)
5504 direct
= FILTER_OUT
;
5506 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5508 return bgp_vty_return(vty
, ret
);
5511 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5512 afi_t afi
, safi_t safi
,
5513 const char *direct_str
)
5517 int direct
= FILTER_IN
;
5519 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5521 return CMD_WARNING_CONFIG_FAILED
;
5523 /* Check filter direction. */
5524 if (strncmp(direct_str
, "i", 1) == 0)
5526 else if (strncmp(direct_str
, "o", 1) == 0)
5527 direct
= FILTER_OUT
;
5529 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5531 return bgp_vty_return(vty
, ret
);
5534 DEFUN (neighbor_prefix_list
,
5535 neighbor_prefix_list_cmd
,
5536 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5539 "Filter updates to/from this neighbor\n"
5540 "Name of a prefix list\n"
5541 "Filter incoming updates\n"
5542 "Filter outgoing updates\n")
5547 return peer_prefix_list_set_vty(
5548 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5549 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5552 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5553 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5554 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5555 "Filter updates to/from this neighbor\n"
5556 "Name of a prefix list\n"
5557 "Filter incoming updates\n"
5558 "Filter outgoing updates\n")
5560 DEFUN (no_neighbor_prefix_list
,
5561 no_neighbor_prefix_list_cmd
,
5562 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5566 "Filter updates to/from this neighbor\n"
5567 "Name of a prefix list\n"
5568 "Filter incoming updates\n"
5569 "Filter outgoing updates\n")
5573 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5574 bgp_node_afi(vty
), bgp_node_safi(vty
),
5575 argv
[idx_in_out
]->arg
);
5578 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5579 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5580 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5581 "Filter updates to/from this neighbor\n"
5582 "Name of a prefix list\n"
5583 "Filter incoming updates\n"
5584 "Filter outgoing updates\n")
5586 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5587 safi_t safi
, const char *name_str
,
5588 const char *direct_str
)
5592 int direct
= FILTER_IN
;
5594 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5596 return CMD_WARNING_CONFIG_FAILED
;
5598 /* Check filter direction. */
5599 if (strncmp(direct_str
, "i", 1) == 0)
5601 else if (strncmp(direct_str
, "o", 1) == 0)
5602 direct
= FILTER_OUT
;
5604 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5606 return bgp_vty_return(vty
, ret
);
5609 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5610 safi_t safi
, const char *direct_str
)
5614 int direct
= FILTER_IN
;
5616 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5618 return CMD_WARNING_CONFIG_FAILED
;
5620 /* Check filter direction. */
5621 if (strncmp(direct_str
, "i", 1) == 0)
5623 else if (strncmp(direct_str
, "o", 1) == 0)
5624 direct
= FILTER_OUT
;
5626 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5628 return bgp_vty_return(vty
, ret
);
5631 DEFUN (neighbor_filter_list
,
5632 neighbor_filter_list_cmd
,
5633 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5636 "Establish BGP filters\n"
5637 "AS path access-list name\n"
5638 "Filter incoming routes\n"
5639 "Filter outgoing routes\n")
5644 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5645 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5646 argv
[idx_in_out
]->arg
);
5649 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5650 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5651 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5652 "Establish BGP filters\n"
5653 "AS path access-list name\n"
5654 "Filter incoming routes\n"
5655 "Filter outgoing routes\n")
5657 DEFUN (no_neighbor_filter_list
,
5658 no_neighbor_filter_list_cmd
,
5659 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5663 "Establish BGP filters\n"
5664 "AS path access-list name\n"
5665 "Filter incoming routes\n"
5666 "Filter outgoing routes\n")
5670 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5671 bgp_node_afi(vty
), bgp_node_safi(vty
),
5672 argv
[idx_in_out
]->arg
);
5675 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5676 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5677 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5678 "Establish BGP filters\n"
5679 "AS path access-list name\n"
5680 "Filter incoming routes\n"
5681 "Filter outgoing routes\n")
5683 /* Set route-map to the peer. */
5684 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5685 afi_t afi
, safi_t safi
, const char *name_str
,
5686 const char *direct_str
)
5690 int direct
= RMAP_IN
;
5691 struct route_map
*route_map
;
5693 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5695 return CMD_WARNING_CONFIG_FAILED
;
5697 /* Check filter direction. */
5698 if (strncmp(direct_str
, "in", 2) == 0)
5700 else if (strncmp(direct_str
, "o", 1) == 0)
5703 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5704 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5706 return bgp_vty_return(vty
, ret
);
5709 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5710 afi_t afi
, safi_t safi
,
5711 const char *direct_str
)
5715 int direct
= RMAP_IN
;
5717 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5719 return CMD_WARNING_CONFIG_FAILED
;
5721 /* Check filter direction. */
5722 if (strncmp(direct_str
, "in", 2) == 0)
5724 else if (strncmp(direct_str
, "o", 1) == 0)
5727 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5729 return bgp_vty_return(vty
, ret
);
5732 DEFUN (neighbor_route_map
,
5733 neighbor_route_map_cmd
,
5734 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5737 "Apply route map to neighbor\n"
5738 "Name of route map\n"
5739 "Apply map to incoming routes\n"
5740 "Apply map to outbound routes\n")
5745 return peer_route_map_set_vty(
5746 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5747 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5750 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5751 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5752 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5753 "Apply route map to neighbor\n"
5754 "Name of route map\n"
5755 "Apply map to incoming routes\n"
5756 "Apply map to outbound routes\n")
5758 DEFUN (no_neighbor_route_map
,
5759 no_neighbor_route_map_cmd
,
5760 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5764 "Apply route map to neighbor\n"
5765 "Name of route map\n"
5766 "Apply map to incoming routes\n"
5767 "Apply map to outbound routes\n")
5771 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5772 bgp_node_afi(vty
), bgp_node_safi(vty
),
5773 argv
[idx_in_out
]->arg
);
5776 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5777 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5778 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5779 "Apply route map to neighbor\n"
5780 "Name of route map\n"
5781 "Apply map to incoming routes\n"
5782 "Apply map to outbound routes\n")
5784 /* Set unsuppress-map to the peer. */
5785 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5786 afi_t afi
, safi_t safi
,
5787 const char *name_str
)
5791 struct route_map
*route_map
;
5793 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5795 return CMD_WARNING_CONFIG_FAILED
;
5797 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5798 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5800 return bgp_vty_return(vty
, ret
);
5803 /* Unset route-map from the peer. */
5804 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5805 afi_t afi
, safi_t safi
)
5810 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5812 return CMD_WARNING_CONFIG_FAILED
;
5814 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5816 return bgp_vty_return(vty
, ret
);
5819 DEFUN (neighbor_unsuppress_map
,
5820 neighbor_unsuppress_map_cmd
,
5821 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5824 "Route-map to selectively unsuppress suppressed routes\n"
5825 "Name of route map\n")
5829 return peer_unsuppress_map_set_vty(
5830 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5831 argv
[idx_word
]->arg
);
5834 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5835 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5836 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5837 "Route-map to selectively unsuppress suppressed routes\n"
5838 "Name of route map\n")
5840 DEFUN (no_neighbor_unsuppress_map
,
5841 no_neighbor_unsuppress_map_cmd
,
5842 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5846 "Route-map to selectively unsuppress suppressed routes\n"
5847 "Name of route map\n")
5850 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5852 bgp_node_safi(vty
));
5855 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5856 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5857 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5858 "Route-map to selectively unsuppress suppressed routes\n"
5859 "Name of route map\n")
5861 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5862 afi_t afi
, safi_t safi
,
5863 const char *num_str
,
5864 const char *threshold_str
, int warning
,
5865 const char *restart_str
)
5873 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5875 return CMD_WARNING_CONFIG_FAILED
;
5877 max
= strtoul(num_str
, NULL
, 10);
5879 threshold
= atoi(threshold_str
);
5881 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5884 restart
= atoi(restart_str
);
5888 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5891 return bgp_vty_return(vty
, ret
);
5894 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5895 afi_t afi
, safi_t safi
)
5900 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5902 return CMD_WARNING_CONFIG_FAILED
;
5904 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5906 return bgp_vty_return(vty
, ret
);
5909 /* Maximum number of prefix configuration. prefix count is different
5910 for each peer configuration. So this configuration can be set for
5911 each peer configuration. */
5912 DEFUN (neighbor_maximum_prefix
,
5913 neighbor_maximum_prefix_cmd
,
5914 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5917 "Maximum number of prefix accept from this peer\n"
5918 "maximum no. of prefix limit\n")
5922 return peer_maximum_prefix_set_vty(
5923 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5924 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5927 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5928 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5929 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5930 "Maximum number of prefix accept from this peer\n"
5931 "maximum no. of prefix limit\n")
5933 DEFUN (neighbor_maximum_prefix_threshold
,
5934 neighbor_maximum_prefix_threshold_cmd
,
5935 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5938 "Maximum number of prefix accept from this peer\n"
5939 "maximum no. of prefix limit\n"
5940 "Threshold value (%) at which to generate a warning msg\n")
5944 int idx_number_2
= 4;
5945 return peer_maximum_prefix_set_vty(
5946 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5947 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5951 neighbor_maximum_prefix_threshold
,
5952 neighbor_maximum_prefix_threshold_hidden_cmd
,
5953 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5954 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5955 "Maximum number of prefix accept from this peer\n"
5956 "maximum no. of prefix limit\n"
5957 "Threshold value (%) at which to generate a warning msg\n")
5959 DEFUN (neighbor_maximum_prefix_warning
,
5960 neighbor_maximum_prefix_warning_cmd
,
5961 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5964 "Maximum number of prefix accept from this peer\n"
5965 "maximum no. of prefix limit\n"
5966 "Only give warning message when limit is exceeded\n")
5970 return peer_maximum_prefix_set_vty(
5971 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5972 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5976 neighbor_maximum_prefix_warning
,
5977 neighbor_maximum_prefix_warning_hidden_cmd
,
5978 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5979 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5980 "Maximum number of prefix accept from this peer\n"
5981 "maximum no. of prefix limit\n"
5982 "Only give warning message when limit is exceeded\n")
5984 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5985 neighbor_maximum_prefix_threshold_warning_cmd
,
5986 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5989 "Maximum number of prefix accept from this peer\n"
5990 "maximum no. of prefix limit\n"
5991 "Threshold value (%) at which to generate a warning msg\n"
5992 "Only give warning message when limit is exceeded\n")
5996 int idx_number_2
= 4;
5997 return peer_maximum_prefix_set_vty(
5998 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5999 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6003 neighbor_maximum_prefix_threshold_warning
,
6004 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6005 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6006 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6007 "Maximum number of prefix accept from this peer\n"
6008 "maximum no. of prefix limit\n"
6009 "Threshold value (%) at which to generate a warning msg\n"
6010 "Only give warning message when limit is exceeded\n")
6012 DEFUN (neighbor_maximum_prefix_restart
,
6013 neighbor_maximum_prefix_restart_cmd
,
6014 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6017 "Maximum number of prefix accept from this peer\n"
6018 "maximum no. of prefix limit\n"
6019 "Restart bgp connection after limit is exceeded\n"
6020 "Restart interval in minutes\n")
6024 int idx_number_2
= 5;
6025 return peer_maximum_prefix_set_vty(
6026 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6027 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6031 neighbor_maximum_prefix_restart
,
6032 neighbor_maximum_prefix_restart_hidden_cmd
,
6033 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6034 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6035 "Maximum number of prefix accept from this peer\n"
6036 "maximum no. of prefix limit\n"
6037 "Restart bgp connection after limit is exceeded\n"
6038 "Restart interval in minutes\n")
6040 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6041 neighbor_maximum_prefix_threshold_restart_cmd
,
6042 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6045 "Maximum number of prefixes to accept from this peer\n"
6046 "maximum no. of prefix limit\n"
6047 "Threshold value (%) at which to generate a warning msg\n"
6048 "Restart bgp connection after limit is exceeded\n"
6049 "Restart interval in minutes\n")
6053 int idx_number_2
= 4;
6054 int idx_number_3
= 6;
6055 return peer_maximum_prefix_set_vty(
6056 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6057 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6058 argv
[idx_number_3
]->arg
);
6062 neighbor_maximum_prefix_threshold_restart
,
6063 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6064 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6065 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6066 "Maximum number of prefixes to accept from this peer\n"
6067 "maximum no. of prefix limit\n"
6068 "Threshold value (%) at which to generate a warning msg\n"
6069 "Restart bgp connection after limit is exceeded\n"
6070 "Restart interval in minutes\n")
6072 DEFUN (no_neighbor_maximum_prefix
,
6073 no_neighbor_maximum_prefix_cmd
,
6074 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6078 "Maximum number of prefixes to accept from this peer\n"
6079 "maximum no. of prefix limit\n"
6080 "Threshold value (%) at which to generate a warning msg\n"
6081 "Restart bgp connection after limit is exceeded\n"
6082 "Restart interval in minutes\n"
6083 "Only give warning message when limit is exceeded\n")
6086 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6088 bgp_node_safi(vty
));
6092 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6093 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6094 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6095 "Maximum number of prefixes to accept from this peer\n"
6096 "maximum no. of prefix limit\n"
6097 "Threshold value (%) at which to generate a warning msg\n"
6098 "Restart bgp connection after limit is exceeded\n"
6099 "Restart interval in minutes\n"
6100 "Only give warning message when limit is exceeded\n")
6103 /* "neighbor allowas-in" */
6104 DEFUN (neighbor_allowas_in
,
6105 neighbor_allowas_in_cmd
,
6106 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6109 "Accept as-path with my AS present in it\n"
6110 "Number of occurences of AS number\n"
6111 "Only accept my AS in the as-path if the route was originated in my AS\n")
6114 int idx_number_origin
= 3;
6120 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6122 return CMD_WARNING_CONFIG_FAILED
;
6124 if (argc
<= idx_number_origin
)
6127 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6130 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6133 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6136 return bgp_vty_return(vty
, ret
);
6140 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6141 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6142 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6143 "Accept as-path with my AS present in it\n"
6144 "Number of occurences of AS number\n"
6145 "Only accept my AS in the as-path if the route was originated in my AS\n")
6147 DEFUN (no_neighbor_allowas_in
,
6148 no_neighbor_allowas_in_cmd
,
6149 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6153 "allow local ASN appears in aspath attribute\n"
6154 "Number of occurences of AS number\n"
6155 "Only accept my AS in the as-path if the route was originated in my AS\n")
6161 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6163 return CMD_WARNING_CONFIG_FAILED
;
6165 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6166 bgp_node_safi(vty
));
6168 return bgp_vty_return(vty
, ret
);
6172 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6173 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6174 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6175 "allow local ASN appears in aspath attribute\n"
6176 "Number of occurences of AS number\n"
6177 "Only accept my AS in the as-path if the route was originated in my AS\n")
6179 DEFUN (neighbor_ttl_security
,
6180 neighbor_ttl_security_cmd
,
6181 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6184 "BGP ttl-security parameters\n"
6185 "Specify the maximum number of hops to the BGP peer\n"
6186 "Number of hops to BGP peer\n")
6193 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6195 return CMD_WARNING_CONFIG_FAILED
;
6197 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6200 * If 'neighbor swpX', then this is for directly connected peers,
6201 * we should not accept a ttl-security hops value greater than 1.
6203 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6205 "%s is directly connected peer, hops cannot exceed 1\n",
6206 argv
[idx_peer
]->arg
);
6207 return CMD_WARNING_CONFIG_FAILED
;
6210 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6213 DEFUN (no_neighbor_ttl_security
,
6214 no_neighbor_ttl_security_cmd
,
6215 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6219 "BGP ttl-security parameters\n"
6220 "Specify the maximum number of hops to the BGP peer\n"
6221 "Number of hops to BGP peer\n")
6226 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6228 return CMD_WARNING_CONFIG_FAILED
;
6230 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6233 DEFUN (neighbor_addpath_tx_all_paths
,
6234 neighbor_addpath_tx_all_paths_cmd
,
6235 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6238 "Use addpath to advertise all paths to a neighbor\n")
6243 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6245 return CMD_WARNING_CONFIG_FAILED
;
6247 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6252 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6253 neighbor_addpath_tx_all_paths_hidden_cmd
,
6254 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6255 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6256 "Use addpath to advertise all paths to a neighbor\n")
6258 DEFUN (no_neighbor_addpath_tx_all_paths
,
6259 no_neighbor_addpath_tx_all_paths_cmd
,
6260 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6264 "Use addpath to advertise all paths to a neighbor\n")
6269 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6271 return CMD_WARNING_CONFIG_FAILED
;
6273 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6274 != BGP_ADDPATH_ALL
) {
6276 "%% Peer not currently configured to transmit all paths.");
6277 return CMD_WARNING_CONFIG_FAILED
;
6280 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6286 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6287 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6288 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6289 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6290 "Use addpath to advertise all paths to a neighbor\n")
6292 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6293 neighbor_addpath_tx_bestpath_per_as_cmd
,
6294 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6297 "Use addpath to advertise the bestpath per each neighboring AS\n")
6302 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6304 return CMD_WARNING_CONFIG_FAILED
;
6306 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6307 BGP_ADDPATH_BEST_PER_AS
);
6312 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6313 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6314 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6315 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6316 "Use addpath to advertise the bestpath per each neighboring AS\n")
6318 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6319 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6320 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6324 "Use addpath to advertise the bestpath per each neighboring AS\n")
6329 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6331 return CMD_WARNING_CONFIG_FAILED
;
6333 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6334 != BGP_ADDPATH_BEST_PER_AS
) {
6336 "%% Peer not currently configured to transmit all best path per as.");
6337 return CMD_WARNING_CONFIG_FAILED
;
6340 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6346 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6347 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6348 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6349 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6350 "Use addpath to advertise the bestpath per each neighboring AS\n")
6352 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6353 struct ecommunity
**list
)
6355 struct ecommunity
*ecom
= NULL
;
6356 struct ecommunity
*ecomadd
;
6358 for (; argc
; --argc
, ++argv
) {
6360 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6361 ECOMMUNITY_ROUTE_TARGET
, 0);
6363 vty_out(vty
, "Malformed community-list value\n");
6365 ecommunity_free(&ecom
);
6366 return CMD_WARNING_CONFIG_FAILED
;
6370 ecommunity_merge(ecom
, ecomadd
);
6371 ecommunity_free(&ecomadd
);
6378 ecommunity_free(&*list
);
6386 * v2vimport is true if we are handling a `import vrf ...` command
6388 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6392 switch (vty
->node
) {
6401 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6406 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6407 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6408 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6409 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6411 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6415 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6416 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6417 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6418 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6420 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6427 DEFPY (af_rd_vpn_export
,
6428 af_rd_vpn_export_cmd
,
6429 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6431 "Specify route distinguisher\n"
6432 "Between current address-family and vpn\n"
6433 "For routes leaked from current address-family to vpn\n"
6434 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6436 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6437 struct prefix_rd prd
;
6443 if (argv_find(argv
, argc
, "no", &idx
))
6447 ret
= str2prefix_rd(rd_str
, &prd
);
6449 vty_out(vty
, "%% Malformed rd\n");
6450 return CMD_WARNING_CONFIG_FAILED
;
6454 afi
= vpn_policy_getafi(vty
, bgp
, false);
6456 return CMD_WARNING_CONFIG_FAILED
;
6459 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6461 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6462 bgp_get_default(), bgp
);
6465 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6466 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6467 BGP_VPN_POLICY_TOVPN_RD_SET
);
6469 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6470 BGP_VPN_POLICY_TOVPN_RD_SET
);
6473 /* post-change: re-export vpn routes */
6474 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6475 bgp_get_default(), bgp
);
6480 ALIAS (af_rd_vpn_export
,
6481 af_no_rd_vpn_export_cmd
,
6484 "Specify route distinguisher\n"
6485 "Between current address-family and vpn\n"
6486 "For routes leaked from current address-family to vpn\n")
6488 DEFPY (af_label_vpn_export
,
6489 af_label_vpn_export_cmd
,
6490 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6492 "label value for VRF\n"
6493 "Between current address-family and vpn\n"
6494 "For routes leaked from current address-family to vpn\n"
6495 "Label Value <0-1048575>\n"
6496 "Automatically assign a label\n")
6498 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6499 mpls_label_t label
= MPLS_LABEL_NONE
;
6504 if (argv_find(argv
, argc
, "no", &idx
))
6507 /* If "no ...", squash trailing parameter */
6513 label
= label_val
; /* parser should force unsigned */
6516 afi
= vpn_policy_getafi(vty
, bgp
, false);
6518 return CMD_WARNING_CONFIG_FAILED
;
6521 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6522 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6527 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6529 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6530 bgp_get_default(), bgp
);
6532 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6533 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6535 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6538 * label has previously been automatically
6539 * assigned by labelpool: release it
6541 * NB if tovpn_label == MPLS_LABEL_NONE it
6542 * means the automatic assignment is in flight
6543 * and therefore the labelpool callback must
6544 * detect that the auto label is not needed.
6547 bgp_lp_release(LP_TYPE_VRF
,
6548 &bgp
->vpn_policy
[afi
],
6549 bgp
->vpn_policy
[afi
].tovpn_label
);
6551 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6552 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6555 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6557 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6558 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6559 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6560 vpn_leak_label_callback
);
6563 /* post-change: re-export vpn routes */
6564 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6565 bgp_get_default(), bgp
);
6570 ALIAS (af_label_vpn_export
,
6571 af_no_label_vpn_export_cmd
,
6572 "no label vpn export",
6574 "label value for VRF\n"
6575 "Between current address-family and vpn\n"
6576 "For routes leaked from current address-family to vpn\n")
6578 DEFPY (af_nexthop_vpn_export
,
6579 af_nexthop_vpn_export_cmd
,
6580 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6582 "Specify next hop to use for VRF advertised prefixes\n"
6583 "Between current address-family and vpn\n"
6584 "For routes leaked from current address-family to vpn\n"
6588 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6594 if (argv_find(argv
, argc
, "no", &idx
))
6598 if (!sockunion2hostprefix(nexthop_str
, &p
))
6599 return CMD_WARNING_CONFIG_FAILED
;
6602 afi
= vpn_policy_getafi(vty
, bgp
, false);
6604 return CMD_WARNING_CONFIG_FAILED
;
6607 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6609 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6610 bgp_get_default(), bgp
);
6613 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6614 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6615 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6617 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6618 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6621 /* post-change: re-export vpn routes */
6622 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6623 bgp_get_default(), bgp
);
6628 ALIAS (af_nexthop_vpn_export
,
6629 af_no_nexthop_vpn_export_cmd
,
6630 "no nexthop vpn export",
6632 "Specify next hop to use for VRF advertised prefixes\n"
6633 "Between current address-family and vpn\n"
6634 "For routes leaked from current address-family to vpn\n")
6636 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6638 if (!strcmp(dstr
, "import")) {
6639 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6640 } else if (!strcmp(dstr
, "export")) {
6641 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6642 } else if (!strcmp(dstr
, "both")) {
6643 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6644 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6646 vty_out(vty
, "%% direction parse error\n");
6647 return CMD_WARNING_CONFIG_FAILED
;
6652 DEFPY (af_rt_vpn_imexport
,
6653 af_rt_vpn_imexport_cmd
,
6654 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6656 "Specify route target list\n"
6657 "Specify route target list\n"
6658 "Between current address-family and vpn\n"
6659 "For routes leaked from vpn to current address-family: match any\n"
6660 "For routes leaked from current address-family to vpn: set\n"
6661 "both import: match any and export: set\n"
6662 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6664 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6666 struct ecommunity
*ecom
= NULL
;
6667 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6668 vpn_policy_direction_t dir
;
6673 if (argv_find(argv
, argc
, "no", &idx
))
6676 afi
= vpn_policy_getafi(vty
, bgp
, false);
6678 return CMD_WARNING_CONFIG_FAILED
;
6680 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6681 if (ret
!= CMD_SUCCESS
)
6685 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6686 vty_out(vty
, "%% Missing RTLIST\n");
6687 return CMD_WARNING_CONFIG_FAILED
;
6689 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6690 if (ret
!= CMD_SUCCESS
) {
6695 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6699 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6702 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6704 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6705 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6706 ecommunity_dup(ecom
);
6708 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6710 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6711 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6714 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6718 ecommunity_free(&ecom
);
6723 ALIAS (af_rt_vpn_imexport
,
6724 af_no_rt_vpn_imexport_cmd
,
6725 "no <rt|route-target> vpn <import|export|both>$direction_str",
6727 "Specify route target list\n"
6728 "Specify route target list\n"
6729 "Between current address-family and vpn\n"
6730 "For routes leaked from vpn to current address-family\n"
6731 "For routes leaked from current address-family to vpn\n"
6732 "both import and export\n")
6734 DEFPY (af_route_map_vpn_imexport
,
6735 af_route_map_vpn_imexport_cmd
,
6736 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6737 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6739 "Specify route map\n"
6740 "Between current address-family and vpn\n"
6741 "For routes leaked from vpn to current address-family\n"
6742 "For routes leaked from current address-family to vpn\n"
6743 "name of route-map\n")
6745 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6747 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6748 vpn_policy_direction_t dir
;
6753 if (argv_find(argv
, argc
, "no", &idx
))
6756 afi
= vpn_policy_getafi(vty
, bgp
, false);
6758 return CMD_WARNING_CONFIG_FAILED
;
6760 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6761 if (ret
!= CMD_SUCCESS
)
6764 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6768 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6771 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6772 XFREE(MTYPE_ROUTE_MAP_NAME
,
6773 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6774 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6775 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6776 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6777 route_map_lookup_warn_noexist(vty
, rmap_str
);
6778 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6781 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6782 XFREE(MTYPE_ROUTE_MAP_NAME
,
6783 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6784 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6785 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6788 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6794 ALIAS (af_route_map_vpn_imexport
,
6795 af_no_route_map_vpn_imexport_cmd
,
6796 "no route-map vpn <import|export>$direction_str",
6798 "Specify route map\n"
6799 "Between current address-family and vpn\n"
6800 "For routes leaked from vpn to current address-family\n"
6801 "For routes leaked from current address-family to vpn\n")
6803 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6804 "[no] import vrf route-map RMAP$rmap_str",
6806 "Import routes from another VRF\n"
6807 "Vrf routes being filtered\n"
6808 "Specify route map\n"
6809 "name of route-map\n")
6811 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6812 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6816 struct bgp
*bgp_default
;
6818 if (argv_find(argv
, argc
, "no", &idx
))
6821 afi
= vpn_policy_getafi(vty
, bgp
, true);
6823 return CMD_WARNING_CONFIG_FAILED
;
6825 bgp_default
= bgp_get_default();
6830 /* Auto-create assuming the same AS */
6831 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6832 BGP_INSTANCE_TYPE_DEFAULT
);
6836 "VRF default is not configured as a bgp instance\n");
6841 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6844 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6845 XFREE(MTYPE_ROUTE_MAP_NAME
,
6846 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6847 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6848 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6849 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6850 route_map_lookup_warn_noexist(vty
, rmap_str
);
6851 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6854 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6855 XFREE(MTYPE_ROUTE_MAP_NAME
,
6856 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6857 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6858 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6861 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6866 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6867 "no import vrf route-map",
6869 "Import routes from another VRF\n"
6870 "Vrf routes being filtered\n"
6871 "Specify route map\n")
6873 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6874 "[no] import vrf VIEWVRFNAME$import_name",
6876 "Import routes from another VRF\n"
6877 "VRF to import from\n"
6878 "The name of the VRF\n")
6880 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6881 struct listnode
*node
;
6882 struct bgp
*vrf_bgp
, *bgp_default
;
6885 bool remove
= false;
6888 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6892 if (import_name
== NULL
) {
6893 vty_out(vty
, "%% Missing import name\n");
6897 if (argv_find(argv
, argc
, "no", &idx
))
6900 afi
= vpn_policy_getafi(vty
, bgp
, true);
6902 return CMD_WARNING_CONFIG_FAILED
;
6904 safi
= bgp_node_safi(vty
);
6906 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6907 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6908 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6909 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6910 remove
? "unimport" : "import", import_name
);
6914 bgp_default
= bgp_get_default();
6916 /* Auto-create assuming the same AS */
6917 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6918 BGP_INSTANCE_TYPE_DEFAULT
);
6922 "VRF default is not configured as a bgp instance\n");
6927 vrf_bgp
= bgp_lookup_by_name(import_name
);
6929 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6930 vrf_bgp
= bgp_default
;
6932 /* Auto-create assuming the same AS */
6933 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6937 "VRF %s is not configured as a bgp instance\n",
6944 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6946 /* Already importing from "import_vrf"? */
6947 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6949 if (strcmp(vname
, import_name
) == 0)
6953 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6959 /* This command is valid only in a bgp vrf instance or the default instance */
6960 DEFPY (bgp_imexport_vpn
,
6961 bgp_imexport_vpn_cmd
,
6962 "[no] <import|export>$direction_str vpn",
6964 "Import routes to this address-family\n"
6965 "Export routes from this address-family\n"
6966 "to/from default instance VPN RIB\n")
6968 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6975 vpn_policy_direction_t dir
;
6977 if (argv_find(argv
, argc
, "no", &idx
))
6980 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6981 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6983 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6984 return CMD_WARNING_CONFIG_FAILED
;
6987 afi
= bgp_node_afi(vty
);
6988 safi
= bgp_node_safi(vty
);
6989 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6990 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6991 return CMD_WARNING_CONFIG_FAILED
;
6994 if (!strcmp(direction_str
, "import")) {
6995 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6996 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6997 } else if (!strcmp(direction_str
, "export")) {
6998 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6999 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7001 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7002 return CMD_WARNING_CONFIG_FAILED
;
7005 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7008 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7009 if (!previous_state
) {
7010 /* trigger export current vrf */
7011 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7014 if (previous_state
) {
7015 /* trigger un-export current vrf */
7016 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7018 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7024 DEFPY (af_routetarget_import
,
7025 af_routetarget_import_cmd
,
7026 "[no] <rt|route-target> redirect import RTLIST...",
7028 "Specify route target list\n"
7029 "Specify route target list\n"
7030 "Flow-spec redirect type route target\n"
7031 "Import routes to this address-family\n"
7032 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7036 struct ecommunity
*ecom
= NULL
;
7041 if (argv_find(argv
, argc
, "no", &idx
))
7044 afi
= vpn_policy_getafi(vty
, bgp
, false);
7046 return CMD_WARNING_CONFIG_FAILED
;
7049 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7050 vty_out(vty
, "%% Missing RTLIST\n");
7051 return CMD_WARNING_CONFIG_FAILED
;
7053 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7054 if (ret
!= CMD_SUCCESS
)
7059 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7060 ecommunity_free(&bgp
->vpn_policy
[afi
]
7061 .import_redirect_rtlist
);
7062 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7063 ecommunity_dup(ecom
);
7065 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7066 ecommunity_free(&bgp
->vpn_policy
[afi
]
7067 .import_redirect_rtlist
);
7068 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7072 ecommunity_free(&ecom
);
7077 DEFUN_NOSH (address_family_ipv4_safi
,
7078 address_family_ipv4_safi_cmd
,
7079 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7080 "Enter Address Family command mode\n"
7082 BGP_SAFI_WITH_LABEL_HELP_STR
)
7086 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7087 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7088 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7089 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7090 && safi
!= SAFI_EVPN
) {
7092 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7093 return CMD_WARNING_CONFIG_FAILED
;
7095 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7097 vty
->node
= BGP_IPV4_NODE
;
7102 DEFUN_NOSH (address_family_ipv6_safi
,
7103 address_family_ipv6_safi_cmd
,
7104 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7105 "Enter Address Family command mode\n"
7107 BGP_SAFI_WITH_LABEL_HELP_STR
)
7110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7111 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7112 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7113 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7114 && safi
!= SAFI_EVPN
) {
7116 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7117 return CMD_WARNING_CONFIG_FAILED
;
7119 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7121 vty
->node
= BGP_IPV6_NODE
;
7126 #ifdef KEEP_OLD_VPN_COMMANDS
7127 DEFUN_NOSH (address_family_vpnv4
,
7128 address_family_vpnv4_cmd
,
7129 "address-family vpnv4 [unicast]",
7130 "Enter Address Family command mode\n"
7132 "Address Family modifier\n")
7134 vty
->node
= BGP_VPNV4_NODE
;
7138 DEFUN_NOSH (address_family_vpnv6
,
7139 address_family_vpnv6_cmd
,
7140 "address-family vpnv6 [unicast]",
7141 "Enter Address Family command mode\n"
7143 "Address Family modifier\n")
7145 vty
->node
= BGP_VPNV6_NODE
;
7148 #endif /* KEEP_OLD_VPN_COMMANDS */
7150 DEFUN_NOSH (address_family_evpn
,
7151 address_family_evpn_cmd
,
7152 "address-family l2vpn evpn",
7153 "Enter Address Family command mode\n"
7155 "Address Family modifier\n")
7157 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7158 vty
->node
= BGP_EVPN_NODE
;
7162 DEFUN_NOSH (exit_address_family
,
7163 exit_address_family_cmd
,
7164 "exit-address-family",
7165 "Exit from Address Family configuration mode\n")
7167 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7168 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7169 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7170 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7171 || vty
->node
== BGP_EVPN_NODE
7172 || vty
->node
== BGP_FLOWSPECV4_NODE
7173 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7174 vty
->node
= BGP_NODE
;
7178 /* Recalculate bestpath and re-advertise a prefix */
7179 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7180 const char *ip_str
, afi_t afi
, safi_t safi
,
7181 struct prefix_rd
*prd
)
7184 struct prefix match
;
7185 struct bgp_node
*rn
;
7186 struct bgp_node
*rm
;
7188 struct bgp_table
*table
;
7189 struct bgp_table
*rib
;
7191 /* BGP structure lookup. */
7193 bgp
= bgp_lookup_by_name(view_name
);
7195 vty_out(vty
, "%% Can't find BGP instance %s\n",
7200 bgp
= bgp_get_default();
7202 vty_out(vty
, "%% No BGP process is configured\n");
7207 /* Check IP address argument. */
7208 ret
= str2prefix(ip_str
, &match
);
7210 vty_out(vty
, "%% address is malformed\n");
7214 match
.family
= afi2family(afi
);
7215 rib
= bgp
->rib
[afi
][safi
];
7217 if (safi
== SAFI_MPLS_VPN
) {
7218 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7219 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7222 table
= bgp_node_get_bgp_table_info(rn
);
7223 if (table
!= NULL
) {
7225 if ((rm
= bgp_node_match(table
, &match
))
7228 == match
.prefixlen
) {
7230 BGP_NODE_USER_CLEAR
);
7231 bgp_process(bgp
, rm
, afi
, safi
);
7233 bgp_unlock_node(rm
);
7238 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7239 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7240 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7241 bgp_process(bgp
, rn
, afi
, safi
);
7243 bgp_unlock_node(rn
);
7250 /* one clear bgp command to rule them all */
7251 DEFUN (clear_ip_bgp_all
,
7252 clear_ip_bgp_all_cmd
,
7253 "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>]",
7257 BGP_INSTANCE_HELP_STR
7260 BGP_SAFI_WITH_LABEL_HELP_STR
7261 "Address Family modifier\n"
7263 "BGP neighbor address to clear\n"
7264 "BGP IPv6 neighbor to clear\n"
7265 "BGP neighbor on interface to clear\n"
7266 "Clear peers with the AS number\n"
7267 "Clear all external peers\n"
7268 "Clear all members of peer-group\n"
7269 "BGP peer-group name\n"
7274 "Push out prefix-list ORF and do inbound soft reconfig\n"
7279 afi_t afi
= AFI_IP6
;
7280 safi_t safi
= SAFI_UNICAST
;
7281 enum clear_sort clr_sort
= clear_peer
;
7282 enum bgp_clear_type clr_type
;
7283 char *clr_arg
= NULL
;
7287 /* clear [ip] bgp */
7288 if (argv_find(argv
, argc
, "ip", &idx
))
7291 /* [<vrf> VIEWVRFNAME] */
7292 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7293 vrf
= argv
[idx
+ 1]->arg
;
7295 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7297 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7298 /* [<view> VIEWVRFNAME] */
7299 vrf
= argv
[idx
+ 1]->arg
;
7302 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7303 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7304 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7306 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7307 if (argv_find(argv
, argc
, "*", &idx
)) {
7308 clr_sort
= clear_all
;
7309 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7310 clr_sort
= clear_peer
;
7311 clr_arg
= argv
[idx
]->arg
;
7312 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7313 clr_sort
= clear_peer
;
7314 clr_arg
= argv
[idx
]->arg
;
7315 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7316 clr_sort
= clear_group
;
7318 clr_arg
= argv
[idx
]->arg
;
7319 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7320 clr_sort
= clear_peer
;
7321 clr_arg
= argv
[idx
]->arg
;
7322 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7323 clr_sort
= clear_as
;
7324 clr_arg
= argv
[idx
]->arg
;
7325 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7326 clr_sort
= clear_external
;
7329 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7330 if (argv_find(argv
, argc
, "soft", &idx
)) {
7331 if (argv_find(argv
, argc
, "in", &idx
)
7332 || argv_find(argv
, argc
, "out", &idx
))
7333 clr_type
= strmatch(argv
[idx
]->text
, "in")
7335 : BGP_CLEAR_SOFT_OUT
;
7337 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7338 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7339 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7340 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7341 : BGP_CLEAR_SOFT_IN
;
7342 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7343 clr_type
= BGP_CLEAR_SOFT_OUT
;
7345 clr_type
= BGP_CLEAR_SOFT_NONE
;
7347 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7350 DEFUN (clear_ip_bgp_prefix
,
7351 clear_ip_bgp_prefix_cmd
,
7352 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7356 BGP_INSTANCE_HELP_STR
7357 "Clear bestpath and re-advertise\n"
7361 char *prefix
= NULL
;
7365 /* [<view|vrf> VIEWVRFNAME] */
7366 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7367 vrf
= argv
[idx
+ 1]->arg
;
7369 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7371 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7372 /* [<view> VIEWVRFNAME] */
7373 vrf
= argv
[idx
+ 1]->arg
;
7377 prefix
= argv
[argc
- 1]->arg
;
7379 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7382 DEFUN (clear_bgp_ipv6_safi_prefix
,
7383 clear_bgp_ipv6_safi_prefix_cmd
,
7384 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7390 "Clear bestpath and re-advertise\n"
7394 int idx_ipv6_prefix
= 0;
7395 safi_t safi
= SAFI_UNICAST
;
7396 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7397 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7399 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7400 return bgp_clear_prefix(
7401 vty
, NULL
, prefix
, AFI_IP6
,
7405 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7406 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7407 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7411 BGP_INSTANCE_HELP_STR
7414 "Clear bestpath and re-advertise\n"
7418 int idx_vrfview
= 0;
7419 int idx_ipv6_prefix
= 0;
7420 safi_t safi
= SAFI_UNICAST
;
7421 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7422 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7423 char *vrfview
= NULL
;
7425 /* [<view|vrf> VIEWVRFNAME] */
7426 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7427 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7428 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7430 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7431 /* [<view> VIEWVRFNAME] */
7432 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7434 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7436 return bgp_clear_prefix(
7437 vty
, vrfview
, prefix
,
7438 AFI_IP6
, safi
, NULL
);
7441 DEFUN (show_bgp_views
,
7443 "show [ip] bgp views",
7447 "Show the defined BGP views\n")
7449 struct list
*inst
= bm
->bgp
;
7450 struct listnode
*node
;
7453 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7454 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7458 vty_out(vty
, "Defined BGP views:\n");
7459 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7461 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7463 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7470 DEFUN (show_bgp_vrfs
,
7472 "show [ip] bgp vrfs [json]",
7479 char buf
[ETHER_ADDR_STRLEN
];
7480 struct list
*inst
= bm
->bgp
;
7481 struct listnode
*node
;
7483 bool uj
= use_json(argc
, argv
);
7484 json_object
*json
= NULL
;
7485 json_object
*json_vrfs
= NULL
;
7488 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7489 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7494 json
= json_object_new_object();
7495 json_vrfs
= json_object_new_object();
7498 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7499 const char *name
, *type
;
7501 struct listnode
*node2
, *nnode2
;
7502 int peers_cfg
, peers_estb
;
7503 json_object
*json_vrf
= NULL
;
7506 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7510 if (!uj
&& count
== 1)
7512 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7513 "Type", "Id", "routerId", "#PeersVfg",
7514 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7516 peers_cfg
= peers_estb
= 0;
7518 json_vrf
= json_object_new_object();
7521 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7522 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7525 if (peer
->status
== Established
)
7529 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7530 name
= VRF_DEFAULT_NAME
;
7539 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7541 : (int64_t)bgp
->vrf_id
;
7542 json_object_string_add(json_vrf
, "type", type
);
7543 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7544 json_object_string_add(json_vrf
, "routerId",
7545 inet_ntoa(bgp
->router_id
));
7546 json_object_int_add(json_vrf
, "numConfiguredPeers",
7548 json_object_int_add(json_vrf
, "numEstablishedPeers",
7551 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7552 json_object_string_add(
7554 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7555 json_object_object_add(json_vrfs
, name
, json_vrf
);
7558 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7560 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7562 inet_ntoa(bgp
->router_id
), peers_cfg
,
7563 peers_estb
, name
, bgp
->l3vni
,
7564 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7568 json_object_object_add(json
, "vrfs", json_vrfs
);
7570 json_object_int_add(json
, "totalVrfs", count
);
7572 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7573 json
, JSON_C_TO_STRING_PRETTY
));
7574 json_object_free(json
);
7578 "\nTotal number of VRFs (including default): %d\n",
7585 DEFUN (show_bgp_mac_hash
,
7586 show_bgp_mac_hash_cmd
,
7587 "show bgp mac hash",
7591 "Mac Address database\n")
7593 bgp_mac_dump_table(vty
);
7598 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7600 struct vty
*vty
= (struct vty
*)args
;
7601 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7603 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7607 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7609 vty_out(vty
, "self nexthop database:\n");
7610 bgp_nexthop_show_address_hash(vty
, bgp
);
7612 vty_out(vty
, "Tunnel-ip database:\n");
7613 hash_iterate(bgp
->tip_hash
,
7614 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7618 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7619 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7620 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7621 "martian next-hops\n"
7622 "martian next-hop database\n")
7624 struct bgp
*bgp
= NULL
;
7628 /* [<vrf> VIEWVRFNAME] */
7629 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7630 name
= argv
[idx
+ 1]->arg
;
7631 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7633 } else if (argv_find(argv
, argc
, "view", &idx
))
7634 /* [<view> VIEWVRFNAME] */
7635 name
= argv
[idx
+ 1]->arg
;
7637 bgp
= bgp_lookup_by_name(name
);
7639 bgp
= bgp_get_default();
7642 vty_out(vty
, "%% No BGP process is configured\n");
7645 bgp_show_martian_nexthops(vty
, bgp
);
7650 DEFUN (show_bgp_memory
,
7651 show_bgp_memory_cmd
,
7652 "show [ip] bgp memory",
7656 "Global BGP memory statistics\n")
7658 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7659 unsigned long count
;
7661 /* RIB related usage stats */
7662 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7663 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7664 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7665 count
* sizeof(struct bgp_node
)));
7667 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7668 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7669 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7670 count
* sizeof(struct bgp_path_info
)));
7671 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7672 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7675 memstrbuf
, sizeof(memstrbuf
),
7676 count
* sizeof(struct bgp_path_info_extra
)));
7678 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7679 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7680 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7681 count
* sizeof(struct bgp_static
)));
7683 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7684 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7685 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7686 count
* sizeof(struct bpacket
)));
7689 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7690 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7691 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7692 count
* sizeof(struct bgp_adj_in
)));
7693 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7694 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7695 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7696 count
* sizeof(struct bgp_adj_out
)));
7698 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7699 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7701 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7702 count
* sizeof(struct bgp_nexthop_cache
)));
7704 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7705 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7707 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7708 count
* sizeof(struct bgp_damp_info
)));
7711 count
= attr_count();
7712 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7713 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7714 count
* sizeof(struct attr
)));
7716 if ((count
= attr_unknown_count()))
7717 vty_out(vty
, "%ld unknown attributes\n", count
);
7719 /* AS_PATH attributes */
7720 count
= aspath_count();
7721 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7722 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7723 count
* sizeof(struct aspath
)));
7725 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7726 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7727 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7728 count
* sizeof(struct assegment
)));
7730 /* Other attributes */
7731 if ((count
= community_count()))
7732 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7733 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7734 count
* sizeof(struct community
)));
7735 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7736 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7737 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7738 count
* sizeof(struct ecommunity
)));
7739 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7741 "%ld BGP large-community entries, using %s of memory\n",
7742 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7743 count
* sizeof(struct lcommunity
)));
7745 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7746 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7747 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7748 count
* sizeof(struct cluster_list
)));
7750 /* Peer related usage */
7751 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7752 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7753 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7754 count
* sizeof(struct peer
)));
7756 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7757 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7758 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7759 count
* sizeof(struct peer_group
)));
7762 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7763 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7764 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7765 count
* sizeof(struct hash
)));
7766 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7767 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7768 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7769 count
* sizeof(struct hash_bucket
)));
7770 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7771 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7772 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7773 count
* sizeof(regex_t
)));
7777 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7779 json_object
*bestpath
= json_object_new_object();
7781 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7782 json_object_string_add(bestpath
, "asPath", "ignore");
7784 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7785 json_object_string_add(bestpath
, "asPath", "confed");
7787 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7788 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7789 json_object_string_add(bestpath
, "multiPathRelax",
7792 json_object_string_add(bestpath
, "multiPathRelax",
7795 json_object_string_add(bestpath
, "multiPathRelax", "false");
7797 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7798 json_object_string_add(bestpath
, "compareRouterId", "true");
7799 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7800 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7801 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7802 json_object_string_add(bestpath
, "med", "confed");
7803 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7804 json_object_string_add(bestpath
, "med",
7805 "missing-as-worst");
7807 json_object_string_add(bestpath
, "med", "true");
7810 json_object_object_add(json
, "bestPath", bestpath
);
7813 /* Show BGP peer's summary information. */
7814 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7815 bool use_json
, json_object
*json
)
7818 struct listnode
*node
, *nnode
;
7819 unsigned int count
= 0, dn_count
= 0;
7820 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7821 char neighbor_buf
[VTY_BUFSIZ
];
7822 int neighbor_col_default_width
= 16;
7824 int max_neighbor_width
= 0;
7826 json_object
*json_peer
= NULL
;
7827 json_object
*json_peers
= NULL
;
7828 struct peer_af
*paf
;
7830 /* labeled-unicast routes are installed in the unicast table so in order
7832 * display the correct PfxRcd value we must look at SAFI_UNICAST
7834 if (safi
== SAFI_LABELED_UNICAST
)
7835 pfx_rcd_safi
= SAFI_UNICAST
;
7837 pfx_rcd_safi
= safi
;
7841 json
= json_object_new_object();
7843 json_peers
= json_object_new_object();
7845 /* Loop over all neighbors that will be displayed to determine
7847 * characters are needed for the Neighbor column
7849 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7850 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7853 if (peer
->afc
[afi
][safi
]) {
7854 memset(dn_flag
, '\0', sizeof(dn_flag
));
7855 if (peer_dynamic_neighbor(peer
))
7859 && bgp_flag_check(bgp
,
7860 BGP_FLAG_SHOW_HOSTNAME
))
7861 sprintf(neighbor_buf
, "%s%s(%s) ",
7862 dn_flag
, peer
->hostname
,
7865 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7868 len
= strlen(neighbor_buf
);
7870 if (len
> max_neighbor_width
)
7871 max_neighbor_width
= len
;
7875 /* Originally we displayed the Neighbor column as 16
7876 * characters wide so make that the default
7878 if (max_neighbor_width
< neighbor_col_default_width
)
7879 max_neighbor_width
= neighbor_col_default_width
;
7882 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7883 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7886 if (!peer
->afc
[afi
][safi
])
7891 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7894 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7896 : (int64_t)bgp
->vrf_id
;
7898 /* Usage summary and header */
7900 json_object_string_add(
7902 inet_ntoa(bgp
->router_id
));
7903 json_object_int_add(json
, "as", bgp
->as
);
7904 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7905 json_object_string_add(
7908 == BGP_INSTANCE_TYPE_DEFAULT
)
7913 "BGP router identifier %s, local AS number %u vrf-id %d",
7914 inet_ntoa(bgp
->router_id
), bgp
->as
,
7915 bgp
->vrf_id
== VRF_UNKNOWN
7917 : (int)bgp
->vrf_id
);
7921 if (bgp_update_delay_configured(bgp
)) {
7923 json_object_int_add(
7924 json
, "updateDelayLimit",
7925 bgp
->v_update_delay
);
7927 if (bgp
->v_update_delay
7928 != bgp
->v_establish_wait
)
7929 json_object_int_add(
7931 "updateDelayEstablishWait",
7932 bgp
->v_establish_wait
);
7934 if (bgp_update_delay_active(bgp
)) {
7935 json_object_string_add(
7937 "updateDelayFirstNeighbor",
7938 bgp
->update_delay_begin_time
);
7939 json_object_boolean_true_add(
7941 "updateDelayInProgress");
7943 if (bgp
->update_delay_over
) {
7944 json_object_string_add(
7946 "updateDelayFirstNeighbor",
7947 bgp
->update_delay_begin_time
);
7948 json_object_string_add(
7950 "updateDelayBestpathResumed",
7951 bgp
->update_delay_end_time
);
7952 json_object_string_add(
7954 "updateDelayZebraUpdateResume",
7955 bgp
->update_delay_zebra_resume_time
);
7956 json_object_string_add(
7958 "updateDelayPeerUpdateResume",
7959 bgp
->update_delay_peers_resume_time
);
7964 "Read-only mode update-delay limit: %d seconds\n",
7965 bgp
->v_update_delay
);
7966 if (bgp
->v_update_delay
7967 != bgp
->v_establish_wait
)
7969 " Establish wait: %d seconds\n",
7970 bgp
->v_establish_wait
);
7972 if (bgp_update_delay_active(bgp
)) {
7974 " First neighbor established: %s\n",
7975 bgp
->update_delay_begin_time
);
7977 " Delay in progress\n");
7979 if (bgp
->update_delay_over
) {
7981 " First neighbor established: %s\n",
7982 bgp
->update_delay_begin_time
);
7984 " Best-paths resumed: %s\n",
7985 bgp
->update_delay_end_time
);
7987 " zebra update resumed: %s\n",
7988 bgp
->update_delay_zebra_resume_time
);
7990 " peers update resumed: %s\n",
7991 bgp
->update_delay_peers_resume_time
);
7998 if (bgp_maxmed_onstartup_configured(bgp
)
7999 && bgp
->maxmed_active
)
8000 json_object_boolean_true_add(
8001 json
, "maxMedOnStartup");
8002 if (bgp
->v_maxmed_admin
)
8003 json_object_boolean_true_add(
8004 json
, "maxMedAdministrative");
8006 json_object_int_add(
8007 json
, "tableVersion",
8008 bgp_table_version(bgp
->rib
[afi
][safi
]));
8010 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8011 json_object_int_add(json
, "ribCount", ents
);
8012 json_object_int_add(
8014 ents
* sizeof(struct bgp_node
));
8016 ents
= bgp
->af_peer_count
[afi
][safi
];
8017 json_object_int_add(json
, "peerCount", ents
);
8018 json_object_int_add(json
, "peerMemory",
8019 ents
* sizeof(struct peer
));
8021 if ((ents
= listcount(bgp
->group
))) {
8022 json_object_int_add(
8023 json
, "peerGroupCount", ents
);
8024 json_object_int_add(
8025 json
, "peerGroupMemory",
8026 ents
* sizeof(struct
8030 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8031 BGP_CONFIG_DAMPENING
))
8032 json_object_boolean_true_add(
8033 json
, "dampeningEnabled");
8035 if (bgp_maxmed_onstartup_configured(bgp
)
8036 && bgp
->maxmed_active
)
8038 "Max-med on-startup active\n");
8039 if (bgp
->v_maxmed_admin
)
8041 "Max-med administrative active\n");
8043 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8044 bgp_table_version(bgp
->rib
[afi
][safi
]));
8046 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8048 "RIB entries %ld, using %s of memory\n",
8050 mtype_memstr(memstrbuf
,
8052 ents
* sizeof(struct
8055 /* Peer related usage */
8056 ents
= bgp
->af_peer_count
[afi
][safi
];
8057 vty_out(vty
, "Peers %ld, using %s of memory\n",
8060 memstrbuf
, sizeof(memstrbuf
),
8061 ents
* sizeof(struct peer
)));
8063 if ((ents
= listcount(bgp
->group
)))
8065 "Peer groups %ld, using %s of memory\n",
8070 ents
* sizeof(struct
8073 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8074 BGP_CONFIG_DAMPENING
))
8075 vty_out(vty
, "Dampening enabled.\n");
8078 /* Subtract 8 here because 'Neighbor' is
8080 vty_out(vty
, "Neighbor");
8081 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8084 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8091 json_peer
= json_object_new_object();
8093 if (peer_dynamic_neighbor(peer
)) {
8095 json_object_boolean_true_add(json_peer
,
8100 json_object_string_add(json_peer
, "hostname",
8103 if (peer
->domainname
)
8104 json_object_string_add(json_peer
, "domainname",
8107 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8108 json_object_int_add(json_peer
, "version", 4);
8109 json_object_int_add(json_peer
, "msgRcvd",
8110 PEER_TOTAL_RX(peer
));
8111 json_object_int_add(json_peer
, "msgSent",
8112 PEER_TOTAL_TX(peer
));
8114 json_object_int_add(json_peer
, "tableVersion",
8115 peer
->version
[afi
][safi
]);
8116 json_object_int_add(json_peer
, "outq",
8118 json_object_int_add(json_peer
, "inq", 0);
8119 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8120 use_json
, json_peer
);
8123 * Adding "pfxRcd" field to match with the corresponding
8124 * CLI. "prefixReceivedCount" will be deprecated in
8127 json_object_int_add(json_peer
, "prefixReceivedCount",
8128 peer
->pcount
[afi
][pfx_rcd_safi
]);
8129 json_object_int_add(json_peer
, "pfxRcd",
8130 peer
->pcount
[afi
][pfx_rcd_safi
]);
8132 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8133 if (paf
&& PAF_SUBGRP(paf
))
8134 json_object_int_add(json_peer
,
8136 (PAF_SUBGRP(paf
))->scount
);
8138 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8139 json_object_string_add(json_peer
, "state",
8141 else if (peer
->afc_recv
[afi
][safi
])
8142 json_object_string_add(
8144 lookup_msg(bgp_status_msg
, peer
->status
,
8146 else if (CHECK_FLAG(peer
->sflags
,
8147 PEER_STATUS_PREFIX_OVERFLOW
))
8148 json_object_string_add(json_peer
, "state",
8151 json_object_string_add(
8153 lookup_msg(bgp_status_msg
, peer
->status
,
8157 json_object_string_add(json_peer
, "idType",
8159 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8160 json_object_string_add(json_peer
, "idType",
8162 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8163 json_object_string_add(json_peer
, "idType",
8166 json_object_object_add(json_peers
, peer
->host
,
8169 memset(dn_flag
, '\0', sizeof(dn_flag
));
8170 if (peer_dynamic_neighbor(peer
)) {
8176 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8177 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8178 peer
->hostname
, peer
->host
);
8180 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8182 /* pad the neighbor column with spaces */
8183 if (len
< max_neighbor_width
)
8184 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8187 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8188 peer
->as
, PEER_TOTAL_RX(peer
),
8189 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8190 0, peer
->obuf
->count
,
8191 peer_uptime(peer
->uptime
, timebuf
,
8192 BGP_UPTIME_LEN
, 0, NULL
));
8194 if (peer
->status
== Established
)
8195 if (peer
->afc_recv
[afi
][safi
])
8196 vty_out(vty
, " %12ld",
8200 vty_out(vty
, " NoNeg");
8202 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8203 vty_out(vty
, " Idle (Admin)");
8204 else if (CHECK_FLAG(
8206 PEER_STATUS_PREFIX_OVERFLOW
))
8207 vty_out(vty
, " Idle (PfxCt)");
8209 vty_out(vty
, " %12s",
8210 lookup_msg(bgp_status_msg
,
8211 peer
->status
, NULL
));
8218 json_object_object_add(json
, "peers", json_peers
);
8220 json_object_int_add(json
, "totalPeers", count
);
8221 json_object_int_add(json
, "dynamicPeers", dn_count
);
8223 bgp_show_bestpath_json(bgp
, json
);
8225 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8226 json
, JSON_C_TO_STRING_PRETTY
));
8227 json_object_free(json
);
8230 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8232 vty_out(vty
, "No %s neighbor is configured\n",
8233 afi_safi_print(afi
, safi
));
8237 vty_out(vty
, "* - dynamic neighbor\n");
8238 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8239 dn_count
, bgp
->dynamic_neighbors_limit
);
8246 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8247 int safi
, bool use_json
,
8251 int afi_wildcard
= (afi
== AFI_MAX
);
8252 int safi_wildcard
= (safi
== SAFI_MAX
);
8253 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8254 bool nbr_output
= false;
8256 if (use_json
&& is_wildcard
)
8257 vty_out(vty
, "{\n");
8259 afi
= 1; /* AFI_IP */
8260 while (afi
< AFI_MAX
) {
8262 safi
= 1; /* SAFI_UNICAST */
8263 while (safi
< SAFI_MAX
) {
8264 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8268 * So limit output to those afi/safi
8270 * actualy have something interesting in
8274 json
= json_object_new_object();
8277 vty_out(vty
, ",\n");
8281 vty_out(vty
, "\"%s\":",
8285 vty_out(vty
, "\n%s Summary:\n",
8290 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8302 if (use_json
&& is_wildcard
)
8303 vty_out(vty
, "}\n");
8304 else if (!nbr_output
) {
8306 vty_out(vty
, "{}\n");
8308 vty_out(vty
, "%% No BGP neighbors found\n");
8312 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8313 safi_t safi
, bool use_json
)
8315 struct listnode
*node
, *nnode
;
8317 json_object
*json
= NULL
;
8319 bool nbr_output
= false;
8322 vty_out(vty
, "{\n");
8324 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8327 json
= json_object_new_object();
8330 vty_out(vty
, ",\n");
8334 vty_out(vty
, "\"%s\":",
8335 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8339 vty_out(vty
, "\nInstance %s:\n",
8340 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8344 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8348 vty_out(vty
, "}\n");
8349 else if (!nbr_output
)
8350 vty_out(vty
, "%% BGP instance not found\n");
8353 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8354 safi_t safi
, bool use_json
)
8359 if (strmatch(name
, "all")) {
8360 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8364 bgp
= bgp_lookup_by_name(name
);
8368 vty_out(vty
, "{}\n");
8371 "%% BGP instance not found\n");
8375 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8381 bgp
= bgp_get_default();
8384 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8387 vty_out(vty
, "{}\n");
8389 vty_out(vty
, "%% BGP instance not found\n");
8396 /* `show [ip] bgp summary' commands. */
8397 DEFUN (show_ip_bgp_summary
,
8398 show_ip_bgp_summary_cmd
,
8399 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8403 BGP_INSTANCE_HELP_STR
8405 BGP_SAFI_WITH_LABEL_HELP_STR
8406 "Summary of BGP neighbor status\n"
8410 afi_t afi
= AFI_MAX
;
8411 safi_t safi
= SAFI_MAX
;
8416 if (argv_find(argv
, argc
, "ip", &idx
))
8418 /* [<vrf> VIEWVRFNAME] */
8419 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8420 vrf
= argv
[idx
+ 1]->arg
;
8421 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8423 } else if (argv_find(argv
, argc
, "view", &idx
))
8424 /* [<view> VIEWVRFNAME] */
8425 vrf
= argv
[idx
+ 1]->arg
;
8426 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8427 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8428 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8431 bool uj
= use_json(argc
, argv
);
8433 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8436 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8438 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8439 return "IPv4 Unicast";
8440 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8441 return "IPv4 Multicast";
8442 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8443 return "IPv4 Labeled Unicast";
8444 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8446 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8447 return "IPv4 Encap";
8448 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8449 return "IPv4 Flowspec";
8450 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8451 return "IPv6 Unicast";
8452 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8453 return "IPv6 Multicast";
8454 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8455 return "IPv6 Labeled Unicast";
8456 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8458 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8459 return "IPv6 Encap";
8460 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8461 return "IPv6 Flowspec";
8462 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8463 return "L2VPN EVPN";
8469 * Please note that we have intentionally camelCased
8470 * the return strings here. So if you want
8471 * to use this function, please ensure you
8472 * are doing this within json output
8474 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8476 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8477 return "ipv4Unicast";
8478 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8479 return "ipv4Multicast";
8480 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8481 return "ipv4LabeledUnicast";
8482 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8484 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8486 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8487 return "ipv4Flowspec";
8488 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8489 return "ipv6Unicast";
8490 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8491 return "ipv6Multicast";
8492 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8493 return "ipv6LabeledUnicast";
8494 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8496 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8498 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8499 return "ipv6Flowspec";
8500 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8506 /* Show BGP peer's information. */
8507 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8509 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8510 afi_t afi
, safi_t safi
,
8511 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8512 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8513 bool use_json
, json_object
*json_pref
)
8516 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8517 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8519 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8520 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8521 json_object_string_add(json_pref
, "sendMode",
8522 "advertisedAndReceived");
8523 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8524 json_object_string_add(json_pref
, "sendMode",
8526 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8527 json_object_string_add(json_pref
, "sendMode",
8530 vty_out(vty
, " Send-mode: ");
8531 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8532 vty_out(vty
, "advertised");
8533 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8534 vty_out(vty
, "%sreceived",
8535 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8544 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8545 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8547 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8548 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8549 json_object_string_add(json_pref
, "recvMode",
8550 "advertisedAndReceived");
8551 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8552 json_object_string_add(json_pref
, "recvMode",
8554 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8555 json_object_string_add(json_pref
, "recvMode",
8558 vty_out(vty
, " Receive-mode: ");
8559 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8560 vty_out(vty
, "advertised");
8561 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8562 vty_out(vty
, "%sreceived",
8563 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8572 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8573 safi_t safi
, bool use_json
,
8574 json_object
*json_neigh
)
8576 struct bgp_filter
*filter
;
8577 struct peer_af
*paf
;
8578 char orf_pfx_name
[BUFSIZ
];
8580 json_object
*json_af
= NULL
;
8581 json_object
*json_prefA
= NULL
;
8582 json_object
*json_prefB
= NULL
;
8583 json_object
*json_addr
= NULL
;
8586 json_addr
= json_object_new_object();
8587 json_af
= json_object_new_object();
8588 filter
= &p
->filter
[afi
][safi
];
8590 if (peer_group_active(p
))
8591 json_object_string_add(json_addr
, "peerGroupMember",
8594 paf
= peer_af_find(p
, afi
, safi
);
8595 if (paf
&& PAF_SUBGRP(paf
)) {
8596 json_object_int_add(json_addr
, "updateGroupId",
8597 PAF_UPDGRP(paf
)->id
);
8598 json_object_int_add(json_addr
, "subGroupId",
8599 PAF_SUBGRP(paf
)->id
);
8600 json_object_int_add(json_addr
, "packetQueueLength",
8601 bpacket_queue_virtual_length(paf
));
8604 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8605 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8606 PEER_CAP_ORF_PREFIX_SM_RCV
)
8607 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8608 PEER_CAP_ORF_PREFIX_RM_ADV
)
8609 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8610 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8611 json_object_int_add(json_af
, "orfType",
8613 json_prefA
= json_object_new_object();
8614 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8615 PEER_CAP_ORF_PREFIX_SM_ADV
,
8616 PEER_CAP_ORF_PREFIX_RM_ADV
,
8617 PEER_CAP_ORF_PREFIX_SM_RCV
,
8618 PEER_CAP_ORF_PREFIX_RM_RCV
,
8619 use_json
, json_prefA
);
8620 json_object_object_add(json_af
, "orfPrefixList",
8624 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8625 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8626 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8627 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8628 PEER_CAP_ORF_PREFIX_RM_ADV
)
8629 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8630 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8631 json_object_int_add(json_af
, "orfOldType",
8632 ORF_TYPE_PREFIX_OLD
);
8633 json_prefB
= json_object_new_object();
8634 bgp_show_peer_afi_orf_cap(
8635 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8636 PEER_CAP_ORF_PREFIX_RM_ADV
,
8637 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8638 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8640 json_object_object_add(json_af
, "orfOldPrefixList",
8644 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8645 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8646 PEER_CAP_ORF_PREFIX_SM_RCV
)
8647 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8648 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8649 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8650 PEER_CAP_ORF_PREFIX_RM_ADV
)
8651 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8652 PEER_CAP_ORF_PREFIX_RM_RCV
)
8653 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8654 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8655 json_object_object_add(json_addr
, "afDependentCap",
8658 json_object_free(json_af
);
8660 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8661 orf_pfx_count
= prefix_bgp_show_prefix_list(
8662 NULL
, afi
, orf_pfx_name
, use_json
);
8664 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8665 PEER_STATUS_ORF_PREFIX_SEND
)
8667 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8668 PEER_STATUS_ORF_PREFIX_SEND
))
8669 json_object_boolean_true_add(json_neigh
,
8672 json_object_int_add(json_addr
, "orfRecvCounter",
8675 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8676 PEER_STATUS_ORF_WAIT_REFRESH
))
8677 json_object_string_add(
8678 json_addr
, "orfFirstUpdate",
8679 "deferredUntilORFOrRouteRefreshRecvd");
8681 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8682 PEER_FLAG_REFLECTOR_CLIENT
))
8683 json_object_boolean_true_add(json_addr
,
8684 "routeReflectorClient");
8685 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8686 PEER_FLAG_RSERVER_CLIENT
))
8687 json_object_boolean_true_add(json_addr
,
8688 "routeServerClient");
8689 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8690 json_object_boolean_true_add(json_addr
,
8691 "inboundSoftConfigPermit");
8693 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8694 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8695 json_object_boolean_true_add(
8697 "privateAsNumsAllReplacedInUpdatesToNbr");
8698 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8699 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8700 json_object_boolean_true_add(
8702 "privateAsNumsReplacedInUpdatesToNbr");
8703 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8704 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8705 json_object_boolean_true_add(
8707 "privateAsNumsAllRemovedInUpdatesToNbr");
8708 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8709 PEER_FLAG_REMOVE_PRIVATE_AS
))
8710 json_object_boolean_true_add(
8712 "privateAsNumsRemovedInUpdatesToNbr");
8714 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8715 json_object_boolean_true_add(
8717 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8720 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8721 json_object_string_add(json_addr
,
8722 "overrideASNsInOutboundUpdates",
8723 "ifAspathEqualRemoteAs");
8725 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8726 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8727 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8728 json_object_boolean_true_add(json_addr
,
8729 "routerAlwaysNextHop");
8730 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8731 PEER_FLAG_AS_PATH_UNCHANGED
))
8732 json_object_boolean_true_add(
8733 json_addr
, "unchangedAsPathPropogatedToNbr");
8734 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8735 PEER_FLAG_NEXTHOP_UNCHANGED
))
8736 json_object_boolean_true_add(
8737 json_addr
, "unchangedNextHopPropogatedToNbr");
8738 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8739 json_object_boolean_true_add(
8740 json_addr
, "unchangedMedPropogatedToNbr");
8741 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8742 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8743 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8744 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8745 PEER_FLAG_SEND_COMMUNITY
)
8746 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8747 PEER_FLAG_SEND_EXT_COMMUNITY
))
8748 json_object_string_add(json_addr
,
8749 "commAttriSentToNbr",
8750 "extendedAndStandard");
8751 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8752 PEER_FLAG_SEND_EXT_COMMUNITY
))
8753 json_object_string_add(json_addr
,
8754 "commAttriSentToNbr",
8757 json_object_string_add(json_addr
,
8758 "commAttriSentToNbr",
8761 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8762 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8763 if (p
->default_rmap
[afi
][safi
].name
)
8764 json_object_string_add(
8765 json_addr
, "defaultRouteMap",
8766 p
->default_rmap
[afi
][safi
].name
);
8768 if (paf
&& PAF_SUBGRP(paf
)
8769 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8770 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8771 json_object_boolean_true_add(json_addr
,
8774 json_object_boolean_true_add(json_addr
,
8778 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8779 if (is_evpn_enabled())
8780 json_object_boolean_true_add(
8781 json_addr
, "advertiseAllVnis");
8784 if (filter
->plist
[FILTER_IN
].name
8785 || filter
->dlist
[FILTER_IN
].name
8786 || filter
->aslist
[FILTER_IN
].name
8787 || filter
->map
[RMAP_IN
].name
)
8788 json_object_boolean_true_add(json_addr
,
8789 "inboundPathPolicyConfig");
8790 if (filter
->plist
[FILTER_OUT
].name
8791 || filter
->dlist
[FILTER_OUT
].name
8792 || filter
->aslist
[FILTER_OUT
].name
8793 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8794 json_object_boolean_true_add(
8795 json_addr
, "outboundPathPolicyConfig");
8798 if (filter
->plist
[FILTER_IN
].name
)
8799 json_object_string_add(json_addr
,
8800 "incomingUpdatePrefixFilterList",
8801 filter
->plist
[FILTER_IN
].name
);
8802 if (filter
->plist
[FILTER_OUT
].name
)
8803 json_object_string_add(json_addr
,
8804 "outgoingUpdatePrefixFilterList",
8805 filter
->plist
[FILTER_OUT
].name
);
8807 /* distribute-list */
8808 if (filter
->dlist
[FILTER_IN
].name
)
8809 json_object_string_add(
8810 json_addr
, "incomingUpdateNetworkFilterList",
8811 filter
->dlist
[FILTER_IN
].name
);
8812 if (filter
->dlist
[FILTER_OUT
].name
)
8813 json_object_string_add(
8814 json_addr
, "outgoingUpdateNetworkFilterList",
8815 filter
->dlist
[FILTER_OUT
].name
);
8818 if (filter
->aslist
[FILTER_IN
].name
)
8819 json_object_string_add(json_addr
,
8820 "incomingUpdateAsPathFilterList",
8821 filter
->aslist
[FILTER_IN
].name
);
8822 if (filter
->aslist
[FILTER_OUT
].name
)
8823 json_object_string_add(json_addr
,
8824 "outgoingUpdateAsPathFilterList",
8825 filter
->aslist
[FILTER_OUT
].name
);
8828 if (filter
->map
[RMAP_IN
].name
)
8829 json_object_string_add(
8830 json_addr
, "routeMapForIncomingAdvertisements",
8831 filter
->map
[RMAP_IN
].name
);
8832 if (filter
->map
[RMAP_OUT
].name
)
8833 json_object_string_add(
8834 json_addr
, "routeMapForOutgoingAdvertisements",
8835 filter
->map
[RMAP_OUT
].name
);
8837 /* ebgp-requires-policy (inbound) */
8838 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8839 && !bgp_inbound_policy_exists(p
, filter
))
8840 json_object_string_add(
8841 json_addr
, "inboundEbgpRequiresPolicy",
8842 "Inbound updates discarded due to missing policy");
8844 /* ebgp-requires-policy (outbound) */
8845 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8846 && (!bgp_outbound_policy_exists(p
, filter
)))
8847 json_object_string_add(
8848 json_addr
, "outboundEbgpRequiresPolicy",
8849 "Outbound updates discarded due to missing policy");
8851 /* unsuppress-map */
8852 if (filter
->usmap
.name
)
8853 json_object_string_add(json_addr
,
8854 "selectiveUnsuppressRouteMap",
8855 filter
->usmap
.name
);
8857 /* Receive prefix count */
8858 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8859 p
->pcount
[afi
][safi
]);
8860 if (paf
&& PAF_SUBGRP(paf
))
8861 json_object_int_add(json_addr
, "sentPrefixCounter",
8862 (PAF_SUBGRP(paf
))->scount
);
8864 /* Maximum prefix */
8865 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8866 json_object_int_add(json_addr
, "prefixAllowedMax",
8867 p
->pmax
[afi
][safi
]);
8868 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8869 PEER_FLAG_MAX_PREFIX_WARNING
))
8870 json_object_boolean_true_add(
8871 json_addr
, "prefixAllowedMaxWarning");
8872 json_object_int_add(json_addr
,
8873 "prefixAllowedWarningThresh",
8874 p
->pmax_threshold
[afi
][safi
]);
8875 if (p
->pmax_restart
[afi
][safi
])
8876 json_object_int_add(
8878 "prefixAllowedRestartIntervalMsecs",
8879 p
->pmax_restart
[afi
][safi
] * 60000);
8881 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8885 filter
= &p
->filter
[afi
][safi
];
8887 vty_out(vty
, " For address family: %s\n",
8888 afi_safi_print(afi
, safi
));
8890 if (peer_group_active(p
))
8891 vty_out(vty
, " %s peer-group member\n",
8894 paf
= peer_af_find(p
, afi
, safi
);
8895 if (paf
&& PAF_SUBGRP(paf
)) {
8896 vty_out(vty
, " Update group %" PRIu64
8897 ", subgroup %" PRIu64
"\n",
8898 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8899 vty_out(vty
, " Packet Queue length %d\n",
8900 bpacket_queue_virtual_length(paf
));
8902 vty_out(vty
, " Not part of any update group\n");
8904 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8905 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8906 PEER_CAP_ORF_PREFIX_SM_RCV
)
8907 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8908 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8909 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8910 PEER_CAP_ORF_PREFIX_RM_ADV
)
8911 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8912 PEER_CAP_ORF_PREFIX_RM_RCV
)
8913 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8914 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8915 vty_out(vty
, " AF-dependant capabilities:\n");
8917 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8918 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8919 PEER_CAP_ORF_PREFIX_SM_RCV
)
8920 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8921 PEER_CAP_ORF_PREFIX_RM_ADV
)
8922 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8923 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8925 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8927 bgp_show_peer_afi_orf_cap(
8928 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8929 PEER_CAP_ORF_PREFIX_RM_ADV
,
8930 PEER_CAP_ORF_PREFIX_SM_RCV
,
8931 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8933 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8934 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8935 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8936 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8937 PEER_CAP_ORF_PREFIX_RM_ADV
)
8938 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8939 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8941 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8942 ORF_TYPE_PREFIX_OLD
);
8943 bgp_show_peer_afi_orf_cap(
8944 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8945 PEER_CAP_ORF_PREFIX_RM_ADV
,
8946 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8947 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8950 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8951 orf_pfx_count
= prefix_bgp_show_prefix_list(
8952 NULL
, afi
, orf_pfx_name
, use_json
);
8954 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8955 PEER_STATUS_ORF_PREFIX_SEND
)
8957 vty_out(vty
, " Outbound Route Filter (ORF):");
8958 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8959 PEER_STATUS_ORF_PREFIX_SEND
))
8960 vty_out(vty
, " sent;");
8962 vty_out(vty
, " received (%d entries)",
8966 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8967 PEER_STATUS_ORF_WAIT_REFRESH
))
8969 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8971 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8972 PEER_FLAG_REFLECTOR_CLIENT
))
8973 vty_out(vty
, " Route-Reflector Client\n");
8974 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8975 PEER_FLAG_RSERVER_CLIENT
))
8976 vty_out(vty
, " Route-Server Client\n");
8977 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8979 " Inbound soft reconfiguration allowed\n");
8981 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8982 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8984 " Private AS numbers (all) replaced in updates to this neighbor\n");
8985 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8986 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8988 " Private AS numbers replaced in updates to this neighbor\n");
8989 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8990 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8992 " Private AS numbers (all) removed in updates to this neighbor\n");
8993 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8994 PEER_FLAG_REMOVE_PRIVATE_AS
))
8996 " Private AS numbers removed in updates to this neighbor\n");
8998 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8999 vty_out(vty
, " %s\n",
9000 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9001 ->human_description
);
9003 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9005 " Override ASNs in outbound updates if aspath equals remote-as\n");
9007 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9008 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9009 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9010 vty_out(vty
, " NEXT_HOP is always this router\n");
9011 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9012 PEER_FLAG_AS_PATH_UNCHANGED
))
9014 " AS_PATH is propagated unchanged to this neighbor\n");
9015 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9016 PEER_FLAG_NEXTHOP_UNCHANGED
))
9018 " NEXT_HOP is propagated unchanged to this neighbor\n");
9019 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9021 " MED is propagated unchanged to this neighbor\n");
9022 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9023 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9024 PEER_FLAG_SEND_EXT_COMMUNITY
)
9025 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9026 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9028 " Community attribute sent to this neighbor");
9029 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9030 PEER_FLAG_SEND_COMMUNITY
)
9031 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9032 PEER_FLAG_SEND_EXT_COMMUNITY
)
9033 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9034 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9035 vty_out(vty
, "(all)\n");
9036 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9037 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9038 vty_out(vty
, "(large)\n");
9039 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9040 PEER_FLAG_SEND_EXT_COMMUNITY
))
9041 vty_out(vty
, "(extended)\n");
9043 vty_out(vty
, "(standard)\n");
9045 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9046 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9047 vty_out(vty
, " Default information originate,");
9049 if (p
->default_rmap
[afi
][safi
].name
)
9050 vty_out(vty
, " default route-map %s%s,",
9051 p
->default_rmap
[afi
][safi
].map
? "*"
9053 p
->default_rmap
[afi
][safi
].name
);
9054 if (paf
&& PAF_SUBGRP(paf
)
9055 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9056 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9057 vty_out(vty
, " default sent\n");
9059 vty_out(vty
, " default not sent\n");
9062 /* advertise-vni-all */
9063 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9064 if (is_evpn_enabled())
9065 vty_out(vty
, " advertise-all-vni\n");
9068 if (filter
->plist
[FILTER_IN
].name
9069 || filter
->dlist
[FILTER_IN
].name
9070 || filter
->aslist
[FILTER_IN
].name
9071 || filter
->map
[RMAP_IN
].name
)
9072 vty_out(vty
, " Inbound path policy configured\n");
9073 if (filter
->plist
[FILTER_OUT
].name
9074 || filter
->dlist
[FILTER_OUT
].name
9075 || filter
->aslist
[FILTER_OUT
].name
9076 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9077 vty_out(vty
, " Outbound path policy configured\n");
9080 if (filter
->plist
[FILTER_IN
].name
)
9082 " Incoming update prefix filter list is %s%s\n",
9083 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9084 filter
->plist
[FILTER_IN
].name
);
9085 if (filter
->plist
[FILTER_OUT
].name
)
9087 " Outgoing update prefix filter list is %s%s\n",
9088 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9089 filter
->plist
[FILTER_OUT
].name
);
9091 /* distribute-list */
9092 if (filter
->dlist
[FILTER_IN
].name
)
9094 " Incoming update network filter list is %s%s\n",
9095 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9096 filter
->dlist
[FILTER_IN
].name
);
9097 if (filter
->dlist
[FILTER_OUT
].name
)
9099 " Outgoing update network filter list is %s%s\n",
9100 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9101 filter
->dlist
[FILTER_OUT
].name
);
9104 if (filter
->aslist
[FILTER_IN
].name
)
9106 " Incoming update AS path filter list is %s%s\n",
9107 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9108 filter
->aslist
[FILTER_IN
].name
);
9109 if (filter
->aslist
[FILTER_OUT
].name
)
9111 " Outgoing update AS path filter list is %s%s\n",
9112 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9113 filter
->aslist
[FILTER_OUT
].name
);
9116 if (filter
->map
[RMAP_IN
].name
)
9118 " Route map for incoming advertisements is %s%s\n",
9119 filter
->map
[RMAP_IN
].map
? "*" : "",
9120 filter
->map
[RMAP_IN
].name
);
9121 if (filter
->map
[RMAP_OUT
].name
)
9123 " Route map for outgoing advertisements is %s%s\n",
9124 filter
->map
[RMAP_OUT
].map
? "*" : "",
9125 filter
->map
[RMAP_OUT
].name
);
9127 /* ebgp-requires-policy (inbound) */
9128 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9129 && !bgp_inbound_policy_exists(p
, filter
))
9131 " Inbound updates discarded due to missing policy\n");
9133 /* ebgp-requires-policy (outbound) */
9134 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9135 && !bgp_outbound_policy_exists(p
, filter
))
9137 " Outbound updates discarded due to missing policy\n");
9139 /* unsuppress-map */
9140 if (filter
->usmap
.name
)
9142 " Route map for selective unsuppress is %s%s\n",
9143 filter
->usmap
.map
? "*" : "",
9144 filter
->usmap
.name
);
9146 /* Receive prefix count */
9147 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9149 /* Maximum prefix */
9150 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9151 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9153 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9154 PEER_FLAG_MAX_PREFIX_WARNING
)
9157 vty_out(vty
, " Threshold for warning message %d%%",
9158 p
->pmax_threshold
[afi
][safi
]);
9159 if (p
->pmax_restart
[afi
][safi
])
9160 vty_out(vty
, ", restart interval %d min",
9161 p
->pmax_restart
[afi
][safi
]);
9169 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9173 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9174 char timebuf
[BGP_UPTIME_LEN
];
9176 const char *subcode_str
;
9177 const char *code_str
;
9182 json_object
*json_neigh
= NULL
;
9188 json_neigh
= json_object_new_object();
9190 memset(dn_flag
, '\0', sizeof(dn_flag
));
9191 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9195 if (p
->conf_if
) /* Configured interface name. */
9196 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9197 BGP_PEER_SU_UNSPEC(p
)
9199 : sockunion2str(&p
->su
, buf
,
9201 else /* Configured IP address. */
9202 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9207 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9208 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9210 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9211 json_object_string_add(
9212 json_neigh
, "bgpNeighborAddr",
9213 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9215 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9217 if (p
->change_local_as
)
9218 json_object_int_add(json_neigh
, "localAs",
9219 p
->change_local_as
);
9221 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9223 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9224 json_object_boolean_true_add(json_neigh
,
9225 "localAsNoPrepend");
9227 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9228 json_object_boolean_true_add(json_neigh
,
9229 "localAsReplaceAs");
9231 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9232 || (p
->as_type
== AS_INTERNAL
))
9233 vty_out(vty
, "remote AS %u, ", p
->as
);
9235 vty_out(vty
, "remote AS Unspecified, ");
9236 vty_out(vty
, "local AS %u%s%s, ",
9237 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9238 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9241 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9245 /* peer type internal or confed-internal */
9246 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9248 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9249 json_object_boolean_true_add(
9250 json_neigh
, "nbrConfedInternalLink");
9252 json_object_boolean_true_add(json_neigh
,
9255 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9256 vty_out(vty
, "confed-internal link\n");
9258 vty_out(vty
, "internal link\n");
9260 /* peer type external or confed-external */
9261 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9263 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9264 json_object_boolean_true_add(
9265 json_neigh
, "nbrConfedExternalLink");
9267 json_object_boolean_true_add(json_neigh
,
9270 if (bgp_confederation_peers_check(bgp
, p
->as
))
9271 vty_out(vty
, "confed-external link\n");
9273 vty_out(vty
, "external link\n");
9277 json_object_boolean_true_add(json_neigh
,
9278 "nbrUnspecifiedLink");
9280 vty_out(vty
, "unspecified link\n");
9286 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9288 vty_out(vty
, " Description: %s\n", p
->desc
);
9294 json_object_string_add(json_neigh
, "hostname",
9298 json_object_string_add(json_neigh
, "domainname",
9301 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9302 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9305 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9312 json_object_string_add(json_neigh
, "peerGroup",
9316 struct prefix prefix
, *range
= NULL
;
9318 sockunion2hostprefix(&(p
->su
), &prefix
);
9319 range
= peer_group_lookup_dynamic_neighbor_range(
9323 prefix2str(range
, buf1
, sizeof(buf1
));
9324 json_object_string_add(
9326 "peerSubnetRangeGroup", buf1
);
9331 " Member of peer-group %s for session parameters\n",
9335 struct prefix prefix
, *range
= NULL
;
9337 sockunion2hostprefix(&(p
->su
), &prefix
);
9338 range
= peer_group_lookup_dynamic_neighbor_range(
9342 prefix2str(range
, buf1
, sizeof(buf1
));
9344 " Belongs to the subnet range group: %s\n",
9352 /* Administrative shutdown. */
9353 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9354 json_object_boolean_true_add(json_neigh
,
9358 json_object_int_add(json_neigh
, "bgpVersion", 4);
9359 json_object_string_add(
9360 json_neigh
, "remoteRouterId",
9361 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9362 json_object_string_add(
9363 json_neigh
, "localRouterId",
9364 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9368 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9369 && bgp_confederation_peers_check(bgp
, p
->as
))
9370 json_object_boolean_true_add(json_neigh
,
9374 json_object_string_add(
9375 json_neigh
, "bgpState",
9376 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9378 if (p
->status
== Established
) {
9381 uptime
= bgp_clock();
9382 uptime
-= p
->uptime
;
9383 epoch_tbuf
= time(NULL
) - uptime
;
9385 #if CONFDATE > 20200101
9387 "bgpTimerUp should be deprecated and can be removed now");
9390 * bgpTimerUp was miliseconds that was accurate
9391 * up to 1 day, then the value returned
9392 * became garbage. So in order to provide
9393 * some level of backwards compatability,
9394 * we still provde the data, but now
9395 * we are returning the correct value
9396 * and also adding a new bgpTimerUpMsec
9397 * which will allow us to deprecate
9400 json_object_int_add(json_neigh
, "bgpTimerUp",
9402 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9404 json_object_string_add(json_neigh
, "bgpTimerUpString",
9405 peer_uptime(p
->uptime
, timebuf
,
9408 json_object_int_add(json_neigh
,
9409 "bgpTimerUpEstablishedEpoch",
9413 else if (p
->status
== Active
) {
9414 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9415 json_object_string_add(json_neigh
, "bgpStateIs",
9417 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9418 json_object_string_add(json_neigh
, "bgpStateIs",
9426 uptime
= bgp_clock();
9427 uptime
-= p
->readtime
;
9428 tm
= gmtime(&uptime
);
9429 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9430 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9431 + (tm
->tm_hour
* 3600000));
9433 uptime
= bgp_clock();
9434 uptime
-= p
->last_write
;
9435 tm
= gmtime(&uptime
);
9436 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9437 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9438 + (tm
->tm_hour
* 3600000));
9440 uptime
= bgp_clock();
9441 uptime
-= p
->update_time
;
9442 tm
= gmtime(&uptime
);
9443 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9444 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9445 + (tm
->tm_hour
* 3600000));
9447 /* Configured timer values. */
9448 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9449 p
->v_holdtime
* 1000);
9450 json_object_int_add(json_neigh
,
9451 "bgpTimerKeepAliveIntervalMsecs",
9452 p
->v_keepalive
* 1000);
9453 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9454 json_object_int_add(json_neigh
,
9455 "bgpTimerConfiguredHoldTimeMsecs",
9456 p
->holdtime
* 1000);
9457 json_object_int_add(
9459 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9460 p
->keepalive
* 1000);
9461 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9462 || (bgp
->default_keepalive
9463 != BGP_DEFAULT_KEEPALIVE
)) {
9464 json_object_int_add(json_neigh
,
9465 "bgpTimerConfiguredHoldTimeMsecs",
9466 bgp
->default_holdtime
);
9467 json_object_int_add(
9469 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9470 bgp
->default_keepalive
);
9473 /* Administrative shutdown. */
9474 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9475 vty_out(vty
, " Administratively shut down\n");
9478 vty_out(vty
, " BGP version 4");
9479 vty_out(vty
, ", remote router ID %s",
9480 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9481 vty_out(vty
, ", local router ID %s\n",
9482 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9486 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9487 && bgp_confederation_peers_check(bgp
, p
->as
))
9489 " Neighbor under common administration\n");
9492 vty_out(vty
, " BGP state = %s",
9493 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9495 if (p
->status
== Established
)
9496 vty_out(vty
, ", up for %8s",
9497 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9500 else if (p
->status
== Active
) {
9501 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9502 vty_out(vty
, " (passive)");
9503 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9504 vty_out(vty
, " (NSF passive)");
9509 vty_out(vty
, " Last read %s",
9510 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9512 vty_out(vty
, ", Last write %s\n",
9513 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9516 /* Configured timer values. */
9518 " Hold time is %d, keepalive interval is %d seconds\n",
9519 p
->v_holdtime
, p
->v_keepalive
);
9520 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9521 vty_out(vty
, " Configured hold time is %d",
9523 vty_out(vty
, ", keepalive interval is %d seconds\n",
9525 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9526 || (bgp
->default_keepalive
9527 != BGP_DEFAULT_KEEPALIVE
)) {
9528 vty_out(vty
, " Configured hold time is %d",
9529 bgp
->default_holdtime
);
9530 vty_out(vty
, ", keepalive interval is %d seconds\n",
9531 bgp
->default_keepalive
);
9535 if (p
->status
== Established
) {
9536 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9537 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9538 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9539 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9540 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9541 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9542 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9543 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9544 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9545 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9546 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9547 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9548 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9549 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9550 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9551 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9552 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9553 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9554 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9555 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9557 json_object
*json_cap
= NULL
;
9559 json_cap
= json_object_new_object();
9562 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9563 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9564 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9565 && CHECK_FLAG(p
->cap
,
9567 json_object_string_add(
9568 json_cap
, "4byteAs",
9569 "advertisedAndReceived");
9570 else if (CHECK_FLAG(p
->cap
,
9572 json_object_string_add(
9573 json_cap
, "4byteAs",
9575 else if (CHECK_FLAG(p
->cap
,
9577 json_object_string_add(
9578 json_cap
, "4byteAs",
9583 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9584 || CHECK_FLAG(p
->cap
,
9585 PEER_CAP_ADDPATH_ADV
)) {
9586 json_object
*json_add
= NULL
;
9587 const char *print_store
;
9589 json_add
= json_object_new_object();
9591 FOREACH_AFI_SAFI (afi
, safi
) {
9592 json_object
*json_sub
= NULL
;
9594 json_object_new_object();
9595 print_store
= afi_safi_print(
9601 PEER_CAP_ADDPATH_AF_TX_ADV
)
9605 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9610 PEER_CAP_ADDPATH_AF_TX_ADV
)
9615 PEER_CAP_ADDPATH_AF_TX_RCV
))
9616 json_object_boolean_true_add(
9618 "txAdvertisedAndReceived");
9624 PEER_CAP_ADDPATH_AF_TX_ADV
))
9625 json_object_boolean_true_add(
9633 PEER_CAP_ADDPATH_AF_TX_RCV
))
9634 json_object_boolean_true_add(
9642 PEER_CAP_ADDPATH_AF_RX_ADV
)
9646 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9651 PEER_CAP_ADDPATH_AF_RX_ADV
)
9656 PEER_CAP_ADDPATH_AF_RX_RCV
))
9657 json_object_boolean_true_add(
9659 "rxAdvertisedAndReceived");
9665 PEER_CAP_ADDPATH_AF_RX_ADV
))
9666 json_object_boolean_true_add(
9674 PEER_CAP_ADDPATH_AF_RX_RCV
))
9675 json_object_boolean_true_add(
9683 PEER_CAP_ADDPATH_AF_TX_ADV
)
9687 PEER_CAP_ADDPATH_AF_TX_RCV
)
9691 PEER_CAP_ADDPATH_AF_RX_ADV
)
9695 PEER_CAP_ADDPATH_AF_RX_RCV
))
9696 json_object_object_add(
9705 json_object_object_add(
9706 json_cap
, "addPath", json_add
);
9710 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9711 || CHECK_FLAG(p
->cap
,
9712 PEER_CAP_DYNAMIC_ADV
)) {
9713 if (CHECK_FLAG(p
->cap
,
9714 PEER_CAP_DYNAMIC_ADV
)
9715 && CHECK_FLAG(p
->cap
,
9716 PEER_CAP_DYNAMIC_RCV
))
9717 json_object_string_add(
9718 json_cap
, "dynamic",
9719 "advertisedAndReceived");
9720 else if (CHECK_FLAG(
9722 PEER_CAP_DYNAMIC_ADV
))
9723 json_object_string_add(
9724 json_cap
, "dynamic",
9726 else if (CHECK_FLAG(
9728 PEER_CAP_DYNAMIC_RCV
))
9729 json_object_string_add(
9730 json_cap
, "dynamic",
9734 /* Extended nexthop */
9735 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9736 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9737 json_object
*json_nxt
= NULL
;
9738 const char *print_store
;
9741 if (CHECK_FLAG(p
->cap
,
9743 && CHECK_FLAG(p
->cap
,
9745 json_object_string_add(
9748 "advertisedAndReceived");
9749 else if (CHECK_FLAG(p
->cap
,
9751 json_object_string_add(
9755 else if (CHECK_FLAG(p
->cap
,
9757 json_object_string_add(
9762 if (CHECK_FLAG(p
->cap
,
9763 PEER_CAP_ENHE_RCV
)) {
9765 json_object_new_object();
9767 for (safi
= SAFI_UNICAST
;
9768 safi
< SAFI_MAX
; safi
++) {
9773 PEER_CAP_ENHE_AF_RCV
)) {
9774 print_store
= afi_safi_print(
9777 json_object_string_add(
9780 "recieved"); /* misspelled for compatibility */
9783 json_object_object_add(
9785 "extendedNexthopFamililesByPeer",
9791 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9792 || CHECK_FLAG(p
->cap
,
9793 PEER_CAP_REFRESH_NEW_RCV
)
9794 || CHECK_FLAG(p
->cap
,
9795 PEER_CAP_REFRESH_OLD_RCV
)) {
9796 if (CHECK_FLAG(p
->cap
,
9797 PEER_CAP_REFRESH_ADV
)
9800 PEER_CAP_REFRESH_NEW_RCV
)
9803 PEER_CAP_REFRESH_OLD_RCV
))) {
9806 PEER_CAP_REFRESH_OLD_RCV
)
9809 PEER_CAP_REFRESH_NEW_RCV
))
9810 json_object_string_add(
9813 "advertisedAndReceivedOldNew");
9817 PEER_CAP_REFRESH_OLD_RCV
))
9818 json_object_string_add(
9821 "advertisedAndReceivedOld");
9823 json_object_string_add(
9826 "advertisedAndReceivedNew");
9831 PEER_CAP_REFRESH_ADV
))
9832 json_object_string_add(
9839 PEER_CAP_REFRESH_NEW_RCV
)
9842 PEER_CAP_REFRESH_OLD_RCV
))
9843 json_object_string_add(
9849 /* Multiprotocol Extensions */
9850 json_object
*json_multi
= NULL
;
9851 json_multi
= json_object_new_object();
9853 FOREACH_AFI_SAFI (afi
, safi
) {
9854 if (p
->afc_adv
[afi
][safi
]
9855 || p
->afc_recv
[afi
][safi
]) {
9856 json_object
*json_exten
= NULL
;
9858 json_object_new_object();
9860 if (p
->afc_adv
[afi
][safi
]
9861 && p
->afc_recv
[afi
][safi
])
9862 json_object_boolean_true_add(
9864 "advertisedAndReceived");
9865 else if (p
->afc_adv
[afi
][safi
])
9866 json_object_boolean_true_add(
9869 else if (p
->afc_recv
[afi
][safi
])
9870 json_object_boolean_true_add(
9874 json_object_object_add(
9881 json_object_object_add(
9882 json_cap
, "multiprotocolExtensions",
9885 /* Hostname capabilities */
9886 json_object
*json_hname
= NULL
;
9888 json_hname
= json_object_new_object();
9890 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9891 json_object_string_add(
9892 json_hname
, "advHostName",
9893 bgp
->peer_self
->hostname
9897 json_object_string_add(
9898 json_hname
, "advDomainName",
9899 bgp
->peer_self
->domainname
9906 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9907 json_object_string_add(
9908 json_hname
, "rcvHostName",
9909 p
->hostname
? p
->hostname
9911 json_object_string_add(
9912 json_hname
, "rcvDomainName",
9913 p
->domainname
? p
->domainname
9917 json_object_object_add(json_cap
, "hostName",
9920 /* Gracefull Restart */
9921 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9922 || CHECK_FLAG(p
->cap
,
9923 PEER_CAP_RESTART_ADV
)) {
9924 if (CHECK_FLAG(p
->cap
,
9925 PEER_CAP_RESTART_ADV
)
9926 && CHECK_FLAG(p
->cap
,
9927 PEER_CAP_RESTART_RCV
))
9928 json_object_string_add(
9931 "advertisedAndReceived");
9932 else if (CHECK_FLAG(
9934 PEER_CAP_RESTART_ADV
))
9935 json_object_string_add(
9937 "gracefulRestartCapability",
9939 else if (CHECK_FLAG(
9941 PEER_CAP_RESTART_RCV
))
9942 json_object_string_add(
9944 "gracefulRestartCapability",
9947 if (CHECK_FLAG(p
->cap
,
9948 PEER_CAP_RESTART_RCV
)) {
9949 int restart_af_count
= 0;
9950 json_object
*json_restart
=
9953 json_object_new_object();
9955 json_object_int_add(
9957 "gracefulRestartRemoteTimerMsecs",
9958 p
->v_gr_restart
* 1000);
9960 FOREACH_AFI_SAFI (afi
, safi
) {
9965 PEER_CAP_RESTART_AF_RCV
)) {
9970 json_object_new_object();
9976 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9977 json_object_boolean_true_add(
9981 json_object_object_add(
9989 if (!restart_af_count
) {
9990 json_object_string_add(
9992 "addressFamiliesByPeer",
9997 json_object_object_add(
9999 "addressFamiliesByPeer",
10003 json_object_object_add(json_neigh
,
10004 "neighborCapabilities",
10007 vty_out(vty
, " Neighbor capabilities:\n");
10010 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10011 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10012 vty_out(vty
, " 4 Byte AS:");
10013 if (CHECK_FLAG(p
->cap
,
10015 vty_out(vty
, " advertised");
10016 if (CHECK_FLAG(p
->cap
,
10018 vty_out(vty
, " %sreceived",
10024 vty_out(vty
, "\n");
10028 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10029 || CHECK_FLAG(p
->cap
,
10030 PEER_CAP_ADDPATH_ADV
)) {
10031 vty_out(vty
, " AddPath:\n");
10033 FOREACH_AFI_SAFI (afi
, safi
) {
10037 PEER_CAP_ADDPATH_AF_TX_ADV
)
10041 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10052 PEER_CAP_ADDPATH_AF_TX_ADV
))
10063 PEER_CAP_ADDPATH_AF_TX_RCV
))
10070 PEER_CAP_ADDPATH_AF_TX_ADV
)
10074 vty_out(vty
, "\n");
10080 PEER_CAP_ADDPATH_AF_RX_ADV
)
10084 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10095 PEER_CAP_ADDPATH_AF_RX_ADV
))
10106 PEER_CAP_ADDPATH_AF_RX_RCV
))
10113 PEER_CAP_ADDPATH_AF_RX_ADV
)
10117 vty_out(vty
, "\n");
10123 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10124 || CHECK_FLAG(p
->cap
,
10125 PEER_CAP_DYNAMIC_ADV
)) {
10126 vty_out(vty
, " Dynamic:");
10127 if (CHECK_FLAG(p
->cap
,
10128 PEER_CAP_DYNAMIC_ADV
))
10129 vty_out(vty
, " advertised");
10130 if (CHECK_FLAG(p
->cap
,
10131 PEER_CAP_DYNAMIC_RCV
))
10132 vty_out(vty
, " %sreceived",
10135 PEER_CAP_DYNAMIC_ADV
)
10138 vty_out(vty
, "\n");
10141 /* Extended nexthop */
10142 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10143 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10144 vty_out(vty
, " Extended nexthop:");
10145 if (CHECK_FLAG(p
->cap
,
10146 PEER_CAP_ENHE_ADV
))
10147 vty_out(vty
, " advertised");
10148 if (CHECK_FLAG(p
->cap
,
10149 PEER_CAP_ENHE_RCV
))
10150 vty_out(vty
, " %sreceived",
10156 vty_out(vty
, "\n");
10158 if (CHECK_FLAG(p
->cap
,
10159 PEER_CAP_ENHE_RCV
)) {
10161 " Address families by peer:\n ");
10162 for (safi
= SAFI_UNICAST
;
10163 safi
< SAFI_MAX
; safi
++)
10168 PEER_CAP_ENHE_AF_RCV
))
10177 /* Route Refresh */
10178 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10179 || CHECK_FLAG(p
->cap
,
10180 PEER_CAP_REFRESH_NEW_RCV
)
10181 || CHECK_FLAG(p
->cap
,
10182 PEER_CAP_REFRESH_OLD_RCV
)) {
10183 vty_out(vty
, " Route refresh:");
10184 if (CHECK_FLAG(p
->cap
,
10185 PEER_CAP_REFRESH_ADV
))
10186 vty_out(vty
, " advertised");
10187 if (CHECK_FLAG(p
->cap
,
10188 PEER_CAP_REFRESH_NEW_RCV
)
10191 PEER_CAP_REFRESH_OLD_RCV
))
10192 vty_out(vty
, " %sreceived(%s)",
10195 PEER_CAP_REFRESH_ADV
)
10200 PEER_CAP_REFRESH_OLD_RCV
)
10203 PEER_CAP_REFRESH_NEW_RCV
))
10207 PEER_CAP_REFRESH_OLD_RCV
)
10211 vty_out(vty
, "\n");
10214 /* Multiprotocol Extensions */
10215 FOREACH_AFI_SAFI (afi
, safi
)
10216 if (p
->afc_adv
[afi
][safi
]
10217 || p
->afc_recv
[afi
][safi
]) {
10219 " Address Family %s:",
10220 afi_safi_print(afi
,
10222 if (p
->afc_adv
[afi
][safi
])
10225 if (p
->afc_recv
[afi
][safi
])
10232 vty_out(vty
, "\n");
10235 /* Hostname capability */
10236 vty_out(vty
, " Hostname Capability:");
10238 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10240 " advertised (name: %s,domain name: %s)",
10241 bgp
->peer_self
->hostname
10245 bgp
->peer_self
->domainname
10250 vty_out(vty
, " not advertised");
10253 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10255 " received (name: %s,domain name: %s)",
10256 p
->hostname
? p
->hostname
10258 p
->domainname
? p
->domainname
10261 vty_out(vty
, " not received");
10264 vty_out(vty
, "\n");
10266 /* Gracefull Restart */
10267 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10268 || CHECK_FLAG(p
->cap
,
10269 PEER_CAP_RESTART_ADV
)) {
10271 " Graceful Restart Capabilty:");
10272 if (CHECK_FLAG(p
->cap
,
10273 PEER_CAP_RESTART_ADV
))
10274 vty_out(vty
, " advertised");
10275 if (CHECK_FLAG(p
->cap
,
10276 PEER_CAP_RESTART_RCV
))
10277 vty_out(vty
, " %sreceived",
10280 PEER_CAP_RESTART_ADV
)
10283 vty_out(vty
, "\n");
10285 if (CHECK_FLAG(p
->cap
,
10286 PEER_CAP_RESTART_RCV
)) {
10287 int restart_af_count
= 0;
10290 " Remote Restart timer is %d seconds\n",
10293 " Address families by peer:\n ");
10295 FOREACH_AFI_SAFI (afi
, safi
)
10300 PEER_CAP_RESTART_AF_RCV
)) {
10313 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10315 : "not preserved");
10316 restart_af_count
++;
10318 if (!restart_af_count
)
10319 vty_out(vty
, "none");
10320 vty_out(vty
, "\n");
10327 /* graceful restart information */
10328 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10329 || p
->t_gr_stale
) {
10330 json_object
*json_grace
= NULL
;
10331 json_object
*json_grace_send
= NULL
;
10332 json_object
*json_grace_recv
= NULL
;
10333 int eor_send_af_count
= 0;
10334 int eor_receive_af_count
= 0;
10337 json_grace
= json_object_new_object();
10338 json_grace_send
= json_object_new_object();
10339 json_grace_recv
= json_object_new_object();
10341 if (p
->status
== Established
) {
10342 FOREACH_AFI_SAFI (afi
, safi
) {
10343 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10344 PEER_STATUS_EOR_SEND
)) {
10345 json_object_boolean_true_add(
10347 afi_safi_print(afi
,
10349 eor_send_af_count
++;
10352 FOREACH_AFI_SAFI (afi
, safi
) {
10354 p
->af_sflags
[afi
][safi
],
10355 PEER_STATUS_EOR_RECEIVED
)) {
10356 json_object_boolean_true_add(
10358 afi_safi_print(afi
,
10360 eor_receive_af_count
++;
10365 json_object_object_add(json_grace
, "endOfRibSend",
10367 json_object_object_add(json_grace
, "endOfRibRecv",
10370 if (p
->t_gr_restart
)
10371 json_object_int_add(json_grace
,
10372 "gracefulRestartTimerMsecs",
10373 thread_timer_remain_second(
10378 json_object_int_add(
10380 "gracefulStalepathTimerMsecs",
10381 thread_timer_remain_second(
10385 json_object_object_add(
10386 json_neigh
, "gracefulRestartInfo", json_grace
);
10388 vty_out(vty
, " Graceful restart information:\n");
10389 if (p
->status
== Established
) {
10390 vty_out(vty
, " End-of-RIB send: ");
10391 FOREACH_AFI_SAFI (afi
, safi
) {
10392 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10393 PEER_STATUS_EOR_SEND
)) {
10394 vty_out(vty
, "%s%s",
10395 eor_send_af_count
? ", "
10397 afi_safi_print(afi
,
10399 eor_send_af_count
++;
10402 vty_out(vty
, "\n");
10403 vty_out(vty
, " End-of-RIB received: ");
10404 FOREACH_AFI_SAFI (afi
, safi
) {
10406 p
->af_sflags
[afi
][safi
],
10407 PEER_STATUS_EOR_RECEIVED
)) {
10408 vty_out(vty
, "%s%s",
10409 eor_receive_af_count
10412 afi_safi_print(afi
,
10414 eor_receive_af_count
++;
10417 vty_out(vty
, "\n");
10420 if (p
->t_gr_restart
)
10422 " The remaining time of restart timer is %ld\n",
10423 thread_timer_remain_second(
10428 " The remaining time of stalepath timer is %ld\n",
10429 thread_timer_remain_second(
10434 json_object
*json_stat
= NULL
;
10435 json_stat
= json_object_new_object();
10436 /* Packet counts. */
10437 json_object_int_add(json_stat
, "depthInq", 0);
10438 json_object_int_add(json_stat
, "depthOutq",
10439 (unsigned long)p
->obuf
->count
);
10440 json_object_int_add(json_stat
, "opensSent",
10441 atomic_load_explicit(&p
->open_out
,
10442 memory_order_relaxed
));
10443 json_object_int_add(json_stat
, "opensRecv",
10444 atomic_load_explicit(&p
->open_in
,
10445 memory_order_relaxed
));
10446 json_object_int_add(json_stat
, "notificationsSent",
10447 atomic_load_explicit(&p
->notify_out
,
10448 memory_order_relaxed
));
10449 json_object_int_add(json_stat
, "notificationsRecv",
10450 atomic_load_explicit(&p
->notify_in
,
10451 memory_order_relaxed
));
10452 json_object_int_add(json_stat
, "updatesSent",
10453 atomic_load_explicit(&p
->update_out
,
10454 memory_order_relaxed
));
10455 json_object_int_add(json_stat
, "updatesRecv",
10456 atomic_load_explicit(&p
->update_in
,
10457 memory_order_relaxed
));
10458 json_object_int_add(json_stat
, "keepalivesSent",
10459 atomic_load_explicit(&p
->keepalive_out
,
10460 memory_order_relaxed
));
10461 json_object_int_add(json_stat
, "keepalivesRecv",
10462 atomic_load_explicit(&p
->keepalive_in
,
10463 memory_order_relaxed
));
10464 json_object_int_add(json_stat
, "routeRefreshSent",
10465 atomic_load_explicit(&p
->refresh_out
,
10466 memory_order_relaxed
));
10467 json_object_int_add(json_stat
, "routeRefreshRecv",
10468 atomic_load_explicit(&p
->refresh_in
,
10469 memory_order_relaxed
));
10470 json_object_int_add(json_stat
, "capabilitySent",
10471 atomic_load_explicit(&p
->dynamic_cap_out
,
10472 memory_order_relaxed
));
10473 json_object_int_add(json_stat
, "capabilityRecv",
10474 atomic_load_explicit(&p
->dynamic_cap_in
,
10475 memory_order_relaxed
));
10476 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10477 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10478 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10480 /* Packet counts. */
10481 vty_out(vty
, " Message statistics:\n");
10482 vty_out(vty
, " Inq depth is 0\n");
10483 vty_out(vty
, " Outq depth is %lu\n",
10484 (unsigned long)p
->obuf
->count
);
10485 vty_out(vty
, " Sent Rcvd\n");
10486 vty_out(vty
, " Opens: %10d %10d\n",
10487 atomic_load_explicit(&p
->open_out
,
10488 memory_order_relaxed
),
10489 atomic_load_explicit(&p
->open_in
,
10490 memory_order_relaxed
));
10491 vty_out(vty
, " Notifications: %10d %10d\n",
10492 atomic_load_explicit(&p
->notify_out
,
10493 memory_order_relaxed
),
10494 atomic_load_explicit(&p
->notify_in
,
10495 memory_order_relaxed
));
10496 vty_out(vty
, " Updates: %10d %10d\n",
10497 atomic_load_explicit(&p
->update_out
,
10498 memory_order_relaxed
),
10499 atomic_load_explicit(&p
->update_in
,
10500 memory_order_relaxed
));
10501 vty_out(vty
, " Keepalives: %10d %10d\n",
10502 atomic_load_explicit(&p
->keepalive_out
,
10503 memory_order_relaxed
),
10504 atomic_load_explicit(&p
->keepalive_in
,
10505 memory_order_relaxed
));
10506 vty_out(vty
, " Route Refresh: %10d %10d\n",
10507 atomic_load_explicit(&p
->refresh_out
,
10508 memory_order_relaxed
),
10509 atomic_load_explicit(&p
->refresh_in
,
10510 memory_order_relaxed
));
10511 vty_out(vty
, " Capability: %10d %10d\n",
10512 atomic_load_explicit(&p
->dynamic_cap_out
,
10513 memory_order_relaxed
),
10514 atomic_load_explicit(&p
->dynamic_cap_in
,
10515 memory_order_relaxed
));
10516 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10521 /* advertisement-interval */
10522 json_object_int_add(json_neigh
,
10523 "minBtwnAdvertisementRunsTimerMsecs",
10524 p
->v_routeadv
* 1000);
10526 /* Update-source. */
10527 if (p
->update_if
|| p
->update_source
) {
10529 json_object_string_add(json_neigh
,
10532 else if (p
->update_source
)
10533 json_object_string_add(
10534 json_neigh
, "updateSource",
10535 sockunion2str(p
->update_source
, buf1
,
10539 /* advertisement-interval */
10541 " Minimum time between advertisement runs is %d seconds\n",
10544 /* Update-source. */
10545 if (p
->update_if
|| p
->update_source
) {
10546 vty_out(vty
, " Update source is ");
10548 vty_out(vty
, "%s", p
->update_if
);
10549 else if (p
->update_source
)
10551 sockunion2str(p
->update_source
, buf1
,
10553 vty_out(vty
, "\n");
10556 vty_out(vty
, "\n");
10559 /* Address Family Information */
10560 json_object
*json_hold
= NULL
;
10563 json_hold
= json_object_new_object();
10565 FOREACH_AFI_SAFI (afi
, safi
)
10566 if (p
->afc
[afi
][safi
])
10567 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10571 json_object_object_add(json_neigh
, "addressFamilyInfo",
10573 json_object_int_add(json_neigh
, "connectionsEstablished",
10575 json_object_int_add(json_neigh
, "connectionsDropped",
10578 vty_out(vty
, " Connections established %d; dropped %d\n",
10579 p
->established
, p
->dropped
);
10581 if (!p
->last_reset
) {
10583 json_object_string_add(json_neigh
, "lastReset",
10586 vty_out(vty
, " Last reset never\n");
10592 uptime
= bgp_clock();
10593 uptime
-= p
->resettime
;
10594 tm
= gmtime(&uptime
);
10595 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10596 (tm
->tm_sec
* 1000)
10597 + (tm
->tm_min
* 60000)
10598 + (tm
->tm_hour
* 3600000));
10599 json_object_string_add(
10600 json_neigh
, "lastResetDueTo",
10601 peer_down_str
[(int)p
->last_reset
]);
10602 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10603 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10604 char errorcodesubcode_hexstr
[5];
10605 char errorcodesubcode_str
[256];
10607 code_str
= bgp_notify_code_str(p
->notify
.code
);
10608 subcode_str
= bgp_notify_subcode_str(
10609 p
->notify
.code
, p
->notify
.subcode
);
10611 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10612 p
->notify
.code
, p
->notify
.subcode
);
10613 json_object_string_add(json_neigh
,
10614 "lastErrorCodeSubcode",
10615 errorcodesubcode_hexstr
);
10616 snprintf(errorcodesubcode_str
, 255, "%s%s",
10617 code_str
, subcode_str
);
10618 json_object_string_add(json_neigh
,
10619 "lastNotificationReason",
10620 errorcodesubcode_str
);
10621 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10622 && p
->notify
.code
== BGP_NOTIFY_CEASE
10623 && (p
->notify
.subcode
10624 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10625 || p
->notify
.subcode
10626 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10627 && p
->notify
.length
) {
10629 const char *msg_str
;
10631 msg_str
= bgp_notify_admin_message(
10632 msgbuf
, sizeof(msgbuf
),
10633 (uint8_t *)p
->notify
.data
,
10636 json_object_string_add(
10638 "lastShutdownDescription",
10643 vty_out(vty
, " Last reset %s, ",
10644 peer_uptime(p
->resettime
, timebuf
,
10645 BGP_UPTIME_LEN
, 0, NULL
));
10647 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10648 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10649 code_str
= bgp_notify_code_str(p
->notify
.code
);
10650 subcode_str
= bgp_notify_subcode_str(
10651 p
->notify
.code
, p
->notify
.subcode
);
10652 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10653 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10656 code_str
, subcode_str
);
10657 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10658 && p
->notify
.code
== BGP_NOTIFY_CEASE
10659 && (p
->notify
.subcode
10660 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10661 || p
->notify
.subcode
10662 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10663 && p
->notify
.length
) {
10665 const char *msg_str
;
10667 msg_str
= bgp_notify_admin_message(
10668 msgbuf
, sizeof(msgbuf
),
10669 (uint8_t *)p
->notify
.data
,
10673 " Message: \"%s\"\n",
10677 vty_out(vty
, "due to %s\n",
10678 peer_down_str
[(int)p
->last_reset
]);
10681 if (p
->last_reset_cause_size
) {
10682 msg
= p
->last_reset_cause
;
10684 " Message received that caused BGP to send a NOTIFICATION:\n ");
10685 for (i
= 1; i
<= p
->last_reset_cause_size
;
10687 vty_out(vty
, "%02X", *msg
++);
10689 if (i
!= p
->last_reset_cause_size
) {
10691 vty_out(vty
, "\n ");
10692 } else if (i
% 4 == 0) {
10697 vty_out(vty
, "\n");
10702 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10704 json_object_boolean_true_add(json_neigh
,
10705 "prefixesConfigExceedMax");
10708 " Peer had exceeded the max. no. of prefixes configured.\n");
10710 if (p
->t_pmax_restart
) {
10712 json_object_boolean_true_add(
10713 json_neigh
, "reducePrefixNumFrom");
10714 json_object_int_add(json_neigh
,
10715 "restartInTimerMsec",
10716 thread_timer_remain_second(
10721 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10722 p
->host
, thread_timer_remain_second(
10723 p
->t_pmax_restart
));
10726 json_object_boolean_true_add(
10728 "reducePrefixNumAndClearIpBgp");
10731 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10736 /* EBGP Multihop and GTSM */
10737 if (p
->sort
!= BGP_PEER_IBGP
) {
10739 if (p
->gtsm_hops
> 0)
10740 json_object_int_add(json_neigh
,
10741 "externalBgpNbrMaxHopsAway",
10743 else if (p
->ttl
> 1)
10744 json_object_int_add(json_neigh
,
10745 "externalBgpNbrMaxHopsAway",
10748 if (p
->gtsm_hops
> 0)
10750 " External BGP neighbor may be up to %d hops away.\n",
10752 else if (p
->ttl
> 1)
10754 " External BGP neighbor may be up to %d hops away.\n",
10758 if (p
->gtsm_hops
> 0) {
10760 json_object_int_add(json_neigh
,
10761 "internalBgpNbrMaxHopsAway",
10765 " Internal BGP neighbor may be up to %d hops away.\n",
10770 /* Local address. */
10773 json_object_string_add(json_neigh
, "hostLocal",
10774 sockunion2str(p
->su_local
, buf1
,
10776 json_object_int_add(json_neigh
, "portLocal",
10777 ntohs(p
->su_local
->sin
.sin_port
));
10779 vty_out(vty
, "Local host: %s, Local port: %d\n",
10780 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10781 ntohs(p
->su_local
->sin
.sin_port
));
10784 /* Remote address. */
10785 if (p
->su_remote
) {
10787 json_object_string_add(json_neigh
, "hostForeign",
10788 sockunion2str(p
->su_remote
, buf1
,
10790 json_object_int_add(json_neigh
, "portForeign",
10791 ntohs(p
->su_remote
->sin
.sin_port
));
10793 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10794 sockunion2str(p
->su_remote
, buf1
,
10796 ntohs(p
->su_remote
->sin
.sin_port
));
10799 /* Nexthop display. */
10802 json_object_string_add(json_neigh
, "nexthop",
10804 &p
->nexthop
.v4
, buf1
,
10806 json_object_string_add(json_neigh
, "nexthopGlobal",
10807 inet_ntop(AF_INET6
,
10808 &p
->nexthop
.v6_global
,
10809 buf1
, sizeof(buf1
)));
10810 json_object_string_add(json_neigh
, "nexthopLocal",
10811 inet_ntop(AF_INET6
,
10812 &p
->nexthop
.v6_local
,
10813 buf1
, sizeof(buf1
)));
10814 if (p
->shared_network
)
10815 json_object_string_add(json_neigh
,
10819 json_object_string_add(json_neigh
,
10821 "nonSharedNetwork");
10823 vty_out(vty
, "Nexthop: %s\n",
10824 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10826 vty_out(vty
, "Nexthop global: %s\n",
10827 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10829 vty_out(vty
, "Nexthop local: %s\n",
10830 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10832 vty_out(vty
, "BGP connection: %s\n",
10833 p
->shared_network
? "shared network"
10834 : "non shared network");
10838 /* Timer information. */
10840 json_object_int_add(json_neigh
, "connectRetryTimer",
10842 if (p
->status
== Established
&& p
->rtt
)
10843 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10846 json_object_int_add(
10847 json_neigh
, "nextStartTimerDueInMsecs",
10848 thread_timer_remain_second(p
->t_start
) * 1000);
10850 json_object_int_add(
10851 json_neigh
, "nextConnectTimerDueInMsecs",
10852 thread_timer_remain_second(p
->t_connect
)
10854 if (p
->t_routeadv
) {
10855 json_object_int_add(json_neigh
, "mraiInterval",
10857 json_object_int_add(
10858 json_neigh
, "mraiTimerExpireInMsecs",
10859 thread_timer_remain_second(p
->t_routeadv
)
10863 json_object_int_add(json_neigh
, "authenticationEnabled",
10867 json_object_string_add(json_neigh
, "readThread", "on");
10869 json_object_string_add(json_neigh
, "readThread", "off");
10871 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10872 json_object_string_add(json_neigh
, "writeThread", "on");
10874 json_object_string_add(json_neigh
, "writeThread",
10877 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10879 if (p
->status
== Established
&& p
->rtt
)
10880 vty_out(vty
, "Estimated round trip time: %d ms\n",
10883 vty_out(vty
, "Next start timer due in %ld seconds\n",
10884 thread_timer_remain_second(p
->t_start
));
10886 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10887 thread_timer_remain_second(p
->t_connect
));
10890 "MRAI (interval %u) timer expires in %ld seconds\n",
10892 thread_timer_remain_second(p
->t_routeadv
));
10894 vty_out(vty
, "Peer Authentication Enabled\n");
10896 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10897 p
->t_read
? "on" : "off",
10898 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10903 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10904 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10905 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10908 vty_out(vty
, "\n");
10910 /* BFD information. */
10911 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10914 if (p
->conf_if
) /* Configured interface name. */
10915 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10916 else /* Configured IP address. */
10917 json_object_object_add(json
, p
->host
, json_neigh
);
10921 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10922 enum show_type type
, union sockunion
*su
,
10923 const char *conf_if
, bool use_json
,
10926 struct listnode
*node
, *nnode
;
10929 bool nbr_output
= false;
10930 afi_t afi
= AFI_MAX
;
10931 safi_t safi
= SAFI_MAX
;
10933 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10935 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10939 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10940 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10945 bgp_show_peer(vty
, peer
, use_json
, json
);
10951 && !strcmp(peer
->conf_if
, conf_if
))
10953 && !strcmp(peer
->hostname
, conf_if
))) {
10955 bgp_show_peer(vty
, peer
, use_json
,
10959 if (sockunion_same(&peer
->su
, su
)) {
10961 bgp_show_peer(vty
, peer
, use_json
,
10966 case show_ipv4_peer
:
10967 case show_ipv6_peer
:
10968 FOREACH_SAFI (safi
) {
10969 if (peer
->afc
[afi
][safi
]) {
10972 && !strcmp(peer
->conf_if
, conf_if
))
10974 && !strcmp(peer
->hostname
, conf_if
))) {
10976 bgp_show_peer(vty
, peer
, use_json
,
10981 if (sockunion_same(&peer
->su
, su
)) {
10983 bgp_show_peer(vty
, peer
, use_json
,
10991 case show_ipv4_all
:
10992 case show_ipv6_all
:
10993 FOREACH_SAFI (safi
) {
10994 if (peer
->afc
[afi
][safi
]) {
10995 bgp_show_peer(vty
, peer
, use_json
, json
);
11004 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11005 type
== show_ipv6_peer
) && !find
) {
11007 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11009 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11012 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11013 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11014 vty_out(vty
, "%% No BGP neighbors found\n");
11017 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11018 json
, JSON_C_TO_STRING_PRETTY
));
11020 vty_out(vty
, "\n");
11023 return CMD_SUCCESS
;
11026 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11027 enum show_type type
,
11028 const char *ip_str
,
11031 struct listnode
*node
, *nnode
;
11033 union sockunion su
;
11034 json_object
*json
= NULL
;
11035 int ret
, is_first
= 1;
11036 bool nbr_output
= false;
11039 vty_out(vty
, "{\n");
11041 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11044 if (!(json
= json_object_new_object())) {
11046 EC_BGP_JSON_MEM_ERROR
,
11047 "Unable to allocate memory for JSON object");
11049 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11053 json_object_int_add(json
, "vrfId",
11054 (bgp
->vrf_id
== VRF_UNKNOWN
)
11056 : (int64_t)bgp
->vrf_id
);
11057 json_object_string_add(
11059 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11064 vty_out(vty
, ",\n");
11068 vty_out(vty
, "\"%s\":",
11069 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11073 vty_out(vty
, "\nInstance %s:\n",
11074 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11079 if (type
== show_peer
|| type
== show_ipv4_peer
||
11080 type
== show_ipv6_peer
) {
11081 ret
= str2sockunion(ip_str
, &su
);
11083 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11086 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11089 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11092 json_object_free(json
);
11096 vty_out(vty
, "}\n");
11097 json_object_free(json
);
11099 else if (!nbr_output
)
11100 vty_out(vty
, "%% BGP instance not found\n");
11103 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11104 enum show_type type
, const char *ip_str
,
11109 union sockunion su
;
11110 json_object
*json
= NULL
;
11113 if (strmatch(name
, "all")) {
11114 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11116 return CMD_SUCCESS
;
11118 bgp
= bgp_lookup_by_name(name
);
11121 json
= json_object_new_object();
11122 vty_out(vty
, "%s\n",
11123 json_object_to_json_string_ext(
11125 JSON_C_TO_STRING_PRETTY
));
11126 json_object_free(json
);
11129 "%% BGP instance not found\n");
11131 return CMD_WARNING
;
11135 bgp
= bgp_get_default();
11139 json
= json_object_new_object();
11141 ret
= str2sockunion(ip_str
, &su
);
11143 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11146 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11149 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11152 json_object_free(json
);
11155 vty_out(vty
, "{}\n");
11157 vty_out(vty
, "%% BGP instance not found\n");
11160 return CMD_SUCCESS
;
11163 /* "show [ip] bgp neighbors" commands. */
11164 DEFUN (show_ip_bgp_neighbors
,
11165 show_ip_bgp_neighbors_cmd
,
11166 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11170 BGP_INSTANCE_HELP_STR
11173 "Detailed information on TCP and BGP neighbor connections\n"
11174 "Neighbor to display information about\n"
11175 "Neighbor to display information about\n"
11176 "Neighbor on BGP configured interface\n"
11180 char *sh_arg
= NULL
;
11181 enum show_type sh_type
;
11182 afi_t afi
= AFI_MAX
;
11184 bool uj
= use_json(argc
, argv
);
11188 /* [<vrf> VIEWVRFNAME] */
11189 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11190 vrf
= argv
[idx
+ 1]->arg
;
11191 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11193 } else if (argv_find(argv
, argc
, "view", &idx
))
11194 /* [<view> VIEWVRFNAME] */
11195 vrf
= argv
[idx
+ 1]->arg
;
11199 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11200 sh_type
= show_ipv4_all
;
11202 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11203 sh_type
= show_ipv6_all
;
11206 sh_type
= show_all
;
11209 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11210 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11211 || argv_find(argv
, argc
, "WORD", &idx
)) {
11212 sh_type
= show_peer
;
11213 sh_arg
= argv
[idx
]->arg
;
11216 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11217 sh_type
= show_ipv4_peer
;
11218 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11219 sh_type
= show_ipv6_peer
;
11222 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11225 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11226 paths' and `show ip mbgp paths'. Those functions results are the
11228 DEFUN (show_ip_bgp_paths
,
11229 show_ip_bgp_paths_cmd
,
11230 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11235 "Path information\n")
11237 vty_out(vty
, "Address Refcnt Path\n");
11238 aspath_print_all_vty(vty
);
11239 return CMD_SUCCESS
;
11244 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11247 struct community
*com
;
11249 com
= (struct community
*)bucket
->data
;
11250 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11251 community_str(com
, false));
11254 /* Show BGP's community internal data. */
11255 DEFUN (show_ip_bgp_community_info
,
11256 show_ip_bgp_community_info_cmd
,
11257 "show [ip] bgp community-info",
11261 "List all bgp community information\n")
11263 vty_out(vty
, "Address Refcnt Community\n");
11265 hash_iterate(community_hash(),
11266 (void (*)(struct hash_bucket
*,
11267 void *))community_show_all_iterator
,
11270 return CMD_SUCCESS
;
11273 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11276 struct lcommunity
*lcom
;
11278 lcom
= (struct lcommunity
*)bucket
->data
;
11279 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11280 lcommunity_str(lcom
, false));
11283 /* Show BGP's community internal data. */
11284 DEFUN (show_ip_bgp_lcommunity_info
,
11285 show_ip_bgp_lcommunity_info_cmd
,
11286 "show ip bgp large-community-info",
11290 "List all bgp large-community information\n")
11292 vty_out(vty
, "Address Refcnt Large-community\n");
11294 hash_iterate(lcommunity_hash(),
11295 (void (*)(struct hash_bucket
*,
11296 void *))lcommunity_show_all_iterator
,
11299 return CMD_SUCCESS
;
11303 DEFUN (show_ip_bgp_attr_info
,
11304 show_ip_bgp_attr_info_cmd
,
11305 "show [ip] bgp attribute-info",
11309 "List all bgp attribute information\n")
11311 attr_show_all(vty
);
11312 return CMD_SUCCESS
;
11315 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11316 afi_t afi
, safi_t safi
,
11317 bool use_json
, json_object
*json
)
11320 struct listnode
*node
;
11322 char buf1
[INET6_ADDRSTRLEN
];
11324 vpn_policy_direction_t dir
;
11327 json_object
*json_import_vrfs
= NULL
;
11328 json_object
*json_export_vrfs
= NULL
;
11330 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11333 vty_out(vty
, "%s\n",
11334 json_object_to_json_string_ext(
11336 JSON_C_TO_STRING_PRETTY
));
11337 json_object_free(json
);
11339 return CMD_WARNING
;
11342 /* Provide context for the block */
11343 json_object_string_add(json
, "vrf", name
? name
: "default");
11344 json_object_string_add(json
, "afiSafi",
11345 afi_safi_print(afi
, safi
));
11347 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11348 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11349 json_object_string_add(json
, "importFromVrfs", "none");
11350 json_object_string_add(json
, "importRts", "none");
11352 json_import_vrfs
= json_object_new_array();
11354 for (ALL_LIST_ELEMENTS_RO(
11355 bgp
->vpn_policy
[afi
].import_vrf
,
11357 json_object_array_add(json_import_vrfs
,
11358 json_object_new_string(vname
));
11360 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11361 ecom_str
= ecommunity_ecom2str(
11362 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11363 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11364 json_object_object_add(json
, "importFromVrfs",
11366 json_object_string_add(json
, "importRts", ecom_str
);
11368 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11371 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11372 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11373 json_object_string_add(json
, "exportToVrfs", "none");
11374 json_object_string_add(json
, "routeDistinguisher",
11376 json_object_string_add(json
, "exportRts", "none");
11378 json_export_vrfs
= json_object_new_array();
11380 for (ALL_LIST_ELEMENTS_RO(
11381 bgp
->vpn_policy
[afi
].export_vrf
,
11383 json_object_array_add(json_export_vrfs
,
11384 json_object_new_string(vname
));
11385 json_object_object_add(json
, "exportToVrfs",
11387 json_object_string_add(json
, "routeDistinguisher",
11388 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11389 buf1
, RD_ADDRSTRLEN
));
11391 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11392 ecom_str
= ecommunity_ecom2str(
11393 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11394 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11395 json_object_string_add(json
, "exportRts", ecom_str
);
11397 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11401 vty_out(vty
, "%s\n",
11402 json_object_to_json_string_ext(json
,
11403 JSON_C_TO_STRING_PRETTY
));
11404 json_object_free(json
);
11407 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11410 vty_out(vty
, "%% No such BGP instance exist\n");
11411 return CMD_WARNING
;
11414 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11415 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11417 "This VRF is not importing %s routes from any other VRF\n",
11418 afi_safi_print(afi
, safi
));
11421 "This VRF is importing %s routes from the following VRFs:\n",
11422 afi_safi_print(afi
, safi
));
11424 for (ALL_LIST_ELEMENTS_RO(
11425 bgp
->vpn_policy
[afi
].import_vrf
,
11427 vty_out(vty
, " %s\n", vname
);
11429 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11430 ecom_str
= ecommunity_ecom2str(
11431 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11432 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11433 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11435 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11438 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11439 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11441 "This VRF is not exporting %s routes to any other VRF\n",
11442 afi_safi_print(afi
, safi
));
11445 "This VRF is exporting %s routes to the following VRFs:\n",
11446 afi_safi_print(afi
, safi
));
11448 for (ALL_LIST_ELEMENTS_RO(
11449 bgp
->vpn_policy
[afi
].export_vrf
,
11451 vty_out(vty
, " %s\n", vname
);
11453 vty_out(vty
, "RD: %s\n",
11454 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11455 buf1
, RD_ADDRSTRLEN
));
11457 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11458 ecom_str
= ecommunity_ecom2str(
11459 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11460 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11461 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11462 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11466 return CMD_SUCCESS
;
11469 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11470 safi_t safi
, bool use_json
)
11472 struct listnode
*node
, *nnode
;
11474 char *vrf_name
= NULL
;
11475 json_object
*json
= NULL
;
11476 json_object
*json_vrf
= NULL
;
11477 json_object
*json_vrfs
= NULL
;
11480 json
= json_object_new_object();
11481 json_vrfs
= json_object_new_object();
11484 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11486 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11487 vrf_name
= bgp
->name
;
11490 json_vrf
= json_object_new_object();
11492 vty_out(vty
, "\nInstance %s:\n",
11493 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11494 ? VRF_DEFAULT_NAME
: bgp
->name
);
11496 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11498 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11499 json_object_object_add(json_vrfs
,
11500 VRF_DEFAULT_NAME
, json_vrf
);
11502 json_object_object_add(json_vrfs
, vrf_name
,
11508 json_object_object_add(json
, "vrfs", json_vrfs
);
11509 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11510 JSON_C_TO_STRING_PRETTY
));
11511 json_object_free(json
);
11514 return CMD_SUCCESS
;
11517 /* "show [ip] bgp route-leak" command. */
11518 DEFUN (show_ip_bgp_route_leak
,
11519 show_ip_bgp_route_leak_cmd
,
11520 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11524 BGP_INSTANCE_HELP_STR
11527 "Route leaking information\n"
11531 afi_t afi
= AFI_MAX
;
11532 safi_t safi
= SAFI_MAX
;
11534 bool uj
= use_json(argc
, argv
);
11536 json_object
*json
= NULL
;
11538 /* show [ip] bgp */
11539 if (argv_find(argv
, argc
, "ip", &idx
)) {
11541 safi
= SAFI_UNICAST
;
11543 /* [vrf VIEWVRFNAME] */
11544 if (argv_find(argv
, argc
, "view", &idx
)) {
11546 "%% This command is not applicable to BGP views\n");
11547 return CMD_WARNING
;
11550 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11551 vrf
= argv
[idx
+ 1]->arg
;
11552 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11555 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11556 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11557 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11560 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11562 "%% This command is applicable only for unicast ipv4|ipv6\n");
11563 return CMD_WARNING
;
11566 if (vrf
&& strmatch(vrf
, "all"))
11567 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11570 json
= json_object_new_object();
11572 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11575 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11578 struct listnode
*node
, *nnode
;
11581 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11582 vty_out(vty
, "\nInstance %s:\n",
11583 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11586 update_group_show(bgp
, afi
, safi
, vty
, 0);
11590 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11591 int safi
, uint64_t subgrp_id
)
11596 if (strmatch(name
, "all")) {
11597 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11598 return CMD_SUCCESS
;
11600 bgp
= bgp_lookup_by_name(name
);
11603 bgp
= bgp_get_default();
11607 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11608 return CMD_SUCCESS
;
11611 DEFUN (show_ip_bgp_updgrps
,
11612 show_ip_bgp_updgrps_cmd
,
11613 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11617 BGP_INSTANCE_HELP_STR
11619 BGP_SAFI_WITH_LABEL_HELP_STR
11620 "Detailed info about dynamic update groups\n"
11621 "Specific subgroup to display detailed info for\n")
11624 afi_t afi
= AFI_IP6
;
11625 safi_t safi
= SAFI_UNICAST
;
11626 uint64_t subgrp_id
= 0;
11630 /* show [ip] bgp */
11631 if (argv_find(argv
, argc
, "ip", &idx
))
11633 /* [<vrf> VIEWVRFNAME] */
11634 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11635 vrf
= argv
[idx
+ 1]->arg
;
11636 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11638 } else if (argv_find(argv
, argc
, "view", &idx
))
11639 /* [<view> VIEWVRFNAME] */
11640 vrf
= argv
[idx
+ 1]->arg
;
11641 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11642 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11643 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11646 /* get subgroup id, if provided */
11648 if (argv
[idx
]->type
== VARIABLE_TKN
)
11649 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11651 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11654 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11655 show_bgp_instance_all_ipv6_updgrps_cmd
,
11656 "show [ip] bgp <view|vrf> all update-groups",
11660 BGP_INSTANCE_ALL_HELP_STR
11661 "Detailed info about dynamic update groups\n")
11663 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11664 return CMD_SUCCESS
;
11667 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11668 show_bgp_l2vpn_evpn_updgrps_cmd
,
11669 "show [ip] bgp l2vpn evpn update-groups",
11673 "l2vpn address family\n"
11674 "evpn sub-address family\n"
11675 "Detailed info about dynamic update groups\n")
11678 uint64_t subgrp_id
= 0;
11680 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11681 return CMD_SUCCESS
;
11684 DEFUN (show_bgp_updgrps_stats
,
11685 show_bgp_updgrps_stats_cmd
,
11686 "show [ip] bgp update-groups statistics",
11690 "Detailed info about dynamic update groups\n"
11695 bgp
= bgp_get_default();
11697 update_group_show_stats(bgp
, vty
);
11699 return CMD_SUCCESS
;
11702 DEFUN (show_bgp_instance_updgrps_stats
,
11703 show_bgp_instance_updgrps_stats_cmd
,
11704 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11708 BGP_INSTANCE_HELP_STR
11709 "Detailed info about dynamic update groups\n"
11715 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11717 update_group_show_stats(bgp
, vty
);
11719 return CMD_SUCCESS
;
11722 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11723 afi_t afi
, safi_t safi
,
11724 const char *what
, uint64_t subgrp_id
)
11729 bgp
= bgp_lookup_by_name(name
);
11731 bgp
= bgp_get_default();
11734 if (!strcmp(what
, "advertise-queue"))
11735 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11737 else if (!strcmp(what
, "advertised-routes"))
11738 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11740 else if (!strcmp(what
, "packet-queue"))
11741 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11746 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11747 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11748 "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",
11749 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11751 "Detailed info about dynamic update groups\n"
11752 "Specific subgroup to display info for\n"
11753 "Advertisement queue\n"
11754 "Announced routes\n"
11757 uint64_t subgrp_id
= 0;
11761 subgrp_id
= strtoull(sgid
, NULL
, 10);
11766 afiz
= bgp_vty_afi_from_str(afi
);
11770 afiz
= bgp_vty_afi_from_str(afi
);
11771 if (afiz
!= AFI_IP
)
11773 "%% Cannot specify both 'ip' and 'ipv6'\n");
11774 return CMD_WARNING
;
11777 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11779 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11780 return CMD_SUCCESS
;
11783 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11785 struct listnode
*node
, *nnode
;
11786 struct prefix
*range
;
11789 char buf
[PREFIX2STR_BUFFER
];
11792 const char *peer_status
;
11793 const char *af_str
;
11798 conf
= group
->conf
;
11800 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11801 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11802 group
->name
, conf
->as
);
11803 } else if (conf
->as_type
== AS_INTERNAL
) {
11804 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11805 group
->name
, group
->bgp
->as
);
11807 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11810 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11811 vty_out(vty
, " Peer-group type is internal\n");
11813 vty_out(vty
, " Peer-group type is external\n");
11815 /* Display AFs configured. */
11816 vty_out(vty
, " Configured address-families:");
11817 FOREACH_AFI_SAFI (afi
, safi
) {
11818 if (conf
->afc
[afi
][safi
]) {
11820 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11824 vty_out(vty
, " none\n");
11826 vty_out(vty
, "\n");
11828 /* Display listen ranges (for dynamic neighbors), if any */
11829 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11832 else if (afi
== AFI_IP6
)
11836 lr_count
= listcount(group
->listen_range
[afi
]);
11838 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11842 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11844 prefix2str(range
, buf
, sizeof(buf
));
11845 vty_out(vty
, " %s\n", buf
);
11850 /* Display group members and their status */
11851 if (listcount(group
->peer
)) {
11852 vty_out(vty
, " Peer-group members:\n");
11853 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11854 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11855 peer_status
= "Idle (Admin)";
11856 else if (CHECK_FLAG(peer
->sflags
,
11857 PEER_STATUS_PREFIX_OVERFLOW
))
11858 peer_status
= "Idle (PfxCt)";
11860 peer_status
= lookup_msg(bgp_status_msg
,
11861 peer
->status
, NULL
);
11863 dynamic
= peer_dynamic_neighbor(peer
);
11864 vty_out(vty
, " %s %s %s \n", peer
->host
,
11865 dynamic
? "(dynamic)" : "", peer_status
);
11869 return CMD_SUCCESS
;
11872 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11873 const char *group_name
)
11876 struct listnode
*node
, *nnode
;
11877 struct peer_group
*group
;
11878 bool found
= false;
11880 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11883 vty_out(vty
, "%% BGP instance not found\n");
11884 return CMD_WARNING
;
11887 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11889 if (strmatch(group
->name
, group_name
)) {
11890 bgp_show_one_peer_group(vty
, group
);
11895 bgp_show_one_peer_group(vty
, group
);
11899 if (group_name
&& !found
)
11900 vty_out(vty
, "%% No such peer-group\n");
11902 return CMD_SUCCESS
;
11905 DEFUN (show_ip_bgp_peer_groups
,
11906 show_ip_bgp_peer_groups_cmd
,
11907 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11911 BGP_INSTANCE_HELP_STR
11912 "Detailed information on BGP peer groups\n"
11913 "Peer group name\n")
11918 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11920 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11922 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11926 /* Redistribute VTY commands. */
11928 DEFUN (bgp_redistribute_ipv4
,
11929 bgp_redistribute_ipv4_cmd
,
11930 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11931 "Redistribute information from another routing protocol\n"
11932 FRR_IP_REDIST_HELP_STR_BGPD
)
11934 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11935 int idx_protocol
= 1;
11938 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11940 vty_out(vty
, "%% Invalid route type\n");
11941 return CMD_WARNING_CONFIG_FAILED
;
11944 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11945 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11949 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11950 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11951 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11953 DEFUN (bgp_redistribute_ipv4_rmap
,
11954 bgp_redistribute_ipv4_rmap_cmd
,
11955 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11956 "Redistribute information from another routing protocol\n"
11957 FRR_IP_REDIST_HELP_STR_BGPD
11958 "Route map reference\n"
11959 "Pointer to route-map entries\n")
11961 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11962 int idx_protocol
= 1;
11965 struct bgp_redist
*red
;
11967 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11968 vty
, argv
[idx_word
]->arg
);
11970 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11972 vty_out(vty
, "%% Invalid route type\n");
11973 return CMD_WARNING_CONFIG_FAILED
;
11976 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11978 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
11979 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
11983 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11984 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11985 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11986 "Route map reference\n"
11987 "Pointer to route-map entries\n")
11989 DEFUN (bgp_redistribute_ipv4_metric
,
11990 bgp_redistribute_ipv4_metric_cmd
,
11991 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11992 "Redistribute information from another routing protocol\n"
11993 FRR_IP_REDIST_HELP_STR_BGPD
11994 "Metric for redistributed routes\n"
11995 "Default metric\n")
11997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11998 int idx_protocol
= 1;
11999 int idx_number
= 3;
12002 struct bgp_redist
*red
;
12005 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12007 vty_out(vty
, "%% Invalid route type\n");
12008 return CMD_WARNING_CONFIG_FAILED
;
12010 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12012 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12013 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12014 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12018 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12019 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12020 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12021 "Metric for redistributed routes\n"
12022 "Default metric\n")
12024 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12025 bgp_redistribute_ipv4_rmap_metric_cmd
,
12026 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12027 "Redistribute information from another routing protocol\n"
12028 FRR_IP_REDIST_HELP_STR_BGPD
12029 "Route map reference\n"
12030 "Pointer to route-map entries\n"
12031 "Metric for redistributed routes\n"
12032 "Default metric\n")
12034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12035 int idx_protocol
= 1;
12037 int idx_number
= 5;
12040 struct bgp_redist
*red
;
12042 struct route_map
*route_map
=
12043 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12045 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12047 vty_out(vty
, "%% Invalid route type\n");
12048 return CMD_WARNING_CONFIG_FAILED
;
12050 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12052 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12054 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12055 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12056 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12060 bgp_redistribute_ipv4_rmap_metric
,
12061 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12062 "redistribute " FRR_IP_REDIST_STR_BGPD
12063 " route-map WORD metric (0-4294967295)",
12064 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12065 "Route map reference\n"
12066 "Pointer to route-map entries\n"
12067 "Metric for redistributed routes\n"
12068 "Default metric\n")
12070 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12071 bgp_redistribute_ipv4_metric_rmap_cmd
,
12072 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12073 "Redistribute information from another routing protocol\n"
12074 FRR_IP_REDIST_HELP_STR_BGPD
12075 "Metric for redistributed routes\n"
12077 "Route map reference\n"
12078 "Pointer to route-map entries\n")
12080 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12081 int idx_protocol
= 1;
12082 int idx_number
= 3;
12086 struct bgp_redist
*red
;
12088 struct route_map
*route_map
=
12089 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12091 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12093 vty_out(vty
, "%% Invalid route type\n");
12094 return CMD_WARNING_CONFIG_FAILED
;
12096 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12098 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12099 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12101 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12102 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12106 bgp_redistribute_ipv4_metric_rmap
,
12107 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12108 "redistribute " FRR_IP_REDIST_STR_BGPD
12109 " metric (0-4294967295) route-map WORD",
12110 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12111 "Metric for redistributed routes\n"
12113 "Route map reference\n"
12114 "Pointer to route-map entries\n")
12116 DEFUN (bgp_redistribute_ipv4_ospf
,
12117 bgp_redistribute_ipv4_ospf_cmd
,
12118 "redistribute <ospf|table> (1-65535)",
12119 "Redistribute information from another routing protocol\n"
12120 "Open Shortest Path First (OSPFv2)\n"
12121 "Non-main Kernel Routing Table\n"
12122 "Instance ID/Table ID\n")
12124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12125 int idx_ospf_table
= 1;
12126 int idx_number
= 2;
12127 unsigned short instance
;
12128 unsigned short protocol
;
12130 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12132 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12133 protocol
= ZEBRA_ROUTE_OSPF
;
12135 protocol
= ZEBRA_ROUTE_TABLE
;
12137 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12138 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12141 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12142 "redistribute <ospf|table> (1-65535)",
12143 "Redistribute information from another routing protocol\n"
12144 "Open Shortest Path First (OSPFv2)\n"
12145 "Non-main Kernel Routing Table\n"
12146 "Instance ID/Table ID\n")
12148 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12149 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12150 "redistribute <ospf|table> (1-65535) route-map WORD",
12151 "Redistribute information from another routing protocol\n"
12152 "Open Shortest Path First (OSPFv2)\n"
12153 "Non-main Kernel Routing Table\n"
12154 "Instance ID/Table ID\n"
12155 "Route map reference\n"
12156 "Pointer to route-map entries\n")
12158 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12159 int idx_ospf_table
= 1;
12160 int idx_number
= 2;
12162 struct bgp_redist
*red
;
12163 unsigned short instance
;
12166 struct route_map
*route_map
=
12167 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12169 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12170 protocol
= ZEBRA_ROUTE_OSPF
;
12172 protocol
= ZEBRA_ROUTE_TABLE
;
12174 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12175 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12177 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12178 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12181 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12182 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12183 "redistribute <ospf|table> (1-65535) route-map WORD",
12184 "Redistribute information from another routing protocol\n"
12185 "Open Shortest Path First (OSPFv2)\n"
12186 "Non-main Kernel Routing Table\n"
12187 "Instance ID/Table ID\n"
12188 "Route map reference\n"
12189 "Pointer to route-map entries\n")
12191 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12192 bgp_redistribute_ipv4_ospf_metric_cmd
,
12193 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12194 "Redistribute information from another routing protocol\n"
12195 "Open Shortest Path First (OSPFv2)\n"
12196 "Non-main Kernel Routing Table\n"
12197 "Instance ID/Table ID\n"
12198 "Metric for redistributed routes\n"
12199 "Default metric\n")
12201 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12202 int idx_ospf_table
= 1;
12203 int idx_number
= 2;
12204 int idx_number_2
= 4;
12206 struct bgp_redist
*red
;
12207 unsigned short instance
;
12211 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12212 protocol
= ZEBRA_ROUTE_OSPF
;
12214 protocol
= ZEBRA_ROUTE_TABLE
;
12216 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12217 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12219 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12220 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12222 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12225 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12226 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12227 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12228 "Redistribute information from another routing protocol\n"
12229 "Open Shortest Path First (OSPFv2)\n"
12230 "Non-main Kernel Routing Table\n"
12231 "Instance ID/Table ID\n"
12232 "Metric for redistributed routes\n"
12233 "Default metric\n")
12235 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12236 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12237 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12238 "Redistribute information from another routing protocol\n"
12239 "Open Shortest Path First (OSPFv2)\n"
12240 "Non-main Kernel Routing Table\n"
12241 "Instance ID/Table ID\n"
12242 "Route map reference\n"
12243 "Pointer to route-map entries\n"
12244 "Metric for redistributed routes\n"
12245 "Default metric\n")
12247 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12248 int idx_ospf_table
= 1;
12249 int idx_number
= 2;
12251 int idx_number_2
= 6;
12253 struct bgp_redist
*red
;
12254 unsigned short instance
;
12257 struct route_map
*route_map
=
12258 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12260 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12261 protocol
= ZEBRA_ROUTE_OSPF
;
12263 protocol
= ZEBRA_ROUTE_TABLE
;
12265 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12266 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12268 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12270 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12271 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12273 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12277 bgp_redistribute_ipv4_ospf_rmap_metric
,
12278 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12279 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12280 "Redistribute information from another routing protocol\n"
12281 "Open Shortest Path First (OSPFv2)\n"
12282 "Non-main Kernel Routing Table\n"
12283 "Instance ID/Table ID\n"
12284 "Route map reference\n"
12285 "Pointer to route-map entries\n"
12286 "Metric for redistributed routes\n"
12287 "Default metric\n")
12289 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12290 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12291 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12292 "Redistribute information from another routing protocol\n"
12293 "Open Shortest Path First (OSPFv2)\n"
12294 "Non-main Kernel Routing Table\n"
12295 "Instance ID/Table ID\n"
12296 "Metric for redistributed routes\n"
12298 "Route map reference\n"
12299 "Pointer to route-map entries\n")
12301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12302 int idx_ospf_table
= 1;
12303 int idx_number
= 2;
12304 int idx_number_2
= 4;
12307 struct bgp_redist
*red
;
12308 unsigned short instance
;
12311 struct route_map
*route_map
=
12312 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12314 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12315 protocol
= ZEBRA_ROUTE_OSPF
;
12317 protocol
= ZEBRA_ROUTE_TABLE
;
12319 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12320 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12322 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12323 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12326 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12327 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12331 bgp_redistribute_ipv4_ospf_metric_rmap
,
12332 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12333 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12334 "Redistribute information from another routing protocol\n"
12335 "Open Shortest Path First (OSPFv2)\n"
12336 "Non-main Kernel Routing Table\n"
12337 "Instance ID/Table ID\n"
12338 "Metric for redistributed routes\n"
12340 "Route map reference\n"
12341 "Pointer to route-map entries\n")
12343 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12344 no_bgp_redistribute_ipv4_ospf_cmd
,
12345 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12347 "Redistribute information from another routing protocol\n"
12348 "Open Shortest Path First (OSPFv2)\n"
12349 "Non-main Kernel Routing Table\n"
12350 "Instance ID/Table ID\n"
12351 "Metric for redistributed routes\n"
12353 "Route map reference\n"
12354 "Pointer to route-map entries\n")
12356 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12357 int idx_ospf_table
= 2;
12358 int idx_number
= 3;
12359 unsigned short instance
;
12362 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12363 protocol
= ZEBRA_ROUTE_OSPF
;
12365 protocol
= ZEBRA_ROUTE_TABLE
;
12367 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12368 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12372 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12373 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12375 "Redistribute information from another routing protocol\n"
12376 "Open Shortest Path First (OSPFv2)\n"
12377 "Non-main Kernel Routing Table\n"
12378 "Instance ID/Table ID\n"
12379 "Metric for redistributed routes\n"
12381 "Route map reference\n"
12382 "Pointer to route-map entries\n")
12384 DEFUN (no_bgp_redistribute_ipv4
,
12385 no_bgp_redistribute_ipv4_cmd
,
12386 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12388 "Redistribute information from another routing protocol\n"
12389 FRR_IP_REDIST_HELP_STR_BGPD
12390 "Metric for redistributed routes\n"
12392 "Route map reference\n"
12393 "Pointer to route-map entries\n")
12395 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12396 int idx_protocol
= 2;
12399 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12401 vty_out(vty
, "%% Invalid route type\n");
12402 return CMD_WARNING_CONFIG_FAILED
;
12404 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12408 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12409 "no redistribute " FRR_IP_REDIST_STR_BGPD
12410 " [metric (0-4294967295)] [route-map WORD]",
12412 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12413 "Metric for redistributed routes\n"
12415 "Route map reference\n"
12416 "Pointer to route-map entries\n")
12418 DEFUN (bgp_redistribute_ipv6
,
12419 bgp_redistribute_ipv6_cmd
,
12420 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12421 "Redistribute information from another routing protocol\n"
12422 FRR_IP6_REDIST_HELP_STR_BGPD
)
12424 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12425 int idx_protocol
= 1;
12428 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12430 vty_out(vty
, "%% Invalid route type\n");
12431 return CMD_WARNING_CONFIG_FAILED
;
12434 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12435 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12438 DEFUN (bgp_redistribute_ipv6_rmap
,
12439 bgp_redistribute_ipv6_rmap_cmd
,
12440 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12441 "Redistribute information from another routing protocol\n"
12442 FRR_IP6_REDIST_HELP_STR_BGPD
12443 "Route map reference\n"
12444 "Pointer to route-map entries\n")
12446 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12447 int idx_protocol
= 1;
12450 struct bgp_redist
*red
;
12452 struct route_map
*route_map
=
12453 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12455 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12457 vty_out(vty
, "%% Invalid route type\n");
12458 return CMD_WARNING_CONFIG_FAILED
;
12461 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12463 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12464 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12467 DEFUN (bgp_redistribute_ipv6_metric
,
12468 bgp_redistribute_ipv6_metric_cmd
,
12469 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12470 "Redistribute information from another routing protocol\n"
12471 FRR_IP6_REDIST_HELP_STR_BGPD
12472 "Metric for redistributed routes\n"
12473 "Default metric\n")
12475 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12476 int idx_protocol
= 1;
12477 int idx_number
= 3;
12480 struct bgp_redist
*red
;
12483 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12485 vty_out(vty
, "%% Invalid route type\n");
12486 return CMD_WARNING_CONFIG_FAILED
;
12488 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12490 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12491 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12492 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12495 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12496 bgp_redistribute_ipv6_rmap_metric_cmd
,
12497 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12498 "Redistribute information from another routing protocol\n"
12499 FRR_IP6_REDIST_HELP_STR_BGPD
12500 "Route map reference\n"
12501 "Pointer to route-map entries\n"
12502 "Metric for redistributed routes\n"
12503 "Default metric\n")
12505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12506 int idx_protocol
= 1;
12508 int idx_number
= 5;
12511 struct bgp_redist
*red
;
12513 struct route_map
*route_map
=
12514 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12516 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12518 vty_out(vty
, "%% Invalid route type\n");
12519 return CMD_WARNING_CONFIG_FAILED
;
12521 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12523 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12525 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12526 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12528 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12531 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12532 bgp_redistribute_ipv6_metric_rmap_cmd
,
12533 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12534 "Redistribute information from another routing protocol\n"
12535 FRR_IP6_REDIST_HELP_STR_BGPD
12536 "Metric for redistributed routes\n"
12538 "Route map reference\n"
12539 "Pointer to route-map entries\n")
12541 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12542 int idx_protocol
= 1;
12543 int idx_number
= 3;
12547 struct bgp_redist
*red
;
12549 struct route_map
*route_map
=
12550 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12552 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12554 vty_out(vty
, "%% Invalid route type\n");
12555 return CMD_WARNING_CONFIG_FAILED
;
12557 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12559 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12560 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12563 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12564 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12567 DEFUN (no_bgp_redistribute_ipv6
,
12568 no_bgp_redistribute_ipv6_cmd
,
12569 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12571 "Redistribute information from another routing protocol\n"
12572 FRR_IP6_REDIST_HELP_STR_BGPD
12573 "Metric for redistributed routes\n"
12575 "Route map reference\n"
12576 "Pointer to route-map entries\n")
12578 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12579 int idx_protocol
= 2;
12582 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12584 vty_out(vty
, "%% Invalid route type\n");
12585 return CMD_WARNING_CONFIG_FAILED
;
12588 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12591 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12596 /* Unicast redistribution only. */
12597 if (safi
!= SAFI_UNICAST
)
12600 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12601 /* Redistribute BGP does not make sense. */
12602 if (i
!= ZEBRA_ROUTE_BGP
) {
12603 struct list
*red_list
;
12604 struct listnode
*node
;
12605 struct bgp_redist
*red
;
12607 red_list
= bgp
->redist
[afi
][i
];
12611 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12612 /* "redistribute" configuration. */
12613 vty_out(vty
, " redistribute %s",
12614 zebra_route_string(i
));
12616 vty_out(vty
, " %d", red
->instance
);
12617 if (red
->redist_metric_flag
)
12618 vty_out(vty
, " metric %u",
12619 red
->redist_metric
);
12620 if (red
->rmap
.name
)
12621 vty_out(vty
, " route-map %s",
12623 vty_out(vty
, "\n");
12629 /* This is part of the address-family block (unicast only) */
12630 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12635 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12636 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12637 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12638 bgp
->vpn_policy
[afi
]
12639 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12641 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12642 bgp
->vpn_policy
[afi
]
12643 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12645 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12646 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12647 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12648 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12651 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12652 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12654 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12657 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12658 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12659 bgp
->vpn_policy
[afi
].tovpn_label
);
12662 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12663 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12664 char buf
[RD_ADDRSTRLEN
];
12665 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12666 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12669 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12670 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12672 char buf
[PREFIX_STRLEN
];
12673 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12674 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12677 vty_out(vty
, "%*snexthop vpn export %s\n",
12681 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12682 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12684 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12685 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12687 char *b
= ecommunity_ecom2str(
12688 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12689 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12690 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12691 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12693 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12694 char *b
= ecommunity_ecom2str(
12695 bgp
->vpn_policy
[afi
]
12696 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12697 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12698 ECOMMUNITY_ROUTE_TARGET
);
12699 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12700 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12702 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12703 char *b
= ecommunity_ecom2str(
12704 bgp
->vpn_policy
[afi
]
12705 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12706 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12707 ECOMMUNITY_ROUTE_TARGET
);
12708 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12709 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12713 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12714 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12715 bgp
->vpn_policy
[afi
]
12716 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12718 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12719 char *b
= ecommunity_ecom2str(
12720 bgp
->vpn_policy
[afi
]
12721 .import_redirect_rtlist
,
12722 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12723 ECOMMUNITY_ROUTE_TARGET
);
12725 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12726 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12731 /* BGP node structure. */
12732 static struct cmd_node bgp_node
= {
12733 BGP_NODE
, "%s(config-router)# ", 1,
12736 static struct cmd_node bgp_ipv4_unicast_node
= {
12737 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12740 static struct cmd_node bgp_ipv4_multicast_node
= {
12741 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12744 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12745 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12748 static struct cmd_node bgp_ipv6_unicast_node
= {
12749 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12752 static struct cmd_node bgp_ipv6_multicast_node
= {
12753 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12756 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12757 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12760 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12761 "%s(config-router-af)# ", 1};
12763 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12764 "%s(config-router-af-vpnv6)# ", 1};
12766 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12767 "%s(config-router-evpn)# ", 1};
12769 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12770 "%s(config-router-af-vni)# ", 1};
12772 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12773 "%s(config-router-af)# ", 1};
12775 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12776 "%s(config-router-af-vpnv6)# ", 1};
12778 static void community_list_vty(void);
12780 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12784 struct listnode
*lnbgp
, *lnpeer
;
12786 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12787 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12788 /* only provide suggestions on the appropriate input
12790 * they'll otherwise show up multiple times */
12791 enum cmd_token_type match_type
;
12792 char *name
= peer
->host
;
12794 if (peer
->conf_if
) {
12795 match_type
= VARIABLE_TKN
;
12796 name
= peer
->conf_if
;
12797 } else if (strchr(peer
->host
, ':'))
12798 match_type
= IPV6_TKN
;
12800 match_type
= IPV4_TKN
;
12802 if (token
->type
!= match_type
)
12805 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12810 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12811 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12812 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12813 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12814 {.completions
= NULL
}};
12816 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12819 struct peer_group
*group
;
12820 struct listnode
*lnbgp
, *lnpeer
;
12822 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12823 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12824 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12829 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12830 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12831 {.completions
= NULL
} };
12833 void bgp_vty_init(void)
12835 cmd_variable_handler_register(bgp_var_neighbor
);
12836 cmd_variable_handler_register(bgp_var_peergroup
);
12838 /* Install bgp top node. */
12839 install_node(&bgp_node
, bgp_config_write
);
12840 install_node(&bgp_ipv4_unicast_node
, NULL
);
12841 install_node(&bgp_ipv4_multicast_node
, NULL
);
12842 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12843 install_node(&bgp_ipv6_unicast_node
, NULL
);
12844 install_node(&bgp_ipv6_multicast_node
, NULL
);
12845 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12846 install_node(&bgp_vpnv4_node
, NULL
);
12847 install_node(&bgp_vpnv6_node
, NULL
);
12848 install_node(&bgp_evpn_node
, NULL
);
12849 install_node(&bgp_evpn_vni_node
, NULL
);
12850 install_node(&bgp_flowspecv4_node
, NULL
);
12851 install_node(&bgp_flowspecv6_node
, NULL
);
12853 /* Install default VTY commands to new nodes. */
12854 install_default(BGP_NODE
);
12855 install_default(BGP_IPV4_NODE
);
12856 install_default(BGP_IPV4M_NODE
);
12857 install_default(BGP_IPV4L_NODE
);
12858 install_default(BGP_IPV6_NODE
);
12859 install_default(BGP_IPV6M_NODE
);
12860 install_default(BGP_IPV6L_NODE
);
12861 install_default(BGP_VPNV4_NODE
);
12862 install_default(BGP_VPNV6_NODE
);
12863 install_default(BGP_FLOWSPECV4_NODE
);
12864 install_default(BGP_FLOWSPECV6_NODE
);
12865 install_default(BGP_EVPN_NODE
);
12866 install_default(BGP_EVPN_VNI_NODE
);
12868 /* "bgp multiple-instance" commands. */
12869 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12870 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12872 /* "bgp config-type" commands. */
12873 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12874 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12876 /* "bgp local-mac" hidden commands. */
12877 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12878 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12880 /* bgp route-map delay-timer commands. */
12881 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12882 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12884 /* Dummy commands (Currently not supported) */
12885 install_element(BGP_NODE
, &no_synchronization_cmd
);
12886 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12888 /* "router bgp" commands. */
12889 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12891 /* "no router bgp" commands. */
12892 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12894 /* "bgp router-id" commands. */
12895 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12896 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12898 /* "bgp cluster-id" commands. */
12899 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12900 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12902 /* "bgp confederation" commands. */
12903 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12904 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12906 /* "bgp confederation peers" commands. */
12907 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12908 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12910 /* bgp max-med command */
12911 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12912 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12913 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12914 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12915 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12917 /* bgp disable-ebgp-connected-nh-check */
12918 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12919 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12921 /* bgp update-delay command */
12922 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12923 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12924 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12926 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12927 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12928 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12929 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12931 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12932 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12934 /* "maximum-paths" commands. */
12935 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12936 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12937 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12938 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12939 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12940 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12941 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12942 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12943 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12944 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12945 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12946 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12947 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12948 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12949 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12951 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12952 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12953 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12954 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12955 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12957 /* "timers bgp" commands. */
12958 install_element(BGP_NODE
, &bgp_timers_cmd
);
12959 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12961 /* route-map delay-timer commands - per instance for backwards compat.
12963 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12964 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12966 /* "bgp client-to-client reflection" commands */
12967 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12968 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12970 /* "bgp always-compare-med" commands */
12971 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12972 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12974 /* bgp ebgp-requires-policy */
12975 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12976 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
12978 /* "bgp deterministic-med" commands */
12979 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12980 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12982 /* "bgp graceful-restart" commands */
12983 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12984 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12985 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12986 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12987 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12988 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12990 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12991 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12993 /* "bgp graceful-shutdown" commands */
12994 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12995 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12997 /* "bgp fast-external-failover" commands */
12998 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12999 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13001 /* "bgp enforce-first-as" commands */
13002 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
13004 /* "bgp bestpath compare-routerid" commands */
13005 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13006 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13008 /* "bgp bestpath as-path ignore" commands */
13009 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13010 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13012 /* "bgp bestpath as-path confed" commands */
13013 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13014 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13016 /* "bgp bestpath as-path multipath-relax" commands */
13017 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13018 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13020 /* "bgp log-neighbor-changes" commands */
13021 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13022 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13024 /* "bgp bestpath med" commands */
13025 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13026 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13028 /* "no bgp default ipv4-unicast" commands. */
13029 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13030 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13032 /* "bgp network import-check" commands. */
13033 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13034 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13035 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13037 /* "bgp default local-preference" commands. */
13038 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13039 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13041 /* bgp default show-hostname */
13042 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13043 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13045 /* "bgp default subgroup-pkt-queue-max" commands. */
13046 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13047 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13049 /* bgp ibgp-allow-policy-mods command */
13050 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13051 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13053 /* "bgp listen limit" commands. */
13054 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13055 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13057 /* "bgp listen range" commands. */
13058 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13059 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13061 /* "bgp default shutdown" command */
13062 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13064 /* "neighbor remote-as" commands. */
13065 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13066 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13067 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13068 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13069 install_element(BGP_NODE
,
13070 &neighbor_interface_v6only_config_remote_as_cmd
);
13071 install_element(BGP_NODE
, &no_neighbor_cmd
);
13072 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13074 /* "neighbor peer-group" commands. */
13075 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13076 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13077 install_element(BGP_NODE
,
13078 &no_neighbor_interface_peer_group_remote_as_cmd
);
13080 /* "neighbor local-as" commands. */
13081 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13082 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13083 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13084 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13086 /* "neighbor solo" commands. */
13087 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13088 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13090 /* "neighbor password" commands. */
13091 install_element(BGP_NODE
, &neighbor_password_cmd
);
13092 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13094 /* "neighbor activate" commands. */
13095 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13096 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13097 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13098 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13099 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13100 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13101 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13102 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13103 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13104 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13105 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13106 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13108 /* "no neighbor activate" commands. */
13109 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13110 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13111 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13112 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13113 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13114 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13115 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13116 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13117 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13118 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13119 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13120 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13122 /* "neighbor peer-group" set commands. */
13123 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13124 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13125 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13126 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13127 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13128 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13129 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13130 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13131 install_element(BGP_FLOWSPECV4_NODE
,
13132 &neighbor_set_peer_group_hidden_cmd
);
13133 install_element(BGP_FLOWSPECV6_NODE
,
13134 &neighbor_set_peer_group_hidden_cmd
);
13136 /* "no neighbor peer-group unset" commands. */
13137 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13138 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13139 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13140 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13141 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13142 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13143 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13144 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13145 install_element(BGP_FLOWSPECV4_NODE
,
13146 &no_neighbor_set_peer_group_hidden_cmd
);
13147 install_element(BGP_FLOWSPECV6_NODE
,
13148 &no_neighbor_set_peer_group_hidden_cmd
);
13150 /* "neighbor softreconfiguration inbound" commands.*/
13151 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13152 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13153 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13154 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13155 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13156 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13157 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13158 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13159 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13160 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13161 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13162 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13163 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13164 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13165 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13166 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13167 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13168 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13169 install_element(BGP_FLOWSPECV4_NODE
,
13170 &neighbor_soft_reconfiguration_cmd
);
13171 install_element(BGP_FLOWSPECV4_NODE
,
13172 &no_neighbor_soft_reconfiguration_cmd
);
13173 install_element(BGP_FLOWSPECV6_NODE
,
13174 &neighbor_soft_reconfiguration_cmd
);
13175 install_element(BGP_FLOWSPECV6_NODE
,
13176 &no_neighbor_soft_reconfiguration_cmd
);
13177 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13178 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13180 /* "neighbor attribute-unchanged" commands. */
13181 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13182 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13183 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13184 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13185 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13186 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13187 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13188 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13189 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13190 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13191 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13192 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13193 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13194 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13195 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13196 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13197 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13198 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13200 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13201 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13203 /* "nexthop-local unchanged" commands */
13204 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13205 install_element(BGP_IPV6_NODE
,
13206 &no_neighbor_nexthop_local_unchanged_cmd
);
13208 /* "neighbor next-hop-self" commands. */
13209 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13210 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13211 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13212 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13213 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13214 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13215 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13216 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13217 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13218 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13219 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13220 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13221 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13222 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13223 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13224 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13225 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13226 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13227 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13228 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13230 /* "neighbor next-hop-self force" commands. */
13231 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13232 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13233 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13234 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13235 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13236 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13237 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13238 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13239 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13240 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13241 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13242 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13243 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13244 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13245 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13246 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13247 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13248 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13250 /* "neighbor as-override" commands. */
13251 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13252 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13253 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13254 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13255 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13256 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13257 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13258 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13259 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13260 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13261 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13262 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13263 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13264 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13265 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13266 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13267 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13268 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13270 /* "neighbor remove-private-AS" commands. */
13271 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13272 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13273 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13274 install_element(BGP_NODE
,
13275 &no_neighbor_remove_private_as_all_hidden_cmd
);
13276 install_element(BGP_NODE
,
13277 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13278 install_element(BGP_NODE
,
13279 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13280 install_element(BGP_NODE
,
13281 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13284 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13285 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13286 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13287 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13288 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13289 install_element(BGP_IPV4_NODE
,
13290 &neighbor_remove_private_as_replace_as_cmd
);
13291 install_element(BGP_IPV4_NODE
,
13292 &no_neighbor_remove_private_as_replace_as_cmd
);
13293 install_element(BGP_IPV4_NODE
,
13294 &neighbor_remove_private_as_all_replace_as_cmd
);
13295 install_element(BGP_IPV4_NODE
,
13296 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13297 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13298 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13299 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13300 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13301 install_element(BGP_IPV4M_NODE
,
13302 &neighbor_remove_private_as_replace_as_cmd
);
13303 install_element(BGP_IPV4M_NODE
,
13304 &no_neighbor_remove_private_as_replace_as_cmd
);
13305 install_element(BGP_IPV4M_NODE
,
13306 &neighbor_remove_private_as_all_replace_as_cmd
);
13307 install_element(BGP_IPV4M_NODE
,
13308 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13309 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13310 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13311 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13312 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13313 install_element(BGP_IPV4L_NODE
,
13314 &neighbor_remove_private_as_replace_as_cmd
);
13315 install_element(BGP_IPV4L_NODE
,
13316 &no_neighbor_remove_private_as_replace_as_cmd
);
13317 install_element(BGP_IPV4L_NODE
,
13318 &neighbor_remove_private_as_all_replace_as_cmd
);
13319 install_element(BGP_IPV4L_NODE
,
13320 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13321 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13322 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13323 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13324 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13325 install_element(BGP_IPV6_NODE
,
13326 &neighbor_remove_private_as_replace_as_cmd
);
13327 install_element(BGP_IPV6_NODE
,
13328 &no_neighbor_remove_private_as_replace_as_cmd
);
13329 install_element(BGP_IPV6_NODE
,
13330 &neighbor_remove_private_as_all_replace_as_cmd
);
13331 install_element(BGP_IPV6_NODE
,
13332 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13333 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13334 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13335 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13336 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13337 install_element(BGP_IPV6M_NODE
,
13338 &neighbor_remove_private_as_replace_as_cmd
);
13339 install_element(BGP_IPV6M_NODE
,
13340 &no_neighbor_remove_private_as_replace_as_cmd
);
13341 install_element(BGP_IPV6M_NODE
,
13342 &neighbor_remove_private_as_all_replace_as_cmd
);
13343 install_element(BGP_IPV6M_NODE
,
13344 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13345 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13346 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13347 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13348 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13349 install_element(BGP_IPV6L_NODE
,
13350 &neighbor_remove_private_as_replace_as_cmd
);
13351 install_element(BGP_IPV6L_NODE
,
13352 &no_neighbor_remove_private_as_replace_as_cmd
);
13353 install_element(BGP_IPV6L_NODE
,
13354 &neighbor_remove_private_as_all_replace_as_cmd
);
13355 install_element(BGP_IPV6L_NODE
,
13356 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13357 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13358 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13359 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13360 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13361 install_element(BGP_VPNV4_NODE
,
13362 &neighbor_remove_private_as_replace_as_cmd
);
13363 install_element(BGP_VPNV4_NODE
,
13364 &no_neighbor_remove_private_as_replace_as_cmd
);
13365 install_element(BGP_VPNV4_NODE
,
13366 &neighbor_remove_private_as_all_replace_as_cmd
);
13367 install_element(BGP_VPNV4_NODE
,
13368 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13369 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13370 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13371 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13372 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13373 install_element(BGP_VPNV6_NODE
,
13374 &neighbor_remove_private_as_replace_as_cmd
);
13375 install_element(BGP_VPNV6_NODE
,
13376 &no_neighbor_remove_private_as_replace_as_cmd
);
13377 install_element(BGP_VPNV6_NODE
,
13378 &neighbor_remove_private_as_all_replace_as_cmd
);
13379 install_element(BGP_VPNV6_NODE
,
13380 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13382 /* "neighbor send-community" commands.*/
13383 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13384 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13385 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13386 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13387 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13388 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13389 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13390 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13391 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13392 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13393 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13394 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13395 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13396 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13397 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13398 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13399 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13400 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13401 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13402 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13403 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13404 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13405 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13406 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13407 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13408 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13409 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13410 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13411 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13412 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13413 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13414 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13415 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13416 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13417 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13418 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13420 /* "neighbor route-reflector" commands.*/
13421 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13422 install_element(BGP_NODE
,
13423 &no_neighbor_route_reflector_client_hidden_cmd
);
13424 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13425 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13426 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13427 install_element(BGP_IPV4M_NODE
,
13428 &no_neighbor_route_reflector_client_cmd
);
13429 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13430 install_element(BGP_IPV4L_NODE
,
13431 &no_neighbor_route_reflector_client_cmd
);
13432 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13433 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13434 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13435 install_element(BGP_IPV6M_NODE
,
13436 &no_neighbor_route_reflector_client_cmd
);
13437 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13438 install_element(BGP_IPV6L_NODE
,
13439 &no_neighbor_route_reflector_client_cmd
);
13440 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13441 install_element(BGP_VPNV4_NODE
,
13442 &no_neighbor_route_reflector_client_cmd
);
13443 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13444 install_element(BGP_VPNV6_NODE
,
13445 &no_neighbor_route_reflector_client_cmd
);
13446 install_element(BGP_FLOWSPECV4_NODE
,
13447 &neighbor_route_reflector_client_cmd
);
13448 install_element(BGP_FLOWSPECV4_NODE
,
13449 &no_neighbor_route_reflector_client_cmd
);
13450 install_element(BGP_FLOWSPECV6_NODE
,
13451 &neighbor_route_reflector_client_cmd
);
13452 install_element(BGP_FLOWSPECV6_NODE
,
13453 &no_neighbor_route_reflector_client_cmd
);
13454 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13455 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13457 /* "neighbor route-server" commands.*/
13458 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13459 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13460 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13461 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13462 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13463 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13464 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13465 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13466 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13467 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13468 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13469 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13470 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13471 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13472 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13473 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13474 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13475 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13476 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13477 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13478 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13479 install_element(BGP_FLOWSPECV4_NODE
,
13480 &no_neighbor_route_server_client_cmd
);
13481 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13482 install_element(BGP_FLOWSPECV6_NODE
,
13483 &no_neighbor_route_server_client_cmd
);
13485 /* "neighbor addpath-tx-all-paths" commands.*/
13486 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13487 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13488 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13489 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13490 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13491 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13492 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13493 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13494 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13495 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13496 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13497 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13498 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13499 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13500 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13501 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13502 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13503 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13505 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13506 install_element(BGP_NODE
,
13507 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13508 install_element(BGP_NODE
,
13509 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13510 install_element(BGP_IPV4_NODE
,
13511 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13512 install_element(BGP_IPV4_NODE
,
13513 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13514 install_element(BGP_IPV4M_NODE
,
13515 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13516 install_element(BGP_IPV4M_NODE
,
13517 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13518 install_element(BGP_IPV4L_NODE
,
13519 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13520 install_element(BGP_IPV4L_NODE
,
13521 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13522 install_element(BGP_IPV6_NODE
,
13523 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13524 install_element(BGP_IPV6_NODE
,
13525 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13526 install_element(BGP_IPV6M_NODE
,
13527 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13528 install_element(BGP_IPV6M_NODE
,
13529 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13530 install_element(BGP_IPV6L_NODE
,
13531 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13532 install_element(BGP_IPV6L_NODE
,
13533 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13534 install_element(BGP_VPNV4_NODE
,
13535 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13536 install_element(BGP_VPNV4_NODE
,
13537 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13538 install_element(BGP_VPNV6_NODE
,
13539 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13540 install_element(BGP_VPNV6_NODE
,
13541 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13543 /* "neighbor passive" commands. */
13544 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13545 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13548 /* "neighbor shutdown" commands. */
13549 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13550 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13551 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13552 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13554 /* "neighbor capability extended-nexthop" commands.*/
13555 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13556 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13558 /* "neighbor capability orf prefix-list" commands.*/
13559 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13560 install_element(BGP_NODE
,
13561 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13562 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13563 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13564 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13565 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13566 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13567 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13568 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13569 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13570 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13571 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13572 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13573 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13575 /* "neighbor capability dynamic" commands.*/
13576 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13577 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13579 /* "neighbor dont-capability-negotiate" commands. */
13580 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13581 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13583 /* "neighbor ebgp-multihop" commands. */
13584 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13585 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13586 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13588 /* "neighbor disable-connected-check" commands. */
13589 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13590 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13592 /* "neighbor enforce-first-as" commands. */
13593 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13594 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13596 /* "neighbor description" commands. */
13597 install_element(BGP_NODE
, &neighbor_description_cmd
);
13598 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13599 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13601 /* "neighbor update-source" commands. "*/
13602 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13603 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13605 /* "neighbor default-originate" commands. */
13606 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13607 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13608 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13609 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13610 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13611 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13612 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13613 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13614 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13615 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13616 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13617 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13618 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13619 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13620 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13621 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13622 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13623 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13624 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13625 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13626 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13628 /* "neighbor port" commands. */
13629 install_element(BGP_NODE
, &neighbor_port_cmd
);
13630 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13632 /* "neighbor weight" commands. */
13633 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13634 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13636 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13637 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13638 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13639 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13640 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13641 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13642 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13643 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13644 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13645 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13646 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13647 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13648 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13649 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13650 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13651 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13653 /* "neighbor override-capability" commands. */
13654 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13655 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13657 /* "neighbor strict-capability-match" commands. */
13658 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13659 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13661 /* "neighbor timers" commands. */
13662 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13663 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13665 /* "neighbor timers connect" commands. */
13666 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13667 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13669 /* "neighbor advertisement-interval" commands. */
13670 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13671 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13673 /* "neighbor interface" commands. */
13674 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13675 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13677 /* "neighbor distribute" commands. */
13678 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13679 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13680 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13681 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13682 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13683 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13684 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13685 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13686 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13687 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13688 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13689 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13690 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13691 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13692 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13693 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13694 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13695 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13697 /* "neighbor prefix-list" commands. */
13698 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13699 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13700 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13701 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13702 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13703 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13704 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13705 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13706 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13707 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13708 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13709 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13710 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13711 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13712 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13713 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13714 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13715 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13716 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13717 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13718 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13719 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13721 /* "neighbor filter-list" commands. */
13722 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13723 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13724 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13725 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13726 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13727 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13728 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13729 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13730 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13731 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13732 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13733 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13734 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13735 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13736 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13737 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13738 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13739 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13740 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13741 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13742 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13743 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13745 /* "neighbor route-map" commands. */
13746 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13747 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13748 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13749 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13750 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13751 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13752 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13753 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13754 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13755 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13756 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13757 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13758 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13759 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13760 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13761 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13762 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13763 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13764 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13765 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13766 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13767 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13768 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13769 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13771 /* "neighbor unsuppress-map" commands. */
13772 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13773 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13774 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13775 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13776 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13777 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13778 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13779 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13780 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13781 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13782 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13783 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13784 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13785 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13786 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13787 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13788 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13789 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13791 /* "neighbor maximum-prefix" commands. */
13792 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13793 install_element(BGP_NODE
,
13794 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13795 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13796 install_element(BGP_NODE
,
13797 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13798 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13799 install_element(BGP_NODE
,
13800 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13801 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13802 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13803 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13804 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13805 install_element(BGP_IPV4_NODE
,
13806 &neighbor_maximum_prefix_threshold_warning_cmd
);
13807 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13808 install_element(BGP_IPV4_NODE
,
13809 &neighbor_maximum_prefix_threshold_restart_cmd
);
13810 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13811 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13812 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13813 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13814 install_element(BGP_IPV4M_NODE
,
13815 &neighbor_maximum_prefix_threshold_warning_cmd
);
13816 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13817 install_element(BGP_IPV4M_NODE
,
13818 &neighbor_maximum_prefix_threshold_restart_cmd
);
13819 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13820 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13821 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13822 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13823 install_element(BGP_IPV4L_NODE
,
13824 &neighbor_maximum_prefix_threshold_warning_cmd
);
13825 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13826 install_element(BGP_IPV4L_NODE
,
13827 &neighbor_maximum_prefix_threshold_restart_cmd
);
13828 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13829 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13830 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13831 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13832 install_element(BGP_IPV6_NODE
,
13833 &neighbor_maximum_prefix_threshold_warning_cmd
);
13834 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13835 install_element(BGP_IPV6_NODE
,
13836 &neighbor_maximum_prefix_threshold_restart_cmd
);
13837 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13838 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13839 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13840 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13841 install_element(BGP_IPV6M_NODE
,
13842 &neighbor_maximum_prefix_threshold_warning_cmd
);
13843 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13844 install_element(BGP_IPV6M_NODE
,
13845 &neighbor_maximum_prefix_threshold_restart_cmd
);
13846 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13847 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13848 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13849 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13850 install_element(BGP_IPV6L_NODE
,
13851 &neighbor_maximum_prefix_threshold_warning_cmd
);
13852 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13853 install_element(BGP_IPV6L_NODE
,
13854 &neighbor_maximum_prefix_threshold_restart_cmd
);
13855 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13856 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13857 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13858 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13859 install_element(BGP_VPNV4_NODE
,
13860 &neighbor_maximum_prefix_threshold_warning_cmd
);
13861 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13862 install_element(BGP_VPNV4_NODE
,
13863 &neighbor_maximum_prefix_threshold_restart_cmd
);
13864 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13865 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13866 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13867 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13868 install_element(BGP_VPNV6_NODE
,
13869 &neighbor_maximum_prefix_threshold_warning_cmd
);
13870 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13871 install_element(BGP_VPNV6_NODE
,
13872 &neighbor_maximum_prefix_threshold_restart_cmd
);
13873 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13875 /* "neighbor allowas-in" */
13876 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13877 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13878 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13879 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13880 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13881 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13882 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13883 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13884 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13885 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13886 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13887 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13888 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13889 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13890 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13891 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13892 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13893 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13894 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13895 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13897 /* address-family commands. */
13898 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13899 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13900 #ifdef KEEP_OLD_VPN_COMMANDS
13901 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13902 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13903 #endif /* KEEP_OLD_VPN_COMMANDS */
13905 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13907 /* "exit-address-family" command. */
13908 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13909 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13910 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13911 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13912 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13913 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13914 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13915 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13916 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13917 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13918 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13920 /* "clear ip bgp commands" */
13921 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13923 /* clear ip bgp prefix */
13924 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13925 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13926 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13928 /* "show [ip] bgp summary" commands. */
13929 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13930 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13931 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13932 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13933 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13934 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13935 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13937 /* "show [ip] bgp neighbors" commands. */
13938 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13940 /* "show [ip] bgp peer-group" commands. */
13941 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13943 /* "show [ip] bgp paths" commands. */
13944 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13946 /* "show [ip] bgp community" commands. */
13947 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13949 /* "show ip bgp large-community" commands. */
13950 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13951 /* "show [ip] bgp attribute-info" commands. */
13952 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13953 /* "show [ip] bgp route-leak" command */
13954 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13956 /* "redistribute" commands. */
13957 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13958 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13959 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13960 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13961 install_element(BGP_NODE
,
13962 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13963 install_element(BGP_NODE
,
13964 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13965 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13966 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13967 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13968 install_element(BGP_NODE
,
13969 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13970 install_element(BGP_NODE
,
13971 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13972 install_element(BGP_NODE
,
13973 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13974 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13975 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13976 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13977 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13978 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13979 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13980 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13981 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13982 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13983 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13984 install_element(BGP_IPV4_NODE
,
13985 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13986 install_element(BGP_IPV4_NODE
,
13987 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13988 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13989 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13990 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13991 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13992 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13993 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13995 /* import|export vpn [route-map WORD] */
13996 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13997 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13999 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14000 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14002 /* ttl_security commands */
14003 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14004 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14006 /* "show [ip] bgp memory" commands. */
14007 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14009 /* "show bgp martian next-hop" */
14010 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14012 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14014 /* "show [ip] bgp views" commands. */
14015 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14017 /* "show [ip] bgp vrfs" commands. */
14018 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14020 /* Community-list. */
14021 community_list_vty();
14023 /* vpn-policy commands */
14024 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14025 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14026 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14027 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14028 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14029 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14030 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14031 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14032 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14033 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14034 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14035 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14037 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14038 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14040 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14041 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14042 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14043 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14044 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14045 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14046 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14047 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14048 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14049 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14050 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14051 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14054 #include "memory.h"
14055 #include "bgp_regex.h"
14056 #include "bgp_clist.h"
14057 #include "bgp_ecommunity.h"
14059 /* VTY functions. */
14061 /* Direction value to string conversion. */
14062 static const char *community_direct_str(int direct
)
14065 case COMMUNITY_DENY
:
14067 case COMMUNITY_PERMIT
:
14074 /* Display error string. */
14075 static void community_list_perror(struct vty
*vty
, int ret
)
14078 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14079 vty_out(vty
, "%% Can't find community-list\n");
14081 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14082 vty_out(vty
, "%% Malformed community-list value\n");
14084 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14086 "%% Community name conflict, previously defined as standard community\n");
14088 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14090 "%% Community name conflict, previously defined as expanded community\n");
14095 /* "community-list" keyword help string. */
14096 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14098 /*community-list standard */
14099 DEFUN (community_list_standard
,
14100 bgp_community_list_standard_cmd
,
14101 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14104 "Community list number (standard)\n"
14105 "Add an standard community-list entry\n"
14106 "Community list name\n"
14107 "Specify community to reject\n"
14108 "Specify community to accept\n"
14111 char *cl_name_or_number
= NULL
;
14113 int style
= COMMUNITY_LIST_STANDARD
;
14117 if (argv_find(argv
, argc
, "ip", &idx
)) {
14118 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14119 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14120 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14121 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14124 argv_find(argv
, argc
, "(1-99)", &idx
);
14125 argv_find(argv
, argc
, "WORD", &idx
);
14126 cl_name_or_number
= argv
[idx
]->arg
;
14127 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14129 argv_find(argv
, argc
, "AA:NN", &idx
);
14130 char *str
= argv_concat(argv
, argc
, idx
);
14132 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14135 XFREE(MTYPE_TMP
, str
);
14138 /* Display error string. */
14139 community_list_perror(vty
, ret
);
14140 return CMD_WARNING_CONFIG_FAILED
;
14143 return CMD_SUCCESS
;
14146 #if CONFDATE > 20191005
14147 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14149 ALIAS (community_list_standard
,
14150 ip_community_list_standard_cmd
,
14151 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14154 "Community list number (standard)\n"
14155 "Add an standard community-list entry\n"
14156 "Community list name\n"
14157 "Specify community to reject\n"
14158 "Specify community to accept\n"
14161 DEFUN (no_community_list_standard_all
,
14162 no_bgp_community_list_standard_all_cmd
,
14163 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14167 "Community list number (standard)\n"
14168 "Add an standard community-list entry\n"
14169 "Community list name\n"
14170 "Specify community to reject\n"
14171 "Specify community to accept\n"
14174 char *cl_name_or_number
= NULL
;
14177 int style
= COMMUNITY_LIST_STANDARD
;
14181 if (argv_find(argv
, argc
, "ip", &idx
)) {
14182 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14183 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14184 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14185 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14188 argv_find(argv
, argc
, "permit", &idx
);
14189 argv_find(argv
, argc
, "deny", &idx
);
14192 direct
= argv_find(argv
, argc
, "permit", &idx
)
14197 argv_find(argv
, argc
, "AA:NN", &idx
);
14198 str
= argv_concat(argv
, argc
, idx
);
14202 argv_find(argv
, argc
, "(1-99)", &idx
);
14203 argv_find(argv
, argc
, "WORD", &idx
);
14204 cl_name_or_number
= argv
[idx
]->arg
;
14206 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14209 XFREE(MTYPE_TMP
, str
);
14212 community_list_perror(vty
, ret
);
14213 return CMD_WARNING_CONFIG_FAILED
;
14216 return CMD_SUCCESS
;
14218 ALIAS (no_community_list_standard_all
,
14219 no_ip_community_list_standard_all_cmd
,
14220 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14224 "Community list number (standard)\n"
14225 "Add an standard community-list entry\n"
14226 "Community list name\n"
14227 "Specify community to reject\n"
14228 "Specify community to accept\n"
14231 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14232 "no bgp community-list <(1-99)|standard WORD>",
14233 NO_STR BGP_STR COMMUNITY_LIST_STR
14234 "Community list number (standard)\n"
14235 "Add an standard community-list entry\n"
14236 "Community list name\n")
14238 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14239 "no ip community-list <(1-99)|standard WORD>",
14240 NO_STR BGP_STR COMMUNITY_LIST_STR
14241 "Community list number (standard)\n"
14242 "Add an standard community-list entry\n"
14243 "Community list name\n")
14245 /*community-list expanded */
14246 DEFUN (community_list_expanded_all
,
14247 bgp_community_list_expanded_all_cmd
,
14248 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14251 "Community list number (expanded)\n"
14252 "Add an expanded community-list entry\n"
14253 "Community list name\n"
14254 "Specify community to reject\n"
14255 "Specify community to accept\n"
14258 char *cl_name_or_number
= NULL
;
14260 int style
= COMMUNITY_LIST_EXPANDED
;
14263 if (argv_find(argv
, argc
, "ip", &idx
)) {
14264 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14265 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14266 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14267 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14269 argv_find(argv
, argc
, "(100-500)", &idx
);
14270 argv_find(argv
, argc
, "WORD", &idx
);
14271 cl_name_or_number
= argv
[idx
]->arg
;
14272 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14274 argv_find(argv
, argc
, "AA:NN", &idx
);
14275 char *str
= argv_concat(argv
, argc
, idx
);
14277 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14280 XFREE(MTYPE_TMP
, str
);
14283 /* Display error string. */
14284 community_list_perror(vty
, ret
);
14285 return CMD_WARNING_CONFIG_FAILED
;
14288 return CMD_SUCCESS
;
14291 ALIAS (community_list_expanded_all
,
14292 ip_community_list_expanded_all_cmd
,
14293 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14296 "Community list number (expanded)\n"
14297 "Add an expanded community-list entry\n"
14298 "Community list name\n"
14299 "Specify community to reject\n"
14300 "Specify community to accept\n"
14303 DEFUN (no_community_list_expanded_all
,
14304 no_bgp_community_list_expanded_all_cmd
,
14305 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14309 "Community list number (expanded)\n"
14310 "Add an expanded community-list entry\n"
14311 "Community list name\n"
14312 "Specify community to reject\n"
14313 "Specify community to accept\n"
14316 char *cl_name_or_number
= NULL
;
14319 int style
= COMMUNITY_LIST_EXPANDED
;
14322 if (argv_find(argv
, argc
, "ip", &idx
)) {
14323 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14324 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14325 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14326 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14330 argv_find(argv
, argc
, "permit", &idx
);
14331 argv_find(argv
, argc
, "deny", &idx
);
14334 direct
= argv_find(argv
, argc
, "permit", &idx
)
14339 argv_find(argv
, argc
, "AA:NN", &idx
);
14340 str
= argv_concat(argv
, argc
, idx
);
14344 argv_find(argv
, argc
, "(100-500)", &idx
);
14345 argv_find(argv
, argc
, "WORD", &idx
);
14346 cl_name_or_number
= argv
[idx
]->arg
;
14348 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14351 XFREE(MTYPE_TMP
, str
);
14354 community_list_perror(vty
, ret
);
14355 return CMD_WARNING_CONFIG_FAILED
;
14358 return CMD_SUCCESS
;
14361 ALIAS (no_community_list_expanded_all
,
14362 no_ip_community_list_expanded_all_cmd
,
14363 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14367 "Community list number (expanded)\n"
14368 "Add an expanded community-list entry\n"
14369 "Community list name\n"
14370 "Specify community to reject\n"
14371 "Specify community to accept\n"
14374 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14375 "no bgp community-list <(100-500)|expanded WORD>",
14376 NO_STR IP_STR COMMUNITY_LIST_STR
14377 "Community list number (expanded)\n"
14378 "Add an expanded community-list entry\n"
14379 "Community list name\n")
14381 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14382 "no ip community-list <(100-500)|expanded WORD>",
14383 NO_STR IP_STR COMMUNITY_LIST_STR
14384 "Community list number (expanded)\n"
14385 "Add an expanded community-list entry\n"
14386 "Community list name\n")
14388 /* Return configuration string of community-list entry. */
14389 static const char *community_list_config_str(struct community_entry
*entry
)
14396 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14397 str
= community_str(entry
->u
.com
, false);
14398 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14399 str
= lcommunity_str(entry
->u
.lcom
, false);
14401 str
= entry
->config
;
14406 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14408 struct community_entry
*entry
;
14410 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14411 if (entry
== list
->head
) {
14412 if (all_digit(list
->name
))
14413 vty_out(vty
, "Community %s list %s\n",
14414 entry
->style
== COMMUNITY_LIST_STANDARD
14416 : "(expanded) access",
14419 vty_out(vty
, "Named Community %s list %s\n",
14420 entry
->style
== COMMUNITY_LIST_STANDARD
14426 vty_out(vty
, " %s\n",
14427 community_direct_str(entry
->direct
));
14429 vty_out(vty
, " %s %s\n",
14430 community_direct_str(entry
->direct
),
14431 community_list_config_str(entry
));
14435 DEFUN (show_community_list
,
14436 show_bgp_community_list_cmd
,
14437 "show bgp community-list",
14440 "List community-list\n")
14442 struct community_list
*list
;
14443 struct community_list_master
*cm
;
14446 if (argv_find(argv
, argc
, "ip", &idx
)) {
14447 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14448 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14449 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14450 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14452 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14454 return CMD_SUCCESS
;
14456 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14457 community_list_show(vty
, list
);
14459 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14460 community_list_show(vty
, list
);
14462 return CMD_SUCCESS
;
14465 ALIAS (show_community_list
,
14466 show_ip_community_list_cmd
,
14467 "show ip community-list",
14470 "List community-list\n")
14472 DEFUN (show_community_list_arg
,
14473 show_bgp_community_list_arg_cmd
,
14474 "show bgp community-list <(1-500)|WORD>",
14477 "List community-list\n"
14478 "Community-list number\n"
14479 "Community-list name\n")
14481 int idx_comm_list
= 3;
14482 struct community_list
*list
;
14485 if (argv_find(argv
, argc
, "ip", &idx
)) {
14486 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14487 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14488 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14489 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14491 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14492 COMMUNITY_LIST_MASTER
);
14494 vty_out(vty
, "%% Can't find community-list\n");
14495 return CMD_WARNING
;
14498 community_list_show(vty
, list
);
14500 return CMD_SUCCESS
;
14503 ALIAS (show_community_list_arg
,
14504 show_ip_community_list_arg_cmd
,
14505 "show ip community-list <(1-500)|WORD>",
14508 "List community-list\n"
14509 "Community-list number\n"
14510 "Community-list name\n")
14513 * Large Community code.
14515 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14516 struct cmd_token
**argv
, int style
,
14517 int reject_all_digit_name
)
14525 if (argv_find(argv
, argc
, "ip", &idx
)) {
14526 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14527 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14528 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14529 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14531 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14534 /* All digit name check. */
14536 argv_find(argv
, argc
, "WORD", &idx
);
14537 argv_find(argv
, argc
, "(1-99)", &idx
);
14538 argv_find(argv
, argc
, "(100-500)", &idx
);
14539 cl_name
= argv
[idx
]->arg
;
14540 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14541 vty_out(vty
, "%% Community name cannot have all digits\n");
14542 return CMD_WARNING_CONFIG_FAILED
;
14546 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14547 argv_find(argv
, argc
, "LINE", &idx
);
14548 /* Concat community string argument. */
14550 str
= argv_concat(argv
, argc
, idx
);
14554 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14556 /* Free temporary community list string allocated by
14558 XFREE(MTYPE_TMP
, str
);
14561 community_list_perror(vty
, ret
);
14562 return CMD_WARNING_CONFIG_FAILED
;
14564 return CMD_SUCCESS
;
14567 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14568 struct cmd_token
**argv
, int style
)
14575 if (argv_find(argv
, argc
, "ip", &idx
)) {
14576 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14577 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14578 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14579 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14581 argv_find(argv
, argc
, "permit", &idx
);
14582 argv_find(argv
, argc
, "deny", &idx
);
14585 /* Check the list direct. */
14586 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14587 direct
= COMMUNITY_PERMIT
;
14589 direct
= COMMUNITY_DENY
;
14592 argv_find(argv
, argc
, "LINE", &idx
);
14593 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14594 /* Concat community string argument. */
14595 str
= argv_concat(argv
, argc
, idx
);
14599 argv_find(argv
, argc
, "(1-99)", &idx
);
14600 argv_find(argv
, argc
, "(100-500)", &idx
);
14601 argv_find(argv
, argc
, "WORD", &idx
);
14603 /* Unset community list. */
14604 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14607 /* Free temporary community list string allocated by
14609 XFREE(MTYPE_TMP
, str
);
14612 community_list_perror(vty
, ret
);
14613 return CMD_WARNING_CONFIG_FAILED
;
14616 return CMD_SUCCESS
;
14619 /* "large-community-list" keyword help string. */
14620 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14621 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14623 #if CONFDATE > 20191005
14624 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14626 DEFUN (lcommunity_list_standard
,
14627 bgp_lcommunity_list_standard_cmd
,
14628 "bgp large-community-list (1-99) <deny|permit>",
14630 LCOMMUNITY_LIST_STR
14631 "Large Community list number (standard)\n"
14632 "Specify large community to reject\n"
14633 "Specify large community to accept\n")
14635 return lcommunity_list_set_vty(vty
, argc
, argv
,
14636 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14639 ALIAS (lcommunity_list_standard
,
14640 ip_lcommunity_list_standard_cmd
,
14641 "ip large-community-list (1-99) <deny|permit>",
14643 LCOMMUNITY_LIST_STR
14644 "Large Community list number (standard)\n"
14645 "Specify large community to reject\n"
14646 "Specify large community to accept\n")
14648 DEFUN (lcommunity_list_standard1
,
14649 bgp_lcommunity_list_standard1_cmd
,
14650 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14652 LCOMMUNITY_LIST_STR
14653 "Large Community list number (standard)\n"
14654 "Specify large community to reject\n"
14655 "Specify large community to accept\n"
14656 LCOMMUNITY_VAL_STR
)
14658 return lcommunity_list_set_vty(vty
, argc
, argv
,
14659 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14662 ALIAS (lcommunity_list_standard1
,
14663 ip_lcommunity_list_standard1_cmd
,
14664 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14666 LCOMMUNITY_LIST_STR
14667 "Large Community list number (standard)\n"
14668 "Specify large community to reject\n"
14669 "Specify large community to accept\n"
14670 LCOMMUNITY_VAL_STR
)
14672 DEFUN (lcommunity_list_expanded
,
14673 bgp_lcommunity_list_expanded_cmd
,
14674 "bgp large-community-list (100-500) <deny|permit> LINE...",
14676 LCOMMUNITY_LIST_STR
14677 "Large Community list number (expanded)\n"
14678 "Specify large community to reject\n"
14679 "Specify large community to accept\n"
14680 "An ordered list as a regular-expression\n")
14682 return lcommunity_list_set_vty(vty
, argc
, argv
,
14683 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14686 ALIAS (lcommunity_list_expanded
,
14687 ip_lcommunity_list_expanded_cmd
,
14688 "ip large-community-list (100-500) <deny|permit> LINE...",
14690 LCOMMUNITY_LIST_STR
14691 "Large Community list number (expanded)\n"
14692 "Specify large community to reject\n"
14693 "Specify large community to accept\n"
14694 "An ordered list as a regular-expression\n")
14696 DEFUN (lcommunity_list_name_standard
,
14697 bgp_lcommunity_list_name_standard_cmd
,
14698 "bgp large-community-list standard WORD <deny|permit>",
14700 LCOMMUNITY_LIST_STR
14701 "Specify standard large-community-list\n"
14702 "Large Community list name\n"
14703 "Specify large community to reject\n"
14704 "Specify large community to accept\n")
14706 return lcommunity_list_set_vty(vty
, argc
, argv
,
14707 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14710 ALIAS (lcommunity_list_name_standard
,
14711 ip_lcommunity_list_name_standard_cmd
,
14712 "ip large-community-list standard WORD <deny|permit>",
14714 LCOMMUNITY_LIST_STR
14715 "Specify standard large-community-list\n"
14716 "Large Community list name\n"
14717 "Specify large community to reject\n"
14718 "Specify large community to accept\n")
14720 DEFUN (lcommunity_list_name_standard1
,
14721 bgp_lcommunity_list_name_standard1_cmd
,
14722 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14724 LCOMMUNITY_LIST_STR
14725 "Specify standard large-community-list\n"
14726 "Large Community list name\n"
14727 "Specify large community to reject\n"
14728 "Specify large community to accept\n"
14729 LCOMMUNITY_VAL_STR
)
14731 return lcommunity_list_set_vty(vty
, argc
, argv
,
14732 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14735 ALIAS (lcommunity_list_name_standard1
,
14736 ip_lcommunity_list_name_standard1_cmd
,
14737 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14739 LCOMMUNITY_LIST_STR
14740 "Specify standard large-community-list\n"
14741 "Large Community list name\n"
14742 "Specify large community to reject\n"
14743 "Specify large community to accept\n"
14744 LCOMMUNITY_VAL_STR
)
14746 DEFUN (lcommunity_list_name_expanded
,
14747 bgp_lcommunity_list_name_expanded_cmd
,
14748 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14750 LCOMMUNITY_LIST_STR
14751 "Specify expanded large-community-list\n"
14752 "Large Community list name\n"
14753 "Specify large community to reject\n"
14754 "Specify large community to accept\n"
14755 "An ordered list as a regular-expression\n")
14757 return lcommunity_list_set_vty(vty
, argc
, argv
,
14758 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14761 ALIAS (lcommunity_list_name_expanded
,
14762 ip_lcommunity_list_name_expanded_cmd
,
14763 "ip large-community-list expanded WORD <deny|permit> LINE...",
14765 LCOMMUNITY_LIST_STR
14766 "Specify expanded large-community-list\n"
14767 "Large Community list name\n"
14768 "Specify large community to reject\n"
14769 "Specify large community to accept\n"
14770 "An ordered list as a regular-expression\n")
14772 DEFUN (no_lcommunity_list_standard_all
,
14773 no_bgp_lcommunity_list_standard_all_cmd
,
14774 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14777 LCOMMUNITY_LIST_STR
14778 "Large Community list number (standard)\n"
14779 "Large Community list number (expanded)\n"
14780 "Large Community list name\n")
14782 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14783 LARGE_COMMUNITY_LIST_STANDARD
);
14786 ALIAS (no_lcommunity_list_standard_all
,
14787 no_ip_lcommunity_list_standard_all_cmd
,
14788 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14791 LCOMMUNITY_LIST_STR
14792 "Large Community list number (standard)\n"
14793 "Large Community list number (expanded)\n"
14794 "Large Community list name\n")
14796 DEFUN (no_lcommunity_list_name_expanded_all
,
14797 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14798 "no bgp large-community-list expanded WORD",
14801 LCOMMUNITY_LIST_STR
14802 "Specify expanded large-community-list\n"
14803 "Large Community list name\n")
14805 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14806 LARGE_COMMUNITY_LIST_EXPANDED
);
14809 ALIAS (no_lcommunity_list_name_expanded_all
,
14810 no_ip_lcommunity_list_name_expanded_all_cmd
,
14811 "no ip large-community-list expanded WORD",
14814 LCOMMUNITY_LIST_STR
14815 "Specify expanded large-community-list\n"
14816 "Large Community list name\n")
14818 DEFUN (no_lcommunity_list_standard
,
14819 no_bgp_lcommunity_list_standard_cmd
,
14820 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14823 LCOMMUNITY_LIST_STR
14824 "Large Community list number (standard)\n"
14825 "Specify large community to reject\n"
14826 "Specify large community to accept\n"
14827 LCOMMUNITY_VAL_STR
)
14829 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14830 LARGE_COMMUNITY_LIST_STANDARD
);
14833 ALIAS (no_lcommunity_list_standard
,
14834 no_ip_lcommunity_list_standard_cmd
,
14835 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14838 LCOMMUNITY_LIST_STR
14839 "Large Community list number (standard)\n"
14840 "Specify large community to reject\n"
14841 "Specify large community to accept\n"
14842 LCOMMUNITY_VAL_STR
)
14844 DEFUN (no_lcommunity_list_expanded
,
14845 no_bgp_lcommunity_list_expanded_cmd
,
14846 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14849 LCOMMUNITY_LIST_STR
14850 "Large Community list number (expanded)\n"
14851 "Specify large community to reject\n"
14852 "Specify large community to accept\n"
14853 "An ordered list as a regular-expression\n")
14855 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14856 LARGE_COMMUNITY_LIST_EXPANDED
);
14859 ALIAS (no_lcommunity_list_expanded
,
14860 no_ip_lcommunity_list_expanded_cmd
,
14861 "no ip large-community-list (100-500) <deny|permit> LINE...",
14864 LCOMMUNITY_LIST_STR
14865 "Large Community list number (expanded)\n"
14866 "Specify large community to reject\n"
14867 "Specify large community to accept\n"
14868 "An ordered list as a regular-expression\n")
14870 DEFUN (no_lcommunity_list_name_standard
,
14871 no_bgp_lcommunity_list_name_standard_cmd
,
14872 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14875 LCOMMUNITY_LIST_STR
14876 "Specify standard large-community-list\n"
14877 "Large Community list name\n"
14878 "Specify large community to reject\n"
14879 "Specify large community to accept\n"
14880 LCOMMUNITY_VAL_STR
)
14882 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14883 LARGE_COMMUNITY_LIST_STANDARD
);
14886 ALIAS (no_lcommunity_list_name_standard
,
14887 no_ip_lcommunity_list_name_standard_cmd
,
14888 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14891 LCOMMUNITY_LIST_STR
14892 "Specify standard large-community-list\n"
14893 "Large Community list name\n"
14894 "Specify large community to reject\n"
14895 "Specify large community to accept\n"
14896 LCOMMUNITY_VAL_STR
)
14898 DEFUN (no_lcommunity_list_name_expanded
,
14899 no_bgp_lcommunity_list_name_expanded_cmd
,
14900 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14903 LCOMMUNITY_LIST_STR
14904 "Specify expanded large-community-list\n"
14905 "Large community list name\n"
14906 "Specify large community to reject\n"
14907 "Specify large community to accept\n"
14908 "An ordered list as a regular-expression\n")
14910 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14911 LARGE_COMMUNITY_LIST_EXPANDED
);
14914 ALIAS (no_lcommunity_list_name_expanded
,
14915 no_ip_lcommunity_list_name_expanded_cmd
,
14916 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14919 LCOMMUNITY_LIST_STR
14920 "Specify expanded large-community-list\n"
14921 "Large community list name\n"
14922 "Specify large community to reject\n"
14923 "Specify large community to accept\n"
14924 "An ordered list as a regular-expression\n")
14926 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14928 struct community_entry
*entry
;
14930 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14931 if (entry
== list
->head
) {
14932 if (all_digit(list
->name
))
14933 vty_out(vty
, "Large community %s list %s\n",
14934 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14936 : "(expanded) access",
14940 "Named large community %s list %s\n",
14941 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14947 vty_out(vty
, " %s\n",
14948 community_direct_str(entry
->direct
));
14950 vty_out(vty
, " %s %s\n",
14951 community_direct_str(entry
->direct
),
14952 community_list_config_str(entry
));
14956 DEFUN (show_lcommunity_list
,
14957 show_bgp_lcommunity_list_cmd
,
14958 "show bgp large-community-list",
14961 "List large-community list\n")
14963 struct community_list
*list
;
14964 struct community_list_master
*cm
;
14967 if (argv_find(argv
, argc
, "ip", &idx
)) {
14968 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14969 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14970 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14971 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14974 cm
= community_list_master_lookup(bgp_clist
,
14975 LARGE_COMMUNITY_LIST_MASTER
);
14977 return CMD_SUCCESS
;
14979 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14980 lcommunity_list_show(vty
, list
);
14982 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14983 lcommunity_list_show(vty
, list
);
14985 return CMD_SUCCESS
;
14988 ALIAS (show_lcommunity_list
,
14989 show_ip_lcommunity_list_cmd
,
14990 "show ip large-community-list",
14993 "List large-community list\n")
14995 DEFUN (show_lcommunity_list_arg
,
14996 show_bgp_lcommunity_list_arg_cmd
,
14997 "show bgp large-community-list <(1-500)|WORD>",
15000 "List large-community list\n"
15001 "large-community-list number\n"
15002 "large-community-list name\n")
15004 struct community_list
*list
;
15007 if (argv_find(argv
, argc
, "ip", &idx
)) {
15008 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15009 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15010 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15011 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15014 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
15015 LARGE_COMMUNITY_LIST_MASTER
);
15017 vty_out(vty
, "%% Can't find extcommunity-list\n");
15018 return CMD_WARNING
;
15021 lcommunity_list_show(vty
, list
);
15023 return CMD_SUCCESS
;
15026 ALIAS (show_lcommunity_list_arg
,
15027 show_ip_lcommunity_list_arg_cmd
,
15028 "show ip large-community-list <(1-500)|WORD>",
15031 "List large-community list\n"
15032 "large-community-list number\n"
15033 "large-community-list name\n")
15035 /* "extcommunity-list" keyword help string. */
15036 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15037 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15039 DEFUN (extcommunity_list_standard
,
15040 bgp_extcommunity_list_standard_cmd
,
15041 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15043 EXTCOMMUNITY_LIST_STR
15044 "Extended Community list number (standard)\n"
15045 "Specify standard extcommunity-list\n"
15046 "Community list name\n"
15047 "Specify community to reject\n"
15048 "Specify community to accept\n"
15049 EXTCOMMUNITY_VAL_STR
)
15051 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15053 char *cl_number_or_name
= NULL
;
15056 if (argv_find(argv
, argc
, "ip", &idx
)) {
15057 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15058 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15059 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15060 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15062 argv_find(argv
, argc
, "(1-99)", &idx
);
15063 argv_find(argv
, argc
, "WORD", &idx
);
15064 cl_number_or_name
= argv
[idx
]->arg
;
15065 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15067 argv_find(argv
, argc
, "AA:NN", &idx
);
15068 char *str
= argv_concat(argv
, argc
, idx
);
15070 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15073 XFREE(MTYPE_TMP
, str
);
15076 community_list_perror(vty
, ret
);
15077 return CMD_WARNING_CONFIG_FAILED
;
15080 return CMD_SUCCESS
;
15083 #if CONFDATE > 20191005
15084 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15086 ALIAS (extcommunity_list_standard
,
15087 ip_extcommunity_list_standard_cmd
,
15088 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15090 EXTCOMMUNITY_LIST_STR
15091 "Extended Community list number (standard)\n"
15092 "Specify standard extcommunity-list\n"
15093 "Community list name\n"
15094 "Specify community to reject\n"
15095 "Specify community to accept\n"
15096 EXTCOMMUNITY_VAL_STR
)
15098 DEFUN (extcommunity_list_name_expanded
,
15099 bgp_extcommunity_list_name_expanded_cmd
,
15100 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15102 EXTCOMMUNITY_LIST_STR
15103 "Extended Community list number (expanded)\n"
15104 "Specify expanded extcommunity-list\n"
15105 "Extended Community list name\n"
15106 "Specify community to reject\n"
15107 "Specify community to accept\n"
15108 "An ordered list as a regular-expression\n")
15110 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15112 char *cl_number_or_name
= NULL
;
15115 if (argv_find(argv
, argc
, "ip", &idx
)) {
15116 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15117 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15118 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15119 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15122 argv_find(argv
, argc
, "(100-500)", &idx
);
15123 argv_find(argv
, argc
, "WORD", &idx
);
15124 cl_number_or_name
= argv
[idx
]->arg
;
15125 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15127 argv_find(argv
, argc
, "LINE", &idx
);
15128 char *str
= argv_concat(argv
, argc
, idx
);
15130 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15133 XFREE(MTYPE_TMP
, str
);
15136 community_list_perror(vty
, ret
);
15137 return CMD_WARNING_CONFIG_FAILED
;
15140 return CMD_SUCCESS
;
15143 ALIAS (extcommunity_list_name_expanded
,
15144 ip_extcommunity_list_name_expanded_cmd
,
15145 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15147 EXTCOMMUNITY_LIST_STR
15148 "Extended Community list number (expanded)\n"
15149 "Specify expanded extcommunity-list\n"
15150 "Extended Community list name\n"
15151 "Specify community to reject\n"
15152 "Specify community to accept\n"
15153 "An ordered list as a regular-expression\n")
15155 DEFUN (no_extcommunity_list_standard_all
,
15156 no_bgp_extcommunity_list_standard_all_cmd
,
15157 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15160 EXTCOMMUNITY_LIST_STR
15161 "Extended Community list number (standard)\n"
15162 "Specify standard extcommunity-list\n"
15163 "Community list name\n"
15164 "Specify community to reject\n"
15165 "Specify community to accept\n"
15166 EXTCOMMUNITY_VAL_STR
)
15168 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15170 char *cl_number_or_name
= NULL
;
15174 if (argv_find(argv
, argc
, "ip", &idx
)) {
15175 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15176 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15177 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15178 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15182 argv_find(argv
, argc
, "permit", &idx
);
15183 argv_find(argv
, argc
, "deny", &idx
);
15186 direct
= argv_find(argv
, argc
, "permit", &idx
)
15191 argv_find(argv
, argc
, "AA:NN", &idx
);
15192 str
= argv_concat(argv
, argc
, idx
);
15196 argv_find(argv
, argc
, "(1-99)", &idx
);
15197 argv_find(argv
, argc
, "WORD", &idx
);
15198 cl_number_or_name
= argv
[idx
]->arg
;
15200 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15203 XFREE(MTYPE_TMP
, str
);
15206 community_list_perror(vty
, ret
);
15207 return CMD_WARNING_CONFIG_FAILED
;
15210 return CMD_SUCCESS
;
15213 ALIAS (no_extcommunity_list_standard_all
,
15214 no_ip_extcommunity_list_standard_all_cmd
,
15215 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15218 EXTCOMMUNITY_LIST_STR
15219 "Extended Community list number (standard)\n"
15220 "Specify standard extcommunity-list\n"
15221 "Community list name\n"
15222 "Specify community to reject\n"
15223 "Specify community to accept\n"
15224 EXTCOMMUNITY_VAL_STR
)
15226 ALIAS(no_extcommunity_list_standard_all
,
15227 no_bgp_extcommunity_list_standard_all_list_cmd
,
15228 "no bgp extcommunity-list <(1-99)|standard WORD>",
15229 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15230 "Extended Community list number (standard)\n"
15231 "Specify standard extcommunity-list\n"
15232 "Community list name\n")
15234 ALIAS(no_extcommunity_list_standard_all
,
15235 no_ip_extcommunity_list_standard_all_list_cmd
,
15236 "no ip extcommunity-list <(1-99)|standard WORD>",
15237 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15238 "Extended Community list number (standard)\n"
15239 "Specify standard extcommunity-list\n"
15240 "Community list name\n")
15242 DEFUN (no_extcommunity_list_expanded_all
,
15243 no_bgp_extcommunity_list_expanded_all_cmd
,
15244 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15247 EXTCOMMUNITY_LIST_STR
15248 "Extended Community list number (expanded)\n"
15249 "Specify expanded extcommunity-list\n"
15250 "Extended Community list name\n"
15251 "Specify community to reject\n"
15252 "Specify community to accept\n"
15253 "An ordered list as a regular-expression\n")
15255 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15257 char *cl_number_or_name
= NULL
;
15261 if (argv_find(argv
, argc
, "ip", &idx
)) {
15262 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15263 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15264 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15265 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15269 argv_find(argv
, argc
, "permit", &idx
);
15270 argv_find(argv
, argc
, "deny", &idx
);
15273 direct
= argv_find(argv
, argc
, "permit", &idx
)
15278 argv_find(argv
, argc
, "LINE", &idx
);
15279 str
= argv_concat(argv
, argc
, idx
);
15283 argv_find(argv
, argc
, "(100-500)", &idx
);
15284 argv_find(argv
, argc
, "WORD", &idx
);
15285 cl_number_or_name
= argv
[idx
]->arg
;
15287 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15290 XFREE(MTYPE_TMP
, str
);
15293 community_list_perror(vty
, ret
);
15294 return CMD_WARNING_CONFIG_FAILED
;
15297 return CMD_SUCCESS
;
15300 ALIAS (no_extcommunity_list_expanded_all
,
15301 no_ip_extcommunity_list_expanded_all_cmd
,
15302 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15305 EXTCOMMUNITY_LIST_STR
15306 "Extended Community list number (expanded)\n"
15307 "Specify expanded extcommunity-list\n"
15308 "Extended Community list name\n"
15309 "Specify community to reject\n"
15310 "Specify community to accept\n"
15311 "An ordered list as a regular-expression\n")
15313 ALIAS(no_extcommunity_list_expanded_all
,
15314 no_ip_extcommunity_list_expanded_all_list_cmd
,
15315 "no ip extcommunity-list <(100-500)|expanded WORD>",
15316 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15317 "Extended Community list number (expanded)\n"
15318 "Specify expanded extcommunity-list\n"
15319 "Extended Community list name\n")
15321 ALIAS(no_extcommunity_list_expanded_all
,
15322 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15323 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15324 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15325 "Extended Community list number (expanded)\n"
15326 "Specify expanded extcommunity-list\n"
15327 "Extended Community list name\n")
15329 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15331 struct community_entry
*entry
;
15333 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15334 if (entry
== list
->head
) {
15335 if (all_digit(list
->name
))
15336 vty_out(vty
, "Extended community %s list %s\n",
15337 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15339 : "(expanded) access",
15343 "Named extended community %s list %s\n",
15344 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15350 vty_out(vty
, " %s\n",
15351 community_direct_str(entry
->direct
));
15353 vty_out(vty
, " %s %s\n",
15354 community_direct_str(entry
->direct
),
15355 community_list_config_str(entry
));
15359 DEFUN (show_extcommunity_list
,
15360 show_bgp_extcommunity_list_cmd
,
15361 "show bgp extcommunity-list",
15364 "List extended-community list\n")
15366 struct community_list
*list
;
15367 struct community_list_master
*cm
;
15370 if (argv_find(argv
, argc
, "ip", &idx
)) {
15371 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15372 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15373 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15374 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15376 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15378 return CMD_SUCCESS
;
15380 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15381 extcommunity_list_show(vty
, list
);
15383 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15384 extcommunity_list_show(vty
, list
);
15386 return CMD_SUCCESS
;
15389 ALIAS (show_extcommunity_list
,
15390 show_ip_extcommunity_list_cmd
,
15391 "show ip extcommunity-list",
15394 "List extended-community list\n")
15396 DEFUN (show_extcommunity_list_arg
,
15397 show_bgp_extcommunity_list_arg_cmd
,
15398 "show bgp extcommunity-list <(1-500)|WORD>",
15401 "List extended-community list\n"
15402 "Extcommunity-list number\n"
15403 "Extcommunity-list name\n")
15405 int idx_comm_list
= 3;
15406 struct community_list
*list
;
15409 if (argv_find(argv
, argc
, "ip", &idx
)) {
15410 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15411 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15412 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15413 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15415 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15416 EXTCOMMUNITY_LIST_MASTER
);
15418 vty_out(vty
, "%% Can't find extcommunity-list\n");
15419 return CMD_WARNING
;
15422 extcommunity_list_show(vty
, list
);
15424 return CMD_SUCCESS
;
15427 ALIAS (show_extcommunity_list_arg
,
15428 show_ip_extcommunity_list_arg_cmd
,
15429 "show ip extcommunity-list <(1-500)|WORD>",
15432 "List extended-community list\n"
15433 "Extcommunity-list number\n"
15434 "Extcommunity-list name\n")
15436 /* Display community-list and extcommunity-list configuration. */
15437 static int community_list_config_write(struct vty
*vty
)
15439 struct community_list
*list
;
15440 struct community_entry
*entry
;
15441 struct community_list_master
*cm
;
15444 /* Community-list. */
15445 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15447 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15448 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15449 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15450 community_direct_str(entry
->direct
),
15451 community_list_config_str(entry
));
15454 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15455 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15456 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15457 entry
->style
== COMMUNITY_LIST_STANDARD
15460 list
->name
, community_direct_str(entry
->direct
),
15461 community_list_config_str(entry
));
15465 /* Extcommunity-list. */
15466 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15468 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15469 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15470 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15471 list
->name
, community_direct_str(entry
->direct
),
15472 community_list_config_str(entry
));
15475 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15476 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15477 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15478 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15481 list
->name
, community_direct_str(entry
->direct
),
15482 community_list_config_str(entry
));
15487 /* lcommunity-list. */
15488 cm
= community_list_master_lookup(bgp_clist
,
15489 LARGE_COMMUNITY_LIST_MASTER
);
15491 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15492 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15493 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15494 list
->name
, community_direct_str(entry
->direct
),
15495 community_list_config_str(entry
));
15498 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15499 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15500 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15501 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15504 list
->name
, community_direct_str(entry
->direct
),
15505 community_list_config_str(entry
));
15512 static struct cmd_node community_list_node
= {
15513 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15516 static void community_list_vty(void)
15518 install_node(&community_list_node
, community_list_config_write
);
15520 /* Community-list. */
15521 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15522 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15523 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15524 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15525 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15526 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15527 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15528 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15529 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15530 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15531 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15532 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15533 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15534 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15535 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15536 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15538 /* Extcommunity-list. */
15539 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15540 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15541 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15542 install_element(CONFIG_NODE
,
15543 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15544 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15545 install_element(CONFIG_NODE
,
15546 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15547 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15548 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15549 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15550 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15551 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15552 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15553 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15554 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15555 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15556 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15558 /* Large Community List */
15559 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15560 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15561 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15562 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15563 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15564 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15565 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15566 install_element(CONFIG_NODE
,
15567 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15568 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15569 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15570 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15571 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15572 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15573 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15574 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15575 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15576 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15577 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15578 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15579 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15580 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15581 install_element(CONFIG_NODE
,
15582 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15583 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15584 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15585 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15586 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15587 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15588 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);