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 static void bgp_redistribute_redo(struct bgp
*bgp
)
2062 struct list
*red_list
;
2063 struct listnode
*node
;
2064 struct bgp_redist
*red
;
2066 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2067 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
2069 red_list
= bgp
->redist
[afi
][i
];
2073 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
2074 bgp_redistribute_resend(bgp
, afi
, i
,
2081 /* "bgp graceful-shutdown" configuration */
2082 DEFUN (bgp_graceful_shutdown
,
2083 bgp_graceful_shutdown_cmd
,
2084 "bgp graceful-shutdown",
2086 "Graceful shutdown parameters\n")
2088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2090 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2091 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2092 bgp_static_redo_import_check(bgp
);
2093 bgp_redistribute_redo(bgp
);
2094 bgp_clear_star_soft_out(vty
, bgp
->name
);
2095 bgp_clear_star_soft_in(vty
, bgp
->name
);
2101 DEFUN (no_bgp_graceful_shutdown
,
2102 no_bgp_graceful_shutdown_cmd
,
2103 "no bgp graceful-shutdown",
2106 "Graceful shutdown parameters\n")
2108 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2110 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2111 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2112 bgp_static_redo_import_check(bgp
);
2113 bgp_redistribute_redo(bgp
);
2114 bgp_clear_star_soft_out(vty
, bgp
->name
);
2115 bgp_clear_star_soft_in(vty
, bgp
->name
);
2121 /* "bgp fast-external-failover" configuration. */
2122 DEFUN (bgp_fast_external_failover
,
2123 bgp_fast_external_failover_cmd
,
2124 "bgp fast-external-failover",
2126 "Immediately reset session if a link to a directly connected external peer goes down\n")
2128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2129 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2133 DEFUN (no_bgp_fast_external_failover
,
2134 no_bgp_fast_external_failover_cmd
,
2135 "no bgp fast-external-failover",
2138 "Immediately reset session if a link to a directly connected external peer goes down\n")
2140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2141 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2145 /* "bgp enforce-first-as" configuration. */
2146 #if CONFDATE > 20190517
2147 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2150 DEFUN_HIDDEN (bgp_enforce_first_as
,
2151 bgp_enforce_first_as_cmd
,
2152 "[no] bgp enforce-first-as",
2155 "Enforce the first AS for EBGP routes\n")
2157 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2159 if (strmatch(argv
[0]->text
, "no"))
2160 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2162 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2167 /* "bgp bestpath compare-routerid" configuration. */
2168 DEFUN (bgp_bestpath_compare_router_id
,
2169 bgp_bestpath_compare_router_id_cmd
,
2170 "bgp bestpath compare-routerid",
2171 "BGP specific commands\n"
2172 "Change the default bestpath selection\n"
2173 "Compare router-id for identical EBGP paths\n")
2175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2176 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2177 bgp_recalculate_all_bestpaths(bgp
);
2182 DEFUN (no_bgp_bestpath_compare_router_id
,
2183 no_bgp_bestpath_compare_router_id_cmd
,
2184 "no bgp bestpath compare-routerid",
2186 "BGP specific commands\n"
2187 "Change the default bestpath selection\n"
2188 "Compare router-id for identical EBGP paths\n")
2190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2191 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2192 bgp_recalculate_all_bestpaths(bgp
);
2197 /* "bgp bestpath as-path ignore" configuration. */
2198 DEFUN (bgp_bestpath_aspath_ignore
,
2199 bgp_bestpath_aspath_ignore_cmd
,
2200 "bgp bestpath as-path ignore",
2201 "BGP specific commands\n"
2202 "Change the default bestpath selection\n"
2203 "AS-path attribute\n"
2204 "Ignore as-path length in selecting a route\n")
2206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2207 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2208 bgp_recalculate_all_bestpaths(bgp
);
2213 DEFUN (no_bgp_bestpath_aspath_ignore
,
2214 no_bgp_bestpath_aspath_ignore_cmd
,
2215 "no bgp bestpath as-path ignore",
2217 "BGP specific commands\n"
2218 "Change the default bestpath selection\n"
2219 "AS-path attribute\n"
2220 "Ignore as-path length in selecting a route\n")
2222 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2223 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2224 bgp_recalculate_all_bestpaths(bgp
);
2229 /* "bgp bestpath as-path confed" configuration. */
2230 DEFUN (bgp_bestpath_aspath_confed
,
2231 bgp_bestpath_aspath_confed_cmd
,
2232 "bgp bestpath as-path confed",
2233 "BGP specific commands\n"
2234 "Change the default bestpath selection\n"
2235 "AS-path attribute\n"
2236 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2239 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2240 bgp_recalculate_all_bestpaths(bgp
);
2245 DEFUN (no_bgp_bestpath_aspath_confed
,
2246 no_bgp_bestpath_aspath_confed_cmd
,
2247 "no bgp bestpath as-path confed",
2249 "BGP specific commands\n"
2250 "Change the default bestpath selection\n"
2251 "AS-path attribute\n"
2252 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2254 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2255 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2256 bgp_recalculate_all_bestpaths(bgp
);
2261 /* "bgp bestpath as-path multipath-relax" configuration. */
2262 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2263 bgp_bestpath_aspath_multipath_relax_cmd
,
2264 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2265 "BGP specific commands\n"
2266 "Change the default bestpath selection\n"
2267 "AS-path attribute\n"
2268 "Allow load sharing across routes that have different AS paths (but same length)\n"
2269 "Generate an AS_SET\n"
2270 "Do not generate an AS_SET\n")
2272 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2274 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2276 /* no-as-set is now the default behavior so we can silently
2278 if (argv_find(argv
, argc
, "as-set", &idx
))
2279 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2281 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2283 bgp_recalculate_all_bestpaths(bgp
);
2288 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2289 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2290 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2292 "BGP specific commands\n"
2293 "Change the default bestpath selection\n"
2294 "AS-path attribute\n"
2295 "Allow load sharing across routes that have different AS paths (but same length)\n"
2296 "Generate an AS_SET\n"
2297 "Do not generate an AS_SET\n")
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2300 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2301 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2302 bgp_recalculate_all_bestpaths(bgp
);
2307 /* "bgp log-neighbor-changes" configuration. */
2308 DEFUN (bgp_log_neighbor_changes
,
2309 bgp_log_neighbor_changes_cmd
,
2310 "bgp log-neighbor-changes",
2311 "BGP specific commands\n"
2312 "Log neighbor up/down and reset reason\n")
2314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2315 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2319 DEFUN (no_bgp_log_neighbor_changes
,
2320 no_bgp_log_neighbor_changes_cmd
,
2321 "no bgp log-neighbor-changes",
2323 "BGP specific commands\n"
2324 "Log neighbor up/down and reset reason\n")
2326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2327 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2331 /* "bgp bestpath med" configuration. */
2332 DEFUN (bgp_bestpath_med
,
2333 bgp_bestpath_med_cmd
,
2334 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2335 "BGP specific commands\n"
2336 "Change the default bestpath selection\n"
2338 "Compare MED among confederation paths\n"
2339 "Treat missing MED as the least preferred one\n"
2340 "Treat missing MED as the least preferred one\n"
2341 "Compare MED among confederation paths\n")
2343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2346 if (argv_find(argv
, argc
, "confed", &idx
))
2347 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2349 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2350 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2352 bgp_recalculate_all_bestpaths(bgp
);
2357 DEFUN (no_bgp_bestpath_med
,
2358 no_bgp_bestpath_med_cmd
,
2359 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2361 "BGP specific commands\n"
2362 "Change the default bestpath selection\n"
2364 "Compare MED among confederation paths\n"
2365 "Treat missing MED as the least preferred one\n"
2366 "Treat missing MED as the least preferred one\n"
2367 "Compare MED among confederation paths\n")
2369 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2372 if (argv_find(argv
, argc
, "confed", &idx
))
2373 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2375 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2376 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2378 bgp_recalculate_all_bestpaths(bgp
);
2383 /* "no bgp default ipv4-unicast". */
2384 DEFUN (no_bgp_default_ipv4_unicast
,
2385 no_bgp_default_ipv4_unicast_cmd
,
2386 "no bgp default ipv4-unicast",
2388 "BGP specific commands\n"
2389 "Configure BGP defaults\n"
2390 "Activate ipv4-unicast for a peer by default\n")
2392 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2393 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2397 DEFUN (bgp_default_ipv4_unicast
,
2398 bgp_default_ipv4_unicast_cmd
,
2399 "bgp default ipv4-unicast",
2400 "BGP specific commands\n"
2401 "Configure BGP defaults\n"
2402 "Activate ipv4-unicast for a peer by default\n")
2404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2405 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2409 /* Display hostname in certain command outputs */
2410 DEFUN (bgp_default_show_hostname
,
2411 bgp_default_show_hostname_cmd
,
2412 "bgp default show-hostname",
2413 "BGP specific commands\n"
2414 "Configure BGP defaults\n"
2415 "Show hostname in certain command outputs\n")
2417 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2418 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2422 DEFUN (no_bgp_default_show_hostname
,
2423 no_bgp_default_show_hostname_cmd
,
2424 "no bgp default show-hostname",
2426 "BGP specific commands\n"
2427 "Configure BGP defaults\n"
2428 "Show hostname in certain command outputs\n")
2430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2431 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2435 /* "bgp network import-check" configuration. */
2436 DEFUN (bgp_network_import_check
,
2437 bgp_network_import_check_cmd
,
2438 "bgp network import-check",
2439 "BGP specific commands\n"
2440 "BGP network command\n"
2441 "Check BGP network route exists in IGP\n")
2443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2444 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2445 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2446 bgp_static_redo_import_check(bgp
);
2452 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2453 "bgp network import-check exact",
2454 "BGP specific commands\n"
2455 "BGP network command\n"
2456 "Check BGP network route exists in IGP\n"
2457 "Match route precisely\n")
2459 DEFUN (no_bgp_network_import_check
,
2460 no_bgp_network_import_check_cmd
,
2461 "no bgp network import-check",
2463 "BGP specific commands\n"
2464 "BGP network command\n"
2465 "Check BGP network route exists in IGP\n")
2467 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2468 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2469 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2470 bgp_static_redo_import_check(bgp
);
2476 DEFUN (bgp_default_local_preference
,
2477 bgp_default_local_preference_cmd
,
2478 "bgp default local-preference (0-4294967295)",
2479 "BGP specific commands\n"
2480 "Configure BGP defaults\n"
2481 "local preference (higher=more preferred)\n"
2482 "Configure default local preference value\n")
2484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2486 uint32_t local_pref
;
2488 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2490 bgp_default_local_preference_set(bgp
, local_pref
);
2491 bgp_clear_star_soft_in(vty
, bgp
->name
);
2496 DEFUN (no_bgp_default_local_preference
,
2497 no_bgp_default_local_preference_cmd
,
2498 "no bgp default local-preference [(0-4294967295)]",
2500 "BGP specific commands\n"
2501 "Configure BGP defaults\n"
2502 "local preference (higher=more preferred)\n"
2503 "Configure default local preference value\n")
2505 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2506 bgp_default_local_preference_unset(bgp
);
2507 bgp_clear_star_soft_in(vty
, bgp
->name
);
2513 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2514 bgp_default_subgroup_pkt_queue_max_cmd
,
2515 "bgp default subgroup-pkt-queue-max (20-100)",
2516 "BGP specific commands\n"
2517 "Configure BGP defaults\n"
2518 "subgroup-pkt-queue-max\n"
2519 "Configure subgroup packet queue max\n")
2521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2525 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2527 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2532 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2533 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2534 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2536 "BGP specific commands\n"
2537 "Configure BGP defaults\n"
2538 "subgroup-pkt-queue-max\n"
2539 "Configure subgroup packet queue max\n")
2541 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2542 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2547 DEFUN (bgp_rr_allow_outbound_policy
,
2548 bgp_rr_allow_outbound_policy_cmd
,
2549 "bgp route-reflector allow-outbound-policy",
2550 "BGP specific commands\n"
2551 "Allow modifications made by out route-map\n"
2552 "on ibgp neighbors\n")
2554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2556 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2557 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2558 update_group_announce_rrclients(bgp
);
2559 bgp_clear_star_soft_out(vty
, bgp
->name
);
2565 DEFUN (no_bgp_rr_allow_outbound_policy
,
2566 no_bgp_rr_allow_outbound_policy_cmd
,
2567 "no bgp route-reflector allow-outbound-policy",
2569 "BGP specific commands\n"
2570 "Allow modifications made by out route-map\n"
2571 "on ibgp neighbors\n")
2573 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2575 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2576 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2577 update_group_announce_rrclients(bgp
);
2578 bgp_clear_star_soft_out(vty
, bgp
->name
);
2584 DEFUN (bgp_listen_limit
,
2585 bgp_listen_limit_cmd
,
2586 "bgp listen limit (1-5000)",
2587 "BGP specific commands\n"
2588 "Configure BGP defaults\n"
2589 "maximum number of BGP Dynamic Neighbors that can be created\n"
2590 "Configure Dynamic Neighbors listen limit value\n")
2592 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2596 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2598 bgp_listen_limit_set(bgp
, listen_limit
);
2603 DEFUN (no_bgp_listen_limit
,
2604 no_bgp_listen_limit_cmd
,
2605 "no bgp listen limit [(1-5000)]",
2606 "BGP specific commands\n"
2607 "Configure BGP defaults\n"
2608 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2609 "Configure Dynamic Neighbors listen limit value to default\n"
2610 "Configure Dynamic Neighbors listen limit value\n")
2612 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2613 bgp_listen_limit_unset(bgp
);
2619 * Check if this listen range is already configured. Check for exact
2620 * match or overlap based on input.
2622 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2623 struct prefix
*range
, int exact
)
2625 struct listnode
*node
, *nnode
;
2626 struct listnode
*node1
, *nnode1
;
2627 struct peer_group
*group
;
2632 afi
= family2afi(range
->family
);
2633 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2634 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2637 match
= prefix_same(range
, lr
);
2639 match
= (prefix_match(range
, lr
)
2640 || prefix_match(lr
, range
));
2649 DEFUN (bgp_listen_range
,
2650 bgp_listen_range_cmd
,
2651 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2652 "BGP specific commands\n"
2653 "Configure BGP dynamic neighbors listen range\n"
2654 "Configure BGP dynamic neighbors listen range\n"
2656 "Member of the peer-group\n"
2657 "Peer-group name\n")
2659 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2660 struct prefix range
;
2661 struct peer_group
*group
, *existing_group
;
2666 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2667 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2668 char *prefix
= argv
[idx
]->arg
;
2669 argv_find(argv
, argc
, "WORD", &idx
);
2670 char *peergroup
= argv
[idx
]->arg
;
2672 /* Convert IP prefix string to struct prefix. */
2673 ret
= str2prefix(prefix
, &range
);
2675 vty_out(vty
, "%% Malformed listen range\n");
2676 return CMD_WARNING_CONFIG_FAILED
;
2679 afi
= family2afi(range
.family
);
2681 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2683 "%% Malformed listen range (link-local address)\n");
2684 return CMD_WARNING_CONFIG_FAILED
;
2689 /* Check if same listen range is already configured. */
2690 existing_group
= listen_range_exists(bgp
, &range
, 1);
2691 if (existing_group
) {
2692 if (strcmp(existing_group
->name
, peergroup
) == 0)
2696 "%% Same listen range is attached to peer-group %s\n",
2697 existing_group
->name
);
2698 return CMD_WARNING_CONFIG_FAILED
;
2702 /* Check if an overlapping listen range exists. */
2703 if (listen_range_exists(bgp
, &range
, 0)) {
2705 "%% Listen range overlaps with existing listen range\n");
2706 return CMD_WARNING_CONFIG_FAILED
;
2709 group
= peer_group_lookup(bgp
, peergroup
);
2711 vty_out(vty
, "%% Configure the peer-group first\n");
2712 return CMD_WARNING_CONFIG_FAILED
;
2715 ret
= peer_group_listen_range_add(group
, &range
);
2716 return bgp_vty_return(vty
, ret
);
2719 DEFUN (no_bgp_listen_range
,
2720 no_bgp_listen_range_cmd
,
2721 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2723 "BGP specific commands\n"
2724 "Unconfigure BGP dynamic neighbors listen range\n"
2725 "Unconfigure BGP dynamic neighbors listen range\n"
2727 "Member of the peer-group\n"
2728 "Peer-group name\n")
2730 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2731 struct prefix range
;
2732 struct peer_group
*group
;
2737 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2738 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2739 char *prefix
= argv
[idx
]->arg
;
2740 argv_find(argv
, argc
, "WORD", &idx
);
2741 char *peergroup
= argv
[idx
]->arg
;
2743 /* Convert IP prefix string to struct prefix. */
2744 ret
= str2prefix(prefix
, &range
);
2746 vty_out(vty
, "%% Malformed listen range\n");
2747 return CMD_WARNING_CONFIG_FAILED
;
2750 afi
= family2afi(range
.family
);
2752 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2754 "%% Malformed listen range (link-local address)\n");
2755 return CMD_WARNING_CONFIG_FAILED
;
2760 group
= peer_group_lookup(bgp
, peergroup
);
2762 vty_out(vty
, "%% Peer-group does not exist\n");
2763 return CMD_WARNING_CONFIG_FAILED
;
2766 ret
= peer_group_listen_range_del(group
, &range
);
2767 return bgp_vty_return(vty
, ret
);
2770 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2772 struct peer_group
*group
;
2773 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2774 struct prefix
*range
;
2776 char buf
[PREFIX2STR_BUFFER
];
2778 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2779 vty_out(vty
, " bgp listen limit %d\n",
2780 bgp
->dynamic_neighbors_limit
);
2782 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2783 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2784 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2786 prefix2str(range
, buf
, sizeof(buf
));
2788 " bgp listen range %s peer-group %s\n",
2796 DEFUN (bgp_disable_connected_route_check
,
2797 bgp_disable_connected_route_check_cmd
,
2798 "bgp disable-ebgp-connected-route-check",
2799 "BGP specific commands\n"
2800 "Disable checking if nexthop is connected on ebgp sessions\n")
2802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2803 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2804 bgp_clear_star_soft_in(vty
, bgp
->name
);
2809 DEFUN (no_bgp_disable_connected_route_check
,
2810 no_bgp_disable_connected_route_check_cmd
,
2811 "no bgp disable-ebgp-connected-route-check",
2813 "BGP specific commands\n"
2814 "Disable checking if nexthop is connected on ebgp sessions\n")
2816 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2817 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2818 bgp_clear_star_soft_in(vty
, bgp
->name
);
2824 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2825 const char *as_str
, afi_t afi
, safi_t safi
)
2827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2830 int as_type
= AS_SPECIFIED
;
2833 if (as_str
[0] == 'i') {
2835 as_type
= AS_INTERNAL
;
2836 } else if (as_str
[0] == 'e') {
2838 as_type
= AS_EXTERNAL
;
2840 /* Get AS number. */
2841 as
= strtoul(as_str
, NULL
, 10);
2844 /* If peer is peer group or interface peer, call proper function. */
2845 ret
= str2sockunion(peer_str
, &su
);
2849 /* Check if existing interface peer */
2850 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2852 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2855 /* if not interface peer, check peer-group settings */
2856 if (ret
< 0 && !peer
) {
2857 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2860 "%% Create the peer-group or interface first\n");
2861 return CMD_WARNING_CONFIG_FAILED
;
2866 if (peer_address_self_check(bgp
, &su
)) {
2868 "%% Can not configure the local system as neighbor\n");
2869 return CMD_WARNING_CONFIG_FAILED
;
2871 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2874 /* This peer belongs to peer group. */
2876 case BGP_ERR_PEER_GROUP_MEMBER
:
2878 "%% Peer-group member cannot override remote-as of peer-group\n");
2879 return CMD_WARNING_CONFIG_FAILED
;
2880 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2882 "%% Peer-group members must be all internal or all external\n");
2883 return CMD_WARNING_CONFIG_FAILED
;
2885 return bgp_vty_return(vty
, ret
);
2888 DEFUN (bgp_default_shutdown
,
2889 bgp_default_shutdown_cmd
,
2890 "[no] bgp default shutdown",
2893 "Configure BGP defaults\n"
2894 "Apply administrative shutdown to newly configured peers\n")
2896 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2897 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2901 DEFUN (neighbor_remote_as
,
2902 neighbor_remote_as_cmd
,
2903 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2906 "Specify a BGP neighbor\n"
2908 "Internal BGP peer\n"
2909 "External BGP peer\n")
2912 int idx_remote_as
= 3;
2913 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2914 argv
[idx_remote_as
]->arg
, AFI_IP
,
2918 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2919 afi_t afi
, safi_t safi
, int v6only
,
2920 const char *peer_group_name
,
2923 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2925 int as_type
= AS_UNSPECIFIED
;
2927 struct peer_group
*group
;
2931 group
= peer_group_lookup(bgp
, conf_if
);
2934 vty_out(vty
, "%% Name conflict with peer-group \n");
2935 return CMD_WARNING_CONFIG_FAILED
;
2939 if (as_str
[0] == 'i') {
2940 as_type
= AS_INTERNAL
;
2941 } else if (as_str
[0] == 'e') {
2942 as_type
= AS_EXTERNAL
;
2944 /* Get AS number. */
2945 as
= strtoul(as_str
, NULL
, 10);
2946 as_type
= AS_SPECIFIED
;
2950 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2953 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2956 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2957 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2958 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2959 as_type
, 0, 0, NULL
);
2961 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2962 as_type
, afi
, safi
, NULL
);
2965 vty_out(vty
, "%% BGP failed to create peer\n");
2966 return CMD_WARNING_CONFIG_FAILED
;
2970 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2972 /* Request zebra to initiate IPv6 RAs on this interface. We do
2974 * any unnumbered peer in order to not worry about run-time
2976 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2978 * gets deleted later etc.)
2981 bgp_zebra_initiate_radv(bgp
, peer
);
2984 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2985 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2987 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2989 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2991 /* v6only flag changed. Reset bgp seesion */
2992 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2993 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2994 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2995 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2997 bgp_session_reset(peer
);
3000 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3001 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3002 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3003 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3006 if (peer_group_name
) {
3007 group
= peer_group_lookup(bgp
, peer_group_name
);
3009 vty_out(vty
, "%% Configure the peer-group first\n");
3010 return CMD_WARNING_CONFIG_FAILED
;
3013 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3016 return bgp_vty_return(vty
, ret
);
3019 DEFUN (neighbor_interface_config
,
3020 neighbor_interface_config_cmd
,
3021 "neighbor WORD interface [peer-group WORD]",
3023 "Interface name or neighbor tag\n"
3024 "Enable BGP on interface\n"
3025 "Member of the peer-group\n"
3026 "Peer-group name\n")
3029 int idx_peer_group_word
= 4;
3031 if (argc
> idx_peer_group_word
)
3032 return peer_conf_interface_get(
3033 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3034 argv
[idx_peer_group_word
]->arg
, NULL
);
3036 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3037 SAFI_UNICAST
, 0, NULL
, NULL
);
3040 DEFUN (neighbor_interface_config_v6only
,
3041 neighbor_interface_config_v6only_cmd
,
3042 "neighbor WORD interface v6only [peer-group WORD]",
3044 "Interface name or neighbor tag\n"
3045 "Enable BGP on interface\n"
3046 "Enable BGP with v6 link-local only\n"
3047 "Member of the peer-group\n"
3048 "Peer-group name\n")
3051 int idx_peer_group_word
= 5;
3053 if (argc
> idx_peer_group_word
)
3054 return peer_conf_interface_get(
3055 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3056 argv
[idx_peer_group_word
]->arg
, NULL
);
3058 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3059 SAFI_UNICAST
, 1, NULL
, NULL
);
3063 DEFUN (neighbor_interface_config_remote_as
,
3064 neighbor_interface_config_remote_as_cmd
,
3065 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3067 "Interface name or neighbor tag\n"
3068 "Enable BGP on interface\n"
3069 "Specify a BGP neighbor\n"
3071 "Internal BGP peer\n"
3072 "External BGP peer\n")
3075 int idx_remote_as
= 4;
3076 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3077 SAFI_UNICAST
, 0, NULL
,
3078 argv
[idx_remote_as
]->arg
);
3081 DEFUN (neighbor_interface_v6only_config_remote_as
,
3082 neighbor_interface_v6only_config_remote_as_cmd
,
3083 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3085 "Interface name or neighbor tag\n"
3086 "Enable BGP with v6 link-local only\n"
3087 "Enable BGP on interface\n"
3088 "Specify a BGP neighbor\n"
3090 "Internal BGP peer\n"
3091 "External BGP peer\n")
3094 int idx_remote_as
= 5;
3095 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3096 SAFI_UNICAST
, 1, NULL
,
3097 argv
[idx_remote_as
]->arg
);
3100 DEFUN (neighbor_peer_group
,
3101 neighbor_peer_group_cmd
,
3102 "neighbor WORD peer-group",
3104 "Interface name or neighbor tag\n"
3105 "Configure peer-group\n")
3107 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3110 struct peer_group
*group
;
3112 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3114 vty_out(vty
, "%% Name conflict with interface: \n");
3115 return CMD_WARNING_CONFIG_FAILED
;
3118 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3120 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3121 return CMD_WARNING_CONFIG_FAILED
;
3129 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3133 "Specify a BGP neighbor\n"
3135 "Internal BGP peer\n"
3136 "External BGP peer\n")
3138 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3142 struct peer_group
*group
;
3146 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3148 /* look up for neighbor by interface name config. */
3149 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3151 /* Request zebra to terminate IPv6 RAs on this
3154 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3159 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3161 peer_group_delete(group
);
3163 vty_out(vty
, "%% Create the peer-group first\n");
3164 return CMD_WARNING_CONFIG_FAILED
;
3167 peer
= peer_lookup(bgp
, &su
);
3169 if (peer_dynamic_neighbor(peer
)) {
3171 "%% Operation not allowed on a dynamic neighbor\n");
3172 return CMD_WARNING_CONFIG_FAILED
;
3175 other
= peer
->doppelganger
;
3177 if (other
&& other
->status
!= Deleted
)
3185 DEFUN (no_neighbor_interface_config
,
3186 no_neighbor_interface_config_cmd
,
3187 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3191 "Configure BGP on interface\n"
3192 "Enable BGP with v6 link-local only\n"
3193 "Member of the peer-group\n"
3195 "Specify a BGP neighbor\n"
3197 "Internal BGP peer\n"
3198 "External BGP peer\n")
3200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3204 /* look up for neighbor by interface name config. */
3205 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3207 /* Request zebra to terminate IPv6 RAs on this interface. */
3209 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3212 vty_out(vty
, "%% Create the bgp interface first\n");
3213 return CMD_WARNING_CONFIG_FAILED
;
3218 DEFUN (no_neighbor_peer_group
,
3219 no_neighbor_peer_group_cmd
,
3220 "no neighbor WORD peer-group",
3224 "Configure peer-group\n")
3226 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3228 struct peer_group
*group
;
3230 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3232 peer_group_delete(group
);
3234 vty_out(vty
, "%% Create the peer-group first\n");
3235 return CMD_WARNING_CONFIG_FAILED
;
3240 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3241 no_neighbor_interface_peer_group_remote_as_cmd
,
3242 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3245 "Interface name or neighbor tag\n"
3246 "Specify a BGP neighbor\n"
3248 "Internal BGP peer\n"
3249 "External BGP peer\n")
3251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3253 struct peer_group
*group
;
3256 /* look up for neighbor by interface name config. */
3257 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3259 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3263 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3265 peer_group_remote_as_delete(group
);
3267 vty_out(vty
, "%% Create the peer-group or interface first\n");
3268 return CMD_WARNING_CONFIG_FAILED
;
3273 DEFUN (neighbor_local_as
,
3274 neighbor_local_as_cmd
,
3275 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3278 "Specify a local-as number\n"
3279 "AS number used as local AS\n")
3287 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3289 return CMD_WARNING_CONFIG_FAILED
;
3291 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3292 ret
= peer_local_as_set(peer
, as
, 0, 0);
3293 return bgp_vty_return(vty
, ret
);
3296 DEFUN (neighbor_local_as_no_prepend
,
3297 neighbor_local_as_no_prepend_cmd
,
3298 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3301 "Specify a local-as number\n"
3302 "AS number used as local AS\n"
3303 "Do not prepend local-as to updates from ebgp peers\n")
3311 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3313 return CMD_WARNING_CONFIG_FAILED
;
3315 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3316 ret
= peer_local_as_set(peer
, as
, 1, 0);
3317 return bgp_vty_return(vty
, ret
);
3320 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3321 neighbor_local_as_no_prepend_replace_as_cmd
,
3322 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3325 "Specify a local-as number\n"
3326 "AS number used as local AS\n"
3327 "Do not prepend local-as to updates from ebgp peers\n"
3328 "Do not prepend local-as to updates from ibgp peers\n")
3336 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3338 return CMD_WARNING_CONFIG_FAILED
;
3340 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3341 ret
= peer_local_as_set(peer
, as
, 1, 1);
3342 return bgp_vty_return(vty
, ret
);
3345 DEFUN (no_neighbor_local_as
,
3346 no_neighbor_local_as_cmd
,
3347 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3351 "Specify a local-as number\n"
3352 "AS number used as local AS\n"
3353 "Do not prepend local-as to updates from ebgp peers\n"
3354 "Do not prepend local-as to updates from ibgp peers\n")
3360 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3362 return CMD_WARNING_CONFIG_FAILED
;
3364 ret
= peer_local_as_unset(peer
);
3365 return bgp_vty_return(vty
, ret
);
3369 DEFUN (neighbor_solo
,
3371 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3374 "Solo peer - part of its own update group\n")
3380 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3382 return CMD_WARNING_CONFIG_FAILED
;
3384 ret
= update_group_adjust_soloness(peer
, 1);
3385 return bgp_vty_return(vty
, ret
);
3388 DEFUN (no_neighbor_solo
,
3389 no_neighbor_solo_cmd
,
3390 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3394 "Solo peer - part of its own update group\n")
3400 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3402 return CMD_WARNING_CONFIG_FAILED
;
3404 ret
= update_group_adjust_soloness(peer
, 0);
3405 return bgp_vty_return(vty
, ret
);
3408 DEFUN (neighbor_password
,
3409 neighbor_password_cmd
,
3410 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3421 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3423 return CMD_WARNING_CONFIG_FAILED
;
3425 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3426 return bgp_vty_return(vty
, ret
);
3429 DEFUN (no_neighbor_password
,
3430 no_neighbor_password_cmd
,
3431 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3442 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3444 return CMD_WARNING_CONFIG_FAILED
;
3446 ret
= peer_password_unset(peer
);
3447 return bgp_vty_return(vty
, ret
);
3450 DEFUN (neighbor_activate
,
3451 neighbor_activate_cmd
,
3452 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3455 "Enable the Address Family for this Neighbor\n")
3461 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3463 return CMD_WARNING_CONFIG_FAILED
;
3465 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3466 return bgp_vty_return(vty
, ret
);
3469 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3470 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3471 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3472 "Enable the Address Family for this Neighbor\n")
3474 DEFUN (no_neighbor_activate
,
3475 no_neighbor_activate_cmd
,
3476 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3480 "Enable the Address Family for this Neighbor\n")
3487 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3489 return CMD_WARNING_CONFIG_FAILED
;
3491 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3492 return bgp_vty_return(vty
, ret
);
3495 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3496 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3497 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3498 "Enable the Address Family for this Neighbor\n")
3500 DEFUN (neighbor_set_peer_group
,
3501 neighbor_set_peer_group_cmd
,
3502 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3505 "Member of the peer-group\n"
3506 "Peer-group name\n")
3508 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3515 struct peer_group
*group
;
3517 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3519 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3521 vty_out(vty
, "%% Malformed address or name: %s\n",
3522 argv
[idx_peer
]->arg
);
3523 return CMD_WARNING_CONFIG_FAILED
;
3526 if (peer_address_self_check(bgp
, &su
)) {
3528 "%% Can not configure the local system as neighbor\n");
3529 return CMD_WARNING_CONFIG_FAILED
;
3532 /* Disallow for dynamic neighbor. */
3533 peer
= peer_lookup(bgp
, &su
);
3534 if (peer
&& peer_dynamic_neighbor(peer
)) {
3536 "%% Operation not allowed on a dynamic neighbor\n");
3537 return CMD_WARNING_CONFIG_FAILED
;
3541 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3543 vty_out(vty
, "%% Configure the peer-group first\n");
3544 return CMD_WARNING_CONFIG_FAILED
;
3547 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3549 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3551 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3553 return CMD_WARNING_CONFIG_FAILED
;
3556 return bgp_vty_return(vty
, ret
);
3559 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3560 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3561 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3562 "Member of the peer-group\n"
3563 "Peer-group name\n")
3565 DEFUN (no_neighbor_set_peer_group
,
3566 no_neighbor_set_peer_group_cmd
,
3567 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3571 "Member of the peer-group\n"
3572 "Peer-group name\n")
3574 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3579 struct peer_group
*group
;
3581 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3583 return CMD_WARNING_CONFIG_FAILED
;
3585 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3587 vty_out(vty
, "%% Configure the peer-group first\n");
3588 return CMD_WARNING_CONFIG_FAILED
;
3591 ret
= peer_delete(peer
);
3593 return bgp_vty_return(vty
, ret
);
3596 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3597 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3598 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3599 "Member of the peer-group\n"
3600 "Peer-group name\n")
3602 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3603 uint32_t flag
, int set
)
3608 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3610 return CMD_WARNING_CONFIG_FAILED
;
3613 * If 'neighbor <interface>', then this is for directly connected peers,
3614 * we should not accept disable-connected-check.
3616 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3618 "%s is directly connected peer, cannot accept disable-"
3619 "connected-check\n",
3621 return CMD_WARNING_CONFIG_FAILED
;
3624 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3625 peer_tx_shutdown_message_unset(peer
);
3628 ret
= peer_flag_set(peer
, flag
);
3630 ret
= peer_flag_unset(peer
, flag
);
3632 return bgp_vty_return(vty
, ret
);
3635 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3637 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3640 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3643 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3646 /* neighbor passive. */
3647 DEFUN (neighbor_passive
,
3648 neighbor_passive_cmd
,
3649 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3652 "Don't send open messages to this neighbor\n")
3655 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3658 DEFUN (no_neighbor_passive
,
3659 no_neighbor_passive_cmd
,
3660 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3664 "Don't send open messages to this neighbor\n")
3667 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3670 /* neighbor shutdown. */
3671 DEFUN (neighbor_shutdown_msg
,
3672 neighbor_shutdown_msg_cmd
,
3673 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3676 "Administratively shut down this neighbor\n"
3677 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3678 "Shutdown message\n")
3684 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3688 return CMD_WARNING_CONFIG_FAILED
;
3689 message
= argv_concat(argv
, argc
, 4);
3690 peer_tx_shutdown_message_set(peer
, message
);
3691 XFREE(MTYPE_TMP
, message
);
3694 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3697 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3698 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3699 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3700 "Administratively shut down this neighbor\n")
3702 DEFUN (no_neighbor_shutdown_msg
,
3703 no_neighbor_shutdown_msg_cmd
,
3704 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3708 "Administratively shut down this neighbor\n"
3709 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3710 "Shutdown message\n")
3714 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3715 PEER_FLAG_SHUTDOWN
);
3718 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3719 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3720 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3721 "Administratively shut down this neighbor\n")
3723 /* neighbor capability dynamic. */
3724 DEFUN (neighbor_capability_dynamic
,
3725 neighbor_capability_dynamic_cmd
,
3726 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3729 "Advertise capability to the peer\n"
3730 "Advertise dynamic capability to this neighbor\n")
3733 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3734 PEER_FLAG_DYNAMIC_CAPABILITY
);
3737 DEFUN (no_neighbor_capability_dynamic
,
3738 no_neighbor_capability_dynamic_cmd
,
3739 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3743 "Advertise capability to the peer\n"
3744 "Advertise dynamic capability to this neighbor\n")
3747 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3748 PEER_FLAG_DYNAMIC_CAPABILITY
);
3751 /* neighbor dont-capability-negotiate */
3752 DEFUN (neighbor_dont_capability_negotiate
,
3753 neighbor_dont_capability_negotiate_cmd
,
3754 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3757 "Do not perform capability negotiation\n")
3760 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3761 PEER_FLAG_DONT_CAPABILITY
);
3764 DEFUN (no_neighbor_dont_capability_negotiate
,
3765 no_neighbor_dont_capability_negotiate_cmd
,
3766 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3770 "Do not perform capability negotiation\n")
3773 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3774 PEER_FLAG_DONT_CAPABILITY
);
3777 /* neighbor capability extended next hop encoding */
3778 DEFUN (neighbor_capability_enhe
,
3779 neighbor_capability_enhe_cmd
,
3780 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3783 "Advertise capability to the peer\n"
3784 "Advertise extended next-hop capability to the peer\n")
3787 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3788 PEER_FLAG_CAPABILITY_ENHE
);
3791 DEFUN (no_neighbor_capability_enhe
,
3792 no_neighbor_capability_enhe_cmd
,
3793 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3797 "Advertise capability to the peer\n"
3798 "Advertise extended next-hop capability to the peer\n")
3801 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3802 PEER_FLAG_CAPABILITY_ENHE
);
3805 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3806 afi_t afi
, safi_t safi
, uint32_t flag
,
3812 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3814 return CMD_WARNING_CONFIG_FAILED
;
3817 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3819 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3821 return bgp_vty_return(vty
, ret
);
3824 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3825 afi_t afi
, safi_t safi
, uint32_t flag
)
3827 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3830 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3831 afi_t afi
, safi_t safi
, uint32_t flag
)
3833 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3836 /* neighbor capability orf prefix-list. */
3837 DEFUN (neighbor_capability_orf_prefix
,
3838 neighbor_capability_orf_prefix_cmd
,
3839 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3842 "Advertise capability to the peer\n"
3843 "Advertise ORF capability to the peer\n"
3844 "Advertise prefixlist ORF capability to this neighbor\n"
3845 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3846 "Capability to RECEIVE the ORF from this neighbor\n"
3847 "Capability to SEND the ORF to this neighbor\n")
3850 int idx_send_recv
= 5;
3853 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3854 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3855 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3856 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3857 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3858 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3860 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3861 return CMD_WARNING_CONFIG_FAILED
;
3864 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3865 bgp_node_safi(vty
), flag
);
3869 neighbor_capability_orf_prefix
,
3870 neighbor_capability_orf_prefix_hidden_cmd
,
3871 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3872 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3873 "Advertise capability to the peer\n"
3874 "Advertise ORF capability to the peer\n"
3875 "Advertise prefixlist ORF capability to this neighbor\n"
3876 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3877 "Capability to RECEIVE the ORF from this neighbor\n"
3878 "Capability to SEND the ORF to this neighbor\n")
3880 DEFUN (no_neighbor_capability_orf_prefix
,
3881 no_neighbor_capability_orf_prefix_cmd
,
3882 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3886 "Advertise capability to the peer\n"
3887 "Advertise ORF capability to the peer\n"
3888 "Advertise prefixlist ORF capability to this neighbor\n"
3889 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3890 "Capability to RECEIVE the ORF from this neighbor\n"
3891 "Capability to SEND the ORF to this neighbor\n")
3894 int idx_send_recv
= 6;
3897 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3898 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3899 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3900 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3901 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3902 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3904 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3905 return CMD_WARNING_CONFIG_FAILED
;
3908 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3909 bgp_node_afi(vty
), bgp_node_safi(vty
),
3914 no_neighbor_capability_orf_prefix
,
3915 no_neighbor_capability_orf_prefix_hidden_cmd
,
3916 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3917 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3918 "Advertise capability to the peer\n"
3919 "Advertise ORF capability to the peer\n"
3920 "Advertise prefixlist ORF capability to this neighbor\n"
3921 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3922 "Capability to RECEIVE the ORF from this neighbor\n"
3923 "Capability to SEND the ORF to this neighbor\n")
3925 /* neighbor next-hop-self. */
3926 DEFUN (neighbor_nexthop_self
,
3927 neighbor_nexthop_self_cmd
,
3928 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3931 "Disable the next hop calculation for this neighbor\n")
3934 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3935 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3938 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3939 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3940 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3941 "Disable the next hop calculation for this neighbor\n")
3943 /* neighbor next-hop-self. */
3944 DEFUN (neighbor_nexthop_self_force
,
3945 neighbor_nexthop_self_force_cmd
,
3946 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3949 "Disable the next hop calculation for this neighbor\n"
3950 "Set the next hop to self for reflected routes\n")
3953 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3955 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3958 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3959 neighbor_nexthop_self_force_hidden_cmd
,
3960 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3961 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3962 "Disable the next hop calculation for this neighbor\n"
3963 "Set the next hop to self for reflected routes\n")
3965 DEFUN (no_neighbor_nexthop_self
,
3966 no_neighbor_nexthop_self_cmd
,
3967 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3971 "Disable the next hop calculation for this neighbor\n")
3974 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3975 bgp_node_afi(vty
), bgp_node_safi(vty
),
3976 PEER_FLAG_NEXTHOP_SELF
);
3979 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3980 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3981 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3982 "Disable the next hop calculation for this neighbor\n")
3984 DEFUN (no_neighbor_nexthop_self_force
,
3985 no_neighbor_nexthop_self_force_cmd
,
3986 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3990 "Disable the next hop calculation for this neighbor\n"
3991 "Set the next hop to self for reflected routes\n")
3994 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3995 bgp_node_afi(vty
), bgp_node_safi(vty
),
3996 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3999 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4000 no_neighbor_nexthop_self_force_hidden_cmd
,
4001 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4002 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4003 "Disable the next hop calculation for this neighbor\n"
4004 "Set the next hop to self for reflected routes\n")
4006 /* neighbor as-override */
4007 DEFUN (neighbor_as_override
,
4008 neighbor_as_override_cmd
,
4009 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4012 "Override ASNs in outbound updates if aspath equals remote-as\n")
4015 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4016 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4019 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4020 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4021 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4022 "Override ASNs in outbound updates if aspath equals remote-as\n")
4024 DEFUN (no_neighbor_as_override
,
4025 no_neighbor_as_override_cmd
,
4026 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4030 "Override ASNs in outbound updates if aspath equals remote-as\n")
4033 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4034 bgp_node_afi(vty
), bgp_node_safi(vty
),
4035 PEER_FLAG_AS_OVERRIDE
);
4038 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4039 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4040 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4041 "Override ASNs in outbound updates if aspath equals remote-as\n")
4043 /* neighbor remove-private-AS. */
4044 DEFUN (neighbor_remove_private_as
,
4045 neighbor_remove_private_as_cmd
,
4046 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4049 "Remove private ASNs in outbound updates\n")
4052 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4054 PEER_FLAG_REMOVE_PRIVATE_AS
);
4057 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4058 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4059 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4060 "Remove private ASNs in outbound updates\n")
4062 DEFUN (neighbor_remove_private_as_all
,
4063 neighbor_remove_private_as_all_cmd
,
4064 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4067 "Remove private ASNs in outbound updates\n"
4068 "Apply to all AS numbers\n")
4071 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4073 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4076 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4077 neighbor_remove_private_as_all_hidden_cmd
,
4078 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4079 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4080 "Remove private ASNs in outbound updates\n"
4081 "Apply to all AS numbers")
4083 DEFUN (neighbor_remove_private_as_replace_as
,
4084 neighbor_remove_private_as_replace_as_cmd
,
4085 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4088 "Remove private ASNs in outbound updates\n"
4089 "Replace private ASNs with our ASN in outbound updates\n")
4092 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4094 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4097 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4098 neighbor_remove_private_as_replace_as_hidden_cmd
,
4099 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4100 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4101 "Remove private ASNs in outbound updates\n"
4102 "Replace private ASNs with our ASN in outbound updates\n")
4104 DEFUN (neighbor_remove_private_as_all_replace_as
,
4105 neighbor_remove_private_as_all_replace_as_cmd
,
4106 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4109 "Remove private ASNs in outbound updates\n"
4110 "Apply to all AS numbers\n"
4111 "Replace private ASNs with our ASN in outbound updates\n")
4114 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4116 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4120 neighbor_remove_private_as_all_replace_as
,
4121 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4122 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4123 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4124 "Remove private ASNs in outbound updates\n"
4125 "Apply to all AS numbers\n"
4126 "Replace private ASNs with our ASN in outbound updates\n")
4128 DEFUN (no_neighbor_remove_private_as
,
4129 no_neighbor_remove_private_as_cmd
,
4130 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4134 "Remove private ASNs in outbound updates\n")
4137 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4138 bgp_node_afi(vty
), bgp_node_safi(vty
),
4139 PEER_FLAG_REMOVE_PRIVATE_AS
);
4142 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4143 no_neighbor_remove_private_as_hidden_cmd
,
4144 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4145 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4146 "Remove private ASNs in outbound updates\n")
4148 DEFUN (no_neighbor_remove_private_as_all
,
4149 no_neighbor_remove_private_as_all_cmd
,
4150 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4154 "Remove private ASNs in outbound updates\n"
4155 "Apply to all AS numbers\n")
4158 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4159 bgp_node_afi(vty
), bgp_node_safi(vty
),
4160 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4163 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4164 no_neighbor_remove_private_as_all_hidden_cmd
,
4165 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4166 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4167 "Remove private ASNs in outbound updates\n"
4168 "Apply to all AS numbers\n")
4170 DEFUN (no_neighbor_remove_private_as_replace_as
,
4171 no_neighbor_remove_private_as_replace_as_cmd
,
4172 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4176 "Remove private ASNs in outbound updates\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_REPLACE
);
4185 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4186 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4187 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4188 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4189 "Remove private ASNs in outbound updates\n"
4190 "Replace private ASNs with our ASN in outbound updates\n")
4192 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4193 no_neighbor_remove_private_as_all_replace_as_cmd
,
4194 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4198 "Remove private ASNs in outbound updates\n"
4199 "Apply to all AS numbers\n"
4200 "Replace private ASNs with our ASN in outbound updates\n")
4203 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4204 bgp_node_afi(vty
), bgp_node_safi(vty
),
4205 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4209 no_neighbor_remove_private_as_all_replace_as
,
4210 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4211 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4212 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4213 "Remove private ASNs in outbound updates\n"
4214 "Apply to all AS numbers\n"
4215 "Replace private ASNs with our ASN in outbound updates\n")
4218 /* neighbor send-community. */
4219 DEFUN (neighbor_send_community
,
4220 neighbor_send_community_cmd
,
4221 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4224 "Send Community attribute to this neighbor\n")
4228 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4230 PEER_FLAG_SEND_COMMUNITY
);
4233 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4234 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4235 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4236 "Send Community attribute to this neighbor\n")
4238 DEFUN (no_neighbor_send_community
,
4239 no_neighbor_send_community_cmd
,
4240 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4244 "Send Community attribute to this neighbor\n")
4248 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4249 bgp_node_afi(vty
), bgp_node_safi(vty
),
4250 PEER_FLAG_SEND_COMMUNITY
);
4253 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4254 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4255 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4256 "Send Community attribute to this neighbor\n")
4258 /* neighbor send-community extended. */
4259 DEFUN (neighbor_send_community_type
,
4260 neighbor_send_community_type_cmd
,
4261 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4264 "Send Community attribute to this neighbor\n"
4265 "Send Standard and Extended Community attributes\n"
4266 "Send Standard, Large and Extended Community attributes\n"
4267 "Send Extended Community attributes\n"
4268 "Send Standard Community attributes\n"
4269 "Send Large Community attributes\n")
4273 const char *type
= argv
[argc
- 1]->text
;
4275 if (strmatch(type
, "standard")) {
4276 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4277 } else if (strmatch(type
, "extended")) {
4278 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4279 } else if (strmatch(type
, "large")) {
4280 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4281 } else if (strmatch(type
, "both")) {
4282 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4283 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4284 } else { /* if (strmatch(type, "all")) */
4285 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4286 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4287 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4290 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4291 bgp_node_safi(vty
), flag
);
4295 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4296 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4297 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4298 "Send Community attribute to this neighbor\n"
4299 "Send Standard and Extended Community attributes\n"
4300 "Send Standard, Large and Extended Community attributes\n"
4301 "Send Extended Community attributes\n"
4302 "Send Standard Community attributes\n"
4303 "Send Large Community attributes\n")
4305 DEFUN (no_neighbor_send_community_type
,
4306 no_neighbor_send_community_type_cmd
,
4307 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4311 "Send Community attribute to this neighbor\n"
4312 "Send Standard and Extended Community attributes\n"
4313 "Send Standard, Large and Extended Community attributes\n"
4314 "Send Extended Community attributes\n"
4315 "Send Standard Community attributes\n"
4316 "Send Large Community attributes\n")
4320 const char *type
= argv
[argc
- 1]->text
;
4322 if (strmatch(type
, "standard")) {
4323 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4324 } else if (strmatch(type
, "extended")) {
4325 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4326 } else if (strmatch(type
, "large")) {
4327 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4328 } else if (strmatch(type
, "both")) {
4329 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4330 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4331 } else { /* if (strmatch(type, "all")) */
4332 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4333 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4334 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4337 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4338 bgp_node_afi(vty
), bgp_node_safi(vty
),
4343 no_neighbor_send_community_type
,
4344 no_neighbor_send_community_type_hidden_cmd
,
4345 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4346 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4347 "Send Community attribute to this neighbor\n"
4348 "Send Standard and Extended Community attributes\n"
4349 "Send Standard, Large and Extended Community attributes\n"
4350 "Send Extended Community attributes\n"
4351 "Send Standard Community attributes\n"
4352 "Send Large Community attributes\n")
4354 /* neighbor soft-reconfig. */
4355 DEFUN (neighbor_soft_reconfiguration
,
4356 neighbor_soft_reconfiguration_cmd
,
4357 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4360 "Per neighbor soft reconfiguration\n"
4361 "Allow inbound soft reconfiguration for this neighbor\n")
4364 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4366 PEER_FLAG_SOFT_RECONFIG
);
4369 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4370 neighbor_soft_reconfiguration_hidden_cmd
,
4371 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4372 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4373 "Per neighbor soft reconfiguration\n"
4374 "Allow inbound soft reconfiguration for this neighbor\n")
4376 DEFUN (no_neighbor_soft_reconfiguration
,
4377 no_neighbor_soft_reconfiguration_cmd
,
4378 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4382 "Per neighbor soft reconfiguration\n"
4383 "Allow inbound soft reconfiguration for this neighbor\n")
4386 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4387 bgp_node_afi(vty
), bgp_node_safi(vty
),
4388 PEER_FLAG_SOFT_RECONFIG
);
4391 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4392 no_neighbor_soft_reconfiguration_hidden_cmd
,
4393 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4394 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4395 "Per neighbor soft reconfiguration\n"
4396 "Allow inbound soft reconfiguration for this neighbor\n")
4398 DEFUN (neighbor_route_reflector_client
,
4399 neighbor_route_reflector_client_cmd
,
4400 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4403 "Configure a neighbor as Route Reflector client\n")
4409 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4411 return CMD_WARNING_CONFIG_FAILED
;
4413 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4415 PEER_FLAG_REFLECTOR_CLIENT
);
4418 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4419 neighbor_route_reflector_client_hidden_cmd
,
4420 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4421 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4422 "Configure a neighbor as Route Reflector client\n")
4424 DEFUN (no_neighbor_route_reflector_client
,
4425 no_neighbor_route_reflector_client_cmd
,
4426 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4430 "Configure a neighbor as Route Reflector client\n")
4433 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4434 bgp_node_afi(vty
), bgp_node_safi(vty
),
4435 PEER_FLAG_REFLECTOR_CLIENT
);
4438 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4439 no_neighbor_route_reflector_client_hidden_cmd
,
4440 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4441 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4442 "Configure a neighbor as Route Reflector client\n")
4444 /* neighbor route-server-client. */
4445 DEFUN (neighbor_route_server_client
,
4446 neighbor_route_server_client_cmd
,
4447 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4450 "Configure a neighbor as Route Server client\n")
4455 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4457 return CMD_WARNING_CONFIG_FAILED
;
4458 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4460 PEER_FLAG_RSERVER_CLIENT
);
4463 ALIAS_HIDDEN(neighbor_route_server_client
,
4464 neighbor_route_server_client_hidden_cmd
,
4465 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4466 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4467 "Configure a neighbor as Route Server client\n")
4469 DEFUN (no_neighbor_route_server_client
,
4470 no_neighbor_route_server_client_cmd
,
4471 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4475 "Configure a neighbor as Route Server client\n")
4478 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4479 bgp_node_afi(vty
), bgp_node_safi(vty
),
4480 PEER_FLAG_RSERVER_CLIENT
);
4483 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4484 no_neighbor_route_server_client_hidden_cmd
,
4485 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4486 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4487 "Configure a neighbor as Route Server client\n")
4489 DEFUN (neighbor_nexthop_local_unchanged
,
4490 neighbor_nexthop_local_unchanged_cmd
,
4491 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4494 "Configure treatment of outgoing link-local nexthop attribute\n"
4495 "Leave link-local nexthop unchanged for this peer\n")
4498 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4500 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4503 DEFUN (no_neighbor_nexthop_local_unchanged
,
4504 no_neighbor_nexthop_local_unchanged_cmd
,
4505 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4509 "Configure treatment of outgoing link-local-nexthop attribute\n"
4510 "Leave link-local nexthop unchanged for this peer\n")
4513 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4514 bgp_node_afi(vty
), bgp_node_safi(vty
),
4515 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4518 DEFUN (neighbor_attr_unchanged
,
4519 neighbor_attr_unchanged_cmd
,
4520 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4523 "BGP attribute is propagated unchanged to this neighbor\n"
4524 "As-path attribute\n"
4525 "Nexthop attribute\n"
4529 char *peer_str
= argv
[1]->arg
;
4532 afi_t afi
= bgp_node_afi(vty
);
4533 safi_t safi
= bgp_node_safi(vty
);
4535 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4537 return CMD_WARNING_CONFIG_FAILED
;
4539 if (argv_find(argv
, argc
, "as-path", &idx
))
4540 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4542 if (argv_find(argv
, argc
, "next-hop", &idx
))
4543 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4545 if (argv_find(argv
, argc
, "med", &idx
))
4546 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4548 /* no flags means all of them! */
4550 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4551 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4552 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4554 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4555 && peer_af_flag_check(peer
, afi
, safi
,
4556 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4557 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4558 PEER_FLAG_AS_PATH_UNCHANGED
);
4561 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4562 && peer_af_flag_check(peer
, afi
, safi
,
4563 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4564 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4565 PEER_FLAG_NEXTHOP_UNCHANGED
);
4568 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4569 && peer_af_flag_check(peer
, afi
, safi
,
4570 PEER_FLAG_MED_UNCHANGED
)) {
4571 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4572 PEER_FLAG_MED_UNCHANGED
);
4576 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4580 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4581 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4582 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4583 "BGP attribute is propagated unchanged to this neighbor\n"
4584 "As-path attribute\n"
4585 "Nexthop attribute\n"
4588 DEFUN (no_neighbor_attr_unchanged
,
4589 no_neighbor_attr_unchanged_cmd
,
4590 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4594 "BGP attribute is propagated unchanged to this neighbor\n"
4595 "As-path attribute\n"
4596 "Nexthop attribute\n"
4600 char *peer
= argv
[2]->arg
;
4603 if (argv_find(argv
, argc
, "as-path", &idx
))
4604 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4606 if (argv_find(argv
, argc
, "next-hop", &idx
))
4607 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4609 if (argv_find(argv
, argc
, "med", &idx
))
4610 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4612 if (!flags
) // no flags means all of them!
4614 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4615 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4616 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4619 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4620 bgp_node_safi(vty
), flags
);
4624 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4625 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4626 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4627 "BGP attribute is propagated unchanged to this neighbor\n"
4628 "As-path attribute\n"
4629 "Nexthop attribute\n"
4632 /* EBGP multihop configuration. */
4633 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4634 const char *ttl_str
)
4639 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4641 return CMD_WARNING_CONFIG_FAILED
;
4644 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4649 ttl
= strtoul(ttl_str
, NULL
, 10);
4651 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4654 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4658 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4660 return CMD_WARNING_CONFIG_FAILED
;
4662 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4665 /* neighbor ebgp-multihop. */
4666 DEFUN (neighbor_ebgp_multihop
,
4667 neighbor_ebgp_multihop_cmd
,
4668 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4671 "Allow EBGP neighbors not on directly connected networks\n")
4674 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4677 DEFUN (neighbor_ebgp_multihop_ttl
,
4678 neighbor_ebgp_multihop_ttl_cmd
,
4679 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4682 "Allow EBGP neighbors not on directly connected networks\n"
4683 "maximum hop count\n")
4687 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4688 argv
[idx_number
]->arg
);
4691 DEFUN (no_neighbor_ebgp_multihop
,
4692 no_neighbor_ebgp_multihop_cmd
,
4693 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4697 "Allow EBGP neighbors not on directly connected networks\n"
4698 "maximum hop count\n")
4701 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4705 /* disable-connected-check */
4706 DEFUN (neighbor_disable_connected_check
,
4707 neighbor_disable_connected_check_cmd
,
4708 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4711 "one-hop away EBGP peer using loopback address\n"
4712 "Enforce EBGP neighbors perform multihop\n")
4715 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4716 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4719 DEFUN (no_neighbor_disable_connected_check
,
4720 no_neighbor_disable_connected_check_cmd
,
4721 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4725 "one-hop away EBGP peer using loopback address\n"
4726 "Enforce EBGP neighbors perform multihop\n")
4729 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4730 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4734 /* enforce-first-as */
4735 DEFUN (neighbor_enforce_first_as
,
4736 neighbor_enforce_first_as_cmd
,
4737 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4740 "Enforce the first AS for EBGP routes\n")
4744 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4745 PEER_FLAG_ENFORCE_FIRST_AS
);
4748 DEFUN (no_neighbor_enforce_first_as
,
4749 no_neighbor_enforce_first_as_cmd
,
4750 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4754 "Enforce the first AS for EBGP routes\n")
4758 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4759 PEER_FLAG_ENFORCE_FIRST_AS
);
4763 DEFUN (neighbor_description
,
4764 neighbor_description_cmd
,
4765 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4768 "Neighbor specific description\n"
4769 "Up to 80 characters describing this neighbor\n")
4776 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4778 return CMD_WARNING_CONFIG_FAILED
;
4780 str
= argv_concat(argv
, argc
, idx_line
);
4782 peer_description_set(peer
, str
);
4784 XFREE(MTYPE_TMP
, str
);
4789 DEFUN (no_neighbor_description
,
4790 no_neighbor_description_cmd
,
4791 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4795 "Neighbor specific description\n")
4800 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4802 return CMD_WARNING_CONFIG_FAILED
;
4804 peer_description_unset(peer
);
4809 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4810 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4811 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4812 "Neighbor specific description\n"
4813 "Up to 80 characters describing this neighbor\n")
4815 /* Neighbor update-source. */
4816 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4817 const char *source_str
)
4823 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4825 return CMD_WARNING_CONFIG_FAILED
;
4831 if (str2sockunion(source_str
, &su
) == 0)
4832 peer_update_source_addr_set(peer
, &su
);
4834 if (str2prefix(source_str
, &p
)) {
4836 "%% Invalid update-source, remove prefix length \n");
4837 return CMD_WARNING_CONFIG_FAILED
;
4839 peer_update_source_if_set(peer
, source_str
);
4842 peer_update_source_unset(peer
);
4847 #define BGP_UPDATE_SOURCE_HELP_STR \
4850 "Interface name (requires zebra to be running)\n"
4852 DEFUN (neighbor_update_source
,
4853 neighbor_update_source_cmd
,
4854 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4857 "Source of routing updates\n"
4858 BGP_UPDATE_SOURCE_HELP_STR
)
4862 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4863 argv
[idx_peer_2
]->arg
);
4866 DEFUN (no_neighbor_update_source
,
4867 no_neighbor_update_source_cmd
,
4868 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4872 "Source of routing updates\n"
4873 BGP_UPDATE_SOURCE_HELP_STR
)
4876 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4879 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4880 afi_t afi
, safi_t safi
,
4881 const char *rmap
, int set
)
4885 struct route_map
*route_map
;
4887 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4889 return CMD_WARNING_CONFIG_FAILED
;
4892 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4893 ret
= peer_default_originate_set(peer
, afi
, safi
,
4896 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4898 return bgp_vty_return(vty
, ret
);
4901 /* neighbor default-originate. */
4902 DEFUN (neighbor_default_originate
,
4903 neighbor_default_originate_cmd
,
4904 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4907 "Originate default route to this neighbor\n")
4910 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4912 bgp_node_safi(vty
), NULL
, 1);
4915 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4916 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4917 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4918 "Originate default route to this neighbor\n")
4920 DEFUN (neighbor_default_originate_rmap
,
4921 neighbor_default_originate_rmap_cmd
,
4922 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4925 "Originate default route to this neighbor\n"
4926 "Route-map to specify criteria to originate default\n"
4931 return peer_default_originate_set_vty(
4932 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4933 argv
[idx_word
]->arg
, 1);
4937 neighbor_default_originate_rmap
,
4938 neighbor_default_originate_rmap_hidden_cmd
,
4939 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4940 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4941 "Originate default route to this neighbor\n"
4942 "Route-map to specify criteria to originate default\n"
4945 DEFUN (no_neighbor_default_originate
,
4946 no_neighbor_default_originate_cmd
,
4947 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4951 "Originate default route to this neighbor\n"
4952 "Route-map to specify criteria to originate default\n"
4956 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4958 bgp_node_safi(vty
), NULL
, 0);
4962 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4963 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4964 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4965 "Originate default route to this neighbor\n"
4966 "Route-map to specify criteria to originate default\n"
4970 /* Set neighbor's BGP port. */
4971 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4972 const char *port_str
)
4978 peer
= peer_lookup_vty(vty
, ip_str
);
4980 return CMD_WARNING_CONFIG_FAILED
;
4983 sp
= getservbyname("bgp", "tcp");
4984 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4986 port
= strtoul(port_str
, NULL
, 10);
4989 peer_port_set(peer
, port
);
4994 /* Set specified peer's BGP port. */
4995 DEFUN (neighbor_port
,
4997 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5000 "Neighbor's BGP port\n"
5001 "TCP port number\n")
5005 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5006 argv
[idx_number
]->arg
);
5009 DEFUN (no_neighbor_port
,
5010 no_neighbor_port_cmd
,
5011 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5015 "Neighbor's BGP port\n"
5016 "TCP port number\n")
5019 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5023 /* neighbor weight. */
5024 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5025 safi_t safi
, const char *weight_str
)
5029 unsigned long weight
;
5031 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5033 return CMD_WARNING_CONFIG_FAILED
;
5035 weight
= strtoul(weight_str
, NULL
, 10);
5037 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5038 return bgp_vty_return(vty
, ret
);
5041 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5047 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5049 return CMD_WARNING_CONFIG_FAILED
;
5051 ret
= peer_weight_unset(peer
, afi
, safi
);
5052 return bgp_vty_return(vty
, ret
);
5055 DEFUN (neighbor_weight
,
5056 neighbor_weight_cmd
,
5057 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5060 "Set default weight for routes from this neighbor\n"
5065 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5066 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5069 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5070 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5071 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5072 "Set default weight for routes from this neighbor\n"
5075 DEFUN (no_neighbor_weight
,
5076 no_neighbor_weight_cmd
,
5077 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5081 "Set default weight for routes from this neighbor\n"
5085 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5086 bgp_node_afi(vty
), bgp_node_safi(vty
));
5089 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5090 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5091 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5092 "Set default weight for routes from this neighbor\n"
5096 /* Override capability negotiation. */
5097 DEFUN (neighbor_override_capability
,
5098 neighbor_override_capability_cmd
,
5099 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5102 "Override capability negotiation result\n")
5105 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5106 PEER_FLAG_OVERRIDE_CAPABILITY
);
5109 DEFUN (no_neighbor_override_capability
,
5110 no_neighbor_override_capability_cmd
,
5111 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5115 "Override capability negotiation result\n")
5118 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5119 PEER_FLAG_OVERRIDE_CAPABILITY
);
5122 DEFUN (neighbor_strict_capability
,
5123 neighbor_strict_capability_cmd
,
5124 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5127 "Strict capability negotiation match\n")
5131 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5132 PEER_FLAG_STRICT_CAP_MATCH
);
5135 DEFUN (no_neighbor_strict_capability
,
5136 no_neighbor_strict_capability_cmd
,
5137 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5141 "Strict capability negotiation match\n")
5145 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5146 PEER_FLAG_STRICT_CAP_MATCH
);
5149 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5150 const char *keep_str
, const char *hold_str
)
5157 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5159 return CMD_WARNING_CONFIG_FAILED
;
5161 keepalive
= strtoul(keep_str
, NULL
, 10);
5162 holdtime
= strtoul(hold_str
, NULL
, 10);
5164 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5166 return bgp_vty_return(vty
, ret
);
5169 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5174 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5176 return CMD_WARNING_CONFIG_FAILED
;
5178 ret
= peer_timers_unset(peer
);
5180 return bgp_vty_return(vty
, ret
);
5183 DEFUN (neighbor_timers
,
5184 neighbor_timers_cmd
,
5185 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5188 "BGP per neighbor timers\n"
5189 "Keepalive interval\n"
5194 int idx_number_2
= 4;
5195 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5196 argv
[idx_number
]->arg
,
5197 argv
[idx_number_2
]->arg
);
5200 DEFUN (no_neighbor_timers
,
5201 no_neighbor_timers_cmd
,
5202 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5206 "BGP per neighbor timers\n"
5207 "Keepalive interval\n"
5211 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5215 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5216 const char *time_str
)
5222 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5224 return CMD_WARNING_CONFIG_FAILED
;
5226 connect
= strtoul(time_str
, NULL
, 10);
5228 ret
= peer_timers_connect_set(peer
, connect
);
5230 return bgp_vty_return(vty
, ret
);
5233 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5238 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5240 return CMD_WARNING_CONFIG_FAILED
;
5242 ret
= peer_timers_connect_unset(peer
);
5244 return bgp_vty_return(vty
, ret
);
5247 DEFUN (neighbor_timers_connect
,
5248 neighbor_timers_connect_cmd
,
5249 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5252 "BGP per neighbor timers\n"
5253 "BGP connect timer\n"
5258 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5259 argv
[idx_number
]->arg
);
5262 DEFUN (no_neighbor_timers_connect
,
5263 no_neighbor_timers_connect_cmd
,
5264 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5268 "BGP per neighbor timers\n"
5269 "BGP connect timer\n"
5273 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5277 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5278 const char *time_str
, int set
)
5282 uint32_t routeadv
= 0;
5284 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5286 return CMD_WARNING_CONFIG_FAILED
;
5289 routeadv
= strtoul(time_str
, NULL
, 10);
5292 ret
= peer_advertise_interval_set(peer
, routeadv
);
5294 ret
= peer_advertise_interval_unset(peer
);
5296 return bgp_vty_return(vty
, ret
);
5299 DEFUN (neighbor_advertise_interval
,
5300 neighbor_advertise_interval_cmd
,
5301 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5304 "Minimum interval between sending BGP routing updates\n"
5305 "time in seconds\n")
5309 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5310 argv
[idx_number
]->arg
, 1);
5313 DEFUN (no_neighbor_advertise_interval
,
5314 no_neighbor_advertise_interval_cmd
,
5315 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5319 "Minimum interval between sending BGP routing updates\n"
5320 "time in seconds\n")
5323 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5327 /* Time to wait before processing route-map updates */
5328 DEFUN (bgp_set_route_map_delay_timer
,
5329 bgp_set_route_map_delay_timer_cmd
,
5330 "bgp route-map delay-timer (0-600)",
5332 "BGP route-map delay timer\n"
5333 "Time in secs to wait before processing route-map changes\n"
5334 "0 disables the timer, no route updates happen when route-maps change\n")
5337 uint32_t rmap_delay_timer
;
5339 if (argv
[idx_number
]->arg
) {
5340 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5341 bm
->rmap_update_timer
= rmap_delay_timer
;
5343 /* if the dynamic update handling is being disabled, and a timer
5345 * running, stop the timer and act as if the timer has already
5348 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5349 BGP_TIMER_OFF(bm
->t_rmap_update
);
5350 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5355 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5356 return CMD_WARNING_CONFIG_FAILED
;
5360 DEFUN (no_bgp_set_route_map_delay_timer
,
5361 no_bgp_set_route_map_delay_timer_cmd
,
5362 "no bgp route-map delay-timer [(0-600)]",
5365 "Default BGP route-map delay timer\n"
5366 "Reset to default time to wait for processing route-map changes\n"
5367 "0 disables the timer, no route updates happen when route-maps change\n")
5370 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5376 /* neighbor interface */
5377 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5382 peer
= peer_lookup_vty(vty
, ip_str
);
5383 if (!peer
|| peer
->conf_if
) {
5384 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5385 return CMD_WARNING_CONFIG_FAILED
;
5389 peer_interface_set(peer
, str
);
5391 peer_interface_unset(peer
);
5396 DEFUN (neighbor_interface
,
5397 neighbor_interface_cmd
,
5398 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5406 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5409 DEFUN (no_neighbor_interface
,
5410 no_neighbor_interface_cmd
,
5411 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5419 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5422 DEFUN (neighbor_distribute_list
,
5423 neighbor_distribute_list_cmd
,
5424 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5427 "Filter updates to/from this neighbor\n"
5428 "IP access-list number\n"
5429 "IP access-list number (expanded range)\n"
5430 "IP Access-list name\n"
5431 "Filter incoming updates\n"
5432 "Filter outgoing updates\n")
5439 const char *pstr
= argv
[idx_peer
]->arg
;
5440 const char *acl
= argv
[idx_acl
]->arg
;
5441 const char *inout
= argv
[argc
- 1]->text
;
5443 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5445 return CMD_WARNING_CONFIG_FAILED
;
5447 /* Check filter direction. */
5448 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5449 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5452 return bgp_vty_return(vty
, ret
);
5456 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5457 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5458 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5459 "Filter updates to/from this neighbor\n"
5460 "IP access-list number\n"
5461 "IP access-list number (expanded range)\n"
5462 "IP Access-list name\n"
5463 "Filter incoming updates\n"
5464 "Filter outgoing updates\n")
5466 DEFUN (no_neighbor_distribute_list
,
5467 no_neighbor_distribute_list_cmd
,
5468 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5472 "Filter updates to/from this neighbor\n"
5473 "IP access-list number\n"
5474 "IP access-list number (expanded range)\n"
5475 "IP Access-list name\n"
5476 "Filter incoming updates\n"
5477 "Filter outgoing updates\n")
5483 const char *pstr
= argv
[idx_peer
]->arg
;
5484 const char *inout
= argv
[argc
- 1]->text
;
5486 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5488 return CMD_WARNING_CONFIG_FAILED
;
5490 /* Check filter direction. */
5491 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5492 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5495 return bgp_vty_return(vty
, ret
);
5499 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5500 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5501 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5502 "Filter updates to/from this neighbor\n"
5503 "IP access-list number\n"
5504 "IP access-list number (expanded range)\n"
5505 "IP Access-list name\n"
5506 "Filter incoming updates\n"
5507 "Filter outgoing updates\n")
5509 /* Set prefix list to the peer. */
5510 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5511 afi_t afi
, safi_t safi
,
5512 const char *name_str
,
5513 const char *direct_str
)
5516 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_set(peer
, afi
, safi
, direct
, name_str
);
5531 return bgp_vty_return(vty
, ret
);
5534 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5535 afi_t afi
, safi_t safi
,
5536 const char *direct_str
)
5540 int direct
= FILTER_IN
;
5542 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5544 return CMD_WARNING_CONFIG_FAILED
;
5546 /* Check filter direction. */
5547 if (strncmp(direct_str
, "i", 1) == 0)
5549 else if (strncmp(direct_str
, "o", 1) == 0)
5550 direct
= FILTER_OUT
;
5552 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5554 return bgp_vty_return(vty
, ret
);
5557 DEFUN (neighbor_prefix_list
,
5558 neighbor_prefix_list_cmd
,
5559 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5562 "Filter updates to/from this neighbor\n"
5563 "Name of a prefix list\n"
5564 "Filter incoming updates\n"
5565 "Filter outgoing updates\n")
5570 return peer_prefix_list_set_vty(
5571 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5572 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5575 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5576 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5577 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5578 "Filter updates to/from this neighbor\n"
5579 "Name of a prefix list\n"
5580 "Filter incoming updates\n"
5581 "Filter outgoing updates\n")
5583 DEFUN (no_neighbor_prefix_list
,
5584 no_neighbor_prefix_list_cmd
,
5585 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5589 "Filter updates to/from this neighbor\n"
5590 "Name of a prefix list\n"
5591 "Filter incoming updates\n"
5592 "Filter outgoing updates\n")
5596 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5597 bgp_node_afi(vty
), bgp_node_safi(vty
),
5598 argv
[idx_in_out
]->arg
);
5601 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5602 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5603 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5604 "Filter updates to/from this neighbor\n"
5605 "Name of a prefix list\n"
5606 "Filter incoming updates\n"
5607 "Filter outgoing updates\n")
5609 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5610 safi_t safi
, const char *name_str
,
5611 const char *direct_str
)
5615 int direct
= FILTER_IN
;
5617 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5619 return CMD_WARNING_CONFIG_FAILED
;
5621 /* Check filter direction. */
5622 if (strncmp(direct_str
, "i", 1) == 0)
5624 else if (strncmp(direct_str
, "o", 1) == 0)
5625 direct
= FILTER_OUT
;
5627 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5629 return bgp_vty_return(vty
, ret
);
5632 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5633 safi_t safi
, const char *direct_str
)
5637 int direct
= FILTER_IN
;
5639 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5641 return CMD_WARNING_CONFIG_FAILED
;
5643 /* Check filter direction. */
5644 if (strncmp(direct_str
, "i", 1) == 0)
5646 else if (strncmp(direct_str
, "o", 1) == 0)
5647 direct
= FILTER_OUT
;
5649 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5651 return bgp_vty_return(vty
, ret
);
5654 DEFUN (neighbor_filter_list
,
5655 neighbor_filter_list_cmd
,
5656 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5659 "Establish BGP filters\n"
5660 "AS path access-list name\n"
5661 "Filter incoming routes\n"
5662 "Filter outgoing routes\n")
5667 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5668 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5669 argv
[idx_in_out
]->arg
);
5672 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5673 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5674 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5675 "Establish BGP filters\n"
5676 "AS path access-list name\n"
5677 "Filter incoming routes\n"
5678 "Filter outgoing routes\n")
5680 DEFUN (no_neighbor_filter_list
,
5681 no_neighbor_filter_list_cmd
,
5682 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5686 "Establish BGP filters\n"
5687 "AS path access-list name\n"
5688 "Filter incoming routes\n"
5689 "Filter outgoing routes\n")
5693 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5694 bgp_node_afi(vty
), bgp_node_safi(vty
),
5695 argv
[idx_in_out
]->arg
);
5698 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5699 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5700 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5701 "Establish BGP filters\n"
5702 "AS path access-list name\n"
5703 "Filter incoming routes\n"
5704 "Filter outgoing routes\n")
5706 /* Set route-map to the peer. */
5707 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5708 afi_t afi
, safi_t safi
, const char *name_str
,
5709 const char *direct_str
)
5713 int direct
= RMAP_IN
;
5714 struct route_map
*route_map
;
5716 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5718 return CMD_WARNING_CONFIG_FAILED
;
5720 /* Check filter direction. */
5721 if (strncmp(direct_str
, "in", 2) == 0)
5723 else if (strncmp(direct_str
, "o", 1) == 0)
5726 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5727 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5729 return bgp_vty_return(vty
, ret
);
5732 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5733 afi_t afi
, safi_t safi
,
5734 const char *direct_str
)
5738 int direct
= RMAP_IN
;
5740 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5742 return CMD_WARNING_CONFIG_FAILED
;
5744 /* Check filter direction. */
5745 if (strncmp(direct_str
, "in", 2) == 0)
5747 else if (strncmp(direct_str
, "o", 1) == 0)
5750 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5752 return bgp_vty_return(vty
, ret
);
5755 DEFUN (neighbor_route_map
,
5756 neighbor_route_map_cmd
,
5757 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5760 "Apply route map to neighbor\n"
5761 "Name of route map\n"
5762 "Apply map to incoming routes\n"
5763 "Apply map to outbound routes\n")
5768 return peer_route_map_set_vty(
5769 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5770 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5773 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5774 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5775 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5776 "Apply route map to neighbor\n"
5777 "Name of route map\n"
5778 "Apply map to incoming routes\n"
5779 "Apply map to outbound routes\n")
5781 DEFUN (no_neighbor_route_map
,
5782 no_neighbor_route_map_cmd
,
5783 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5787 "Apply route map to neighbor\n"
5788 "Name of route map\n"
5789 "Apply map to incoming routes\n"
5790 "Apply map to outbound routes\n")
5794 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5795 bgp_node_afi(vty
), bgp_node_safi(vty
),
5796 argv
[idx_in_out
]->arg
);
5799 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5800 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5801 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5802 "Apply route map to neighbor\n"
5803 "Name of route map\n"
5804 "Apply map to incoming routes\n"
5805 "Apply map to outbound routes\n")
5807 /* Set unsuppress-map to the peer. */
5808 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5809 afi_t afi
, safi_t safi
,
5810 const char *name_str
)
5814 struct route_map
*route_map
;
5816 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5818 return CMD_WARNING_CONFIG_FAILED
;
5820 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5821 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5823 return bgp_vty_return(vty
, ret
);
5826 /* Unset route-map from the peer. */
5827 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5828 afi_t afi
, safi_t safi
)
5833 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5835 return CMD_WARNING_CONFIG_FAILED
;
5837 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5839 return bgp_vty_return(vty
, ret
);
5842 DEFUN (neighbor_unsuppress_map
,
5843 neighbor_unsuppress_map_cmd
,
5844 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5847 "Route-map to selectively unsuppress suppressed routes\n"
5848 "Name of route map\n")
5852 return peer_unsuppress_map_set_vty(
5853 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5854 argv
[idx_word
]->arg
);
5857 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5858 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5859 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5860 "Route-map to selectively unsuppress suppressed routes\n"
5861 "Name of route map\n")
5863 DEFUN (no_neighbor_unsuppress_map
,
5864 no_neighbor_unsuppress_map_cmd
,
5865 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5869 "Route-map to selectively unsuppress suppressed routes\n"
5870 "Name of route map\n")
5873 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5875 bgp_node_safi(vty
));
5878 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5879 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5880 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5881 "Route-map to selectively unsuppress suppressed routes\n"
5882 "Name of route map\n")
5884 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5885 afi_t afi
, safi_t safi
,
5886 const char *num_str
,
5887 const char *threshold_str
, int warning
,
5888 const char *restart_str
)
5896 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5898 return CMD_WARNING_CONFIG_FAILED
;
5900 max
= strtoul(num_str
, NULL
, 10);
5902 threshold
= atoi(threshold_str
);
5904 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5907 restart
= atoi(restart_str
);
5911 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5914 return bgp_vty_return(vty
, ret
);
5917 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5918 afi_t afi
, safi_t safi
)
5923 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5925 return CMD_WARNING_CONFIG_FAILED
;
5927 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5929 return bgp_vty_return(vty
, ret
);
5932 /* Maximum number of prefix configuration. prefix count is different
5933 for each peer configuration. So this configuration can be set for
5934 each peer configuration. */
5935 DEFUN (neighbor_maximum_prefix
,
5936 neighbor_maximum_prefix_cmd
,
5937 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5940 "Maximum number of prefix accept from this peer\n"
5941 "maximum no. of prefix limit\n")
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
, NULL
, 0, NULL
);
5950 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5952 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5953 "Maximum number of prefix accept from this peer\n"
5954 "maximum no. of prefix limit\n")
5956 DEFUN (neighbor_maximum_prefix_threshold
,
5957 neighbor_maximum_prefix_threshold_cmd
,
5958 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5961 "Maximum number of prefix accept from this peer\n"
5962 "maximum no. of prefix limit\n"
5963 "Threshold value (%) at which to generate a warning msg\n")
5967 int idx_number_2
= 4;
5968 return peer_maximum_prefix_set_vty(
5969 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5970 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5974 neighbor_maximum_prefix_threshold
,
5975 neighbor_maximum_prefix_threshold_hidden_cmd
,
5976 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5977 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5978 "Maximum number of prefix accept from this peer\n"
5979 "maximum no. of prefix limit\n"
5980 "Threshold value (%) at which to generate a warning msg\n")
5982 DEFUN (neighbor_maximum_prefix_warning
,
5983 neighbor_maximum_prefix_warning_cmd
,
5984 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5987 "Maximum number of prefix accept from this peer\n"
5988 "maximum no. of prefix limit\n"
5989 "Only give warning message when limit is exceeded\n")
5993 return peer_maximum_prefix_set_vty(
5994 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5995 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5999 neighbor_maximum_prefix_warning
,
6000 neighbor_maximum_prefix_warning_hidden_cmd
,
6001 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6002 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6003 "Maximum number of prefix accept from this peer\n"
6004 "maximum no. of prefix limit\n"
6005 "Only give warning message when limit is exceeded\n")
6007 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6008 neighbor_maximum_prefix_threshold_warning_cmd
,
6009 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6012 "Maximum number of prefix accept from this peer\n"
6013 "maximum no. of prefix limit\n"
6014 "Threshold value (%) at which to generate a warning msg\n"
6015 "Only give warning message when limit is exceeded\n")
6019 int idx_number_2
= 4;
6020 return peer_maximum_prefix_set_vty(
6021 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6022 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6026 neighbor_maximum_prefix_threshold_warning
,
6027 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6028 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6029 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6030 "Maximum number of prefix accept from this peer\n"
6031 "maximum no. of prefix limit\n"
6032 "Threshold value (%) at which to generate a warning msg\n"
6033 "Only give warning message when limit is exceeded\n")
6035 DEFUN (neighbor_maximum_prefix_restart
,
6036 neighbor_maximum_prefix_restart_cmd
,
6037 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6040 "Maximum number of prefix accept from this peer\n"
6041 "maximum no. of prefix limit\n"
6042 "Restart bgp connection after limit is exceeded\n"
6043 "Restart interval in minutes\n")
6047 int idx_number_2
= 5;
6048 return peer_maximum_prefix_set_vty(
6049 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6050 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6054 neighbor_maximum_prefix_restart
,
6055 neighbor_maximum_prefix_restart_hidden_cmd
,
6056 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6057 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6058 "Maximum number of prefix accept from this peer\n"
6059 "maximum no. of prefix limit\n"
6060 "Restart bgp connection after limit is exceeded\n"
6061 "Restart interval in minutes\n")
6063 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6064 neighbor_maximum_prefix_threshold_restart_cmd
,
6065 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6068 "Maximum number of prefixes to accept from this peer\n"
6069 "maximum no. of prefix limit\n"
6070 "Threshold value (%) at which to generate a warning msg\n"
6071 "Restart bgp connection after limit is exceeded\n"
6072 "Restart interval in minutes\n")
6076 int idx_number_2
= 4;
6077 int idx_number_3
= 6;
6078 return peer_maximum_prefix_set_vty(
6079 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6080 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6081 argv
[idx_number_3
]->arg
);
6085 neighbor_maximum_prefix_threshold_restart
,
6086 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6087 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6088 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6089 "Maximum number of prefixes to accept from this peer\n"
6090 "maximum no. of prefix limit\n"
6091 "Threshold value (%) at which to generate a warning msg\n"
6092 "Restart bgp connection after limit is exceeded\n"
6093 "Restart interval in minutes\n")
6095 DEFUN (no_neighbor_maximum_prefix
,
6096 no_neighbor_maximum_prefix_cmd
,
6097 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6101 "Maximum number of prefixes to accept from this peer\n"
6102 "maximum no. of prefix limit\n"
6103 "Threshold value (%) at which to generate a warning msg\n"
6104 "Restart bgp connection after limit is exceeded\n"
6105 "Restart interval in minutes\n"
6106 "Only give warning message when limit is exceeded\n")
6109 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6111 bgp_node_safi(vty
));
6115 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6116 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6117 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6118 "Maximum number of prefixes to accept from this peer\n"
6119 "maximum no. of prefix limit\n"
6120 "Threshold value (%) at which to generate a warning msg\n"
6121 "Restart bgp connection after limit is exceeded\n"
6122 "Restart interval in minutes\n"
6123 "Only give warning message when limit is exceeded\n")
6126 /* "neighbor allowas-in" */
6127 DEFUN (neighbor_allowas_in
,
6128 neighbor_allowas_in_cmd
,
6129 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6132 "Accept as-path with my AS present in it\n"
6133 "Number of occurences of AS number\n"
6134 "Only accept my AS in the as-path if the route was originated in my AS\n")
6137 int idx_number_origin
= 3;
6143 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6145 return CMD_WARNING_CONFIG_FAILED
;
6147 if (argc
<= idx_number_origin
)
6150 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6153 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6156 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6159 return bgp_vty_return(vty
, ret
);
6163 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6164 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6165 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6166 "Accept as-path with my AS present in it\n"
6167 "Number of occurences of AS number\n"
6168 "Only accept my AS in the as-path if the route was originated in my AS\n")
6170 DEFUN (no_neighbor_allowas_in
,
6171 no_neighbor_allowas_in_cmd
,
6172 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6176 "allow local ASN appears in aspath attribute\n"
6177 "Number of occurences of AS number\n"
6178 "Only accept my AS in the as-path if the route was originated in my AS\n")
6184 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6186 return CMD_WARNING_CONFIG_FAILED
;
6188 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6189 bgp_node_safi(vty
));
6191 return bgp_vty_return(vty
, ret
);
6195 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6196 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6197 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6198 "allow local ASN appears in aspath attribute\n"
6199 "Number of occurences of AS number\n"
6200 "Only accept my AS in the as-path if the route was originated in my AS\n")
6202 DEFUN (neighbor_ttl_security
,
6203 neighbor_ttl_security_cmd
,
6204 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6207 "BGP ttl-security parameters\n"
6208 "Specify the maximum number of hops to the BGP peer\n"
6209 "Number of hops to BGP peer\n")
6216 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6218 return CMD_WARNING_CONFIG_FAILED
;
6220 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6223 * If 'neighbor swpX', then this is for directly connected peers,
6224 * we should not accept a ttl-security hops value greater than 1.
6226 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6228 "%s is directly connected peer, hops cannot exceed 1\n",
6229 argv
[idx_peer
]->arg
);
6230 return CMD_WARNING_CONFIG_FAILED
;
6233 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6236 DEFUN (no_neighbor_ttl_security
,
6237 no_neighbor_ttl_security_cmd
,
6238 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6242 "BGP ttl-security parameters\n"
6243 "Specify the maximum number of hops to the BGP peer\n"
6244 "Number of hops to BGP peer\n")
6249 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6251 return CMD_WARNING_CONFIG_FAILED
;
6253 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6256 DEFUN (neighbor_addpath_tx_all_paths
,
6257 neighbor_addpath_tx_all_paths_cmd
,
6258 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6261 "Use addpath to advertise all paths to a neighbor\n")
6266 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6268 return CMD_WARNING_CONFIG_FAILED
;
6270 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6275 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6276 neighbor_addpath_tx_all_paths_hidden_cmd
,
6277 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6278 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6279 "Use addpath to advertise all paths to a neighbor\n")
6281 DEFUN (no_neighbor_addpath_tx_all_paths
,
6282 no_neighbor_addpath_tx_all_paths_cmd
,
6283 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6287 "Use addpath to advertise all paths to a neighbor\n")
6292 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6294 return CMD_WARNING_CONFIG_FAILED
;
6296 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6297 != BGP_ADDPATH_ALL
) {
6299 "%% Peer not currently configured to transmit all paths.");
6300 return CMD_WARNING_CONFIG_FAILED
;
6303 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6309 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6310 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6311 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6312 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6313 "Use addpath to advertise all paths to a neighbor\n")
6315 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6316 neighbor_addpath_tx_bestpath_per_as_cmd
,
6317 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6320 "Use addpath to advertise the bestpath per each neighboring AS\n")
6325 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6327 return CMD_WARNING_CONFIG_FAILED
;
6329 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6330 BGP_ADDPATH_BEST_PER_AS
);
6335 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6336 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6337 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6338 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6339 "Use addpath to advertise the bestpath per each neighboring AS\n")
6341 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6342 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6343 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6347 "Use addpath to advertise the bestpath per each neighboring AS\n")
6352 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6354 return CMD_WARNING_CONFIG_FAILED
;
6356 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6357 != BGP_ADDPATH_BEST_PER_AS
) {
6359 "%% Peer not currently configured to transmit all best path per as.");
6360 return CMD_WARNING_CONFIG_FAILED
;
6363 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6369 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6370 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6371 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6372 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6373 "Use addpath to advertise the bestpath per each neighboring AS\n")
6375 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6376 struct ecommunity
**list
)
6378 struct ecommunity
*ecom
= NULL
;
6379 struct ecommunity
*ecomadd
;
6381 for (; argc
; --argc
, ++argv
) {
6383 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6384 ECOMMUNITY_ROUTE_TARGET
, 0);
6386 vty_out(vty
, "Malformed community-list value\n");
6388 ecommunity_free(&ecom
);
6389 return CMD_WARNING_CONFIG_FAILED
;
6393 ecommunity_merge(ecom
, ecomadd
);
6394 ecommunity_free(&ecomadd
);
6401 ecommunity_free(&*list
);
6409 * v2vimport is true if we are handling a `import vrf ...` command
6411 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6415 switch (vty
->node
) {
6424 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6429 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6430 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6431 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6432 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6434 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6438 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6439 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6440 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6441 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6443 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6450 DEFPY (af_rd_vpn_export
,
6451 af_rd_vpn_export_cmd
,
6452 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6454 "Specify route distinguisher\n"
6455 "Between current address-family and vpn\n"
6456 "For routes leaked from current address-family to vpn\n"
6457 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6459 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6460 struct prefix_rd prd
;
6466 if (argv_find(argv
, argc
, "no", &idx
))
6470 ret
= str2prefix_rd(rd_str
, &prd
);
6472 vty_out(vty
, "%% Malformed rd\n");
6473 return CMD_WARNING_CONFIG_FAILED
;
6477 afi
= vpn_policy_getafi(vty
, bgp
, false);
6479 return CMD_WARNING_CONFIG_FAILED
;
6482 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6484 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6485 bgp_get_default(), bgp
);
6488 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6489 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6490 BGP_VPN_POLICY_TOVPN_RD_SET
);
6492 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6493 BGP_VPN_POLICY_TOVPN_RD_SET
);
6496 /* post-change: re-export vpn routes */
6497 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6498 bgp_get_default(), bgp
);
6503 ALIAS (af_rd_vpn_export
,
6504 af_no_rd_vpn_export_cmd
,
6507 "Specify route distinguisher\n"
6508 "Between current address-family and vpn\n"
6509 "For routes leaked from current address-family to vpn\n")
6511 DEFPY (af_label_vpn_export
,
6512 af_label_vpn_export_cmd
,
6513 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6515 "label value for VRF\n"
6516 "Between current address-family and vpn\n"
6517 "For routes leaked from current address-family to vpn\n"
6518 "Label Value <0-1048575>\n"
6519 "Automatically assign a label\n")
6521 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6522 mpls_label_t label
= MPLS_LABEL_NONE
;
6527 if (argv_find(argv
, argc
, "no", &idx
))
6530 /* If "no ...", squash trailing parameter */
6536 label
= label_val
; /* parser should force unsigned */
6539 afi
= vpn_policy_getafi(vty
, bgp
, false);
6541 return CMD_WARNING_CONFIG_FAILED
;
6544 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6545 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6550 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6552 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6553 bgp_get_default(), bgp
);
6555 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6556 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6558 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6561 * label has previously been automatically
6562 * assigned by labelpool: release it
6564 * NB if tovpn_label == MPLS_LABEL_NONE it
6565 * means the automatic assignment is in flight
6566 * and therefore the labelpool callback must
6567 * detect that the auto label is not needed.
6570 bgp_lp_release(LP_TYPE_VRF
,
6571 &bgp
->vpn_policy
[afi
],
6572 bgp
->vpn_policy
[afi
].tovpn_label
);
6574 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6575 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6578 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6580 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6581 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6582 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6583 vpn_leak_label_callback
);
6586 /* post-change: re-export vpn routes */
6587 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6588 bgp_get_default(), bgp
);
6593 ALIAS (af_label_vpn_export
,
6594 af_no_label_vpn_export_cmd
,
6595 "no label vpn export",
6597 "label value for VRF\n"
6598 "Between current address-family and vpn\n"
6599 "For routes leaked from current address-family to vpn\n")
6601 DEFPY (af_nexthop_vpn_export
,
6602 af_nexthop_vpn_export_cmd
,
6603 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6605 "Specify next hop to use for VRF advertised prefixes\n"
6606 "Between current address-family and vpn\n"
6607 "For routes leaked from current address-family to vpn\n"
6611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6617 if (argv_find(argv
, argc
, "no", &idx
))
6621 if (!sockunion2hostprefix(nexthop_str
, &p
))
6622 return CMD_WARNING_CONFIG_FAILED
;
6625 afi
= vpn_policy_getafi(vty
, bgp
, false);
6627 return CMD_WARNING_CONFIG_FAILED
;
6630 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6632 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6633 bgp_get_default(), bgp
);
6636 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6637 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6638 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6640 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6641 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6644 /* post-change: re-export vpn routes */
6645 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6646 bgp_get_default(), bgp
);
6651 ALIAS (af_nexthop_vpn_export
,
6652 af_no_nexthop_vpn_export_cmd
,
6653 "no nexthop vpn export",
6655 "Specify next hop to use for VRF advertised prefixes\n"
6656 "Between current address-family and vpn\n"
6657 "For routes leaked from current address-family to vpn\n")
6659 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6661 if (!strcmp(dstr
, "import")) {
6662 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6663 } else if (!strcmp(dstr
, "export")) {
6664 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6665 } else if (!strcmp(dstr
, "both")) {
6666 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6667 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6669 vty_out(vty
, "%% direction parse error\n");
6670 return CMD_WARNING_CONFIG_FAILED
;
6675 DEFPY (af_rt_vpn_imexport
,
6676 af_rt_vpn_imexport_cmd
,
6677 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6679 "Specify route target list\n"
6680 "Specify route target list\n"
6681 "Between current address-family and vpn\n"
6682 "For routes leaked from vpn to current address-family: match any\n"
6683 "For routes leaked from current address-family to vpn: set\n"
6684 "both import: match any and export: set\n"
6685 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6687 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6689 struct ecommunity
*ecom
= NULL
;
6690 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6691 vpn_policy_direction_t dir
;
6696 if (argv_find(argv
, argc
, "no", &idx
))
6699 afi
= vpn_policy_getafi(vty
, bgp
, false);
6701 return CMD_WARNING_CONFIG_FAILED
;
6703 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6704 if (ret
!= CMD_SUCCESS
)
6708 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6709 vty_out(vty
, "%% Missing RTLIST\n");
6710 return CMD_WARNING_CONFIG_FAILED
;
6712 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6713 if (ret
!= CMD_SUCCESS
) {
6718 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6722 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6725 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6727 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6728 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6729 ecommunity_dup(ecom
);
6731 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6733 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6734 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6737 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6741 ecommunity_free(&ecom
);
6746 ALIAS (af_rt_vpn_imexport
,
6747 af_no_rt_vpn_imexport_cmd
,
6748 "no <rt|route-target> vpn <import|export|both>$direction_str",
6750 "Specify route target list\n"
6751 "Specify route target list\n"
6752 "Between current address-family and vpn\n"
6753 "For routes leaked from vpn to current address-family\n"
6754 "For routes leaked from current address-family to vpn\n"
6755 "both import and export\n")
6757 DEFPY (af_route_map_vpn_imexport
,
6758 af_route_map_vpn_imexport_cmd
,
6759 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6760 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6762 "Specify route map\n"
6763 "Between current address-family and vpn\n"
6764 "For routes leaked from vpn to current address-family\n"
6765 "For routes leaked from current address-family to vpn\n"
6766 "name of route-map\n")
6768 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6770 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6771 vpn_policy_direction_t dir
;
6776 if (argv_find(argv
, argc
, "no", &idx
))
6779 afi
= vpn_policy_getafi(vty
, bgp
, false);
6781 return CMD_WARNING_CONFIG_FAILED
;
6783 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6784 if (ret
!= CMD_SUCCESS
)
6787 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6791 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6794 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6795 XFREE(MTYPE_ROUTE_MAP_NAME
,
6796 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6797 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6798 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6799 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6800 route_map_lookup_warn_noexist(vty
, rmap_str
);
6801 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6804 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6805 XFREE(MTYPE_ROUTE_MAP_NAME
,
6806 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6807 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6808 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6811 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6817 ALIAS (af_route_map_vpn_imexport
,
6818 af_no_route_map_vpn_imexport_cmd
,
6819 "no route-map vpn <import|export>$direction_str",
6821 "Specify route map\n"
6822 "Between current address-family and vpn\n"
6823 "For routes leaked from vpn to current address-family\n"
6824 "For routes leaked from current address-family to vpn\n")
6826 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6827 "[no] import vrf route-map RMAP$rmap_str",
6829 "Import routes from another VRF\n"
6830 "Vrf routes being filtered\n"
6831 "Specify route map\n"
6832 "name of route-map\n")
6834 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6835 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6839 struct bgp
*bgp_default
;
6841 if (argv_find(argv
, argc
, "no", &idx
))
6844 afi
= vpn_policy_getafi(vty
, bgp
, true);
6846 return CMD_WARNING_CONFIG_FAILED
;
6848 bgp_default
= bgp_get_default();
6853 /* Auto-create assuming the same AS */
6854 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6855 BGP_INSTANCE_TYPE_DEFAULT
);
6859 "VRF default is not configured as a bgp instance\n");
6864 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6867 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6868 XFREE(MTYPE_ROUTE_MAP_NAME
,
6869 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6870 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6871 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6872 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6873 route_map_lookup_warn_noexist(vty
, rmap_str
);
6874 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6877 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6878 XFREE(MTYPE_ROUTE_MAP_NAME
,
6879 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6880 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6881 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6884 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6889 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6890 "no import vrf route-map",
6892 "Import routes from another VRF\n"
6893 "Vrf routes being filtered\n"
6894 "Specify route map\n")
6896 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6897 "[no] import vrf VIEWVRFNAME$import_name",
6899 "Import routes from another VRF\n"
6900 "VRF to import from\n"
6901 "The name of the VRF\n")
6903 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6904 struct listnode
*node
;
6905 struct bgp
*vrf_bgp
, *bgp_default
;
6908 bool remove
= false;
6911 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6915 if (import_name
== NULL
) {
6916 vty_out(vty
, "%% Missing import name\n");
6920 if (argv_find(argv
, argc
, "no", &idx
))
6923 afi
= vpn_policy_getafi(vty
, bgp
, true);
6925 return CMD_WARNING_CONFIG_FAILED
;
6927 safi
= bgp_node_safi(vty
);
6929 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6930 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6931 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6932 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6933 remove
? "unimport" : "import", import_name
);
6937 bgp_default
= bgp_get_default();
6939 /* Auto-create assuming the same AS */
6940 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6941 BGP_INSTANCE_TYPE_DEFAULT
);
6945 "VRF default is not configured as a bgp instance\n");
6950 vrf_bgp
= bgp_lookup_by_name(import_name
);
6952 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6953 vrf_bgp
= bgp_default
;
6955 /* Auto-create assuming the same AS */
6956 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6960 "VRF %s is not configured as a bgp instance\n",
6967 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6969 /* Already importing from "import_vrf"? */
6970 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6972 if (strcmp(vname
, import_name
) == 0)
6976 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6982 /* This command is valid only in a bgp vrf instance or the default instance */
6983 DEFPY (bgp_imexport_vpn
,
6984 bgp_imexport_vpn_cmd
,
6985 "[no] <import|export>$direction_str vpn",
6987 "Import routes to this address-family\n"
6988 "Export routes from this address-family\n"
6989 "to/from default instance VPN RIB\n")
6991 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6998 vpn_policy_direction_t dir
;
7000 if (argv_find(argv
, argc
, "no", &idx
))
7003 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7004 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7006 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7007 return CMD_WARNING_CONFIG_FAILED
;
7010 afi
= bgp_node_afi(vty
);
7011 safi
= bgp_node_safi(vty
);
7012 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7013 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7014 return CMD_WARNING_CONFIG_FAILED
;
7017 if (!strcmp(direction_str
, "import")) {
7018 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7019 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7020 } else if (!strcmp(direction_str
, "export")) {
7021 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7022 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7024 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7025 return CMD_WARNING_CONFIG_FAILED
;
7028 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7031 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7032 if (!previous_state
) {
7033 /* trigger export current vrf */
7034 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7037 if (previous_state
) {
7038 /* trigger un-export current vrf */
7039 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7041 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7047 DEFPY (af_routetarget_import
,
7048 af_routetarget_import_cmd
,
7049 "[no] <rt|route-target> redirect import RTLIST...",
7051 "Specify route target list\n"
7052 "Specify route target list\n"
7053 "Flow-spec redirect type route target\n"
7054 "Import routes to this address-family\n"
7055 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7059 struct ecommunity
*ecom
= NULL
;
7064 if (argv_find(argv
, argc
, "no", &idx
))
7067 afi
= vpn_policy_getafi(vty
, bgp
, false);
7069 return CMD_WARNING_CONFIG_FAILED
;
7072 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7073 vty_out(vty
, "%% Missing RTLIST\n");
7074 return CMD_WARNING_CONFIG_FAILED
;
7076 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7077 if (ret
!= CMD_SUCCESS
)
7082 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7083 ecommunity_free(&bgp
->vpn_policy
[afi
]
7084 .import_redirect_rtlist
);
7085 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7086 ecommunity_dup(ecom
);
7088 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7089 ecommunity_free(&bgp
->vpn_policy
[afi
]
7090 .import_redirect_rtlist
);
7091 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7095 ecommunity_free(&ecom
);
7100 DEFUN_NOSH (address_family_ipv4_safi
,
7101 address_family_ipv4_safi_cmd
,
7102 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7103 "Enter Address Family command mode\n"
7105 BGP_SAFI_WITH_LABEL_HELP_STR
)
7109 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7110 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7111 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7112 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7113 && safi
!= SAFI_EVPN
) {
7115 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7116 return CMD_WARNING_CONFIG_FAILED
;
7118 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7120 vty
->node
= BGP_IPV4_NODE
;
7125 DEFUN_NOSH (address_family_ipv6_safi
,
7126 address_family_ipv6_safi_cmd
,
7127 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7128 "Enter Address Family command mode\n"
7130 BGP_SAFI_WITH_LABEL_HELP_STR
)
7133 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7134 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7135 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7136 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7137 && safi
!= SAFI_EVPN
) {
7139 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7140 return CMD_WARNING_CONFIG_FAILED
;
7142 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7144 vty
->node
= BGP_IPV6_NODE
;
7149 #ifdef KEEP_OLD_VPN_COMMANDS
7150 DEFUN_NOSH (address_family_vpnv4
,
7151 address_family_vpnv4_cmd
,
7152 "address-family vpnv4 [unicast]",
7153 "Enter Address Family command mode\n"
7155 "Address Family modifier\n")
7157 vty
->node
= BGP_VPNV4_NODE
;
7161 DEFUN_NOSH (address_family_vpnv6
,
7162 address_family_vpnv6_cmd
,
7163 "address-family vpnv6 [unicast]",
7164 "Enter Address Family command mode\n"
7166 "Address Family modifier\n")
7168 vty
->node
= BGP_VPNV6_NODE
;
7171 #endif /* KEEP_OLD_VPN_COMMANDS */
7173 DEFUN_NOSH (address_family_evpn
,
7174 address_family_evpn_cmd
,
7175 "address-family l2vpn evpn",
7176 "Enter Address Family command mode\n"
7178 "Address Family modifier\n")
7180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7181 vty
->node
= BGP_EVPN_NODE
;
7185 DEFUN_NOSH (exit_address_family
,
7186 exit_address_family_cmd
,
7187 "exit-address-family",
7188 "Exit from Address Family configuration mode\n")
7190 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7191 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7192 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7193 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7194 || vty
->node
== BGP_EVPN_NODE
7195 || vty
->node
== BGP_FLOWSPECV4_NODE
7196 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7197 vty
->node
= BGP_NODE
;
7201 /* Recalculate bestpath and re-advertise a prefix */
7202 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7203 const char *ip_str
, afi_t afi
, safi_t safi
,
7204 struct prefix_rd
*prd
)
7207 struct prefix match
;
7208 struct bgp_node
*rn
;
7209 struct bgp_node
*rm
;
7211 struct bgp_table
*table
;
7212 struct bgp_table
*rib
;
7214 /* BGP structure lookup. */
7216 bgp
= bgp_lookup_by_name(view_name
);
7218 vty_out(vty
, "%% Can't find BGP instance %s\n",
7223 bgp
= bgp_get_default();
7225 vty_out(vty
, "%% No BGP process is configured\n");
7230 /* Check IP address argument. */
7231 ret
= str2prefix(ip_str
, &match
);
7233 vty_out(vty
, "%% address is malformed\n");
7237 match
.family
= afi2family(afi
);
7238 rib
= bgp
->rib
[afi
][safi
];
7240 if (safi
== SAFI_MPLS_VPN
) {
7241 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7242 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7245 table
= bgp_node_get_bgp_table_info(rn
);
7246 if (table
!= NULL
) {
7248 if ((rm
= bgp_node_match(table
, &match
))
7251 == match
.prefixlen
) {
7253 BGP_NODE_USER_CLEAR
);
7254 bgp_process(bgp
, rm
, afi
, safi
);
7256 bgp_unlock_node(rm
);
7261 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7262 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7263 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7264 bgp_process(bgp
, rn
, afi
, safi
);
7266 bgp_unlock_node(rn
);
7273 /* one clear bgp command to rule them all */
7274 DEFUN (clear_ip_bgp_all
,
7275 clear_ip_bgp_all_cmd
,
7276 "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>]",
7280 BGP_INSTANCE_HELP_STR
7283 BGP_SAFI_WITH_LABEL_HELP_STR
7284 "Address Family modifier\n"
7286 "BGP neighbor address to clear\n"
7287 "BGP IPv6 neighbor to clear\n"
7288 "BGP neighbor on interface to clear\n"
7289 "Clear peers with the AS number\n"
7290 "Clear all external peers\n"
7291 "Clear all members of peer-group\n"
7292 "BGP peer-group name\n"
7297 "Push out prefix-list ORF and do inbound soft reconfig\n"
7302 afi_t afi
= AFI_IP6
;
7303 safi_t safi
= SAFI_UNICAST
;
7304 enum clear_sort clr_sort
= clear_peer
;
7305 enum bgp_clear_type clr_type
;
7306 char *clr_arg
= NULL
;
7310 /* clear [ip] bgp */
7311 if (argv_find(argv
, argc
, "ip", &idx
))
7314 /* [<vrf> VIEWVRFNAME] */
7315 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7316 vrf
= argv
[idx
+ 1]->arg
;
7318 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7320 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7321 /* [<view> VIEWVRFNAME] */
7322 vrf
= argv
[idx
+ 1]->arg
;
7325 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7326 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7327 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7329 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7330 if (argv_find(argv
, argc
, "*", &idx
)) {
7331 clr_sort
= clear_all
;
7332 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7333 clr_sort
= clear_peer
;
7334 clr_arg
= argv
[idx
]->arg
;
7335 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7336 clr_sort
= clear_peer
;
7337 clr_arg
= argv
[idx
]->arg
;
7338 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7339 clr_sort
= clear_group
;
7341 clr_arg
= argv
[idx
]->arg
;
7342 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7343 clr_sort
= clear_peer
;
7344 clr_arg
= argv
[idx
]->arg
;
7345 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7346 clr_sort
= clear_as
;
7347 clr_arg
= argv
[idx
]->arg
;
7348 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7349 clr_sort
= clear_external
;
7352 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7353 if (argv_find(argv
, argc
, "soft", &idx
)) {
7354 if (argv_find(argv
, argc
, "in", &idx
)
7355 || argv_find(argv
, argc
, "out", &idx
))
7356 clr_type
= strmatch(argv
[idx
]->text
, "in")
7358 : BGP_CLEAR_SOFT_OUT
;
7360 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7361 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7362 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7363 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7364 : BGP_CLEAR_SOFT_IN
;
7365 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7366 clr_type
= BGP_CLEAR_SOFT_OUT
;
7368 clr_type
= BGP_CLEAR_SOFT_NONE
;
7370 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7373 DEFUN (clear_ip_bgp_prefix
,
7374 clear_ip_bgp_prefix_cmd
,
7375 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7379 BGP_INSTANCE_HELP_STR
7380 "Clear bestpath and re-advertise\n"
7384 char *prefix
= NULL
;
7388 /* [<view|vrf> VIEWVRFNAME] */
7389 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7390 vrf
= argv
[idx
+ 1]->arg
;
7392 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7394 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7395 /* [<view> VIEWVRFNAME] */
7396 vrf
= argv
[idx
+ 1]->arg
;
7400 prefix
= argv
[argc
- 1]->arg
;
7402 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7405 DEFUN (clear_bgp_ipv6_safi_prefix
,
7406 clear_bgp_ipv6_safi_prefix_cmd
,
7407 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7413 "Clear bestpath and re-advertise\n"
7417 int idx_ipv6_prefix
= 0;
7418 safi_t safi
= SAFI_UNICAST
;
7419 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7420 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7422 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7423 return bgp_clear_prefix(
7424 vty
, NULL
, prefix
, AFI_IP6
,
7428 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7429 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7430 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7434 BGP_INSTANCE_HELP_STR
7437 "Clear bestpath and re-advertise\n"
7441 int idx_vrfview
= 0;
7442 int idx_ipv6_prefix
= 0;
7443 safi_t safi
= SAFI_UNICAST
;
7444 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7445 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7446 char *vrfview
= NULL
;
7448 /* [<view|vrf> VIEWVRFNAME] */
7449 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7450 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7451 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7453 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7454 /* [<view> VIEWVRFNAME] */
7455 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7457 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7459 return bgp_clear_prefix(
7460 vty
, vrfview
, prefix
,
7461 AFI_IP6
, safi
, NULL
);
7464 DEFUN (show_bgp_views
,
7466 "show [ip] bgp views",
7470 "Show the defined BGP views\n")
7472 struct list
*inst
= bm
->bgp
;
7473 struct listnode
*node
;
7476 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7477 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7481 vty_out(vty
, "Defined BGP views:\n");
7482 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7484 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7486 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7493 DEFUN (show_bgp_vrfs
,
7495 "show [ip] bgp vrfs [json]",
7502 char buf
[ETHER_ADDR_STRLEN
];
7503 struct list
*inst
= bm
->bgp
;
7504 struct listnode
*node
;
7506 bool uj
= use_json(argc
, argv
);
7507 json_object
*json
= NULL
;
7508 json_object
*json_vrfs
= NULL
;
7511 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7512 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7517 json
= json_object_new_object();
7518 json_vrfs
= json_object_new_object();
7521 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7522 const char *name
, *type
;
7524 struct listnode
*node2
, *nnode2
;
7525 int peers_cfg
, peers_estb
;
7526 json_object
*json_vrf
= NULL
;
7529 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7533 if (!uj
&& count
== 1)
7535 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7536 "Type", "Id", "routerId", "#PeersVfg",
7537 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7539 peers_cfg
= peers_estb
= 0;
7541 json_vrf
= json_object_new_object();
7544 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7545 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7548 if (peer
->status
== Established
)
7552 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7553 name
= VRF_DEFAULT_NAME
;
7562 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7564 : (int64_t)bgp
->vrf_id
;
7565 json_object_string_add(json_vrf
, "type", type
);
7566 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7567 json_object_string_add(json_vrf
, "routerId",
7568 inet_ntoa(bgp
->router_id
));
7569 json_object_int_add(json_vrf
, "numConfiguredPeers",
7571 json_object_int_add(json_vrf
, "numEstablishedPeers",
7574 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7575 json_object_string_add(
7577 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7578 json_object_object_add(json_vrfs
, name
, json_vrf
);
7581 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7583 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7585 inet_ntoa(bgp
->router_id
), peers_cfg
,
7586 peers_estb
, name
, bgp
->l3vni
,
7587 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7591 json_object_object_add(json
, "vrfs", json_vrfs
);
7593 json_object_int_add(json
, "totalVrfs", count
);
7595 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7596 json
, JSON_C_TO_STRING_PRETTY
));
7597 json_object_free(json
);
7601 "\nTotal number of VRFs (including default): %d\n",
7608 DEFUN (show_bgp_mac_hash
,
7609 show_bgp_mac_hash_cmd
,
7610 "show bgp mac hash",
7614 "Mac Address database\n")
7616 bgp_mac_dump_table(vty
);
7621 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7623 struct vty
*vty
= (struct vty
*)args
;
7624 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7626 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7630 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7632 vty_out(vty
, "self nexthop database:\n");
7633 bgp_nexthop_show_address_hash(vty
, bgp
);
7635 vty_out(vty
, "Tunnel-ip database:\n");
7636 hash_iterate(bgp
->tip_hash
,
7637 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7641 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7642 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7643 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7644 "martian next-hops\n"
7645 "martian next-hop database\n")
7647 struct bgp
*bgp
= NULL
;
7651 /* [<vrf> VIEWVRFNAME] */
7652 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7653 name
= argv
[idx
+ 1]->arg
;
7654 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7656 } else if (argv_find(argv
, argc
, "view", &idx
))
7657 /* [<view> VIEWVRFNAME] */
7658 name
= argv
[idx
+ 1]->arg
;
7660 bgp
= bgp_lookup_by_name(name
);
7662 bgp
= bgp_get_default();
7665 vty_out(vty
, "%% No BGP process is configured\n");
7668 bgp_show_martian_nexthops(vty
, bgp
);
7673 DEFUN (show_bgp_memory
,
7674 show_bgp_memory_cmd
,
7675 "show [ip] bgp memory",
7679 "Global BGP memory statistics\n")
7681 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7682 unsigned long count
;
7684 /* RIB related usage stats */
7685 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7686 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7687 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7688 count
* sizeof(struct bgp_node
)));
7690 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7691 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7692 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7693 count
* sizeof(struct bgp_path_info
)));
7694 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7695 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7698 memstrbuf
, sizeof(memstrbuf
),
7699 count
* sizeof(struct bgp_path_info_extra
)));
7701 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7702 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7703 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7704 count
* sizeof(struct bgp_static
)));
7706 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7707 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7708 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7709 count
* sizeof(struct bpacket
)));
7712 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7713 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7714 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7715 count
* sizeof(struct bgp_adj_in
)));
7716 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7717 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7718 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7719 count
* sizeof(struct bgp_adj_out
)));
7721 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7722 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7724 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7725 count
* sizeof(struct bgp_nexthop_cache
)));
7727 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7728 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7730 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7731 count
* sizeof(struct bgp_damp_info
)));
7734 count
= attr_count();
7735 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7736 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7737 count
* sizeof(struct attr
)));
7739 if ((count
= attr_unknown_count()))
7740 vty_out(vty
, "%ld unknown attributes\n", count
);
7742 /* AS_PATH attributes */
7743 count
= aspath_count();
7744 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7745 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7746 count
* sizeof(struct aspath
)));
7748 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7749 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7750 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7751 count
* sizeof(struct assegment
)));
7753 /* Other attributes */
7754 if ((count
= community_count()))
7755 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7756 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7757 count
* sizeof(struct community
)));
7758 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7759 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7760 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7761 count
* sizeof(struct ecommunity
)));
7762 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7764 "%ld BGP large-community entries, using %s of memory\n",
7765 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7766 count
* sizeof(struct lcommunity
)));
7768 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7769 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7770 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7771 count
* sizeof(struct cluster_list
)));
7773 /* Peer related usage */
7774 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7775 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7776 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7777 count
* sizeof(struct peer
)));
7779 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7780 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7781 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7782 count
* sizeof(struct peer_group
)));
7785 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7786 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7787 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7788 count
* sizeof(struct hash
)));
7789 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7790 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7791 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7792 count
* sizeof(struct hash_bucket
)));
7793 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7794 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7795 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7796 count
* sizeof(regex_t
)));
7800 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7802 json_object
*bestpath
= json_object_new_object();
7804 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7805 json_object_string_add(bestpath
, "asPath", "ignore");
7807 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7808 json_object_string_add(bestpath
, "asPath", "confed");
7810 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7811 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7812 json_object_string_add(bestpath
, "multiPathRelax",
7815 json_object_string_add(bestpath
, "multiPathRelax",
7818 json_object_string_add(bestpath
, "multiPathRelax", "false");
7820 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7821 json_object_string_add(bestpath
, "compareRouterId", "true");
7822 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7823 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7824 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7825 json_object_string_add(bestpath
, "med", "confed");
7826 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7827 json_object_string_add(bestpath
, "med",
7828 "missing-as-worst");
7830 json_object_string_add(bestpath
, "med", "true");
7833 json_object_object_add(json
, "bestPath", bestpath
);
7836 /* Show BGP peer's summary information. */
7837 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7838 bool use_json
, json_object
*json
)
7841 struct listnode
*node
, *nnode
;
7842 unsigned int count
= 0, dn_count
= 0;
7843 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7844 char neighbor_buf
[VTY_BUFSIZ
];
7845 int neighbor_col_default_width
= 16;
7847 int max_neighbor_width
= 0;
7849 json_object
*json_peer
= NULL
;
7850 json_object
*json_peers
= NULL
;
7851 struct peer_af
*paf
;
7853 /* labeled-unicast routes are installed in the unicast table so in order
7855 * display the correct PfxRcd value we must look at SAFI_UNICAST
7857 if (safi
== SAFI_LABELED_UNICAST
)
7858 pfx_rcd_safi
= SAFI_UNICAST
;
7860 pfx_rcd_safi
= safi
;
7864 json
= json_object_new_object();
7866 json_peers
= json_object_new_object();
7868 /* Loop over all neighbors that will be displayed to determine
7870 * characters are needed for the Neighbor column
7872 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7873 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7876 if (peer
->afc
[afi
][safi
]) {
7877 memset(dn_flag
, '\0', sizeof(dn_flag
));
7878 if (peer_dynamic_neighbor(peer
))
7882 && bgp_flag_check(bgp
,
7883 BGP_FLAG_SHOW_HOSTNAME
))
7884 sprintf(neighbor_buf
, "%s%s(%s) ",
7885 dn_flag
, peer
->hostname
,
7888 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7891 len
= strlen(neighbor_buf
);
7893 if (len
> max_neighbor_width
)
7894 max_neighbor_width
= len
;
7898 /* Originally we displayed the Neighbor column as 16
7899 * characters wide so make that the default
7901 if (max_neighbor_width
< neighbor_col_default_width
)
7902 max_neighbor_width
= neighbor_col_default_width
;
7905 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7906 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7909 if (!peer
->afc
[afi
][safi
])
7914 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7917 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7919 : (int64_t)bgp
->vrf_id
;
7921 /* Usage summary and header */
7923 json_object_string_add(
7925 inet_ntoa(bgp
->router_id
));
7926 json_object_int_add(json
, "as", bgp
->as
);
7927 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7928 json_object_string_add(
7931 == BGP_INSTANCE_TYPE_DEFAULT
)
7936 "BGP router identifier %s, local AS number %u vrf-id %d",
7937 inet_ntoa(bgp
->router_id
), bgp
->as
,
7938 bgp
->vrf_id
== VRF_UNKNOWN
7940 : (int)bgp
->vrf_id
);
7944 if (bgp_update_delay_configured(bgp
)) {
7946 json_object_int_add(
7947 json
, "updateDelayLimit",
7948 bgp
->v_update_delay
);
7950 if (bgp
->v_update_delay
7951 != bgp
->v_establish_wait
)
7952 json_object_int_add(
7954 "updateDelayEstablishWait",
7955 bgp
->v_establish_wait
);
7957 if (bgp_update_delay_active(bgp
)) {
7958 json_object_string_add(
7960 "updateDelayFirstNeighbor",
7961 bgp
->update_delay_begin_time
);
7962 json_object_boolean_true_add(
7964 "updateDelayInProgress");
7966 if (bgp
->update_delay_over
) {
7967 json_object_string_add(
7969 "updateDelayFirstNeighbor",
7970 bgp
->update_delay_begin_time
);
7971 json_object_string_add(
7973 "updateDelayBestpathResumed",
7974 bgp
->update_delay_end_time
);
7975 json_object_string_add(
7977 "updateDelayZebraUpdateResume",
7978 bgp
->update_delay_zebra_resume_time
);
7979 json_object_string_add(
7981 "updateDelayPeerUpdateResume",
7982 bgp
->update_delay_peers_resume_time
);
7987 "Read-only mode update-delay limit: %d seconds\n",
7988 bgp
->v_update_delay
);
7989 if (bgp
->v_update_delay
7990 != bgp
->v_establish_wait
)
7992 " Establish wait: %d seconds\n",
7993 bgp
->v_establish_wait
);
7995 if (bgp_update_delay_active(bgp
)) {
7997 " First neighbor established: %s\n",
7998 bgp
->update_delay_begin_time
);
8000 " Delay in progress\n");
8002 if (bgp
->update_delay_over
) {
8004 " First neighbor established: %s\n",
8005 bgp
->update_delay_begin_time
);
8007 " Best-paths resumed: %s\n",
8008 bgp
->update_delay_end_time
);
8010 " zebra update resumed: %s\n",
8011 bgp
->update_delay_zebra_resume_time
);
8013 " peers update resumed: %s\n",
8014 bgp
->update_delay_peers_resume_time
);
8021 if (bgp_maxmed_onstartup_configured(bgp
)
8022 && bgp
->maxmed_active
)
8023 json_object_boolean_true_add(
8024 json
, "maxMedOnStartup");
8025 if (bgp
->v_maxmed_admin
)
8026 json_object_boolean_true_add(
8027 json
, "maxMedAdministrative");
8029 json_object_int_add(
8030 json
, "tableVersion",
8031 bgp_table_version(bgp
->rib
[afi
][safi
]));
8033 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8034 json_object_int_add(json
, "ribCount", ents
);
8035 json_object_int_add(
8037 ents
* sizeof(struct bgp_node
));
8039 ents
= bgp
->af_peer_count
[afi
][safi
];
8040 json_object_int_add(json
, "peerCount", ents
);
8041 json_object_int_add(json
, "peerMemory",
8042 ents
* sizeof(struct peer
));
8044 if ((ents
= listcount(bgp
->group
))) {
8045 json_object_int_add(
8046 json
, "peerGroupCount", ents
);
8047 json_object_int_add(
8048 json
, "peerGroupMemory",
8049 ents
* sizeof(struct
8053 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8054 BGP_CONFIG_DAMPENING
))
8055 json_object_boolean_true_add(
8056 json
, "dampeningEnabled");
8058 if (bgp_maxmed_onstartup_configured(bgp
)
8059 && bgp
->maxmed_active
)
8061 "Max-med on-startup active\n");
8062 if (bgp
->v_maxmed_admin
)
8064 "Max-med administrative active\n");
8066 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8067 bgp_table_version(bgp
->rib
[afi
][safi
]));
8069 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8071 "RIB entries %ld, using %s of memory\n",
8073 mtype_memstr(memstrbuf
,
8075 ents
* sizeof(struct
8078 /* Peer related usage */
8079 ents
= bgp
->af_peer_count
[afi
][safi
];
8080 vty_out(vty
, "Peers %ld, using %s of memory\n",
8083 memstrbuf
, sizeof(memstrbuf
),
8084 ents
* sizeof(struct peer
)));
8086 if ((ents
= listcount(bgp
->group
)))
8088 "Peer groups %ld, using %s of memory\n",
8093 ents
* sizeof(struct
8096 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8097 BGP_CONFIG_DAMPENING
))
8098 vty_out(vty
, "Dampening enabled.\n");
8101 /* Subtract 8 here because 'Neighbor' is
8103 vty_out(vty
, "Neighbor");
8104 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8107 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8114 json_peer
= json_object_new_object();
8116 if (peer_dynamic_neighbor(peer
)) {
8118 json_object_boolean_true_add(json_peer
,
8123 json_object_string_add(json_peer
, "hostname",
8126 if (peer
->domainname
)
8127 json_object_string_add(json_peer
, "domainname",
8130 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8131 json_object_int_add(json_peer
, "version", 4);
8132 json_object_int_add(json_peer
, "msgRcvd",
8133 PEER_TOTAL_RX(peer
));
8134 json_object_int_add(json_peer
, "msgSent",
8135 PEER_TOTAL_TX(peer
));
8137 json_object_int_add(json_peer
, "tableVersion",
8138 peer
->version
[afi
][safi
]);
8139 json_object_int_add(json_peer
, "outq",
8141 json_object_int_add(json_peer
, "inq", 0);
8142 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8143 use_json
, json_peer
);
8146 * Adding "pfxRcd" field to match with the corresponding
8147 * CLI. "prefixReceivedCount" will be deprecated in
8150 json_object_int_add(json_peer
, "prefixReceivedCount",
8151 peer
->pcount
[afi
][pfx_rcd_safi
]);
8152 json_object_int_add(json_peer
, "pfxRcd",
8153 peer
->pcount
[afi
][pfx_rcd_safi
]);
8155 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8156 if (paf
&& PAF_SUBGRP(paf
))
8157 json_object_int_add(json_peer
,
8159 (PAF_SUBGRP(paf
))->scount
);
8161 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8162 json_object_string_add(json_peer
, "state",
8164 else if (peer
->afc_recv
[afi
][safi
])
8165 json_object_string_add(
8167 lookup_msg(bgp_status_msg
, peer
->status
,
8169 else if (CHECK_FLAG(peer
->sflags
,
8170 PEER_STATUS_PREFIX_OVERFLOW
))
8171 json_object_string_add(json_peer
, "state",
8174 json_object_string_add(
8176 lookup_msg(bgp_status_msg
, peer
->status
,
8180 json_object_string_add(json_peer
, "idType",
8182 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8183 json_object_string_add(json_peer
, "idType",
8185 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8186 json_object_string_add(json_peer
, "idType",
8189 json_object_object_add(json_peers
, peer
->host
,
8192 memset(dn_flag
, '\0', sizeof(dn_flag
));
8193 if (peer_dynamic_neighbor(peer
)) {
8199 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8200 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8201 peer
->hostname
, peer
->host
);
8203 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8205 /* pad the neighbor column with spaces */
8206 if (len
< max_neighbor_width
)
8207 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8210 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8211 peer
->as
, PEER_TOTAL_RX(peer
),
8212 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8213 0, peer
->obuf
->count
,
8214 peer_uptime(peer
->uptime
, timebuf
,
8215 BGP_UPTIME_LEN
, 0, NULL
));
8217 if (peer
->status
== Established
)
8218 if (peer
->afc_recv
[afi
][safi
])
8219 vty_out(vty
, " %12ld",
8223 vty_out(vty
, " NoNeg");
8225 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8226 vty_out(vty
, " Idle (Admin)");
8227 else if (CHECK_FLAG(
8229 PEER_STATUS_PREFIX_OVERFLOW
))
8230 vty_out(vty
, " Idle (PfxCt)");
8232 vty_out(vty
, " %12s",
8233 lookup_msg(bgp_status_msg
,
8234 peer
->status
, NULL
));
8241 json_object_object_add(json
, "peers", json_peers
);
8243 json_object_int_add(json
, "totalPeers", count
);
8244 json_object_int_add(json
, "dynamicPeers", dn_count
);
8246 bgp_show_bestpath_json(bgp
, json
);
8248 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8249 json
, JSON_C_TO_STRING_PRETTY
));
8250 json_object_free(json
);
8253 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8255 vty_out(vty
, "No %s neighbor is configured\n",
8256 afi_safi_print(afi
, safi
));
8260 vty_out(vty
, "* - dynamic neighbor\n");
8261 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8262 dn_count
, bgp
->dynamic_neighbors_limit
);
8269 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8270 int safi
, bool use_json
,
8274 int afi_wildcard
= (afi
== AFI_MAX
);
8275 int safi_wildcard
= (safi
== SAFI_MAX
);
8276 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8277 bool nbr_output
= false;
8279 if (use_json
&& is_wildcard
)
8280 vty_out(vty
, "{\n");
8282 afi
= 1; /* AFI_IP */
8283 while (afi
< AFI_MAX
) {
8285 safi
= 1; /* SAFI_UNICAST */
8286 while (safi
< SAFI_MAX
) {
8287 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8291 * So limit output to those afi/safi
8293 * actualy have something interesting in
8297 json
= json_object_new_object();
8300 vty_out(vty
, ",\n");
8304 vty_out(vty
, "\"%s\":",
8308 vty_out(vty
, "\n%s Summary:\n",
8313 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8325 if (use_json
&& is_wildcard
)
8326 vty_out(vty
, "}\n");
8327 else if (!nbr_output
) {
8329 vty_out(vty
, "{}\n");
8331 vty_out(vty
, "%% No BGP neighbors found\n");
8335 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8336 safi_t safi
, bool use_json
)
8338 struct listnode
*node
, *nnode
;
8340 json_object
*json
= NULL
;
8342 bool nbr_output
= false;
8345 vty_out(vty
, "{\n");
8347 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8350 json
= json_object_new_object();
8353 vty_out(vty
, ",\n");
8357 vty_out(vty
, "\"%s\":",
8358 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8362 vty_out(vty
, "\nInstance %s:\n",
8363 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8367 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8371 vty_out(vty
, "}\n");
8372 else if (!nbr_output
)
8373 vty_out(vty
, "%% BGP instance not found\n");
8376 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8377 safi_t safi
, bool use_json
)
8382 if (strmatch(name
, "all")) {
8383 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8387 bgp
= bgp_lookup_by_name(name
);
8391 vty_out(vty
, "{}\n");
8394 "%% BGP instance not found\n");
8398 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8404 bgp
= bgp_get_default();
8407 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8410 vty_out(vty
, "{}\n");
8412 vty_out(vty
, "%% BGP instance not found\n");
8419 /* `show [ip] bgp summary' commands. */
8420 DEFUN (show_ip_bgp_summary
,
8421 show_ip_bgp_summary_cmd
,
8422 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8426 BGP_INSTANCE_HELP_STR
8428 BGP_SAFI_WITH_LABEL_HELP_STR
8429 "Summary of BGP neighbor status\n"
8433 afi_t afi
= AFI_MAX
;
8434 safi_t safi
= SAFI_MAX
;
8439 if (argv_find(argv
, argc
, "ip", &idx
))
8441 /* [<vrf> VIEWVRFNAME] */
8442 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8443 vrf
= argv
[idx
+ 1]->arg
;
8444 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8446 } else if (argv_find(argv
, argc
, "view", &idx
))
8447 /* [<view> VIEWVRFNAME] */
8448 vrf
= argv
[idx
+ 1]->arg
;
8449 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8450 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8451 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8454 bool uj
= use_json(argc
, argv
);
8456 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8459 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8461 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8462 return "IPv4 Unicast";
8463 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8464 return "IPv4 Multicast";
8465 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8466 return "IPv4 Labeled Unicast";
8467 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8469 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8470 return "IPv4 Encap";
8471 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8472 return "IPv4 Flowspec";
8473 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8474 return "IPv6 Unicast";
8475 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8476 return "IPv6 Multicast";
8477 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8478 return "IPv6 Labeled Unicast";
8479 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8481 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8482 return "IPv6 Encap";
8483 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8484 return "IPv6 Flowspec";
8485 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8486 return "L2VPN EVPN";
8492 * Please note that we have intentionally camelCased
8493 * the return strings here. So if you want
8494 * to use this function, please ensure you
8495 * are doing this within json output
8497 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8499 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8500 return "ipv4Unicast";
8501 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8502 return "ipv4Multicast";
8503 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8504 return "ipv4LabeledUnicast";
8505 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8507 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8509 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8510 return "ipv4Flowspec";
8511 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8512 return "ipv6Unicast";
8513 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8514 return "ipv6Multicast";
8515 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8516 return "ipv6LabeledUnicast";
8517 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8519 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8521 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8522 return "ipv6Flowspec";
8523 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8529 /* Show BGP peer's information. */
8530 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8532 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8533 afi_t afi
, safi_t safi
,
8534 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8535 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8536 bool use_json
, json_object
*json_pref
)
8539 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8540 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8542 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8543 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8544 json_object_string_add(json_pref
, "sendMode",
8545 "advertisedAndReceived");
8546 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8547 json_object_string_add(json_pref
, "sendMode",
8549 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8550 json_object_string_add(json_pref
, "sendMode",
8553 vty_out(vty
, " Send-mode: ");
8554 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8555 vty_out(vty
, "advertised");
8556 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8557 vty_out(vty
, "%sreceived",
8558 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8567 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8568 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8570 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8571 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8572 json_object_string_add(json_pref
, "recvMode",
8573 "advertisedAndReceived");
8574 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8575 json_object_string_add(json_pref
, "recvMode",
8577 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8578 json_object_string_add(json_pref
, "recvMode",
8581 vty_out(vty
, " Receive-mode: ");
8582 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8583 vty_out(vty
, "advertised");
8584 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8585 vty_out(vty
, "%sreceived",
8586 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8595 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8596 safi_t safi
, bool use_json
,
8597 json_object
*json_neigh
)
8599 struct bgp_filter
*filter
;
8600 struct peer_af
*paf
;
8601 char orf_pfx_name
[BUFSIZ
];
8603 json_object
*json_af
= NULL
;
8604 json_object
*json_prefA
= NULL
;
8605 json_object
*json_prefB
= NULL
;
8606 json_object
*json_addr
= NULL
;
8609 json_addr
= json_object_new_object();
8610 json_af
= json_object_new_object();
8611 filter
= &p
->filter
[afi
][safi
];
8613 if (peer_group_active(p
))
8614 json_object_string_add(json_addr
, "peerGroupMember",
8617 paf
= peer_af_find(p
, afi
, safi
);
8618 if (paf
&& PAF_SUBGRP(paf
)) {
8619 json_object_int_add(json_addr
, "updateGroupId",
8620 PAF_UPDGRP(paf
)->id
);
8621 json_object_int_add(json_addr
, "subGroupId",
8622 PAF_SUBGRP(paf
)->id
);
8623 json_object_int_add(json_addr
, "packetQueueLength",
8624 bpacket_queue_virtual_length(paf
));
8627 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8628 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8629 PEER_CAP_ORF_PREFIX_SM_RCV
)
8630 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8631 PEER_CAP_ORF_PREFIX_RM_ADV
)
8632 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8633 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8634 json_object_int_add(json_af
, "orfType",
8636 json_prefA
= json_object_new_object();
8637 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8638 PEER_CAP_ORF_PREFIX_SM_ADV
,
8639 PEER_CAP_ORF_PREFIX_RM_ADV
,
8640 PEER_CAP_ORF_PREFIX_SM_RCV
,
8641 PEER_CAP_ORF_PREFIX_RM_RCV
,
8642 use_json
, json_prefA
);
8643 json_object_object_add(json_af
, "orfPrefixList",
8647 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8648 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8649 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8650 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8651 PEER_CAP_ORF_PREFIX_RM_ADV
)
8652 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8653 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8654 json_object_int_add(json_af
, "orfOldType",
8655 ORF_TYPE_PREFIX_OLD
);
8656 json_prefB
= json_object_new_object();
8657 bgp_show_peer_afi_orf_cap(
8658 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8659 PEER_CAP_ORF_PREFIX_RM_ADV
,
8660 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8661 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8663 json_object_object_add(json_af
, "orfOldPrefixList",
8667 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8668 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8669 PEER_CAP_ORF_PREFIX_SM_RCV
)
8670 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8671 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8672 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8673 PEER_CAP_ORF_PREFIX_RM_ADV
)
8674 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8675 PEER_CAP_ORF_PREFIX_RM_RCV
)
8676 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8677 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8678 json_object_object_add(json_addr
, "afDependentCap",
8681 json_object_free(json_af
);
8683 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8684 orf_pfx_count
= prefix_bgp_show_prefix_list(
8685 NULL
, afi
, orf_pfx_name
, use_json
);
8687 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8688 PEER_STATUS_ORF_PREFIX_SEND
)
8690 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8691 PEER_STATUS_ORF_PREFIX_SEND
))
8692 json_object_boolean_true_add(json_neigh
,
8695 json_object_int_add(json_addr
, "orfRecvCounter",
8698 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8699 PEER_STATUS_ORF_WAIT_REFRESH
))
8700 json_object_string_add(
8701 json_addr
, "orfFirstUpdate",
8702 "deferredUntilORFOrRouteRefreshRecvd");
8704 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8705 PEER_FLAG_REFLECTOR_CLIENT
))
8706 json_object_boolean_true_add(json_addr
,
8707 "routeReflectorClient");
8708 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8709 PEER_FLAG_RSERVER_CLIENT
))
8710 json_object_boolean_true_add(json_addr
,
8711 "routeServerClient");
8712 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8713 json_object_boolean_true_add(json_addr
,
8714 "inboundSoftConfigPermit");
8716 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8717 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8718 json_object_boolean_true_add(
8720 "privateAsNumsAllReplacedInUpdatesToNbr");
8721 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8722 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8723 json_object_boolean_true_add(
8725 "privateAsNumsReplacedInUpdatesToNbr");
8726 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8727 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8728 json_object_boolean_true_add(
8730 "privateAsNumsAllRemovedInUpdatesToNbr");
8731 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8732 PEER_FLAG_REMOVE_PRIVATE_AS
))
8733 json_object_boolean_true_add(
8735 "privateAsNumsRemovedInUpdatesToNbr");
8737 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8738 json_object_boolean_true_add(
8740 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8743 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8744 json_object_string_add(json_addr
,
8745 "overrideASNsInOutboundUpdates",
8746 "ifAspathEqualRemoteAs");
8748 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8749 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8750 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8751 json_object_boolean_true_add(json_addr
,
8752 "routerAlwaysNextHop");
8753 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8754 PEER_FLAG_AS_PATH_UNCHANGED
))
8755 json_object_boolean_true_add(
8756 json_addr
, "unchangedAsPathPropogatedToNbr");
8757 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8758 PEER_FLAG_NEXTHOP_UNCHANGED
))
8759 json_object_boolean_true_add(
8760 json_addr
, "unchangedNextHopPropogatedToNbr");
8761 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8762 json_object_boolean_true_add(
8763 json_addr
, "unchangedMedPropogatedToNbr");
8764 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8765 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8766 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8767 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8768 PEER_FLAG_SEND_COMMUNITY
)
8769 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8770 PEER_FLAG_SEND_EXT_COMMUNITY
))
8771 json_object_string_add(json_addr
,
8772 "commAttriSentToNbr",
8773 "extendedAndStandard");
8774 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8775 PEER_FLAG_SEND_EXT_COMMUNITY
))
8776 json_object_string_add(json_addr
,
8777 "commAttriSentToNbr",
8780 json_object_string_add(json_addr
,
8781 "commAttriSentToNbr",
8784 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8785 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8786 if (p
->default_rmap
[afi
][safi
].name
)
8787 json_object_string_add(
8788 json_addr
, "defaultRouteMap",
8789 p
->default_rmap
[afi
][safi
].name
);
8791 if (paf
&& PAF_SUBGRP(paf
)
8792 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8793 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8794 json_object_boolean_true_add(json_addr
,
8797 json_object_boolean_true_add(json_addr
,
8801 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8802 if (is_evpn_enabled())
8803 json_object_boolean_true_add(
8804 json_addr
, "advertiseAllVnis");
8807 if (filter
->plist
[FILTER_IN
].name
8808 || filter
->dlist
[FILTER_IN
].name
8809 || filter
->aslist
[FILTER_IN
].name
8810 || filter
->map
[RMAP_IN
].name
)
8811 json_object_boolean_true_add(json_addr
,
8812 "inboundPathPolicyConfig");
8813 if (filter
->plist
[FILTER_OUT
].name
8814 || filter
->dlist
[FILTER_OUT
].name
8815 || filter
->aslist
[FILTER_OUT
].name
8816 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8817 json_object_boolean_true_add(
8818 json_addr
, "outboundPathPolicyConfig");
8821 if (filter
->plist
[FILTER_IN
].name
)
8822 json_object_string_add(json_addr
,
8823 "incomingUpdatePrefixFilterList",
8824 filter
->plist
[FILTER_IN
].name
);
8825 if (filter
->plist
[FILTER_OUT
].name
)
8826 json_object_string_add(json_addr
,
8827 "outgoingUpdatePrefixFilterList",
8828 filter
->plist
[FILTER_OUT
].name
);
8830 /* distribute-list */
8831 if (filter
->dlist
[FILTER_IN
].name
)
8832 json_object_string_add(
8833 json_addr
, "incomingUpdateNetworkFilterList",
8834 filter
->dlist
[FILTER_IN
].name
);
8835 if (filter
->dlist
[FILTER_OUT
].name
)
8836 json_object_string_add(
8837 json_addr
, "outgoingUpdateNetworkFilterList",
8838 filter
->dlist
[FILTER_OUT
].name
);
8841 if (filter
->aslist
[FILTER_IN
].name
)
8842 json_object_string_add(json_addr
,
8843 "incomingUpdateAsPathFilterList",
8844 filter
->aslist
[FILTER_IN
].name
);
8845 if (filter
->aslist
[FILTER_OUT
].name
)
8846 json_object_string_add(json_addr
,
8847 "outgoingUpdateAsPathFilterList",
8848 filter
->aslist
[FILTER_OUT
].name
);
8851 if (filter
->map
[RMAP_IN
].name
)
8852 json_object_string_add(
8853 json_addr
, "routeMapForIncomingAdvertisements",
8854 filter
->map
[RMAP_IN
].name
);
8855 if (filter
->map
[RMAP_OUT
].name
)
8856 json_object_string_add(
8857 json_addr
, "routeMapForOutgoingAdvertisements",
8858 filter
->map
[RMAP_OUT
].name
);
8860 /* ebgp-requires-policy (inbound) */
8861 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8862 && !bgp_inbound_policy_exists(p
, filter
))
8863 json_object_string_add(
8864 json_addr
, "inboundEbgpRequiresPolicy",
8865 "Inbound updates discarded due to missing policy");
8867 /* ebgp-requires-policy (outbound) */
8868 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
8869 && (!bgp_outbound_policy_exists(p
, filter
)))
8870 json_object_string_add(
8871 json_addr
, "outboundEbgpRequiresPolicy",
8872 "Outbound updates discarded due to missing policy");
8874 /* unsuppress-map */
8875 if (filter
->usmap
.name
)
8876 json_object_string_add(json_addr
,
8877 "selectiveUnsuppressRouteMap",
8878 filter
->usmap
.name
);
8880 /* Receive prefix count */
8881 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8882 p
->pcount
[afi
][safi
]);
8883 if (paf
&& PAF_SUBGRP(paf
))
8884 json_object_int_add(json_addr
, "sentPrefixCounter",
8885 (PAF_SUBGRP(paf
))->scount
);
8887 /* Maximum prefix */
8888 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8889 json_object_int_add(json_addr
, "prefixAllowedMax",
8890 p
->pmax
[afi
][safi
]);
8891 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8892 PEER_FLAG_MAX_PREFIX_WARNING
))
8893 json_object_boolean_true_add(
8894 json_addr
, "prefixAllowedMaxWarning");
8895 json_object_int_add(json_addr
,
8896 "prefixAllowedWarningThresh",
8897 p
->pmax_threshold
[afi
][safi
]);
8898 if (p
->pmax_restart
[afi
][safi
])
8899 json_object_int_add(
8901 "prefixAllowedRestartIntervalMsecs",
8902 p
->pmax_restart
[afi
][safi
] * 60000);
8904 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8908 filter
= &p
->filter
[afi
][safi
];
8910 vty_out(vty
, " For address family: %s\n",
8911 afi_safi_print(afi
, safi
));
8913 if (peer_group_active(p
))
8914 vty_out(vty
, " %s peer-group member\n",
8917 paf
= peer_af_find(p
, afi
, safi
);
8918 if (paf
&& PAF_SUBGRP(paf
)) {
8919 vty_out(vty
, " Update group %" PRIu64
8920 ", subgroup %" PRIu64
"\n",
8921 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8922 vty_out(vty
, " Packet Queue length %d\n",
8923 bpacket_queue_virtual_length(paf
));
8925 vty_out(vty
, " Not part of any update group\n");
8927 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8928 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8929 PEER_CAP_ORF_PREFIX_SM_RCV
)
8930 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8931 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8932 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8933 PEER_CAP_ORF_PREFIX_RM_ADV
)
8934 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8935 PEER_CAP_ORF_PREFIX_RM_RCV
)
8936 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8937 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8938 vty_out(vty
, " AF-dependant capabilities:\n");
8940 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8941 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8942 PEER_CAP_ORF_PREFIX_SM_RCV
)
8943 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8944 PEER_CAP_ORF_PREFIX_RM_ADV
)
8945 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8946 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8948 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8950 bgp_show_peer_afi_orf_cap(
8951 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8952 PEER_CAP_ORF_PREFIX_RM_ADV
,
8953 PEER_CAP_ORF_PREFIX_SM_RCV
,
8954 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8956 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8957 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8958 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8959 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8960 PEER_CAP_ORF_PREFIX_RM_ADV
)
8961 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8962 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8964 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8965 ORF_TYPE_PREFIX_OLD
);
8966 bgp_show_peer_afi_orf_cap(
8967 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8968 PEER_CAP_ORF_PREFIX_RM_ADV
,
8969 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8970 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8973 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8974 orf_pfx_count
= prefix_bgp_show_prefix_list(
8975 NULL
, afi
, orf_pfx_name
, use_json
);
8977 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8978 PEER_STATUS_ORF_PREFIX_SEND
)
8980 vty_out(vty
, " Outbound Route Filter (ORF):");
8981 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8982 PEER_STATUS_ORF_PREFIX_SEND
))
8983 vty_out(vty
, " sent;");
8985 vty_out(vty
, " received (%d entries)",
8989 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8990 PEER_STATUS_ORF_WAIT_REFRESH
))
8992 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8994 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8995 PEER_FLAG_REFLECTOR_CLIENT
))
8996 vty_out(vty
, " Route-Reflector Client\n");
8997 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8998 PEER_FLAG_RSERVER_CLIENT
))
8999 vty_out(vty
, " Route-Server Client\n");
9000 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9002 " Inbound soft reconfiguration allowed\n");
9004 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9005 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9007 " Private AS numbers (all) replaced in updates to this neighbor\n");
9008 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9009 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9011 " Private AS numbers replaced in updates to this neighbor\n");
9012 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9013 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9015 " Private AS numbers (all) removed in updates to this neighbor\n");
9016 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9017 PEER_FLAG_REMOVE_PRIVATE_AS
))
9019 " Private AS numbers removed in updates to this neighbor\n");
9021 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9022 vty_out(vty
, " %s\n",
9023 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9024 ->human_description
);
9026 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9028 " Override ASNs in outbound updates if aspath equals remote-as\n");
9030 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9031 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9032 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9033 vty_out(vty
, " NEXT_HOP is always this router\n");
9034 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9035 PEER_FLAG_AS_PATH_UNCHANGED
))
9037 " AS_PATH is propagated unchanged to this neighbor\n");
9038 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9039 PEER_FLAG_NEXTHOP_UNCHANGED
))
9041 " NEXT_HOP is propagated unchanged to this neighbor\n");
9042 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9044 " MED is propagated unchanged to this neighbor\n");
9045 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9046 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9047 PEER_FLAG_SEND_EXT_COMMUNITY
)
9048 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9049 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9051 " Community attribute sent to this neighbor");
9052 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9053 PEER_FLAG_SEND_COMMUNITY
)
9054 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9055 PEER_FLAG_SEND_EXT_COMMUNITY
)
9056 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9057 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9058 vty_out(vty
, "(all)\n");
9059 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9060 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9061 vty_out(vty
, "(large)\n");
9062 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9063 PEER_FLAG_SEND_EXT_COMMUNITY
))
9064 vty_out(vty
, "(extended)\n");
9066 vty_out(vty
, "(standard)\n");
9068 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9069 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9070 vty_out(vty
, " Default information originate,");
9072 if (p
->default_rmap
[afi
][safi
].name
)
9073 vty_out(vty
, " default route-map %s%s,",
9074 p
->default_rmap
[afi
][safi
].map
? "*"
9076 p
->default_rmap
[afi
][safi
].name
);
9077 if (paf
&& PAF_SUBGRP(paf
)
9078 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9079 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9080 vty_out(vty
, " default sent\n");
9082 vty_out(vty
, " default not sent\n");
9085 /* advertise-vni-all */
9086 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9087 if (is_evpn_enabled())
9088 vty_out(vty
, " advertise-all-vni\n");
9091 if (filter
->plist
[FILTER_IN
].name
9092 || filter
->dlist
[FILTER_IN
].name
9093 || filter
->aslist
[FILTER_IN
].name
9094 || filter
->map
[RMAP_IN
].name
)
9095 vty_out(vty
, " Inbound path policy configured\n");
9096 if (filter
->plist
[FILTER_OUT
].name
9097 || filter
->dlist
[FILTER_OUT
].name
9098 || filter
->aslist
[FILTER_OUT
].name
9099 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9100 vty_out(vty
, " Outbound path policy configured\n");
9103 if (filter
->plist
[FILTER_IN
].name
)
9105 " Incoming update prefix filter list is %s%s\n",
9106 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9107 filter
->plist
[FILTER_IN
].name
);
9108 if (filter
->plist
[FILTER_OUT
].name
)
9110 " Outgoing update prefix filter list is %s%s\n",
9111 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9112 filter
->plist
[FILTER_OUT
].name
);
9114 /* distribute-list */
9115 if (filter
->dlist
[FILTER_IN
].name
)
9117 " Incoming update network filter list is %s%s\n",
9118 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9119 filter
->dlist
[FILTER_IN
].name
);
9120 if (filter
->dlist
[FILTER_OUT
].name
)
9122 " Outgoing update network filter list is %s%s\n",
9123 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9124 filter
->dlist
[FILTER_OUT
].name
);
9127 if (filter
->aslist
[FILTER_IN
].name
)
9129 " Incoming update AS path filter list is %s%s\n",
9130 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9131 filter
->aslist
[FILTER_IN
].name
);
9132 if (filter
->aslist
[FILTER_OUT
].name
)
9134 " Outgoing update AS path filter list is %s%s\n",
9135 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9136 filter
->aslist
[FILTER_OUT
].name
);
9139 if (filter
->map
[RMAP_IN
].name
)
9141 " Route map for incoming advertisements is %s%s\n",
9142 filter
->map
[RMAP_IN
].map
? "*" : "",
9143 filter
->map
[RMAP_IN
].name
);
9144 if (filter
->map
[RMAP_OUT
].name
)
9146 " Route map for outgoing advertisements is %s%s\n",
9147 filter
->map
[RMAP_OUT
].map
? "*" : "",
9148 filter
->map
[RMAP_OUT
].name
);
9150 /* ebgp-requires-policy (inbound) */
9151 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9152 && !bgp_inbound_policy_exists(p
, filter
))
9154 " Inbound updates discarded due to missing policy\n");
9156 /* ebgp-requires-policy (outbound) */
9157 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9158 && !bgp_outbound_policy_exists(p
, filter
))
9160 " Outbound updates discarded due to missing policy\n");
9162 /* unsuppress-map */
9163 if (filter
->usmap
.name
)
9165 " Route map for selective unsuppress is %s%s\n",
9166 filter
->usmap
.map
? "*" : "",
9167 filter
->usmap
.name
);
9169 /* Receive prefix count */
9170 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9172 /* Maximum prefix */
9173 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9174 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9176 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9177 PEER_FLAG_MAX_PREFIX_WARNING
)
9180 vty_out(vty
, " Threshold for warning message %d%%",
9181 p
->pmax_threshold
[afi
][safi
]);
9182 if (p
->pmax_restart
[afi
][safi
])
9183 vty_out(vty
, ", restart interval %d min",
9184 p
->pmax_restart
[afi
][safi
]);
9192 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9196 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9197 char timebuf
[BGP_UPTIME_LEN
];
9199 const char *subcode_str
;
9200 const char *code_str
;
9205 json_object
*json_neigh
= NULL
;
9211 json_neigh
= json_object_new_object();
9213 memset(dn_flag
, '\0', sizeof(dn_flag
));
9214 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9218 if (p
->conf_if
) /* Configured interface name. */
9219 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9220 BGP_PEER_SU_UNSPEC(p
)
9222 : sockunion2str(&p
->su
, buf
,
9224 else /* Configured IP address. */
9225 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9230 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9231 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9233 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9234 json_object_string_add(
9235 json_neigh
, "bgpNeighborAddr",
9236 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9238 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9240 if (p
->change_local_as
)
9241 json_object_int_add(json_neigh
, "localAs",
9242 p
->change_local_as
);
9244 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9246 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9247 json_object_boolean_true_add(json_neigh
,
9248 "localAsNoPrepend");
9250 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9251 json_object_boolean_true_add(json_neigh
,
9252 "localAsReplaceAs");
9254 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9255 || (p
->as_type
== AS_INTERNAL
))
9256 vty_out(vty
, "remote AS %u, ", p
->as
);
9258 vty_out(vty
, "remote AS Unspecified, ");
9259 vty_out(vty
, "local AS %u%s%s, ",
9260 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9261 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9264 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9268 /* peer type internal or confed-internal */
9269 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9271 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9272 json_object_boolean_true_add(
9273 json_neigh
, "nbrConfedInternalLink");
9275 json_object_boolean_true_add(json_neigh
,
9278 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9279 vty_out(vty
, "confed-internal link\n");
9281 vty_out(vty
, "internal link\n");
9283 /* peer type external or confed-external */
9284 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9286 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9287 json_object_boolean_true_add(
9288 json_neigh
, "nbrConfedExternalLink");
9290 json_object_boolean_true_add(json_neigh
,
9293 if (bgp_confederation_peers_check(bgp
, p
->as
))
9294 vty_out(vty
, "confed-external link\n");
9296 vty_out(vty
, "external link\n");
9300 json_object_boolean_true_add(json_neigh
,
9301 "nbrUnspecifiedLink");
9303 vty_out(vty
, "unspecified link\n");
9309 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9311 vty_out(vty
, " Description: %s\n", p
->desc
);
9317 json_object_string_add(json_neigh
, "hostname",
9321 json_object_string_add(json_neigh
, "domainname",
9324 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9325 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9328 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9335 json_object_string_add(json_neigh
, "peerGroup",
9339 struct prefix prefix
, *range
= NULL
;
9341 sockunion2hostprefix(&(p
->su
), &prefix
);
9342 range
= peer_group_lookup_dynamic_neighbor_range(
9346 prefix2str(range
, buf1
, sizeof(buf1
));
9347 json_object_string_add(
9349 "peerSubnetRangeGroup", buf1
);
9354 " Member of peer-group %s for session parameters\n",
9358 struct prefix prefix
, *range
= NULL
;
9360 sockunion2hostprefix(&(p
->su
), &prefix
);
9361 range
= peer_group_lookup_dynamic_neighbor_range(
9365 prefix2str(range
, buf1
, sizeof(buf1
));
9367 " Belongs to the subnet range group: %s\n",
9375 /* Administrative shutdown. */
9376 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9377 json_object_boolean_true_add(json_neigh
,
9381 json_object_int_add(json_neigh
, "bgpVersion", 4);
9382 json_object_string_add(
9383 json_neigh
, "remoteRouterId",
9384 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9385 json_object_string_add(
9386 json_neigh
, "localRouterId",
9387 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9391 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9392 && bgp_confederation_peers_check(bgp
, p
->as
))
9393 json_object_boolean_true_add(json_neigh
,
9397 json_object_string_add(
9398 json_neigh
, "bgpState",
9399 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9401 if (p
->status
== Established
) {
9404 uptime
= bgp_clock();
9405 uptime
-= p
->uptime
;
9406 epoch_tbuf
= time(NULL
) - uptime
;
9408 #if CONFDATE > 20200101
9410 "bgpTimerUp should be deprecated and can be removed now");
9413 * bgpTimerUp was miliseconds that was accurate
9414 * up to 1 day, then the value returned
9415 * became garbage. So in order to provide
9416 * some level of backwards compatability,
9417 * we still provde the data, but now
9418 * we are returning the correct value
9419 * and also adding a new bgpTimerUpMsec
9420 * which will allow us to deprecate
9423 json_object_int_add(json_neigh
, "bgpTimerUp",
9425 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9427 json_object_string_add(json_neigh
, "bgpTimerUpString",
9428 peer_uptime(p
->uptime
, timebuf
,
9431 json_object_int_add(json_neigh
,
9432 "bgpTimerUpEstablishedEpoch",
9436 else if (p
->status
== Active
) {
9437 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9438 json_object_string_add(json_neigh
, "bgpStateIs",
9440 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9441 json_object_string_add(json_neigh
, "bgpStateIs",
9449 uptime
= bgp_clock();
9450 uptime
-= p
->readtime
;
9451 tm
= gmtime(&uptime
);
9452 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9453 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9454 + (tm
->tm_hour
* 3600000));
9456 uptime
= bgp_clock();
9457 uptime
-= p
->last_write
;
9458 tm
= gmtime(&uptime
);
9459 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9460 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9461 + (tm
->tm_hour
* 3600000));
9463 uptime
= bgp_clock();
9464 uptime
-= p
->update_time
;
9465 tm
= gmtime(&uptime
);
9466 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9467 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9468 + (tm
->tm_hour
* 3600000));
9470 /* Configured timer values. */
9471 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9472 p
->v_holdtime
* 1000);
9473 json_object_int_add(json_neigh
,
9474 "bgpTimerKeepAliveIntervalMsecs",
9475 p
->v_keepalive
* 1000);
9476 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9477 json_object_int_add(json_neigh
,
9478 "bgpTimerConfiguredHoldTimeMsecs",
9479 p
->holdtime
* 1000);
9480 json_object_int_add(
9482 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9483 p
->keepalive
* 1000);
9484 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9485 || (bgp
->default_keepalive
9486 != BGP_DEFAULT_KEEPALIVE
)) {
9487 json_object_int_add(json_neigh
,
9488 "bgpTimerConfiguredHoldTimeMsecs",
9489 bgp
->default_holdtime
);
9490 json_object_int_add(
9492 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9493 bgp
->default_keepalive
);
9496 /* Administrative shutdown. */
9497 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9498 vty_out(vty
, " Administratively shut down\n");
9501 vty_out(vty
, " BGP version 4");
9502 vty_out(vty
, ", remote router ID %s",
9503 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9504 vty_out(vty
, ", local router ID %s\n",
9505 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9509 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9510 && bgp_confederation_peers_check(bgp
, p
->as
))
9512 " Neighbor under common administration\n");
9515 vty_out(vty
, " BGP state = %s",
9516 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9518 if (p
->status
== Established
)
9519 vty_out(vty
, ", up for %8s",
9520 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9523 else if (p
->status
== Active
) {
9524 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9525 vty_out(vty
, " (passive)");
9526 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9527 vty_out(vty
, " (NSF passive)");
9532 vty_out(vty
, " Last read %s",
9533 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9535 vty_out(vty
, ", Last write %s\n",
9536 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9539 /* Configured timer values. */
9541 " Hold time is %d, keepalive interval is %d seconds\n",
9542 p
->v_holdtime
, p
->v_keepalive
);
9543 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9544 vty_out(vty
, " Configured hold time is %d",
9546 vty_out(vty
, ", keepalive interval is %d seconds\n",
9548 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9549 || (bgp
->default_keepalive
9550 != BGP_DEFAULT_KEEPALIVE
)) {
9551 vty_out(vty
, " Configured hold time is %d",
9552 bgp
->default_holdtime
);
9553 vty_out(vty
, ", keepalive interval is %d seconds\n",
9554 bgp
->default_keepalive
);
9558 if (p
->status
== Established
) {
9559 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9560 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9561 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9562 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9563 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9564 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9565 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9566 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9567 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9568 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9569 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9570 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9571 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9572 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9573 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9574 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9575 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9576 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9577 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9578 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9580 json_object
*json_cap
= NULL
;
9582 json_cap
= json_object_new_object();
9585 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9586 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9587 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9588 && CHECK_FLAG(p
->cap
,
9590 json_object_string_add(
9591 json_cap
, "4byteAs",
9592 "advertisedAndReceived");
9593 else if (CHECK_FLAG(p
->cap
,
9595 json_object_string_add(
9596 json_cap
, "4byteAs",
9598 else if (CHECK_FLAG(p
->cap
,
9600 json_object_string_add(
9601 json_cap
, "4byteAs",
9606 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9607 || CHECK_FLAG(p
->cap
,
9608 PEER_CAP_ADDPATH_ADV
)) {
9609 json_object
*json_add
= NULL
;
9610 const char *print_store
;
9612 json_add
= json_object_new_object();
9614 FOREACH_AFI_SAFI (afi
, safi
) {
9615 json_object
*json_sub
= NULL
;
9617 json_object_new_object();
9618 print_store
= afi_safi_print(
9624 PEER_CAP_ADDPATH_AF_TX_ADV
)
9628 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9633 PEER_CAP_ADDPATH_AF_TX_ADV
)
9638 PEER_CAP_ADDPATH_AF_TX_RCV
))
9639 json_object_boolean_true_add(
9641 "txAdvertisedAndReceived");
9647 PEER_CAP_ADDPATH_AF_TX_ADV
))
9648 json_object_boolean_true_add(
9656 PEER_CAP_ADDPATH_AF_TX_RCV
))
9657 json_object_boolean_true_add(
9665 PEER_CAP_ADDPATH_AF_RX_ADV
)
9669 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9674 PEER_CAP_ADDPATH_AF_RX_ADV
)
9679 PEER_CAP_ADDPATH_AF_RX_RCV
))
9680 json_object_boolean_true_add(
9682 "rxAdvertisedAndReceived");
9688 PEER_CAP_ADDPATH_AF_RX_ADV
))
9689 json_object_boolean_true_add(
9697 PEER_CAP_ADDPATH_AF_RX_RCV
))
9698 json_object_boolean_true_add(
9706 PEER_CAP_ADDPATH_AF_TX_ADV
)
9710 PEER_CAP_ADDPATH_AF_TX_RCV
)
9714 PEER_CAP_ADDPATH_AF_RX_ADV
)
9718 PEER_CAP_ADDPATH_AF_RX_RCV
))
9719 json_object_object_add(
9728 json_object_object_add(
9729 json_cap
, "addPath", json_add
);
9733 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9734 || CHECK_FLAG(p
->cap
,
9735 PEER_CAP_DYNAMIC_ADV
)) {
9736 if (CHECK_FLAG(p
->cap
,
9737 PEER_CAP_DYNAMIC_ADV
)
9738 && CHECK_FLAG(p
->cap
,
9739 PEER_CAP_DYNAMIC_RCV
))
9740 json_object_string_add(
9741 json_cap
, "dynamic",
9742 "advertisedAndReceived");
9743 else if (CHECK_FLAG(
9745 PEER_CAP_DYNAMIC_ADV
))
9746 json_object_string_add(
9747 json_cap
, "dynamic",
9749 else if (CHECK_FLAG(
9751 PEER_CAP_DYNAMIC_RCV
))
9752 json_object_string_add(
9753 json_cap
, "dynamic",
9757 /* Extended nexthop */
9758 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9759 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9760 json_object
*json_nxt
= NULL
;
9761 const char *print_store
;
9764 if (CHECK_FLAG(p
->cap
,
9766 && CHECK_FLAG(p
->cap
,
9768 json_object_string_add(
9771 "advertisedAndReceived");
9772 else if (CHECK_FLAG(p
->cap
,
9774 json_object_string_add(
9778 else if (CHECK_FLAG(p
->cap
,
9780 json_object_string_add(
9785 if (CHECK_FLAG(p
->cap
,
9786 PEER_CAP_ENHE_RCV
)) {
9788 json_object_new_object();
9790 for (safi
= SAFI_UNICAST
;
9791 safi
< SAFI_MAX
; safi
++) {
9796 PEER_CAP_ENHE_AF_RCV
)) {
9797 print_store
= afi_safi_print(
9800 json_object_string_add(
9803 "recieved"); /* misspelled for compatibility */
9806 json_object_object_add(
9808 "extendedNexthopFamililesByPeer",
9814 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9815 || CHECK_FLAG(p
->cap
,
9816 PEER_CAP_REFRESH_NEW_RCV
)
9817 || CHECK_FLAG(p
->cap
,
9818 PEER_CAP_REFRESH_OLD_RCV
)) {
9819 if (CHECK_FLAG(p
->cap
,
9820 PEER_CAP_REFRESH_ADV
)
9823 PEER_CAP_REFRESH_NEW_RCV
)
9826 PEER_CAP_REFRESH_OLD_RCV
))) {
9829 PEER_CAP_REFRESH_OLD_RCV
)
9832 PEER_CAP_REFRESH_NEW_RCV
))
9833 json_object_string_add(
9836 "advertisedAndReceivedOldNew");
9840 PEER_CAP_REFRESH_OLD_RCV
))
9841 json_object_string_add(
9844 "advertisedAndReceivedOld");
9846 json_object_string_add(
9849 "advertisedAndReceivedNew");
9854 PEER_CAP_REFRESH_ADV
))
9855 json_object_string_add(
9862 PEER_CAP_REFRESH_NEW_RCV
)
9865 PEER_CAP_REFRESH_OLD_RCV
))
9866 json_object_string_add(
9872 /* Multiprotocol Extensions */
9873 json_object
*json_multi
= NULL
;
9874 json_multi
= json_object_new_object();
9876 FOREACH_AFI_SAFI (afi
, safi
) {
9877 if (p
->afc_adv
[afi
][safi
]
9878 || p
->afc_recv
[afi
][safi
]) {
9879 json_object
*json_exten
= NULL
;
9881 json_object_new_object();
9883 if (p
->afc_adv
[afi
][safi
]
9884 && p
->afc_recv
[afi
][safi
])
9885 json_object_boolean_true_add(
9887 "advertisedAndReceived");
9888 else if (p
->afc_adv
[afi
][safi
])
9889 json_object_boolean_true_add(
9892 else if (p
->afc_recv
[afi
][safi
])
9893 json_object_boolean_true_add(
9897 json_object_object_add(
9904 json_object_object_add(
9905 json_cap
, "multiprotocolExtensions",
9908 /* Hostname capabilities */
9909 json_object
*json_hname
= NULL
;
9911 json_hname
= json_object_new_object();
9913 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9914 json_object_string_add(
9915 json_hname
, "advHostName",
9916 bgp
->peer_self
->hostname
9920 json_object_string_add(
9921 json_hname
, "advDomainName",
9922 bgp
->peer_self
->domainname
9929 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9930 json_object_string_add(
9931 json_hname
, "rcvHostName",
9932 p
->hostname
? p
->hostname
9934 json_object_string_add(
9935 json_hname
, "rcvDomainName",
9936 p
->domainname
? p
->domainname
9940 json_object_object_add(json_cap
, "hostName",
9943 /* Gracefull Restart */
9944 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9945 || CHECK_FLAG(p
->cap
,
9946 PEER_CAP_RESTART_ADV
)) {
9947 if (CHECK_FLAG(p
->cap
,
9948 PEER_CAP_RESTART_ADV
)
9949 && CHECK_FLAG(p
->cap
,
9950 PEER_CAP_RESTART_RCV
))
9951 json_object_string_add(
9954 "advertisedAndReceived");
9955 else if (CHECK_FLAG(
9957 PEER_CAP_RESTART_ADV
))
9958 json_object_string_add(
9960 "gracefulRestartCapability",
9962 else if (CHECK_FLAG(
9964 PEER_CAP_RESTART_RCV
))
9965 json_object_string_add(
9967 "gracefulRestartCapability",
9970 if (CHECK_FLAG(p
->cap
,
9971 PEER_CAP_RESTART_RCV
)) {
9972 int restart_af_count
= 0;
9973 json_object
*json_restart
=
9976 json_object_new_object();
9978 json_object_int_add(
9980 "gracefulRestartRemoteTimerMsecs",
9981 p
->v_gr_restart
* 1000);
9983 FOREACH_AFI_SAFI (afi
, safi
) {
9988 PEER_CAP_RESTART_AF_RCV
)) {
9993 json_object_new_object();
9999 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10000 json_object_boolean_true_add(
10003 restart_af_count
++;
10004 json_object_object_add(
10012 if (!restart_af_count
) {
10013 json_object_string_add(
10015 "addressFamiliesByPeer",
10020 json_object_object_add(
10022 "addressFamiliesByPeer",
10026 json_object_object_add(json_neigh
,
10027 "neighborCapabilities",
10030 vty_out(vty
, " Neighbor capabilities:\n");
10033 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10034 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10035 vty_out(vty
, " 4 Byte AS:");
10036 if (CHECK_FLAG(p
->cap
,
10038 vty_out(vty
, " advertised");
10039 if (CHECK_FLAG(p
->cap
,
10041 vty_out(vty
, " %sreceived",
10047 vty_out(vty
, "\n");
10051 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10052 || CHECK_FLAG(p
->cap
,
10053 PEER_CAP_ADDPATH_ADV
)) {
10054 vty_out(vty
, " AddPath:\n");
10056 FOREACH_AFI_SAFI (afi
, safi
) {
10060 PEER_CAP_ADDPATH_AF_TX_ADV
)
10064 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10075 PEER_CAP_ADDPATH_AF_TX_ADV
))
10086 PEER_CAP_ADDPATH_AF_TX_RCV
))
10093 PEER_CAP_ADDPATH_AF_TX_ADV
)
10097 vty_out(vty
, "\n");
10103 PEER_CAP_ADDPATH_AF_RX_ADV
)
10107 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10118 PEER_CAP_ADDPATH_AF_RX_ADV
))
10129 PEER_CAP_ADDPATH_AF_RX_RCV
))
10136 PEER_CAP_ADDPATH_AF_RX_ADV
)
10140 vty_out(vty
, "\n");
10146 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10147 || CHECK_FLAG(p
->cap
,
10148 PEER_CAP_DYNAMIC_ADV
)) {
10149 vty_out(vty
, " Dynamic:");
10150 if (CHECK_FLAG(p
->cap
,
10151 PEER_CAP_DYNAMIC_ADV
))
10152 vty_out(vty
, " advertised");
10153 if (CHECK_FLAG(p
->cap
,
10154 PEER_CAP_DYNAMIC_RCV
))
10155 vty_out(vty
, " %sreceived",
10158 PEER_CAP_DYNAMIC_ADV
)
10161 vty_out(vty
, "\n");
10164 /* Extended nexthop */
10165 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10166 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10167 vty_out(vty
, " Extended nexthop:");
10168 if (CHECK_FLAG(p
->cap
,
10169 PEER_CAP_ENHE_ADV
))
10170 vty_out(vty
, " advertised");
10171 if (CHECK_FLAG(p
->cap
,
10172 PEER_CAP_ENHE_RCV
))
10173 vty_out(vty
, " %sreceived",
10179 vty_out(vty
, "\n");
10181 if (CHECK_FLAG(p
->cap
,
10182 PEER_CAP_ENHE_RCV
)) {
10184 " Address families by peer:\n ");
10185 for (safi
= SAFI_UNICAST
;
10186 safi
< SAFI_MAX
; safi
++)
10191 PEER_CAP_ENHE_AF_RCV
))
10200 /* Route Refresh */
10201 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10202 || CHECK_FLAG(p
->cap
,
10203 PEER_CAP_REFRESH_NEW_RCV
)
10204 || CHECK_FLAG(p
->cap
,
10205 PEER_CAP_REFRESH_OLD_RCV
)) {
10206 vty_out(vty
, " Route refresh:");
10207 if (CHECK_FLAG(p
->cap
,
10208 PEER_CAP_REFRESH_ADV
))
10209 vty_out(vty
, " advertised");
10210 if (CHECK_FLAG(p
->cap
,
10211 PEER_CAP_REFRESH_NEW_RCV
)
10214 PEER_CAP_REFRESH_OLD_RCV
))
10215 vty_out(vty
, " %sreceived(%s)",
10218 PEER_CAP_REFRESH_ADV
)
10223 PEER_CAP_REFRESH_OLD_RCV
)
10226 PEER_CAP_REFRESH_NEW_RCV
))
10230 PEER_CAP_REFRESH_OLD_RCV
)
10234 vty_out(vty
, "\n");
10237 /* Multiprotocol Extensions */
10238 FOREACH_AFI_SAFI (afi
, safi
)
10239 if (p
->afc_adv
[afi
][safi
]
10240 || p
->afc_recv
[afi
][safi
]) {
10242 " Address Family %s:",
10243 afi_safi_print(afi
,
10245 if (p
->afc_adv
[afi
][safi
])
10248 if (p
->afc_recv
[afi
][safi
])
10255 vty_out(vty
, "\n");
10258 /* Hostname capability */
10259 vty_out(vty
, " Hostname Capability:");
10261 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10263 " advertised (name: %s,domain name: %s)",
10264 bgp
->peer_self
->hostname
10268 bgp
->peer_self
->domainname
10273 vty_out(vty
, " not advertised");
10276 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10278 " received (name: %s,domain name: %s)",
10279 p
->hostname
? p
->hostname
10281 p
->domainname
? p
->domainname
10284 vty_out(vty
, " not received");
10287 vty_out(vty
, "\n");
10289 /* Gracefull Restart */
10290 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10291 || CHECK_FLAG(p
->cap
,
10292 PEER_CAP_RESTART_ADV
)) {
10294 " Graceful Restart Capabilty:");
10295 if (CHECK_FLAG(p
->cap
,
10296 PEER_CAP_RESTART_ADV
))
10297 vty_out(vty
, " advertised");
10298 if (CHECK_FLAG(p
->cap
,
10299 PEER_CAP_RESTART_RCV
))
10300 vty_out(vty
, " %sreceived",
10303 PEER_CAP_RESTART_ADV
)
10306 vty_out(vty
, "\n");
10308 if (CHECK_FLAG(p
->cap
,
10309 PEER_CAP_RESTART_RCV
)) {
10310 int restart_af_count
= 0;
10313 " Remote Restart timer is %d seconds\n",
10316 " Address families by peer:\n ");
10318 FOREACH_AFI_SAFI (afi
, safi
)
10323 PEER_CAP_RESTART_AF_RCV
)) {
10336 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10338 : "not preserved");
10339 restart_af_count
++;
10341 if (!restart_af_count
)
10342 vty_out(vty
, "none");
10343 vty_out(vty
, "\n");
10350 /* graceful restart information */
10351 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10352 || p
->t_gr_stale
) {
10353 json_object
*json_grace
= NULL
;
10354 json_object
*json_grace_send
= NULL
;
10355 json_object
*json_grace_recv
= NULL
;
10356 int eor_send_af_count
= 0;
10357 int eor_receive_af_count
= 0;
10360 json_grace
= json_object_new_object();
10361 json_grace_send
= json_object_new_object();
10362 json_grace_recv
= json_object_new_object();
10364 if (p
->status
== Established
) {
10365 FOREACH_AFI_SAFI (afi
, safi
) {
10366 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10367 PEER_STATUS_EOR_SEND
)) {
10368 json_object_boolean_true_add(
10370 afi_safi_print(afi
,
10372 eor_send_af_count
++;
10375 FOREACH_AFI_SAFI (afi
, safi
) {
10377 p
->af_sflags
[afi
][safi
],
10378 PEER_STATUS_EOR_RECEIVED
)) {
10379 json_object_boolean_true_add(
10381 afi_safi_print(afi
,
10383 eor_receive_af_count
++;
10388 json_object_object_add(json_grace
, "endOfRibSend",
10390 json_object_object_add(json_grace
, "endOfRibRecv",
10393 if (p
->t_gr_restart
)
10394 json_object_int_add(json_grace
,
10395 "gracefulRestartTimerMsecs",
10396 thread_timer_remain_second(
10401 json_object_int_add(
10403 "gracefulStalepathTimerMsecs",
10404 thread_timer_remain_second(
10408 json_object_object_add(
10409 json_neigh
, "gracefulRestartInfo", json_grace
);
10411 vty_out(vty
, " Graceful restart information:\n");
10412 if (p
->status
== Established
) {
10413 vty_out(vty
, " End-of-RIB send: ");
10414 FOREACH_AFI_SAFI (afi
, safi
) {
10415 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10416 PEER_STATUS_EOR_SEND
)) {
10417 vty_out(vty
, "%s%s",
10418 eor_send_af_count
? ", "
10420 afi_safi_print(afi
,
10422 eor_send_af_count
++;
10425 vty_out(vty
, "\n");
10426 vty_out(vty
, " End-of-RIB received: ");
10427 FOREACH_AFI_SAFI (afi
, safi
) {
10429 p
->af_sflags
[afi
][safi
],
10430 PEER_STATUS_EOR_RECEIVED
)) {
10431 vty_out(vty
, "%s%s",
10432 eor_receive_af_count
10435 afi_safi_print(afi
,
10437 eor_receive_af_count
++;
10440 vty_out(vty
, "\n");
10443 if (p
->t_gr_restart
)
10445 " The remaining time of restart timer is %ld\n",
10446 thread_timer_remain_second(
10451 " The remaining time of stalepath timer is %ld\n",
10452 thread_timer_remain_second(
10457 json_object
*json_stat
= NULL
;
10458 json_stat
= json_object_new_object();
10459 /* Packet counts. */
10460 json_object_int_add(json_stat
, "depthInq", 0);
10461 json_object_int_add(json_stat
, "depthOutq",
10462 (unsigned long)p
->obuf
->count
);
10463 json_object_int_add(json_stat
, "opensSent",
10464 atomic_load_explicit(&p
->open_out
,
10465 memory_order_relaxed
));
10466 json_object_int_add(json_stat
, "opensRecv",
10467 atomic_load_explicit(&p
->open_in
,
10468 memory_order_relaxed
));
10469 json_object_int_add(json_stat
, "notificationsSent",
10470 atomic_load_explicit(&p
->notify_out
,
10471 memory_order_relaxed
));
10472 json_object_int_add(json_stat
, "notificationsRecv",
10473 atomic_load_explicit(&p
->notify_in
,
10474 memory_order_relaxed
));
10475 json_object_int_add(json_stat
, "updatesSent",
10476 atomic_load_explicit(&p
->update_out
,
10477 memory_order_relaxed
));
10478 json_object_int_add(json_stat
, "updatesRecv",
10479 atomic_load_explicit(&p
->update_in
,
10480 memory_order_relaxed
));
10481 json_object_int_add(json_stat
, "keepalivesSent",
10482 atomic_load_explicit(&p
->keepalive_out
,
10483 memory_order_relaxed
));
10484 json_object_int_add(json_stat
, "keepalivesRecv",
10485 atomic_load_explicit(&p
->keepalive_in
,
10486 memory_order_relaxed
));
10487 json_object_int_add(json_stat
, "routeRefreshSent",
10488 atomic_load_explicit(&p
->refresh_out
,
10489 memory_order_relaxed
));
10490 json_object_int_add(json_stat
, "routeRefreshRecv",
10491 atomic_load_explicit(&p
->refresh_in
,
10492 memory_order_relaxed
));
10493 json_object_int_add(json_stat
, "capabilitySent",
10494 atomic_load_explicit(&p
->dynamic_cap_out
,
10495 memory_order_relaxed
));
10496 json_object_int_add(json_stat
, "capabilityRecv",
10497 atomic_load_explicit(&p
->dynamic_cap_in
,
10498 memory_order_relaxed
));
10499 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10500 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10501 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10503 /* Packet counts. */
10504 vty_out(vty
, " Message statistics:\n");
10505 vty_out(vty
, " Inq depth is 0\n");
10506 vty_out(vty
, " Outq depth is %lu\n",
10507 (unsigned long)p
->obuf
->count
);
10508 vty_out(vty
, " Sent Rcvd\n");
10509 vty_out(vty
, " Opens: %10d %10d\n",
10510 atomic_load_explicit(&p
->open_out
,
10511 memory_order_relaxed
),
10512 atomic_load_explicit(&p
->open_in
,
10513 memory_order_relaxed
));
10514 vty_out(vty
, " Notifications: %10d %10d\n",
10515 atomic_load_explicit(&p
->notify_out
,
10516 memory_order_relaxed
),
10517 atomic_load_explicit(&p
->notify_in
,
10518 memory_order_relaxed
));
10519 vty_out(vty
, " Updates: %10d %10d\n",
10520 atomic_load_explicit(&p
->update_out
,
10521 memory_order_relaxed
),
10522 atomic_load_explicit(&p
->update_in
,
10523 memory_order_relaxed
));
10524 vty_out(vty
, " Keepalives: %10d %10d\n",
10525 atomic_load_explicit(&p
->keepalive_out
,
10526 memory_order_relaxed
),
10527 atomic_load_explicit(&p
->keepalive_in
,
10528 memory_order_relaxed
));
10529 vty_out(vty
, " Route Refresh: %10d %10d\n",
10530 atomic_load_explicit(&p
->refresh_out
,
10531 memory_order_relaxed
),
10532 atomic_load_explicit(&p
->refresh_in
,
10533 memory_order_relaxed
));
10534 vty_out(vty
, " Capability: %10d %10d\n",
10535 atomic_load_explicit(&p
->dynamic_cap_out
,
10536 memory_order_relaxed
),
10537 atomic_load_explicit(&p
->dynamic_cap_in
,
10538 memory_order_relaxed
));
10539 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10544 /* advertisement-interval */
10545 json_object_int_add(json_neigh
,
10546 "minBtwnAdvertisementRunsTimerMsecs",
10547 p
->v_routeadv
* 1000);
10549 /* Update-source. */
10550 if (p
->update_if
|| p
->update_source
) {
10552 json_object_string_add(json_neigh
,
10555 else if (p
->update_source
)
10556 json_object_string_add(
10557 json_neigh
, "updateSource",
10558 sockunion2str(p
->update_source
, buf1
,
10562 /* advertisement-interval */
10564 " Minimum time between advertisement runs is %d seconds\n",
10567 /* Update-source. */
10568 if (p
->update_if
|| p
->update_source
) {
10569 vty_out(vty
, " Update source is ");
10571 vty_out(vty
, "%s", p
->update_if
);
10572 else if (p
->update_source
)
10574 sockunion2str(p
->update_source
, buf1
,
10576 vty_out(vty
, "\n");
10579 vty_out(vty
, "\n");
10582 /* Address Family Information */
10583 json_object
*json_hold
= NULL
;
10586 json_hold
= json_object_new_object();
10588 FOREACH_AFI_SAFI (afi
, safi
)
10589 if (p
->afc
[afi
][safi
])
10590 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10594 json_object_object_add(json_neigh
, "addressFamilyInfo",
10596 json_object_int_add(json_neigh
, "connectionsEstablished",
10598 json_object_int_add(json_neigh
, "connectionsDropped",
10601 vty_out(vty
, " Connections established %d; dropped %d\n",
10602 p
->established
, p
->dropped
);
10604 if (!p
->last_reset
) {
10606 json_object_string_add(json_neigh
, "lastReset",
10609 vty_out(vty
, " Last reset never\n");
10615 uptime
= bgp_clock();
10616 uptime
-= p
->resettime
;
10617 tm
= gmtime(&uptime
);
10618 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10619 (tm
->tm_sec
* 1000)
10620 + (tm
->tm_min
* 60000)
10621 + (tm
->tm_hour
* 3600000));
10622 json_object_string_add(
10623 json_neigh
, "lastResetDueTo",
10624 peer_down_str
[(int)p
->last_reset
]);
10625 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10626 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10627 char errorcodesubcode_hexstr
[5];
10628 char errorcodesubcode_str
[256];
10630 code_str
= bgp_notify_code_str(p
->notify
.code
);
10631 subcode_str
= bgp_notify_subcode_str(
10632 p
->notify
.code
, p
->notify
.subcode
);
10634 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10635 p
->notify
.code
, p
->notify
.subcode
);
10636 json_object_string_add(json_neigh
,
10637 "lastErrorCodeSubcode",
10638 errorcodesubcode_hexstr
);
10639 snprintf(errorcodesubcode_str
, 255, "%s%s",
10640 code_str
, subcode_str
);
10641 json_object_string_add(json_neigh
,
10642 "lastNotificationReason",
10643 errorcodesubcode_str
);
10644 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10645 && p
->notify
.code
== BGP_NOTIFY_CEASE
10646 && (p
->notify
.subcode
10647 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10648 || p
->notify
.subcode
10649 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10650 && p
->notify
.length
) {
10652 const char *msg_str
;
10654 msg_str
= bgp_notify_admin_message(
10655 msgbuf
, sizeof(msgbuf
),
10656 (uint8_t *)p
->notify
.data
,
10659 json_object_string_add(
10661 "lastShutdownDescription",
10666 vty_out(vty
, " Last reset %s, ",
10667 peer_uptime(p
->resettime
, timebuf
,
10668 BGP_UPTIME_LEN
, 0, NULL
));
10670 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10671 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10672 code_str
= bgp_notify_code_str(p
->notify
.code
);
10673 subcode_str
= bgp_notify_subcode_str(
10674 p
->notify
.code
, p
->notify
.subcode
);
10675 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10676 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10679 code_str
, subcode_str
);
10680 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10681 && p
->notify
.code
== BGP_NOTIFY_CEASE
10682 && (p
->notify
.subcode
10683 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10684 || p
->notify
.subcode
10685 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10686 && p
->notify
.length
) {
10688 const char *msg_str
;
10690 msg_str
= bgp_notify_admin_message(
10691 msgbuf
, sizeof(msgbuf
),
10692 (uint8_t *)p
->notify
.data
,
10696 " Message: \"%s\"\n",
10700 vty_out(vty
, "due to %s\n",
10701 peer_down_str
[(int)p
->last_reset
]);
10704 if (p
->last_reset_cause_size
) {
10705 msg
= p
->last_reset_cause
;
10707 " Message received that caused BGP to send a NOTIFICATION:\n ");
10708 for (i
= 1; i
<= p
->last_reset_cause_size
;
10710 vty_out(vty
, "%02X", *msg
++);
10712 if (i
!= p
->last_reset_cause_size
) {
10714 vty_out(vty
, "\n ");
10715 } else if (i
% 4 == 0) {
10720 vty_out(vty
, "\n");
10725 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10727 json_object_boolean_true_add(json_neigh
,
10728 "prefixesConfigExceedMax");
10731 " Peer had exceeded the max. no. of prefixes configured.\n");
10733 if (p
->t_pmax_restart
) {
10735 json_object_boolean_true_add(
10736 json_neigh
, "reducePrefixNumFrom");
10737 json_object_int_add(json_neigh
,
10738 "restartInTimerMsec",
10739 thread_timer_remain_second(
10744 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10745 p
->host
, thread_timer_remain_second(
10746 p
->t_pmax_restart
));
10749 json_object_boolean_true_add(
10751 "reducePrefixNumAndClearIpBgp");
10754 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10759 /* EBGP Multihop and GTSM */
10760 if (p
->sort
!= BGP_PEER_IBGP
) {
10762 if (p
->gtsm_hops
> 0)
10763 json_object_int_add(json_neigh
,
10764 "externalBgpNbrMaxHopsAway",
10766 else if (p
->ttl
> 1)
10767 json_object_int_add(json_neigh
,
10768 "externalBgpNbrMaxHopsAway",
10771 if (p
->gtsm_hops
> 0)
10773 " External BGP neighbor may be up to %d hops away.\n",
10775 else if (p
->ttl
> 1)
10777 " External BGP neighbor may be up to %d hops away.\n",
10781 if (p
->gtsm_hops
> 0) {
10783 json_object_int_add(json_neigh
,
10784 "internalBgpNbrMaxHopsAway",
10788 " Internal BGP neighbor may be up to %d hops away.\n",
10793 /* Local address. */
10796 json_object_string_add(json_neigh
, "hostLocal",
10797 sockunion2str(p
->su_local
, buf1
,
10799 json_object_int_add(json_neigh
, "portLocal",
10800 ntohs(p
->su_local
->sin
.sin_port
));
10802 vty_out(vty
, "Local host: %s, Local port: %d\n",
10803 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10804 ntohs(p
->su_local
->sin
.sin_port
));
10807 /* Remote address. */
10808 if (p
->su_remote
) {
10810 json_object_string_add(json_neigh
, "hostForeign",
10811 sockunion2str(p
->su_remote
, buf1
,
10813 json_object_int_add(json_neigh
, "portForeign",
10814 ntohs(p
->su_remote
->sin
.sin_port
));
10816 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10817 sockunion2str(p
->su_remote
, buf1
,
10819 ntohs(p
->su_remote
->sin
.sin_port
));
10822 /* Nexthop display. */
10825 json_object_string_add(json_neigh
, "nexthop",
10827 &p
->nexthop
.v4
, buf1
,
10829 json_object_string_add(json_neigh
, "nexthopGlobal",
10830 inet_ntop(AF_INET6
,
10831 &p
->nexthop
.v6_global
,
10832 buf1
, sizeof(buf1
)));
10833 json_object_string_add(json_neigh
, "nexthopLocal",
10834 inet_ntop(AF_INET6
,
10835 &p
->nexthop
.v6_local
,
10836 buf1
, sizeof(buf1
)));
10837 if (p
->shared_network
)
10838 json_object_string_add(json_neigh
,
10842 json_object_string_add(json_neigh
,
10844 "nonSharedNetwork");
10846 vty_out(vty
, "Nexthop: %s\n",
10847 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10849 vty_out(vty
, "Nexthop global: %s\n",
10850 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10852 vty_out(vty
, "Nexthop local: %s\n",
10853 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10855 vty_out(vty
, "BGP connection: %s\n",
10856 p
->shared_network
? "shared network"
10857 : "non shared network");
10861 /* Timer information. */
10863 json_object_int_add(json_neigh
, "connectRetryTimer",
10865 if (p
->status
== Established
&& p
->rtt
)
10866 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10869 json_object_int_add(
10870 json_neigh
, "nextStartTimerDueInMsecs",
10871 thread_timer_remain_second(p
->t_start
) * 1000);
10873 json_object_int_add(
10874 json_neigh
, "nextConnectTimerDueInMsecs",
10875 thread_timer_remain_second(p
->t_connect
)
10877 if (p
->t_routeadv
) {
10878 json_object_int_add(json_neigh
, "mraiInterval",
10880 json_object_int_add(
10881 json_neigh
, "mraiTimerExpireInMsecs",
10882 thread_timer_remain_second(p
->t_routeadv
)
10886 json_object_int_add(json_neigh
, "authenticationEnabled",
10890 json_object_string_add(json_neigh
, "readThread", "on");
10892 json_object_string_add(json_neigh
, "readThread", "off");
10894 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10895 json_object_string_add(json_neigh
, "writeThread", "on");
10897 json_object_string_add(json_neigh
, "writeThread",
10900 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10902 if (p
->status
== Established
&& p
->rtt
)
10903 vty_out(vty
, "Estimated round trip time: %d ms\n",
10906 vty_out(vty
, "Next start timer due in %ld seconds\n",
10907 thread_timer_remain_second(p
->t_start
));
10909 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10910 thread_timer_remain_second(p
->t_connect
));
10913 "MRAI (interval %u) timer expires in %ld seconds\n",
10915 thread_timer_remain_second(p
->t_routeadv
));
10917 vty_out(vty
, "Peer Authentication Enabled\n");
10919 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10920 p
->t_read
? "on" : "off",
10921 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10926 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10927 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10928 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10931 vty_out(vty
, "\n");
10933 /* BFD information. */
10934 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10937 if (p
->conf_if
) /* Configured interface name. */
10938 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10939 else /* Configured IP address. */
10940 json_object_object_add(json
, p
->host
, json_neigh
);
10944 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10945 enum show_type type
, union sockunion
*su
,
10946 const char *conf_if
, bool use_json
,
10949 struct listnode
*node
, *nnode
;
10952 bool nbr_output
= false;
10953 afi_t afi
= AFI_MAX
;
10954 safi_t safi
= SAFI_MAX
;
10956 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
10958 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
10962 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10963 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10968 bgp_show_peer(vty
, peer
, use_json
, json
);
10974 && !strcmp(peer
->conf_if
, conf_if
))
10976 && !strcmp(peer
->hostname
, conf_if
))) {
10978 bgp_show_peer(vty
, peer
, use_json
,
10982 if (sockunion_same(&peer
->su
, su
)) {
10984 bgp_show_peer(vty
, peer
, use_json
,
10989 case show_ipv4_peer
:
10990 case show_ipv6_peer
:
10991 FOREACH_SAFI (safi
) {
10992 if (peer
->afc
[afi
][safi
]) {
10995 && !strcmp(peer
->conf_if
, conf_if
))
10997 && !strcmp(peer
->hostname
, conf_if
))) {
10999 bgp_show_peer(vty
, peer
, use_json
,
11004 if (sockunion_same(&peer
->su
, su
)) {
11006 bgp_show_peer(vty
, peer
, use_json
,
11014 case show_ipv4_all
:
11015 case show_ipv6_all
:
11016 FOREACH_SAFI (safi
) {
11017 if (peer
->afc
[afi
][safi
]) {
11018 bgp_show_peer(vty
, peer
, use_json
, json
);
11027 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11028 type
== show_ipv6_peer
) && !find
) {
11030 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11032 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11035 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11036 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11037 vty_out(vty
, "%% No BGP neighbors found\n");
11040 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11041 json
, JSON_C_TO_STRING_PRETTY
));
11043 vty_out(vty
, "\n");
11046 return CMD_SUCCESS
;
11049 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11050 enum show_type type
,
11051 const char *ip_str
,
11054 struct listnode
*node
, *nnode
;
11056 union sockunion su
;
11057 json_object
*json
= NULL
;
11058 int ret
, is_first
= 1;
11059 bool nbr_output
= false;
11062 vty_out(vty
, "{\n");
11064 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11067 if (!(json
= json_object_new_object())) {
11069 EC_BGP_JSON_MEM_ERROR
,
11070 "Unable to allocate memory for JSON object");
11072 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11076 json_object_int_add(json
, "vrfId",
11077 (bgp
->vrf_id
== VRF_UNKNOWN
)
11079 : (int64_t)bgp
->vrf_id
);
11080 json_object_string_add(
11082 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11087 vty_out(vty
, ",\n");
11091 vty_out(vty
, "\"%s\":",
11092 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11096 vty_out(vty
, "\nInstance %s:\n",
11097 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11102 if (type
== show_peer
|| type
== show_ipv4_peer
||
11103 type
== show_ipv6_peer
) {
11104 ret
= str2sockunion(ip_str
, &su
);
11106 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11109 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11112 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11115 json_object_free(json
);
11119 vty_out(vty
, "}\n");
11120 json_object_free(json
);
11122 else if (!nbr_output
)
11123 vty_out(vty
, "%% BGP instance not found\n");
11126 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11127 enum show_type type
, const char *ip_str
,
11132 union sockunion su
;
11133 json_object
*json
= NULL
;
11136 if (strmatch(name
, "all")) {
11137 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11139 return CMD_SUCCESS
;
11141 bgp
= bgp_lookup_by_name(name
);
11144 json
= json_object_new_object();
11145 vty_out(vty
, "%s\n",
11146 json_object_to_json_string_ext(
11148 JSON_C_TO_STRING_PRETTY
));
11149 json_object_free(json
);
11152 "%% BGP instance not found\n");
11154 return CMD_WARNING
;
11158 bgp
= bgp_get_default();
11162 json
= json_object_new_object();
11164 ret
= str2sockunion(ip_str
, &su
);
11166 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11169 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11172 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11175 json_object_free(json
);
11178 vty_out(vty
, "{}\n");
11180 vty_out(vty
, "%% BGP instance not found\n");
11183 return CMD_SUCCESS
;
11186 /* "show [ip] bgp neighbors" commands. */
11187 DEFUN (show_ip_bgp_neighbors
,
11188 show_ip_bgp_neighbors_cmd
,
11189 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11193 BGP_INSTANCE_HELP_STR
11196 "Detailed information on TCP and BGP neighbor connections\n"
11197 "Neighbor to display information about\n"
11198 "Neighbor to display information about\n"
11199 "Neighbor on BGP configured interface\n"
11203 char *sh_arg
= NULL
;
11204 enum show_type sh_type
;
11205 afi_t afi
= AFI_MAX
;
11207 bool uj
= use_json(argc
, argv
);
11211 /* [<vrf> VIEWVRFNAME] */
11212 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11213 vrf
= argv
[idx
+ 1]->arg
;
11214 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11216 } else if (argv_find(argv
, argc
, "view", &idx
))
11217 /* [<view> VIEWVRFNAME] */
11218 vrf
= argv
[idx
+ 1]->arg
;
11222 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11223 sh_type
= show_ipv4_all
;
11225 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11226 sh_type
= show_ipv6_all
;
11229 sh_type
= show_all
;
11232 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11233 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11234 || argv_find(argv
, argc
, "WORD", &idx
)) {
11235 sh_type
= show_peer
;
11236 sh_arg
= argv
[idx
]->arg
;
11239 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11240 sh_type
= show_ipv4_peer
;
11241 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11242 sh_type
= show_ipv6_peer
;
11245 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11248 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11249 paths' and `show ip mbgp paths'. Those functions results are the
11251 DEFUN (show_ip_bgp_paths
,
11252 show_ip_bgp_paths_cmd
,
11253 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11258 "Path information\n")
11260 vty_out(vty
, "Address Refcnt Path\n");
11261 aspath_print_all_vty(vty
);
11262 return CMD_SUCCESS
;
11267 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11270 struct community
*com
;
11272 com
= (struct community
*)bucket
->data
;
11273 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11274 community_str(com
, false));
11277 /* Show BGP's community internal data. */
11278 DEFUN (show_ip_bgp_community_info
,
11279 show_ip_bgp_community_info_cmd
,
11280 "show [ip] bgp community-info",
11284 "List all bgp community information\n")
11286 vty_out(vty
, "Address Refcnt Community\n");
11288 hash_iterate(community_hash(),
11289 (void (*)(struct hash_bucket
*,
11290 void *))community_show_all_iterator
,
11293 return CMD_SUCCESS
;
11296 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11299 struct lcommunity
*lcom
;
11301 lcom
= (struct lcommunity
*)bucket
->data
;
11302 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11303 lcommunity_str(lcom
, false));
11306 /* Show BGP's community internal data. */
11307 DEFUN (show_ip_bgp_lcommunity_info
,
11308 show_ip_bgp_lcommunity_info_cmd
,
11309 "show ip bgp large-community-info",
11313 "List all bgp large-community information\n")
11315 vty_out(vty
, "Address Refcnt Large-community\n");
11317 hash_iterate(lcommunity_hash(),
11318 (void (*)(struct hash_bucket
*,
11319 void *))lcommunity_show_all_iterator
,
11322 return CMD_SUCCESS
;
11326 DEFUN (show_ip_bgp_attr_info
,
11327 show_ip_bgp_attr_info_cmd
,
11328 "show [ip] bgp attribute-info",
11332 "List all bgp attribute information\n")
11334 attr_show_all(vty
);
11335 return CMD_SUCCESS
;
11338 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11339 afi_t afi
, safi_t safi
,
11340 bool use_json
, json_object
*json
)
11343 struct listnode
*node
;
11345 char buf1
[INET6_ADDRSTRLEN
];
11347 vpn_policy_direction_t dir
;
11350 json_object
*json_import_vrfs
= NULL
;
11351 json_object
*json_export_vrfs
= NULL
;
11353 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11356 vty_out(vty
, "%s\n",
11357 json_object_to_json_string_ext(
11359 JSON_C_TO_STRING_PRETTY
));
11360 json_object_free(json
);
11362 return CMD_WARNING
;
11365 /* Provide context for the block */
11366 json_object_string_add(json
, "vrf", name
? name
: "default");
11367 json_object_string_add(json
, "afiSafi",
11368 afi_safi_print(afi
, safi
));
11370 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11371 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11372 json_object_string_add(json
, "importFromVrfs", "none");
11373 json_object_string_add(json
, "importRts", "none");
11375 json_import_vrfs
= json_object_new_array();
11377 for (ALL_LIST_ELEMENTS_RO(
11378 bgp
->vpn_policy
[afi
].import_vrf
,
11380 json_object_array_add(json_import_vrfs
,
11381 json_object_new_string(vname
));
11383 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11384 ecom_str
= ecommunity_ecom2str(
11385 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11386 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11387 json_object_object_add(json
, "importFromVrfs",
11389 json_object_string_add(json
, "importRts", ecom_str
);
11391 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11394 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11395 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11396 json_object_string_add(json
, "exportToVrfs", "none");
11397 json_object_string_add(json
, "routeDistinguisher",
11399 json_object_string_add(json
, "exportRts", "none");
11401 json_export_vrfs
= json_object_new_array();
11403 for (ALL_LIST_ELEMENTS_RO(
11404 bgp
->vpn_policy
[afi
].export_vrf
,
11406 json_object_array_add(json_export_vrfs
,
11407 json_object_new_string(vname
));
11408 json_object_object_add(json
, "exportToVrfs",
11410 json_object_string_add(json
, "routeDistinguisher",
11411 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11412 buf1
, RD_ADDRSTRLEN
));
11414 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11415 ecom_str
= ecommunity_ecom2str(
11416 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11417 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11418 json_object_string_add(json
, "exportRts", ecom_str
);
11420 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11424 vty_out(vty
, "%s\n",
11425 json_object_to_json_string_ext(json
,
11426 JSON_C_TO_STRING_PRETTY
));
11427 json_object_free(json
);
11430 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11433 vty_out(vty
, "%% No such BGP instance exist\n");
11434 return CMD_WARNING
;
11437 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11438 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11440 "This VRF is not importing %s routes from any other VRF\n",
11441 afi_safi_print(afi
, safi
));
11444 "This VRF is importing %s routes from the following VRFs:\n",
11445 afi_safi_print(afi
, safi
));
11447 for (ALL_LIST_ELEMENTS_RO(
11448 bgp
->vpn_policy
[afi
].import_vrf
,
11450 vty_out(vty
, " %s\n", vname
);
11452 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11453 ecom_str
= ecommunity_ecom2str(
11454 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11455 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11456 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11458 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11461 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11462 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11464 "This VRF is not exporting %s routes to any other VRF\n",
11465 afi_safi_print(afi
, safi
));
11468 "This VRF is exporting %s routes to the following VRFs:\n",
11469 afi_safi_print(afi
, safi
));
11471 for (ALL_LIST_ELEMENTS_RO(
11472 bgp
->vpn_policy
[afi
].export_vrf
,
11474 vty_out(vty
, " %s\n", vname
);
11476 vty_out(vty
, "RD: %s\n",
11477 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11478 buf1
, RD_ADDRSTRLEN
));
11480 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11481 ecom_str
= ecommunity_ecom2str(
11482 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11483 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11484 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11485 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11489 return CMD_SUCCESS
;
11492 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11493 safi_t safi
, bool use_json
)
11495 struct listnode
*node
, *nnode
;
11497 char *vrf_name
= NULL
;
11498 json_object
*json
= NULL
;
11499 json_object
*json_vrf
= NULL
;
11500 json_object
*json_vrfs
= NULL
;
11503 json
= json_object_new_object();
11504 json_vrfs
= json_object_new_object();
11507 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11509 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11510 vrf_name
= bgp
->name
;
11513 json_vrf
= json_object_new_object();
11515 vty_out(vty
, "\nInstance %s:\n",
11516 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11517 ? VRF_DEFAULT_NAME
: bgp
->name
);
11519 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11521 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11522 json_object_object_add(json_vrfs
,
11523 VRF_DEFAULT_NAME
, json_vrf
);
11525 json_object_object_add(json_vrfs
, vrf_name
,
11531 json_object_object_add(json
, "vrfs", json_vrfs
);
11532 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11533 JSON_C_TO_STRING_PRETTY
));
11534 json_object_free(json
);
11537 return CMD_SUCCESS
;
11540 /* "show [ip] bgp route-leak" command. */
11541 DEFUN (show_ip_bgp_route_leak
,
11542 show_ip_bgp_route_leak_cmd
,
11543 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11547 BGP_INSTANCE_HELP_STR
11550 "Route leaking information\n"
11554 afi_t afi
= AFI_MAX
;
11555 safi_t safi
= SAFI_MAX
;
11557 bool uj
= use_json(argc
, argv
);
11559 json_object
*json
= NULL
;
11561 /* show [ip] bgp */
11562 if (argv_find(argv
, argc
, "ip", &idx
)) {
11564 safi
= SAFI_UNICAST
;
11566 /* [vrf VIEWVRFNAME] */
11567 if (argv_find(argv
, argc
, "view", &idx
)) {
11569 "%% This command is not applicable to BGP views\n");
11570 return CMD_WARNING
;
11573 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11574 vrf
= argv
[idx
+ 1]->arg
;
11575 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11578 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11579 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11580 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11583 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11585 "%% This command is applicable only for unicast ipv4|ipv6\n");
11586 return CMD_WARNING
;
11589 if (vrf
&& strmatch(vrf
, "all"))
11590 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11593 json
= json_object_new_object();
11595 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11598 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11601 struct listnode
*node
, *nnode
;
11604 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11605 vty_out(vty
, "\nInstance %s:\n",
11606 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11609 update_group_show(bgp
, afi
, safi
, vty
, 0);
11613 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11614 int safi
, uint64_t subgrp_id
)
11619 if (strmatch(name
, "all")) {
11620 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11621 return CMD_SUCCESS
;
11623 bgp
= bgp_lookup_by_name(name
);
11626 bgp
= bgp_get_default();
11630 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11631 return CMD_SUCCESS
;
11634 DEFUN (show_ip_bgp_updgrps
,
11635 show_ip_bgp_updgrps_cmd
,
11636 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11640 BGP_INSTANCE_HELP_STR
11642 BGP_SAFI_WITH_LABEL_HELP_STR
11643 "Detailed info about dynamic update groups\n"
11644 "Specific subgroup to display detailed info for\n")
11647 afi_t afi
= AFI_IP6
;
11648 safi_t safi
= SAFI_UNICAST
;
11649 uint64_t subgrp_id
= 0;
11653 /* show [ip] bgp */
11654 if (argv_find(argv
, argc
, "ip", &idx
))
11656 /* [<vrf> VIEWVRFNAME] */
11657 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11658 vrf
= argv
[idx
+ 1]->arg
;
11659 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11661 } else if (argv_find(argv
, argc
, "view", &idx
))
11662 /* [<view> VIEWVRFNAME] */
11663 vrf
= argv
[idx
+ 1]->arg
;
11664 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11665 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11666 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11669 /* get subgroup id, if provided */
11671 if (argv
[idx
]->type
== VARIABLE_TKN
)
11672 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11674 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11677 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11678 show_bgp_instance_all_ipv6_updgrps_cmd
,
11679 "show [ip] bgp <view|vrf> all update-groups",
11683 BGP_INSTANCE_ALL_HELP_STR
11684 "Detailed info about dynamic update groups\n")
11686 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11687 return CMD_SUCCESS
;
11690 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11691 show_bgp_l2vpn_evpn_updgrps_cmd
,
11692 "show [ip] bgp l2vpn evpn update-groups",
11696 "l2vpn address family\n"
11697 "evpn sub-address family\n"
11698 "Detailed info about dynamic update groups\n")
11701 uint64_t subgrp_id
= 0;
11703 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11704 return CMD_SUCCESS
;
11707 DEFUN (show_bgp_updgrps_stats
,
11708 show_bgp_updgrps_stats_cmd
,
11709 "show [ip] bgp update-groups statistics",
11713 "Detailed info about dynamic update groups\n"
11718 bgp
= bgp_get_default();
11720 update_group_show_stats(bgp
, vty
);
11722 return CMD_SUCCESS
;
11725 DEFUN (show_bgp_instance_updgrps_stats
,
11726 show_bgp_instance_updgrps_stats_cmd
,
11727 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11731 BGP_INSTANCE_HELP_STR
11732 "Detailed info about dynamic update groups\n"
11738 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11740 update_group_show_stats(bgp
, vty
);
11742 return CMD_SUCCESS
;
11745 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11746 afi_t afi
, safi_t safi
,
11747 const char *what
, uint64_t subgrp_id
)
11752 bgp
= bgp_lookup_by_name(name
);
11754 bgp
= bgp_get_default();
11757 if (!strcmp(what
, "advertise-queue"))
11758 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11760 else if (!strcmp(what
, "advertised-routes"))
11761 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11763 else if (!strcmp(what
, "packet-queue"))
11764 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11769 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11770 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11771 "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",
11772 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11774 "Detailed info about dynamic update groups\n"
11775 "Specific subgroup to display info for\n"
11776 "Advertisement queue\n"
11777 "Announced routes\n"
11780 uint64_t subgrp_id
= 0;
11784 subgrp_id
= strtoull(sgid
, NULL
, 10);
11789 afiz
= bgp_vty_afi_from_str(afi
);
11793 afiz
= bgp_vty_afi_from_str(afi
);
11794 if (afiz
!= AFI_IP
)
11796 "%% Cannot specify both 'ip' and 'ipv6'\n");
11797 return CMD_WARNING
;
11800 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11802 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11803 return CMD_SUCCESS
;
11806 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11808 struct listnode
*node
, *nnode
;
11809 struct prefix
*range
;
11812 char buf
[PREFIX2STR_BUFFER
];
11815 const char *peer_status
;
11816 const char *af_str
;
11821 conf
= group
->conf
;
11823 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11824 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11825 group
->name
, conf
->as
);
11826 } else if (conf
->as_type
== AS_INTERNAL
) {
11827 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11828 group
->name
, group
->bgp
->as
);
11830 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11833 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11834 vty_out(vty
, " Peer-group type is internal\n");
11836 vty_out(vty
, " Peer-group type is external\n");
11838 /* Display AFs configured. */
11839 vty_out(vty
, " Configured address-families:");
11840 FOREACH_AFI_SAFI (afi
, safi
) {
11841 if (conf
->afc
[afi
][safi
]) {
11843 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11847 vty_out(vty
, " none\n");
11849 vty_out(vty
, "\n");
11851 /* Display listen ranges (for dynamic neighbors), if any */
11852 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11855 else if (afi
== AFI_IP6
)
11859 lr_count
= listcount(group
->listen_range
[afi
]);
11861 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11865 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11867 prefix2str(range
, buf
, sizeof(buf
));
11868 vty_out(vty
, " %s\n", buf
);
11873 /* Display group members and their status */
11874 if (listcount(group
->peer
)) {
11875 vty_out(vty
, " Peer-group members:\n");
11876 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11877 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11878 peer_status
= "Idle (Admin)";
11879 else if (CHECK_FLAG(peer
->sflags
,
11880 PEER_STATUS_PREFIX_OVERFLOW
))
11881 peer_status
= "Idle (PfxCt)";
11883 peer_status
= lookup_msg(bgp_status_msg
,
11884 peer
->status
, NULL
);
11886 dynamic
= peer_dynamic_neighbor(peer
);
11887 vty_out(vty
, " %s %s %s \n", peer
->host
,
11888 dynamic
? "(dynamic)" : "", peer_status
);
11892 return CMD_SUCCESS
;
11895 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11896 const char *group_name
)
11899 struct listnode
*node
, *nnode
;
11900 struct peer_group
*group
;
11901 bool found
= false;
11903 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11906 vty_out(vty
, "%% BGP instance not found\n");
11907 return CMD_WARNING
;
11910 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11912 if (strmatch(group
->name
, group_name
)) {
11913 bgp_show_one_peer_group(vty
, group
);
11918 bgp_show_one_peer_group(vty
, group
);
11922 if (group_name
&& !found
)
11923 vty_out(vty
, "%% No such peer-group\n");
11925 return CMD_SUCCESS
;
11928 DEFUN (show_ip_bgp_peer_groups
,
11929 show_ip_bgp_peer_groups_cmd
,
11930 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11934 BGP_INSTANCE_HELP_STR
11935 "Detailed information on BGP peer groups\n"
11936 "Peer group name\n")
11941 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11943 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11945 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11949 /* Redistribute VTY commands. */
11951 DEFUN (bgp_redistribute_ipv4
,
11952 bgp_redistribute_ipv4_cmd
,
11953 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11954 "Redistribute information from another routing protocol\n"
11955 FRR_IP_REDIST_HELP_STR_BGPD
)
11957 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11958 int idx_protocol
= 1;
11961 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11963 vty_out(vty
, "%% Invalid route type\n");
11964 return CMD_WARNING_CONFIG_FAILED
;
11967 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11968 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
11972 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11973 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11974 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11976 DEFUN (bgp_redistribute_ipv4_rmap
,
11977 bgp_redistribute_ipv4_rmap_cmd
,
11978 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11979 "Redistribute information from another routing protocol\n"
11980 FRR_IP_REDIST_HELP_STR_BGPD
11981 "Route map reference\n"
11982 "Pointer to route-map entries\n")
11984 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11985 int idx_protocol
= 1;
11988 struct bgp_redist
*red
;
11990 struct route_map
*route_map
= route_map_lookup_warn_noexist(
11991 vty
, argv
[idx_word
]->arg
);
11993 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11995 vty_out(vty
, "%% Invalid route type\n");
11996 return CMD_WARNING_CONFIG_FAILED
;
11999 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12001 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12002 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12006 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12007 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12008 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12009 "Route map reference\n"
12010 "Pointer to route-map entries\n")
12012 DEFUN (bgp_redistribute_ipv4_metric
,
12013 bgp_redistribute_ipv4_metric_cmd
,
12014 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12015 "Redistribute information from another routing protocol\n"
12016 FRR_IP_REDIST_HELP_STR_BGPD
12017 "Metric for redistributed routes\n"
12018 "Default metric\n")
12020 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12021 int idx_protocol
= 1;
12022 int idx_number
= 3;
12025 struct bgp_redist
*red
;
12028 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12030 vty_out(vty
, "%% Invalid route type\n");
12031 return CMD_WARNING_CONFIG_FAILED
;
12033 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12035 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12036 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12037 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12041 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12042 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12043 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12044 "Metric for redistributed routes\n"
12045 "Default metric\n")
12047 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12048 bgp_redistribute_ipv4_rmap_metric_cmd
,
12049 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12050 "Redistribute information from another routing protocol\n"
12051 FRR_IP_REDIST_HELP_STR_BGPD
12052 "Route map reference\n"
12053 "Pointer to route-map entries\n"
12054 "Metric for redistributed routes\n"
12055 "Default metric\n")
12057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12058 int idx_protocol
= 1;
12060 int idx_number
= 5;
12063 struct bgp_redist
*red
;
12065 struct route_map
*route_map
=
12066 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12068 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12070 vty_out(vty
, "%% Invalid route type\n");
12071 return CMD_WARNING_CONFIG_FAILED
;
12073 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12075 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12077 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12078 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12079 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12083 bgp_redistribute_ipv4_rmap_metric
,
12084 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12085 "redistribute " FRR_IP_REDIST_STR_BGPD
12086 " route-map WORD metric (0-4294967295)",
12087 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12088 "Route map reference\n"
12089 "Pointer to route-map entries\n"
12090 "Metric for redistributed routes\n"
12091 "Default metric\n")
12093 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12094 bgp_redistribute_ipv4_metric_rmap_cmd
,
12095 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12096 "Redistribute information from another routing protocol\n"
12097 FRR_IP_REDIST_HELP_STR_BGPD
12098 "Metric for redistributed routes\n"
12100 "Route map reference\n"
12101 "Pointer to route-map entries\n")
12103 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12104 int idx_protocol
= 1;
12105 int idx_number
= 3;
12109 struct bgp_redist
*red
;
12111 struct route_map
*route_map
=
12112 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12114 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12116 vty_out(vty
, "%% Invalid route type\n");
12117 return CMD_WARNING_CONFIG_FAILED
;
12119 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12121 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12122 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12124 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12125 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12129 bgp_redistribute_ipv4_metric_rmap
,
12130 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12131 "redistribute " FRR_IP_REDIST_STR_BGPD
12132 " metric (0-4294967295) route-map WORD",
12133 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12134 "Metric for redistributed routes\n"
12136 "Route map reference\n"
12137 "Pointer to route-map entries\n")
12139 DEFUN (bgp_redistribute_ipv4_ospf
,
12140 bgp_redistribute_ipv4_ospf_cmd
,
12141 "redistribute <ospf|table> (1-65535)",
12142 "Redistribute information from another routing protocol\n"
12143 "Open Shortest Path First (OSPFv2)\n"
12144 "Non-main Kernel Routing Table\n"
12145 "Instance ID/Table ID\n")
12147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12148 int idx_ospf_table
= 1;
12149 int idx_number
= 2;
12150 unsigned short instance
;
12151 unsigned short protocol
;
12153 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12155 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12156 protocol
= ZEBRA_ROUTE_OSPF
;
12158 protocol
= ZEBRA_ROUTE_TABLE
;
12160 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12161 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12164 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12165 "redistribute <ospf|table> (1-65535)",
12166 "Redistribute information from another routing protocol\n"
12167 "Open Shortest Path First (OSPFv2)\n"
12168 "Non-main Kernel Routing Table\n"
12169 "Instance ID/Table ID\n")
12171 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12172 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12173 "redistribute <ospf|table> (1-65535) route-map WORD",
12174 "Redistribute information from another routing protocol\n"
12175 "Open Shortest Path First (OSPFv2)\n"
12176 "Non-main Kernel Routing Table\n"
12177 "Instance ID/Table ID\n"
12178 "Route map reference\n"
12179 "Pointer to route-map entries\n")
12181 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12182 int idx_ospf_table
= 1;
12183 int idx_number
= 2;
12185 struct bgp_redist
*red
;
12186 unsigned short instance
;
12189 struct route_map
*route_map
=
12190 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12192 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12193 protocol
= ZEBRA_ROUTE_OSPF
;
12195 protocol
= ZEBRA_ROUTE_TABLE
;
12197 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12198 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12200 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12201 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12204 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12205 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12206 "redistribute <ospf|table> (1-65535) route-map WORD",
12207 "Redistribute information from another routing protocol\n"
12208 "Open Shortest Path First (OSPFv2)\n"
12209 "Non-main Kernel Routing Table\n"
12210 "Instance ID/Table ID\n"
12211 "Route map reference\n"
12212 "Pointer to route-map entries\n")
12214 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12215 bgp_redistribute_ipv4_ospf_metric_cmd
,
12216 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12217 "Redistribute information from another routing protocol\n"
12218 "Open Shortest Path First (OSPFv2)\n"
12219 "Non-main Kernel Routing Table\n"
12220 "Instance ID/Table ID\n"
12221 "Metric for redistributed routes\n"
12222 "Default metric\n")
12224 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12225 int idx_ospf_table
= 1;
12226 int idx_number
= 2;
12227 int idx_number_2
= 4;
12229 struct bgp_redist
*red
;
12230 unsigned short instance
;
12234 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12235 protocol
= ZEBRA_ROUTE_OSPF
;
12237 protocol
= ZEBRA_ROUTE_TABLE
;
12239 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12240 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12242 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12243 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12245 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12248 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12249 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12250 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12251 "Redistribute information from another routing protocol\n"
12252 "Open Shortest Path First (OSPFv2)\n"
12253 "Non-main Kernel Routing Table\n"
12254 "Instance ID/Table ID\n"
12255 "Metric for redistributed routes\n"
12256 "Default metric\n")
12258 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12259 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12260 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12261 "Redistribute information from another routing protocol\n"
12262 "Open Shortest Path First (OSPFv2)\n"
12263 "Non-main Kernel Routing Table\n"
12264 "Instance ID/Table ID\n"
12265 "Route map reference\n"
12266 "Pointer to route-map entries\n"
12267 "Metric for redistributed routes\n"
12268 "Default metric\n")
12270 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12271 int idx_ospf_table
= 1;
12272 int idx_number
= 2;
12274 int idx_number_2
= 6;
12276 struct bgp_redist
*red
;
12277 unsigned short instance
;
12280 struct route_map
*route_map
=
12281 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12283 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12284 protocol
= ZEBRA_ROUTE_OSPF
;
12286 protocol
= ZEBRA_ROUTE_TABLE
;
12288 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12289 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12291 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12293 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12294 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12296 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12300 bgp_redistribute_ipv4_ospf_rmap_metric
,
12301 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12302 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12303 "Redistribute information from another routing protocol\n"
12304 "Open Shortest Path First (OSPFv2)\n"
12305 "Non-main Kernel Routing Table\n"
12306 "Instance ID/Table ID\n"
12307 "Route map reference\n"
12308 "Pointer to route-map entries\n"
12309 "Metric for redistributed routes\n"
12310 "Default metric\n")
12312 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12313 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12314 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12315 "Redistribute information from another routing protocol\n"
12316 "Open Shortest Path First (OSPFv2)\n"
12317 "Non-main Kernel Routing Table\n"
12318 "Instance ID/Table ID\n"
12319 "Metric for redistributed routes\n"
12321 "Route map reference\n"
12322 "Pointer to route-map entries\n")
12324 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12325 int idx_ospf_table
= 1;
12326 int idx_number
= 2;
12327 int idx_number_2
= 4;
12330 struct bgp_redist
*red
;
12331 unsigned short instance
;
12334 struct route_map
*route_map
=
12335 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12337 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12338 protocol
= ZEBRA_ROUTE_OSPF
;
12340 protocol
= ZEBRA_ROUTE_TABLE
;
12342 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12343 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12345 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12346 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12349 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12350 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12354 bgp_redistribute_ipv4_ospf_metric_rmap
,
12355 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12356 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12357 "Redistribute information from another routing protocol\n"
12358 "Open Shortest Path First (OSPFv2)\n"
12359 "Non-main Kernel Routing Table\n"
12360 "Instance ID/Table ID\n"
12361 "Metric for redistributed routes\n"
12363 "Route map reference\n"
12364 "Pointer to route-map entries\n")
12366 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12367 no_bgp_redistribute_ipv4_ospf_cmd
,
12368 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12370 "Redistribute information from another routing protocol\n"
12371 "Open Shortest Path First (OSPFv2)\n"
12372 "Non-main Kernel Routing Table\n"
12373 "Instance ID/Table ID\n"
12374 "Metric for redistributed routes\n"
12376 "Route map reference\n"
12377 "Pointer to route-map entries\n")
12379 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12380 int idx_ospf_table
= 2;
12381 int idx_number
= 3;
12382 unsigned short instance
;
12385 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12386 protocol
= ZEBRA_ROUTE_OSPF
;
12388 protocol
= ZEBRA_ROUTE_TABLE
;
12390 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12391 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12395 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12396 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
12398 "Redistribute information from another routing protocol\n"
12399 "Open Shortest Path First (OSPFv2)\n"
12400 "Non-main Kernel Routing Table\n"
12401 "Instance ID/Table ID\n"
12402 "Metric for redistributed routes\n"
12404 "Route map reference\n"
12405 "Pointer to route-map entries\n")
12407 DEFUN (no_bgp_redistribute_ipv4
,
12408 no_bgp_redistribute_ipv4_cmd
,
12409 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12411 "Redistribute information from another routing protocol\n"
12412 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 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12419 int idx_protocol
= 2;
12422 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12424 vty_out(vty
, "%% Invalid route type\n");
12425 return CMD_WARNING_CONFIG_FAILED
;
12427 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12431 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12432 "no redistribute " FRR_IP_REDIST_STR_BGPD
12433 " [metric (0-4294967295)] [route-map WORD]",
12435 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12436 "Metric for redistributed routes\n"
12438 "Route map reference\n"
12439 "Pointer to route-map entries\n")
12441 DEFUN (bgp_redistribute_ipv6
,
12442 bgp_redistribute_ipv6_cmd
,
12443 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12444 "Redistribute information from another routing protocol\n"
12445 FRR_IP6_REDIST_HELP_STR_BGPD
)
12447 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12448 int idx_protocol
= 1;
12451 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12453 vty_out(vty
, "%% Invalid route type\n");
12454 return CMD_WARNING_CONFIG_FAILED
;
12457 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12458 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12461 DEFUN (bgp_redistribute_ipv6_rmap
,
12462 bgp_redistribute_ipv6_rmap_cmd
,
12463 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12464 "Redistribute information from another routing protocol\n"
12465 FRR_IP6_REDIST_HELP_STR_BGPD
12466 "Route map reference\n"
12467 "Pointer to route-map entries\n")
12469 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12470 int idx_protocol
= 1;
12473 struct bgp_redist
*red
;
12475 struct route_map
*route_map
=
12476 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12478 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12480 vty_out(vty
, "%% Invalid route type\n");
12481 return CMD_WARNING_CONFIG_FAILED
;
12484 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12486 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12487 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12490 DEFUN (bgp_redistribute_ipv6_metric
,
12491 bgp_redistribute_ipv6_metric_cmd
,
12492 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12493 "Redistribute information from another routing protocol\n"
12494 FRR_IP6_REDIST_HELP_STR_BGPD
12495 "Metric for redistributed routes\n"
12496 "Default metric\n")
12498 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12499 int idx_protocol
= 1;
12500 int idx_number
= 3;
12503 struct bgp_redist
*red
;
12506 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12508 vty_out(vty
, "%% Invalid route type\n");
12509 return CMD_WARNING_CONFIG_FAILED
;
12511 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12513 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12514 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12515 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12518 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12519 bgp_redistribute_ipv6_rmap_metric_cmd
,
12520 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12521 "Redistribute information from another routing protocol\n"
12522 FRR_IP6_REDIST_HELP_STR_BGPD
12523 "Route map reference\n"
12524 "Pointer to route-map entries\n"
12525 "Metric for redistributed routes\n"
12526 "Default metric\n")
12528 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12529 int idx_protocol
= 1;
12531 int idx_number
= 5;
12534 struct bgp_redist
*red
;
12536 struct route_map
*route_map
=
12537 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12539 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12541 vty_out(vty
, "%% Invalid route type\n");
12542 return CMD_WARNING_CONFIG_FAILED
;
12544 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12546 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12548 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12549 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12551 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12554 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12555 bgp_redistribute_ipv6_metric_rmap_cmd
,
12556 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12557 "Redistribute information from another routing protocol\n"
12558 FRR_IP6_REDIST_HELP_STR_BGPD
12559 "Metric for redistributed routes\n"
12561 "Route map reference\n"
12562 "Pointer to route-map entries\n")
12564 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12565 int idx_protocol
= 1;
12566 int idx_number
= 3;
12570 struct bgp_redist
*red
;
12572 struct route_map
*route_map
=
12573 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12575 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12577 vty_out(vty
, "%% Invalid route type\n");
12578 return CMD_WARNING_CONFIG_FAILED
;
12580 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12582 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12583 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12586 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12587 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12590 DEFUN (no_bgp_redistribute_ipv6
,
12591 no_bgp_redistribute_ipv6_cmd
,
12592 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12594 "Redistribute information from another routing protocol\n"
12595 FRR_IP6_REDIST_HELP_STR_BGPD
12596 "Metric for redistributed routes\n"
12598 "Route map reference\n"
12599 "Pointer to route-map entries\n")
12601 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12602 int idx_protocol
= 2;
12605 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12607 vty_out(vty
, "%% Invalid route type\n");
12608 return CMD_WARNING_CONFIG_FAILED
;
12611 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12614 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12619 /* Unicast redistribution only. */
12620 if (safi
!= SAFI_UNICAST
)
12623 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12624 /* Redistribute BGP does not make sense. */
12625 if (i
!= ZEBRA_ROUTE_BGP
) {
12626 struct list
*red_list
;
12627 struct listnode
*node
;
12628 struct bgp_redist
*red
;
12630 red_list
= bgp
->redist
[afi
][i
];
12634 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12635 /* "redistribute" configuration. */
12636 vty_out(vty
, " redistribute %s",
12637 zebra_route_string(i
));
12639 vty_out(vty
, " %d", red
->instance
);
12640 if (red
->redist_metric_flag
)
12641 vty_out(vty
, " metric %u",
12642 red
->redist_metric
);
12643 if (red
->rmap
.name
)
12644 vty_out(vty
, " route-map %s",
12646 vty_out(vty
, "\n");
12652 /* This is part of the address-family block (unicast only) */
12653 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12658 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12659 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12660 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12661 bgp
->vpn_policy
[afi
]
12662 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12664 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12665 bgp
->vpn_policy
[afi
]
12666 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12668 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12669 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12670 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12671 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12674 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12675 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12677 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12680 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12681 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12682 bgp
->vpn_policy
[afi
].tovpn_label
);
12685 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12686 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12687 char buf
[RD_ADDRSTRLEN
];
12688 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12689 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12692 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12693 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12695 char buf
[PREFIX_STRLEN
];
12696 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12697 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12700 vty_out(vty
, "%*snexthop vpn export %s\n",
12704 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12705 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12707 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12708 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12710 char *b
= ecommunity_ecom2str(
12711 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12712 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12713 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12714 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12716 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12717 char *b
= ecommunity_ecom2str(
12718 bgp
->vpn_policy
[afi
]
12719 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12720 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12721 ECOMMUNITY_ROUTE_TARGET
);
12722 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12723 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12725 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12726 char *b
= ecommunity_ecom2str(
12727 bgp
->vpn_policy
[afi
]
12728 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12729 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12730 ECOMMUNITY_ROUTE_TARGET
);
12731 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12732 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12736 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12737 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12738 bgp
->vpn_policy
[afi
]
12739 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12741 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12742 char *b
= ecommunity_ecom2str(
12743 bgp
->vpn_policy
[afi
]
12744 .import_redirect_rtlist
,
12745 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12746 ECOMMUNITY_ROUTE_TARGET
);
12748 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12749 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12754 /* BGP node structure. */
12755 static struct cmd_node bgp_node
= {
12756 BGP_NODE
, "%s(config-router)# ", 1,
12759 static struct cmd_node bgp_ipv4_unicast_node
= {
12760 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12763 static struct cmd_node bgp_ipv4_multicast_node
= {
12764 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12767 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12768 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12771 static struct cmd_node bgp_ipv6_unicast_node
= {
12772 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12775 static struct cmd_node bgp_ipv6_multicast_node
= {
12776 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12779 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12780 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12783 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12784 "%s(config-router-af)# ", 1};
12786 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12787 "%s(config-router-af-vpnv6)# ", 1};
12789 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12790 "%s(config-router-evpn)# ", 1};
12792 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12793 "%s(config-router-af-vni)# ", 1};
12795 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12796 "%s(config-router-af)# ", 1};
12798 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12799 "%s(config-router-af-vpnv6)# ", 1};
12801 static void community_list_vty(void);
12803 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12807 struct listnode
*lnbgp
, *lnpeer
;
12809 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12810 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12811 /* only provide suggestions on the appropriate input
12813 * they'll otherwise show up multiple times */
12814 enum cmd_token_type match_type
;
12815 char *name
= peer
->host
;
12817 if (peer
->conf_if
) {
12818 match_type
= VARIABLE_TKN
;
12819 name
= peer
->conf_if
;
12820 } else if (strchr(peer
->host
, ':'))
12821 match_type
= IPV6_TKN
;
12823 match_type
= IPV4_TKN
;
12825 if (token
->type
!= match_type
)
12828 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12833 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12834 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12835 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12836 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12837 {.completions
= NULL
}};
12839 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12842 struct peer_group
*group
;
12843 struct listnode
*lnbgp
, *lnpeer
;
12845 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12846 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12847 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12852 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12853 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12854 {.completions
= NULL
} };
12856 void bgp_vty_init(void)
12858 cmd_variable_handler_register(bgp_var_neighbor
);
12859 cmd_variable_handler_register(bgp_var_peergroup
);
12861 /* Install bgp top node. */
12862 install_node(&bgp_node
, bgp_config_write
);
12863 install_node(&bgp_ipv4_unicast_node
, NULL
);
12864 install_node(&bgp_ipv4_multicast_node
, NULL
);
12865 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12866 install_node(&bgp_ipv6_unicast_node
, NULL
);
12867 install_node(&bgp_ipv6_multicast_node
, NULL
);
12868 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12869 install_node(&bgp_vpnv4_node
, NULL
);
12870 install_node(&bgp_vpnv6_node
, NULL
);
12871 install_node(&bgp_evpn_node
, NULL
);
12872 install_node(&bgp_evpn_vni_node
, NULL
);
12873 install_node(&bgp_flowspecv4_node
, NULL
);
12874 install_node(&bgp_flowspecv6_node
, NULL
);
12876 /* Install default VTY commands to new nodes. */
12877 install_default(BGP_NODE
);
12878 install_default(BGP_IPV4_NODE
);
12879 install_default(BGP_IPV4M_NODE
);
12880 install_default(BGP_IPV4L_NODE
);
12881 install_default(BGP_IPV6_NODE
);
12882 install_default(BGP_IPV6M_NODE
);
12883 install_default(BGP_IPV6L_NODE
);
12884 install_default(BGP_VPNV4_NODE
);
12885 install_default(BGP_VPNV6_NODE
);
12886 install_default(BGP_FLOWSPECV4_NODE
);
12887 install_default(BGP_FLOWSPECV6_NODE
);
12888 install_default(BGP_EVPN_NODE
);
12889 install_default(BGP_EVPN_VNI_NODE
);
12891 /* "bgp multiple-instance" commands. */
12892 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12893 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12895 /* "bgp config-type" commands. */
12896 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12897 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12899 /* "bgp local-mac" hidden commands. */
12900 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
12901 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
12903 /* bgp route-map delay-timer commands. */
12904 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12905 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12907 /* Dummy commands (Currently not supported) */
12908 install_element(BGP_NODE
, &no_synchronization_cmd
);
12909 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12911 /* "router bgp" commands. */
12912 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12914 /* "no router bgp" commands. */
12915 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12917 /* "bgp router-id" commands. */
12918 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12919 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12921 /* "bgp cluster-id" commands. */
12922 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12923 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12925 /* "bgp confederation" commands. */
12926 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12927 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12929 /* "bgp confederation peers" commands. */
12930 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12931 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12933 /* bgp max-med command */
12934 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12935 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12936 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12937 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12938 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12940 /* bgp disable-ebgp-connected-nh-check */
12941 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12942 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12944 /* bgp update-delay command */
12945 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12946 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12947 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12949 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12950 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12951 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12952 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12954 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12955 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12957 /* "maximum-paths" commands. */
12958 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12959 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12960 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12961 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12962 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12963 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12964 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12965 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12966 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12967 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12968 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12969 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12970 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12971 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12972 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12974 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12975 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12976 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12977 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12978 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12980 /* "timers bgp" commands. */
12981 install_element(BGP_NODE
, &bgp_timers_cmd
);
12982 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12984 /* route-map delay-timer commands - per instance for backwards compat.
12986 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12987 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12989 /* "bgp client-to-client reflection" commands */
12990 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12991 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12993 /* "bgp always-compare-med" commands */
12994 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12995 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12997 /* bgp ebgp-requires-policy */
12998 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
12999 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
13001 /* "bgp deterministic-med" commands */
13002 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
13003 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
13005 /* "bgp graceful-restart" commands */
13006 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
13007 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
13008 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
13009 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
13010 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
13011 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
13013 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
13014 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
13016 /* "bgp graceful-shutdown" commands */
13017 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
13018 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13020 /* "bgp fast-external-failover" commands */
13021 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13022 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13024 /* "bgp enforce-first-as" commands */
13025 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
13027 /* "bgp bestpath compare-routerid" commands */
13028 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13029 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13031 /* "bgp bestpath as-path ignore" commands */
13032 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13033 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13035 /* "bgp bestpath as-path confed" commands */
13036 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13037 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13039 /* "bgp bestpath as-path multipath-relax" commands */
13040 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13041 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13043 /* "bgp log-neighbor-changes" commands */
13044 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13045 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13047 /* "bgp bestpath med" commands */
13048 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13049 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13051 /* "no bgp default ipv4-unicast" commands. */
13052 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13053 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13055 /* "bgp network import-check" commands. */
13056 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13057 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13058 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13060 /* "bgp default local-preference" commands. */
13061 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13062 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13064 /* bgp default show-hostname */
13065 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13066 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13068 /* "bgp default subgroup-pkt-queue-max" commands. */
13069 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13070 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13072 /* bgp ibgp-allow-policy-mods command */
13073 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13074 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13076 /* "bgp listen limit" commands. */
13077 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13078 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13080 /* "bgp listen range" commands. */
13081 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13082 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13084 /* "bgp default shutdown" command */
13085 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13087 /* "neighbor remote-as" commands. */
13088 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13089 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13090 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13091 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13092 install_element(BGP_NODE
,
13093 &neighbor_interface_v6only_config_remote_as_cmd
);
13094 install_element(BGP_NODE
, &no_neighbor_cmd
);
13095 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13097 /* "neighbor peer-group" commands. */
13098 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13099 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13100 install_element(BGP_NODE
,
13101 &no_neighbor_interface_peer_group_remote_as_cmd
);
13103 /* "neighbor local-as" commands. */
13104 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13105 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13106 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13107 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13109 /* "neighbor solo" commands. */
13110 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13111 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13113 /* "neighbor password" commands. */
13114 install_element(BGP_NODE
, &neighbor_password_cmd
);
13115 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13117 /* "neighbor activate" commands. */
13118 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13119 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13120 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13121 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13122 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13123 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13124 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13125 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13126 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13127 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13128 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13129 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13131 /* "no neighbor activate" commands. */
13132 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13133 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13134 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13135 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13136 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13137 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13138 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13139 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13140 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13141 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13142 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13143 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13145 /* "neighbor peer-group" set commands. */
13146 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13147 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13148 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13149 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13150 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13151 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13152 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13153 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13154 install_element(BGP_FLOWSPECV4_NODE
,
13155 &neighbor_set_peer_group_hidden_cmd
);
13156 install_element(BGP_FLOWSPECV6_NODE
,
13157 &neighbor_set_peer_group_hidden_cmd
);
13159 /* "no neighbor peer-group unset" commands. */
13160 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13161 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13162 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13163 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13164 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13165 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13166 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13167 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13168 install_element(BGP_FLOWSPECV4_NODE
,
13169 &no_neighbor_set_peer_group_hidden_cmd
);
13170 install_element(BGP_FLOWSPECV6_NODE
,
13171 &no_neighbor_set_peer_group_hidden_cmd
);
13173 /* "neighbor softreconfiguration inbound" commands.*/
13174 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13175 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13176 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13177 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13178 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13179 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13180 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13181 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13182 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13183 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13184 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13185 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13186 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13187 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13188 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13189 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13190 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13191 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13192 install_element(BGP_FLOWSPECV4_NODE
,
13193 &neighbor_soft_reconfiguration_cmd
);
13194 install_element(BGP_FLOWSPECV4_NODE
,
13195 &no_neighbor_soft_reconfiguration_cmd
);
13196 install_element(BGP_FLOWSPECV6_NODE
,
13197 &neighbor_soft_reconfiguration_cmd
);
13198 install_element(BGP_FLOWSPECV6_NODE
,
13199 &no_neighbor_soft_reconfiguration_cmd
);
13200 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13201 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13203 /* "neighbor attribute-unchanged" commands. */
13204 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13205 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13206 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13207 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13208 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13209 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13210 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13211 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13212 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13213 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13214 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13215 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13216 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13217 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13218 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13219 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13220 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13221 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13223 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13224 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13226 /* "nexthop-local unchanged" commands */
13227 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13228 install_element(BGP_IPV6_NODE
,
13229 &no_neighbor_nexthop_local_unchanged_cmd
);
13231 /* "neighbor next-hop-self" commands. */
13232 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13233 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13234 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13235 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13236 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13237 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13238 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13239 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13240 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13241 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13242 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13243 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13244 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13245 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13246 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13247 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13248 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13249 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13250 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13251 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13253 /* "neighbor next-hop-self force" commands. */
13254 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13255 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13256 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13257 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13258 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13259 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13260 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13261 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13262 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13263 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13264 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13265 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13266 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13267 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13268 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13269 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13270 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13271 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13273 /* "neighbor as-override" commands. */
13274 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13275 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13276 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13277 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13278 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13279 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13280 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13281 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13282 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13283 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13284 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13285 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13286 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13287 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13288 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13289 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13290 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13291 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13293 /* "neighbor remove-private-AS" commands. */
13294 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13295 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13296 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13297 install_element(BGP_NODE
,
13298 &no_neighbor_remove_private_as_all_hidden_cmd
);
13299 install_element(BGP_NODE
,
13300 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13301 install_element(BGP_NODE
,
13302 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13303 install_element(BGP_NODE
,
13304 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13307 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13308 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13309 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13310 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13311 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13312 install_element(BGP_IPV4_NODE
,
13313 &neighbor_remove_private_as_replace_as_cmd
);
13314 install_element(BGP_IPV4_NODE
,
13315 &no_neighbor_remove_private_as_replace_as_cmd
);
13316 install_element(BGP_IPV4_NODE
,
13317 &neighbor_remove_private_as_all_replace_as_cmd
);
13318 install_element(BGP_IPV4_NODE
,
13319 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13320 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13321 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13322 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13323 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13324 install_element(BGP_IPV4M_NODE
,
13325 &neighbor_remove_private_as_replace_as_cmd
);
13326 install_element(BGP_IPV4M_NODE
,
13327 &no_neighbor_remove_private_as_replace_as_cmd
);
13328 install_element(BGP_IPV4M_NODE
,
13329 &neighbor_remove_private_as_all_replace_as_cmd
);
13330 install_element(BGP_IPV4M_NODE
,
13331 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13332 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13333 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13334 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13335 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13336 install_element(BGP_IPV4L_NODE
,
13337 &neighbor_remove_private_as_replace_as_cmd
);
13338 install_element(BGP_IPV4L_NODE
,
13339 &no_neighbor_remove_private_as_replace_as_cmd
);
13340 install_element(BGP_IPV4L_NODE
,
13341 &neighbor_remove_private_as_all_replace_as_cmd
);
13342 install_element(BGP_IPV4L_NODE
,
13343 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13344 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13345 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13346 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13347 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13348 install_element(BGP_IPV6_NODE
,
13349 &neighbor_remove_private_as_replace_as_cmd
);
13350 install_element(BGP_IPV6_NODE
,
13351 &no_neighbor_remove_private_as_replace_as_cmd
);
13352 install_element(BGP_IPV6_NODE
,
13353 &neighbor_remove_private_as_all_replace_as_cmd
);
13354 install_element(BGP_IPV6_NODE
,
13355 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13356 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13357 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13358 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13359 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13360 install_element(BGP_IPV6M_NODE
,
13361 &neighbor_remove_private_as_replace_as_cmd
);
13362 install_element(BGP_IPV6M_NODE
,
13363 &no_neighbor_remove_private_as_replace_as_cmd
);
13364 install_element(BGP_IPV6M_NODE
,
13365 &neighbor_remove_private_as_all_replace_as_cmd
);
13366 install_element(BGP_IPV6M_NODE
,
13367 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13368 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13369 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13370 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13371 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13372 install_element(BGP_IPV6L_NODE
,
13373 &neighbor_remove_private_as_replace_as_cmd
);
13374 install_element(BGP_IPV6L_NODE
,
13375 &no_neighbor_remove_private_as_replace_as_cmd
);
13376 install_element(BGP_IPV6L_NODE
,
13377 &neighbor_remove_private_as_all_replace_as_cmd
);
13378 install_element(BGP_IPV6L_NODE
,
13379 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13380 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13381 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13382 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13383 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13384 install_element(BGP_VPNV4_NODE
,
13385 &neighbor_remove_private_as_replace_as_cmd
);
13386 install_element(BGP_VPNV4_NODE
,
13387 &no_neighbor_remove_private_as_replace_as_cmd
);
13388 install_element(BGP_VPNV4_NODE
,
13389 &neighbor_remove_private_as_all_replace_as_cmd
);
13390 install_element(BGP_VPNV4_NODE
,
13391 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13392 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13393 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13394 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13395 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13396 install_element(BGP_VPNV6_NODE
,
13397 &neighbor_remove_private_as_replace_as_cmd
);
13398 install_element(BGP_VPNV6_NODE
,
13399 &no_neighbor_remove_private_as_replace_as_cmd
);
13400 install_element(BGP_VPNV6_NODE
,
13401 &neighbor_remove_private_as_all_replace_as_cmd
);
13402 install_element(BGP_VPNV6_NODE
,
13403 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13405 /* "neighbor send-community" commands.*/
13406 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13407 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13408 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13409 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13410 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13411 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13412 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13413 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13414 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13415 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13416 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13417 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13418 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13419 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13420 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13421 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13422 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13423 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13424 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13425 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13426 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13427 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13428 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13429 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13430 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13431 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13432 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13433 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13434 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13435 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13436 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13437 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13438 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13439 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13440 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13441 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13443 /* "neighbor route-reflector" commands.*/
13444 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13445 install_element(BGP_NODE
,
13446 &no_neighbor_route_reflector_client_hidden_cmd
);
13447 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13448 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13449 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13450 install_element(BGP_IPV4M_NODE
,
13451 &no_neighbor_route_reflector_client_cmd
);
13452 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13453 install_element(BGP_IPV4L_NODE
,
13454 &no_neighbor_route_reflector_client_cmd
);
13455 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13456 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13457 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13458 install_element(BGP_IPV6M_NODE
,
13459 &no_neighbor_route_reflector_client_cmd
);
13460 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13461 install_element(BGP_IPV6L_NODE
,
13462 &no_neighbor_route_reflector_client_cmd
);
13463 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13464 install_element(BGP_VPNV4_NODE
,
13465 &no_neighbor_route_reflector_client_cmd
);
13466 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13467 install_element(BGP_VPNV6_NODE
,
13468 &no_neighbor_route_reflector_client_cmd
);
13469 install_element(BGP_FLOWSPECV4_NODE
,
13470 &neighbor_route_reflector_client_cmd
);
13471 install_element(BGP_FLOWSPECV4_NODE
,
13472 &no_neighbor_route_reflector_client_cmd
);
13473 install_element(BGP_FLOWSPECV6_NODE
,
13474 &neighbor_route_reflector_client_cmd
);
13475 install_element(BGP_FLOWSPECV6_NODE
,
13476 &no_neighbor_route_reflector_client_cmd
);
13477 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13478 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13480 /* "neighbor route-server" commands.*/
13481 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13482 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13483 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13484 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13485 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13486 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13487 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13488 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13489 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13490 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13491 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13492 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13493 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13494 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13495 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13496 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13497 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13498 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13499 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13500 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13501 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13502 install_element(BGP_FLOWSPECV4_NODE
,
13503 &no_neighbor_route_server_client_cmd
);
13504 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13505 install_element(BGP_FLOWSPECV6_NODE
,
13506 &no_neighbor_route_server_client_cmd
);
13508 /* "neighbor addpath-tx-all-paths" commands.*/
13509 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13510 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13511 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13512 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13513 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13514 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13515 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13516 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13517 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13518 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13519 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13520 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13521 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13522 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13523 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13524 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13525 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13526 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13528 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13529 install_element(BGP_NODE
,
13530 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13531 install_element(BGP_NODE
,
13532 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13533 install_element(BGP_IPV4_NODE
,
13534 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13535 install_element(BGP_IPV4_NODE
,
13536 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13537 install_element(BGP_IPV4M_NODE
,
13538 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13539 install_element(BGP_IPV4M_NODE
,
13540 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13541 install_element(BGP_IPV4L_NODE
,
13542 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13543 install_element(BGP_IPV4L_NODE
,
13544 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13545 install_element(BGP_IPV6_NODE
,
13546 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13547 install_element(BGP_IPV6_NODE
,
13548 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13549 install_element(BGP_IPV6M_NODE
,
13550 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13551 install_element(BGP_IPV6M_NODE
,
13552 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13553 install_element(BGP_IPV6L_NODE
,
13554 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13555 install_element(BGP_IPV6L_NODE
,
13556 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13557 install_element(BGP_VPNV4_NODE
,
13558 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13559 install_element(BGP_VPNV4_NODE
,
13560 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13561 install_element(BGP_VPNV6_NODE
,
13562 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13563 install_element(BGP_VPNV6_NODE
,
13564 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13566 /* "neighbor passive" commands. */
13567 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13568 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13571 /* "neighbor shutdown" commands. */
13572 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13573 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13574 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13575 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13577 /* "neighbor capability extended-nexthop" commands.*/
13578 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13579 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13581 /* "neighbor capability orf prefix-list" commands.*/
13582 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13583 install_element(BGP_NODE
,
13584 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13585 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13586 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13587 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13588 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13589 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13590 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13591 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13592 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13593 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13594 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13595 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13596 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13598 /* "neighbor capability dynamic" commands.*/
13599 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13600 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13602 /* "neighbor dont-capability-negotiate" commands. */
13603 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13604 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13606 /* "neighbor ebgp-multihop" commands. */
13607 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13608 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13609 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13611 /* "neighbor disable-connected-check" commands. */
13612 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13613 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13615 /* "neighbor enforce-first-as" commands. */
13616 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13617 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13619 /* "neighbor description" commands. */
13620 install_element(BGP_NODE
, &neighbor_description_cmd
);
13621 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13622 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13624 /* "neighbor update-source" commands. "*/
13625 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13626 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13628 /* "neighbor default-originate" commands. */
13629 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13630 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13631 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13632 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13633 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13634 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13635 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13636 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13637 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13638 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13639 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13640 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13641 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13642 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13643 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13644 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13645 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13646 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13647 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13648 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13649 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13651 /* "neighbor port" commands. */
13652 install_element(BGP_NODE
, &neighbor_port_cmd
);
13653 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13655 /* "neighbor weight" commands. */
13656 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13657 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13659 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13660 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13661 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13662 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13663 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13664 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13665 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13666 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13667 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13668 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13669 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13670 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13671 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13672 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13673 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13674 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13676 /* "neighbor override-capability" commands. */
13677 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13678 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13680 /* "neighbor strict-capability-match" commands. */
13681 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13682 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13684 /* "neighbor timers" commands. */
13685 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13686 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13688 /* "neighbor timers connect" commands. */
13689 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13690 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13692 /* "neighbor advertisement-interval" commands. */
13693 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13694 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13696 /* "neighbor interface" commands. */
13697 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13698 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13700 /* "neighbor distribute" commands. */
13701 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13702 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13703 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13704 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13705 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13706 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13707 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13708 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13709 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13710 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13711 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13712 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13713 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13714 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13715 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13716 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13717 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13718 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13720 /* "neighbor prefix-list" commands. */
13721 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13722 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13723 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13724 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13725 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13726 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13727 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13728 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13729 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13730 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13731 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13732 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13733 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13734 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13735 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13736 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13737 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13738 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13739 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13740 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13741 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13742 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13744 /* "neighbor filter-list" commands. */
13745 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13746 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13747 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13748 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13749 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13750 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13751 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13752 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13753 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13754 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13755 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13756 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13757 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13758 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13759 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13760 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13761 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13762 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13763 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13764 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13765 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13766 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13768 /* "neighbor route-map" commands. */
13769 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13770 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13771 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13772 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13773 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13774 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13775 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13776 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13777 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13778 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13779 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13780 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13781 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13782 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13783 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13784 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13785 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13786 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13787 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13788 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13789 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13790 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13791 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13792 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13794 /* "neighbor unsuppress-map" commands. */
13795 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13796 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13797 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13798 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13799 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13800 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13801 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13802 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13803 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13804 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13805 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13806 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13807 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13808 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13809 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13810 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13811 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13812 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13814 /* "neighbor maximum-prefix" commands. */
13815 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13816 install_element(BGP_NODE
,
13817 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13818 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13819 install_element(BGP_NODE
,
13820 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13821 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13822 install_element(BGP_NODE
,
13823 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13824 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13825 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13826 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13827 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13828 install_element(BGP_IPV4_NODE
,
13829 &neighbor_maximum_prefix_threshold_warning_cmd
);
13830 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13831 install_element(BGP_IPV4_NODE
,
13832 &neighbor_maximum_prefix_threshold_restart_cmd
);
13833 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13834 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13835 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13836 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13837 install_element(BGP_IPV4M_NODE
,
13838 &neighbor_maximum_prefix_threshold_warning_cmd
);
13839 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13840 install_element(BGP_IPV4M_NODE
,
13841 &neighbor_maximum_prefix_threshold_restart_cmd
);
13842 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13843 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13844 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13845 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13846 install_element(BGP_IPV4L_NODE
,
13847 &neighbor_maximum_prefix_threshold_warning_cmd
);
13848 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13849 install_element(BGP_IPV4L_NODE
,
13850 &neighbor_maximum_prefix_threshold_restart_cmd
);
13851 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13852 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13853 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13854 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13855 install_element(BGP_IPV6_NODE
,
13856 &neighbor_maximum_prefix_threshold_warning_cmd
);
13857 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13858 install_element(BGP_IPV6_NODE
,
13859 &neighbor_maximum_prefix_threshold_restart_cmd
);
13860 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13861 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13862 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13863 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13864 install_element(BGP_IPV6M_NODE
,
13865 &neighbor_maximum_prefix_threshold_warning_cmd
);
13866 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13867 install_element(BGP_IPV6M_NODE
,
13868 &neighbor_maximum_prefix_threshold_restart_cmd
);
13869 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13870 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13871 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13872 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13873 install_element(BGP_IPV6L_NODE
,
13874 &neighbor_maximum_prefix_threshold_warning_cmd
);
13875 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13876 install_element(BGP_IPV6L_NODE
,
13877 &neighbor_maximum_prefix_threshold_restart_cmd
);
13878 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13879 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13880 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13881 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13882 install_element(BGP_VPNV4_NODE
,
13883 &neighbor_maximum_prefix_threshold_warning_cmd
);
13884 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13885 install_element(BGP_VPNV4_NODE
,
13886 &neighbor_maximum_prefix_threshold_restart_cmd
);
13887 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13888 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13889 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13890 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13891 install_element(BGP_VPNV6_NODE
,
13892 &neighbor_maximum_prefix_threshold_warning_cmd
);
13893 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13894 install_element(BGP_VPNV6_NODE
,
13895 &neighbor_maximum_prefix_threshold_restart_cmd
);
13896 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13898 /* "neighbor allowas-in" */
13899 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13900 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13901 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13902 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13903 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13904 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13905 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13906 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13907 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13908 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13909 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13910 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13911 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13912 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13913 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13914 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13915 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13916 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13917 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13918 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13920 /* address-family commands. */
13921 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13922 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13923 #ifdef KEEP_OLD_VPN_COMMANDS
13924 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13925 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13926 #endif /* KEEP_OLD_VPN_COMMANDS */
13928 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13930 /* "exit-address-family" command. */
13931 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13932 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13933 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13934 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13935 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13936 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13937 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13938 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13939 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13940 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13941 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13943 /* "clear ip bgp commands" */
13944 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13946 /* clear ip bgp prefix */
13947 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13948 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13949 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13951 /* "show [ip] bgp summary" commands. */
13952 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13953 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
13954 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13955 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13956 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13957 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13958 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13960 /* "show [ip] bgp neighbors" commands. */
13961 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13963 /* "show [ip] bgp peer-group" commands. */
13964 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13966 /* "show [ip] bgp paths" commands. */
13967 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13969 /* "show [ip] bgp community" commands. */
13970 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13972 /* "show ip bgp large-community" commands. */
13973 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13974 /* "show [ip] bgp attribute-info" commands. */
13975 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13976 /* "show [ip] bgp route-leak" command */
13977 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13979 /* "redistribute" commands. */
13980 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13981 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13982 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13983 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13984 install_element(BGP_NODE
,
13985 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13986 install_element(BGP_NODE
,
13987 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13988 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13989 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13990 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13991 install_element(BGP_NODE
,
13992 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13993 install_element(BGP_NODE
,
13994 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13995 install_element(BGP_NODE
,
13996 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13997 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13998 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13999 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
14000 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
14001 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
14002 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
14003 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
14004 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
14005 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
14006 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
14007 install_element(BGP_IPV4_NODE
,
14008 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
14009 install_element(BGP_IPV4_NODE
,
14010 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
14011 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
14012 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
14013 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
14014 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
14015 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
14016 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
14018 /* import|export vpn [route-map WORD] */
14019 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14020 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14022 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14023 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14025 /* ttl_security commands */
14026 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14027 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14029 /* "show [ip] bgp memory" commands. */
14030 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14032 /* "show bgp martian next-hop" */
14033 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14035 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14037 /* "show [ip] bgp views" commands. */
14038 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14040 /* "show [ip] bgp vrfs" commands. */
14041 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14043 /* Community-list. */
14044 community_list_vty();
14046 /* vpn-policy commands */
14047 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14048 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14049 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14050 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14051 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14052 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14053 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14054 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14055 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14056 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14057 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14058 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14060 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14061 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14063 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14064 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14065 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14066 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14067 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14068 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14069 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14070 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14071 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14072 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14073 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14074 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14077 #include "memory.h"
14078 #include "bgp_regex.h"
14079 #include "bgp_clist.h"
14080 #include "bgp_ecommunity.h"
14082 /* VTY functions. */
14084 /* Direction value to string conversion. */
14085 static const char *community_direct_str(int direct
)
14088 case COMMUNITY_DENY
:
14090 case COMMUNITY_PERMIT
:
14097 /* Display error string. */
14098 static void community_list_perror(struct vty
*vty
, int ret
)
14101 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14102 vty_out(vty
, "%% Can't find community-list\n");
14104 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14105 vty_out(vty
, "%% Malformed community-list value\n");
14107 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14109 "%% Community name conflict, previously defined as standard community\n");
14111 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14113 "%% Community name conflict, previously defined as expanded community\n");
14118 /* "community-list" keyword help string. */
14119 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14121 /*community-list standard */
14122 DEFUN (community_list_standard
,
14123 bgp_community_list_standard_cmd
,
14124 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14127 "Community list number (standard)\n"
14128 "Add an standard community-list entry\n"
14129 "Community list name\n"
14130 "Specify community to reject\n"
14131 "Specify community to accept\n"
14134 char *cl_name_or_number
= NULL
;
14136 int style
= COMMUNITY_LIST_STANDARD
;
14140 if (argv_find(argv
, argc
, "ip", &idx
)) {
14141 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14142 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14143 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14144 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14147 argv_find(argv
, argc
, "(1-99)", &idx
);
14148 argv_find(argv
, argc
, "WORD", &idx
);
14149 cl_name_or_number
= argv
[idx
]->arg
;
14150 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14152 argv_find(argv
, argc
, "AA:NN", &idx
);
14153 char *str
= argv_concat(argv
, argc
, idx
);
14155 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14158 XFREE(MTYPE_TMP
, str
);
14161 /* Display error string. */
14162 community_list_perror(vty
, ret
);
14163 return CMD_WARNING_CONFIG_FAILED
;
14166 return CMD_SUCCESS
;
14169 #if CONFDATE > 20191005
14170 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14172 ALIAS (community_list_standard
,
14173 ip_community_list_standard_cmd
,
14174 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14177 "Community list number (standard)\n"
14178 "Add an standard community-list entry\n"
14179 "Community list name\n"
14180 "Specify community to reject\n"
14181 "Specify community to accept\n"
14184 DEFUN (no_community_list_standard_all
,
14185 no_bgp_community_list_standard_all_cmd
,
14186 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14190 "Community list number (standard)\n"
14191 "Add an standard community-list entry\n"
14192 "Community list name\n"
14193 "Specify community to reject\n"
14194 "Specify community to accept\n"
14197 char *cl_name_or_number
= NULL
;
14200 int style
= COMMUNITY_LIST_STANDARD
;
14204 if (argv_find(argv
, argc
, "ip", &idx
)) {
14205 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14206 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14207 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14208 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14211 argv_find(argv
, argc
, "permit", &idx
);
14212 argv_find(argv
, argc
, "deny", &idx
);
14215 direct
= argv_find(argv
, argc
, "permit", &idx
)
14220 argv_find(argv
, argc
, "AA:NN", &idx
);
14221 str
= argv_concat(argv
, argc
, idx
);
14225 argv_find(argv
, argc
, "(1-99)", &idx
);
14226 argv_find(argv
, argc
, "WORD", &idx
);
14227 cl_name_or_number
= argv
[idx
]->arg
;
14229 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14232 XFREE(MTYPE_TMP
, str
);
14235 community_list_perror(vty
, ret
);
14236 return CMD_WARNING_CONFIG_FAILED
;
14239 return CMD_SUCCESS
;
14241 ALIAS (no_community_list_standard_all
,
14242 no_ip_community_list_standard_all_cmd
,
14243 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14247 "Community list number (standard)\n"
14248 "Add an standard community-list entry\n"
14249 "Community list name\n"
14250 "Specify community to reject\n"
14251 "Specify community to accept\n"
14254 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14255 "no bgp community-list <(1-99)|standard WORD>",
14256 NO_STR BGP_STR COMMUNITY_LIST_STR
14257 "Community list number (standard)\n"
14258 "Add an standard community-list entry\n"
14259 "Community list name\n")
14261 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14262 "no ip community-list <(1-99)|standard WORD>",
14263 NO_STR BGP_STR COMMUNITY_LIST_STR
14264 "Community list number (standard)\n"
14265 "Add an standard community-list entry\n"
14266 "Community list name\n")
14268 /*community-list expanded */
14269 DEFUN (community_list_expanded_all
,
14270 bgp_community_list_expanded_all_cmd
,
14271 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14274 "Community list number (expanded)\n"
14275 "Add an expanded community-list entry\n"
14276 "Community list name\n"
14277 "Specify community to reject\n"
14278 "Specify community to accept\n"
14281 char *cl_name_or_number
= NULL
;
14283 int style
= COMMUNITY_LIST_EXPANDED
;
14286 if (argv_find(argv
, argc
, "ip", &idx
)) {
14287 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14288 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14289 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14290 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14292 argv_find(argv
, argc
, "(100-500)", &idx
);
14293 argv_find(argv
, argc
, "WORD", &idx
);
14294 cl_name_or_number
= argv
[idx
]->arg
;
14295 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14297 argv_find(argv
, argc
, "AA:NN", &idx
);
14298 char *str
= argv_concat(argv
, argc
, idx
);
14300 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14303 XFREE(MTYPE_TMP
, str
);
14306 /* Display error string. */
14307 community_list_perror(vty
, ret
);
14308 return CMD_WARNING_CONFIG_FAILED
;
14311 return CMD_SUCCESS
;
14314 ALIAS (community_list_expanded_all
,
14315 ip_community_list_expanded_all_cmd
,
14316 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14319 "Community list number (expanded)\n"
14320 "Add an expanded community-list entry\n"
14321 "Community list name\n"
14322 "Specify community to reject\n"
14323 "Specify community to accept\n"
14326 DEFUN (no_community_list_expanded_all
,
14327 no_bgp_community_list_expanded_all_cmd
,
14328 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14332 "Community list number (expanded)\n"
14333 "Add an expanded community-list entry\n"
14334 "Community list name\n"
14335 "Specify community to reject\n"
14336 "Specify community to accept\n"
14339 char *cl_name_or_number
= NULL
;
14342 int style
= COMMUNITY_LIST_EXPANDED
;
14345 if (argv_find(argv
, argc
, "ip", &idx
)) {
14346 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14347 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14348 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14349 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14353 argv_find(argv
, argc
, "permit", &idx
);
14354 argv_find(argv
, argc
, "deny", &idx
);
14357 direct
= argv_find(argv
, argc
, "permit", &idx
)
14362 argv_find(argv
, argc
, "AA:NN", &idx
);
14363 str
= argv_concat(argv
, argc
, idx
);
14367 argv_find(argv
, argc
, "(100-500)", &idx
);
14368 argv_find(argv
, argc
, "WORD", &idx
);
14369 cl_name_or_number
= argv
[idx
]->arg
;
14371 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14374 XFREE(MTYPE_TMP
, str
);
14377 community_list_perror(vty
, ret
);
14378 return CMD_WARNING_CONFIG_FAILED
;
14381 return CMD_SUCCESS
;
14384 ALIAS (no_community_list_expanded_all
,
14385 no_ip_community_list_expanded_all_cmd
,
14386 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14390 "Community list number (expanded)\n"
14391 "Add an expanded community-list entry\n"
14392 "Community list name\n"
14393 "Specify community to reject\n"
14394 "Specify community to accept\n"
14397 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14398 "no bgp community-list <(100-500)|expanded WORD>",
14399 NO_STR IP_STR COMMUNITY_LIST_STR
14400 "Community list number (expanded)\n"
14401 "Add an expanded community-list entry\n"
14402 "Community list name\n")
14404 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14405 "no ip community-list <(100-500)|expanded WORD>",
14406 NO_STR IP_STR COMMUNITY_LIST_STR
14407 "Community list number (expanded)\n"
14408 "Add an expanded community-list entry\n"
14409 "Community list name\n")
14411 /* Return configuration string of community-list entry. */
14412 static const char *community_list_config_str(struct community_entry
*entry
)
14419 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14420 str
= community_str(entry
->u
.com
, false);
14421 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14422 str
= lcommunity_str(entry
->u
.lcom
, false);
14424 str
= entry
->config
;
14429 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14431 struct community_entry
*entry
;
14433 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14434 if (entry
== list
->head
) {
14435 if (all_digit(list
->name
))
14436 vty_out(vty
, "Community %s list %s\n",
14437 entry
->style
== COMMUNITY_LIST_STANDARD
14439 : "(expanded) access",
14442 vty_out(vty
, "Named Community %s list %s\n",
14443 entry
->style
== COMMUNITY_LIST_STANDARD
14449 vty_out(vty
, " %s\n",
14450 community_direct_str(entry
->direct
));
14452 vty_out(vty
, " %s %s\n",
14453 community_direct_str(entry
->direct
),
14454 community_list_config_str(entry
));
14458 DEFUN (show_community_list
,
14459 show_bgp_community_list_cmd
,
14460 "show bgp community-list",
14463 "List community-list\n")
14465 struct community_list
*list
;
14466 struct community_list_master
*cm
;
14469 if (argv_find(argv
, argc
, "ip", &idx
)) {
14470 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14471 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14472 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14473 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14475 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14477 return CMD_SUCCESS
;
14479 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14480 community_list_show(vty
, list
);
14482 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14483 community_list_show(vty
, list
);
14485 return CMD_SUCCESS
;
14488 ALIAS (show_community_list
,
14489 show_ip_community_list_cmd
,
14490 "show ip community-list",
14493 "List community-list\n")
14495 DEFUN (show_community_list_arg
,
14496 show_bgp_community_list_arg_cmd
,
14497 "show bgp community-list <(1-500)|WORD>",
14500 "List community-list\n"
14501 "Community-list number\n"
14502 "Community-list name\n")
14504 int idx_comm_list
= 3;
14505 struct community_list
*list
;
14508 if (argv_find(argv
, argc
, "ip", &idx
)) {
14509 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14510 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14511 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14512 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14514 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14515 COMMUNITY_LIST_MASTER
);
14517 vty_out(vty
, "%% Can't find community-list\n");
14518 return CMD_WARNING
;
14521 community_list_show(vty
, list
);
14523 return CMD_SUCCESS
;
14526 ALIAS (show_community_list_arg
,
14527 show_ip_community_list_arg_cmd
,
14528 "show ip community-list <(1-500)|WORD>",
14531 "List community-list\n"
14532 "Community-list number\n"
14533 "Community-list name\n")
14536 * Large Community code.
14538 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14539 struct cmd_token
**argv
, int style
,
14540 int reject_all_digit_name
)
14548 if (argv_find(argv
, argc
, "ip", &idx
)) {
14549 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14550 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14551 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14552 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14554 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14557 /* All digit name check. */
14559 argv_find(argv
, argc
, "WORD", &idx
);
14560 argv_find(argv
, argc
, "(1-99)", &idx
);
14561 argv_find(argv
, argc
, "(100-500)", &idx
);
14562 cl_name
= argv
[idx
]->arg
;
14563 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14564 vty_out(vty
, "%% Community name cannot have all digits\n");
14565 return CMD_WARNING_CONFIG_FAILED
;
14569 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14570 argv_find(argv
, argc
, "LINE", &idx
);
14571 /* Concat community string argument. */
14573 str
= argv_concat(argv
, argc
, idx
);
14577 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14579 /* Free temporary community list string allocated by
14581 XFREE(MTYPE_TMP
, str
);
14584 community_list_perror(vty
, ret
);
14585 return CMD_WARNING_CONFIG_FAILED
;
14587 return CMD_SUCCESS
;
14590 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14591 struct cmd_token
**argv
, int style
)
14598 if (argv_find(argv
, argc
, "ip", &idx
)) {
14599 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14600 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14601 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14602 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14604 argv_find(argv
, argc
, "permit", &idx
);
14605 argv_find(argv
, argc
, "deny", &idx
);
14608 /* Check the list direct. */
14609 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14610 direct
= COMMUNITY_PERMIT
;
14612 direct
= COMMUNITY_DENY
;
14615 argv_find(argv
, argc
, "LINE", &idx
);
14616 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14617 /* Concat community string argument. */
14618 str
= argv_concat(argv
, argc
, idx
);
14622 argv_find(argv
, argc
, "(1-99)", &idx
);
14623 argv_find(argv
, argc
, "(100-500)", &idx
);
14624 argv_find(argv
, argc
, "WORD", &idx
);
14626 /* Unset community list. */
14627 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14630 /* Free temporary community list string allocated by
14632 XFREE(MTYPE_TMP
, str
);
14635 community_list_perror(vty
, ret
);
14636 return CMD_WARNING_CONFIG_FAILED
;
14639 return CMD_SUCCESS
;
14642 /* "large-community-list" keyword help string. */
14643 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14644 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14646 #if CONFDATE > 20191005
14647 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14649 DEFUN (lcommunity_list_standard
,
14650 bgp_lcommunity_list_standard_cmd
,
14651 "bgp large-community-list (1-99) <deny|permit>",
14653 LCOMMUNITY_LIST_STR
14654 "Large Community list number (standard)\n"
14655 "Specify large community to reject\n"
14656 "Specify large community to accept\n")
14658 return lcommunity_list_set_vty(vty
, argc
, argv
,
14659 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14662 ALIAS (lcommunity_list_standard
,
14663 ip_lcommunity_list_standard_cmd
,
14664 "ip large-community-list (1-99) <deny|permit>",
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")
14671 DEFUN (lcommunity_list_standard1
,
14672 bgp_lcommunity_list_standard1_cmd
,
14673 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14675 LCOMMUNITY_LIST_STR
14676 "Large Community list number (standard)\n"
14677 "Specify large community to reject\n"
14678 "Specify large community to accept\n"
14679 LCOMMUNITY_VAL_STR
)
14681 return lcommunity_list_set_vty(vty
, argc
, argv
,
14682 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14685 ALIAS (lcommunity_list_standard1
,
14686 ip_lcommunity_list_standard1_cmd
,
14687 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14689 LCOMMUNITY_LIST_STR
14690 "Large Community list number (standard)\n"
14691 "Specify large community to reject\n"
14692 "Specify large community to accept\n"
14693 LCOMMUNITY_VAL_STR
)
14695 DEFUN (lcommunity_list_expanded
,
14696 bgp_lcommunity_list_expanded_cmd
,
14697 "bgp large-community-list (100-500) <deny|permit> LINE...",
14699 LCOMMUNITY_LIST_STR
14700 "Large Community list number (expanded)\n"
14701 "Specify large community to reject\n"
14702 "Specify large community to accept\n"
14703 "An ordered list as a regular-expression\n")
14705 return lcommunity_list_set_vty(vty
, argc
, argv
,
14706 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14709 ALIAS (lcommunity_list_expanded
,
14710 ip_lcommunity_list_expanded_cmd
,
14711 "ip large-community-list (100-500) <deny|permit> LINE...",
14713 LCOMMUNITY_LIST_STR
14714 "Large Community list number (expanded)\n"
14715 "Specify large community to reject\n"
14716 "Specify large community to accept\n"
14717 "An ordered list as a regular-expression\n")
14719 DEFUN (lcommunity_list_name_standard
,
14720 bgp_lcommunity_list_name_standard_cmd
,
14721 "bgp large-community-list standard WORD <deny|permit>",
14723 LCOMMUNITY_LIST_STR
14724 "Specify standard large-community-list\n"
14725 "Large Community list name\n"
14726 "Specify large community to reject\n"
14727 "Specify large community to accept\n")
14729 return lcommunity_list_set_vty(vty
, argc
, argv
,
14730 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14733 ALIAS (lcommunity_list_name_standard
,
14734 ip_lcommunity_list_name_standard_cmd
,
14735 "ip large-community-list standard WORD <deny|permit>",
14737 LCOMMUNITY_LIST_STR
14738 "Specify standard large-community-list\n"
14739 "Large Community list name\n"
14740 "Specify large community to reject\n"
14741 "Specify large community to accept\n")
14743 DEFUN (lcommunity_list_name_standard1
,
14744 bgp_lcommunity_list_name_standard1_cmd
,
14745 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14747 LCOMMUNITY_LIST_STR
14748 "Specify standard large-community-list\n"
14749 "Large Community list name\n"
14750 "Specify large community to reject\n"
14751 "Specify large community to accept\n"
14752 LCOMMUNITY_VAL_STR
)
14754 return lcommunity_list_set_vty(vty
, argc
, argv
,
14755 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14758 ALIAS (lcommunity_list_name_standard1
,
14759 ip_lcommunity_list_name_standard1_cmd
,
14760 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14762 LCOMMUNITY_LIST_STR
14763 "Specify standard large-community-list\n"
14764 "Large Community list name\n"
14765 "Specify large community to reject\n"
14766 "Specify large community to accept\n"
14767 LCOMMUNITY_VAL_STR
)
14769 DEFUN (lcommunity_list_name_expanded
,
14770 bgp_lcommunity_list_name_expanded_cmd
,
14771 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14773 LCOMMUNITY_LIST_STR
14774 "Specify expanded large-community-list\n"
14775 "Large Community list name\n"
14776 "Specify large community to reject\n"
14777 "Specify large community to accept\n"
14778 "An ordered list as a regular-expression\n")
14780 return lcommunity_list_set_vty(vty
, argc
, argv
,
14781 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14784 ALIAS (lcommunity_list_name_expanded
,
14785 ip_lcommunity_list_name_expanded_cmd
,
14786 "ip large-community-list expanded WORD <deny|permit> LINE...",
14788 LCOMMUNITY_LIST_STR
14789 "Specify expanded large-community-list\n"
14790 "Large Community list name\n"
14791 "Specify large community to reject\n"
14792 "Specify large community to accept\n"
14793 "An ordered list as a regular-expression\n")
14795 DEFUN (no_lcommunity_list_standard_all
,
14796 no_bgp_lcommunity_list_standard_all_cmd
,
14797 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14800 LCOMMUNITY_LIST_STR
14801 "Large Community list number (standard)\n"
14802 "Large Community list number (expanded)\n"
14803 "Large Community list name\n")
14805 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14806 LARGE_COMMUNITY_LIST_STANDARD
);
14809 ALIAS (no_lcommunity_list_standard_all
,
14810 no_ip_lcommunity_list_standard_all_cmd
,
14811 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14814 LCOMMUNITY_LIST_STR
14815 "Large Community list number (standard)\n"
14816 "Large Community list number (expanded)\n"
14817 "Large Community list name\n")
14819 DEFUN (no_lcommunity_list_name_expanded_all
,
14820 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14821 "no bgp large-community-list expanded WORD",
14824 LCOMMUNITY_LIST_STR
14825 "Specify expanded large-community-list\n"
14826 "Large Community list name\n")
14828 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14829 LARGE_COMMUNITY_LIST_EXPANDED
);
14832 ALIAS (no_lcommunity_list_name_expanded_all
,
14833 no_ip_lcommunity_list_name_expanded_all_cmd
,
14834 "no ip large-community-list expanded WORD",
14837 LCOMMUNITY_LIST_STR
14838 "Specify expanded large-community-list\n"
14839 "Large Community list name\n")
14841 DEFUN (no_lcommunity_list_standard
,
14842 no_bgp_lcommunity_list_standard_cmd
,
14843 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14846 LCOMMUNITY_LIST_STR
14847 "Large Community list number (standard)\n"
14848 "Specify large community to reject\n"
14849 "Specify large community to accept\n"
14850 LCOMMUNITY_VAL_STR
)
14852 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14853 LARGE_COMMUNITY_LIST_STANDARD
);
14856 ALIAS (no_lcommunity_list_standard
,
14857 no_ip_lcommunity_list_standard_cmd
,
14858 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14861 LCOMMUNITY_LIST_STR
14862 "Large Community list number (standard)\n"
14863 "Specify large community to reject\n"
14864 "Specify large community to accept\n"
14865 LCOMMUNITY_VAL_STR
)
14867 DEFUN (no_lcommunity_list_expanded
,
14868 no_bgp_lcommunity_list_expanded_cmd
,
14869 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14872 LCOMMUNITY_LIST_STR
14873 "Large Community list number (expanded)\n"
14874 "Specify large community to reject\n"
14875 "Specify large community to accept\n"
14876 "An ordered list as a regular-expression\n")
14878 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14879 LARGE_COMMUNITY_LIST_EXPANDED
);
14882 ALIAS (no_lcommunity_list_expanded
,
14883 no_ip_lcommunity_list_expanded_cmd
,
14884 "no ip large-community-list (100-500) <deny|permit> LINE...",
14887 LCOMMUNITY_LIST_STR
14888 "Large Community list number (expanded)\n"
14889 "Specify large community to reject\n"
14890 "Specify large community to accept\n"
14891 "An ordered list as a regular-expression\n")
14893 DEFUN (no_lcommunity_list_name_standard
,
14894 no_bgp_lcommunity_list_name_standard_cmd
,
14895 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14898 LCOMMUNITY_LIST_STR
14899 "Specify standard large-community-list\n"
14900 "Large Community list name\n"
14901 "Specify large community to reject\n"
14902 "Specify large community to accept\n"
14903 LCOMMUNITY_VAL_STR
)
14905 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14906 LARGE_COMMUNITY_LIST_STANDARD
);
14909 ALIAS (no_lcommunity_list_name_standard
,
14910 no_ip_lcommunity_list_name_standard_cmd
,
14911 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14914 LCOMMUNITY_LIST_STR
14915 "Specify standard large-community-list\n"
14916 "Large Community list name\n"
14917 "Specify large community to reject\n"
14918 "Specify large community to accept\n"
14919 LCOMMUNITY_VAL_STR
)
14921 DEFUN (no_lcommunity_list_name_expanded
,
14922 no_bgp_lcommunity_list_name_expanded_cmd
,
14923 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14926 LCOMMUNITY_LIST_STR
14927 "Specify expanded large-community-list\n"
14928 "Large community list name\n"
14929 "Specify large community to reject\n"
14930 "Specify large community to accept\n"
14931 "An ordered list as a regular-expression\n")
14933 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14934 LARGE_COMMUNITY_LIST_EXPANDED
);
14937 ALIAS (no_lcommunity_list_name_expanded
,
14938 no_ip_lcommunity_list_name_expanded_cmd
,
14939 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14942 LCOMMUNITY_LIST_STR
14943 "Specify expanded large-community-list\n"
14944 "Large community list name\n"
14945 "Specify large community to reject\n"
14946 "Specify large community to accept\n"
14947 "An ordered list as a regular-expression\n")
14949 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14951 struct community_entry
*entry
;
14953 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14954 if (entry
== list
->head
) {
14955 if (all_digit(list
->name
))
14956 vty_out(vty
, "Large community %s list %s\n",
14957 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14959 : "(expanded) access",
14963 "Named large community %s list %s\n",
14964 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14970 vty_out(vty
, " %s\n",
14971 community_direct_str(entry
->direct
));
14973 vty_out(vty
, " %s %s\n",
14974 community_direct_str(entry
->direct
),
14975 community_list_config_str(entry
));
14979 DEFUN (show_lcommunity_list
,
14980 show_bgp_lcommunity_list_cmd
,
14981 "show bgp large-community-list",
14984 "List large-community list\n")
14986 struct community_list
*list
;
14987 struct community_list_master
*cm
;
14990 if (argv_find(argv
, argc
, "ip", &idx
)) {
14991 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14992 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14993 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
14994 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
14997 cm
= community_list_master_lookup(bgp_clist
,
14998 LARGE_COMMUNITY_LIST_MASTER
);
15000 return CMD_SUCCESS
;
15002 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15003 lcommunity_list_show(vty
, list
);
15005 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15006 lcommunity_list_show(vty
, list
);
15008 return CMD_SUCCESS
;
15011 ALIAS (show_lcommunity_list
,
15012 show_ip_lcommunity_list_cmd
,
15013 "show ip large-community-list",
15016 "List large-community list\n")
15018 DEFUN (show_lcommunity_list_arg
,
15019 show_bgp_lcommunity_list_arg_cmd
,
15020 "show bgp large-community-list <(1-500)|WORD>",
15023 "List large-community list\n"
15024 "large-community-list number\n"
15025 "large-community-list name\n")
15027 struct community_list
*list
;
15030 if (argv_find(argv
, argc
, "ip", &idx
)) {
15031 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15032 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15033 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15034 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15037 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
15038 LARGE_COMMUNITY_LIST_MASTER
);
15040 vty_out(vty
, "%% Can't find extcommunity-list\n");
15041 return CMD_WARNING
;
15044 lcommunity_list_show(vty
, list
);
15046 return CMD_SUCCESS
;
15049 ALIAS (show_lcommunity_list_arg
,
15050 show_ip_lcommunity_list_arg_cmd
,
15051 "show ip large-community-list <(1-500)|WORD>",
15054 "List large-community list\n"
15055 "large-community-list number\n"
15056 "large-community-list name\n")
15058 /* "extcommunity-list" keyword help string. */
15059 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15060 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15062 DEFUN (extcommunity_list_standard
,
15063 bgp_extcommunity_list_standard_cmd
,
15064 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15066 EXTCOMMUNITY_LIST_STR
15067 "Extended Community list number (standard)\n"
15068 "Specify standard extcommunity-list\n"
15069 "Community list name\n"
15070 "Specify community to reject\n"
15071 "Specify community to accept\n"
15072 EXTCOMMUNITY_VAL_STR
)
15074 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15076 char *cl_number_or_name
= NULL
;
15079 if (argv_find(argv
, argc
, "ip", &idx
)) {
15080 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15081 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15082 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15083 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15085 argv_find(argv
, argc
, "(1-99)", &idx
);
15086 argv_find(argv
, argc
, "WORD", &idx
);
15087 cl_number_or_name
= argv
[idx
]->arg
;
15088 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15090 argv_find(argv
, argc
, "AA:NN", &idx
);
15091 char *str
= argv_concat(argv
, argc
, idx
);
15093 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15096 XFREE(MTYPE_TMP
, str
);
15099 community_list_perror(vty
, ret
);
15100 return CMD_WARNING_CONFIG_FAILED
;
15103 return CMD_SUCCESS
;
15106 #if CONFDATE > 20191005
15107 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15109 ALIAS (extcommunity_list_standard
,
15110 ip_extcommunity_list_standard_cmd
,
15111 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15113 EXTCOMMUNITY_LIST_STR
15114 "Extended Community list number (standard)\n"
15115 "Specify standard extcommunity-list\n"
15116 "Community list name\n"
15117 "Specify community to reject\n"
15118 "Specify community to accept\n"
15119 EXTCOMMUNITY_VAL_STR
)
15121 DEFUN (extcommunity_list_name_expanded
,
15122 bgp_extcommunity_list_name_expanded_cmd
,
15123 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15125 EXTCOMMUNITY_LIST_STR
15126 "Extended Community list number (expanded)\n"
15127 "Specify expanded extcommunity-list\n"
15128 "Extended Community list name\n"
15129 "Specify community to reject\n"
15130 "Specify community to accept\n"
15131 "An ordered list as a regular-expression\n")
15133 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15135 char *cl_number_or_name
= NULL
;
15138 if (argv_find(argv
, argc
, "ip", &idx
)) {
15139 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15140 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15141 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15142 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15145 argv_find(argv
, argc
, "(100-500)", &idx
);
15146 argv_find(argv
, argc
, "WORD", &idx
);
15147 cl_number_or_name
= argv
[idx
]->arg
;
15148 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15150 argv_find(argv
, argc
, "LINE", &idx
);
15151 char *str
= argv_concat(argv
, argc
, idx
);
15153 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15156 XFREE(MTYPE_TMP
, str
);
15159 community_list_perror(vty
, ret
);
15160 return CMD_WARNING_CONFIG_FAILED
;
15163 return CMD_SUCCESS
;
15166 ALIAS (extcommunity_list_name_expanded
,
15167 ip_extcommunity_list_name_expanded_cmd
,
15168 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15170 EXTCOMMUNITY_LIST_STR
15171 "Extended Community list number (expanded)\n"
15172 "Specify expanded extcommunity-list\n"
15173 "Extended Community list name\n"
15174 "Specify community to reject\n"
15175 "Specify community to accept\n"
15176 "An ordered list as a regular-expression\n")
15178 DEFUN (no_extcommunity_list_standard_all
,
15179 no_bgp_extcommunity_list_standard_all_cmd
,
15180 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15183 EXTCOMMUNITY_LIST_STR
15184 "Extended Community list number (standard)\n"
15185 "Specify standard extcommunity-list\n"
15186 "Community list name\n"
15187 "Specify community to reject\n"
15188 "Specify community to accept\n"
15189 EXTCOMMUNITY_VAL_STR
)
15191 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15193 char *cl_number_or_name
= NULL
;
15197 if (argv_find(argv
, argc
, "ip", &idx
)) {
15198 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15199 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15200 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15201 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15205 argv_find(argv
, argc
, "permit", &idx
);
15206 argv_find(argv
, argc
, "deny", &idx
);
15209 direct
= argv_find(argv
, argc
, "permit", &idx
)
15214 argv_find(argv
, argc
, "AA:NN", &idx
);
15215 str
= argv_concat(argv
, argc
, idx
);
15219 argv_find(argv
, argc
, "(1-99)", &idx
);
15220 argv_find(argv
, argc
, "WORD", &idx
);
15221 cl_number_or_name
= argv
[idx
]->arg
;
15223 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15226 XFREE(MTYPE_TMP
, str
);
15229 community_list_perror(vty
, ret
);
15230 return CMD_WARNING_CONFIG_FAILED
;
15233 return CMD_SUCCESS
;
15236 ALIAS (no_extcommunity_list_standard_all
,
15237 no_ip_extcommunity_list_standard_all_cmd
,
15238 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15241 EXTCOMMUNITY_LIST_STR
15242 "Extended Community list number (standard)\n"
15243 "Specify standard extcommunity-list\n"
15244 "Community list name\n"
15245 "Specify community to reject\n"
15246 "Specify community to accept\n"
15247 EXTCOMMUNITY_VAL_STR
)
15249 ALIAS(no_extcommunity_list_standard_all
,
15250 no_bgp_extcommunity_list_standard_all_list_cmd
,
15251 "no bgp extcommunity-list <(1-99)|standard WORD>",
15252 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15253 "Extended Community list number (standard)\n"
15254 "Specify standard extcommunity-list\n"
15255 "Community list name\n")
15257 ALIAS(no_extcommunity_list_standard_all
,
15258 no_ip_extcommunity_list_standard_all_list_cmd
,
15259 "no ip extcommunity-list <(1-99)|standard WORD>",
15260 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15261 "Extended Community list number (standard)\n"
15262 "Specify standard extcommunity-list\n"
15263 "Community list name\n")
15265 DEFUN (no_extcommunity_list_expanded_all
,
15266 no_bgp_extcommunity_list_expanded_all_cmd
,
15267 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15270 EXTCOMMUNITY_LIST_STR
15271 "Extended Community list number (expanded)\n"
15272 "Specify expanded extcommunity-list\n"
15273 "Extended Community list name\n"
15274 "Specify community to reject\n"
15275 "Specify community to accept\n"
15276 "An ordered list as a regular-expression\n")
15278 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15280 char *cl_number_or_name
= NULL
;
15284 if (argv_find(argv
, argc
, "ip", &idx
)) {
15285 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15286 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15287 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15288 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15292 argv_find(argv
, argc
, "permit", &idx
);
15293 argv_find(argv
, argc
, "deny", &idx
);
15296 direct
= argv_find(argv
, argc
, "permit", &idx
)
15301 argv_find(argv
, argc
, "LINE", &idx
);
15302 str
= argv_concat(argv
, argc
, idx
);
15306 argv_find(argv
, argc
, "(100-500)", &idx
);
15307 argv_find(argv
, argc
, "WORD", &idx
);
15308 cl_number_or_name
= argv
[idx
]->arg
;
15310 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15313 XFREE(MTYPE_TMP
, str
);
15316 community_list_perror(vty
, ret
);
15317 return CMD_WARNING_CONFIG_FAILED
;
15320 return CMD_SUCCESS
;
15323 ALIAS (no_extcommunity_list_expanded_all
,
15324 no_ip_extcommunity_list_expanded_all_cmd
,
15325 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15328 EXTCOMMUNITY_LIST_STR
15329 "Extended Community list number (expanded)\n"
15330 "Specify expanded extcommunity-list\n"
15331 "Extended Community list name\n"
15332 "Specify community to reject\n"
15333 "Specify community to accept\n"
15334 "An ordered list as a regular-expression\n")
15336 ALIAS(no_extcommunity_list_expanded_all
,
15337 no_ip_extcommunity_list_expanded_all_list_cmd
,
15338 "no ip extcommunity-list <(100-500)|expanded WORD>",
15339 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15340 "Extended Community list number (expanded)\n"
15341 "Specify expanded extcommunity-list\n"
15342 "Extended Community list name\n")
15344 ALIAS(no_extcommunity_list_expanded_all
,
15345 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15346 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15347 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15348 "Extended Community list number (expanded)\n"
15349 "Specify expanded extcommunity-list\n"
15350 "Extended Community list name\n")
15352 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15354 struct community_entry
*entry
;
15356 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15357 if (entry
== list
->head
) {
15358 if (all_digit(list
->name
))
15359 vty_out(vty
, "Extended community %s list %s\n",
15360 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15362 : "(expanded) access",
15366 "Named extended community %s list %s\n",
15367 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15373 vty_out(vty
, " %s\n",
15374 community_direct_str(entry
->direct
));
15376 vty_out(vty
, " %s %s\n",
15377 community_direct_str(entry
->direct
),
15378 community_list_config_str(entry
));
15382 DEFUN (show_extcommunity_list
,
15383 show_bgp_extcommunity_list_cmd
,
15384 "show bgp extcommunity-list",
15387 "List extended-community list\n")
15389 struct community_list
*list
;
15390 struct community_list_master
*cm
;
15393 if (argv_find(argv
, argc
, "ip", &idx
)) {
15394 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15395 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15396 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15397 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15399 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15401 return CMD_SUCCESS
;
15403 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15404 extcommunity_list_show(vty
, list
);
15406 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15407 extcommunity_list_show(vty
, list
);
15409 return CMD_SUCCESS
;
15412 ALIAS (show_extcommunity_list
,
15413 show_ip_extcommunity_list_cmd
,
15414 "show ip extcommunity-list",
15417 "List extended-community list\n")
15419 DEFUN (show_extcommunity_list_arg
,
15420 show_bgp_extcommunity_list_arg_cmd
,
15421 "show bgp extcommunity-list <(1-500)|WORD>",
15424 "List extended-community list\n"
15425 "Extcommunity-list number\n"
15426 "Extcommunity-list name\n")
15428 int idx_comm_list
= 3;
15429 struct community_list
*list
;
15432 if (argv_find(argv
, argc
, "ip", &idx
)) {
15433 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15434 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15435 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15436 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15438 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15439 EXTCOMMUNITY_LIST_MASTER
);
15441 vty_out(vty
, "%% Can't find extcommunity-list\n");
15442 return CMD_WARNING
;
15445 extcommunity_list_show(vty
, list
);
15447 return CMD_SUCCESS
;
15450 ALIAS (show_extcommunity_list_arg
,
15451 show_ip_extcommunity_list_arg_cmd
,
15452 "show ip extcommunity-list <(1-500)|WORD>",
15455 "List extended-community list\n"
15456 "Extcommunity-list number\n"
15457 "Extcommunity-list name\n")
15459 /* Display community-list and extcommunity-list configuration. */
15460 static int community_list_config_write(struct vty
*vty
)
15462 struct community_list
*list
;
15463 struct community_entry
*entry
;
15464 struct community_list_master
*cm
;
15467 /* Community-list. */
15468 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15470 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15471 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15472 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15473 community_direct_str(entry
->direct
),
15474 community_list_config_str(entry
));
15477 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15478 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15479 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15480 entry
->style
== COMMUNITY_LIST_STANDARD
15483 list
->name
, community_direct_str(entry
->direct
),
15484 community_list_config_str(entry
));
15488 /* Extcommunity-list. */
15489 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_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 extcommunity-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 extcommunity-list %s %s %s %s\n",
15501 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15504 list
->name
, community_direct_str(entry
->direct
),
15505 community_list_config_str(entry
));
15510 /* lcommunity-list. */
15511 cm
= community_list_master_lookup(bgp_clist
,
15512 LARGE_COMMUNITY_LIST_MASTER
);
15514 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15515 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15516 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15517 list
->name
, community_direct_str(entry
->direct
),
15518 community_list_config_str(entry
));
15521 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15522 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15523 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15524 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15527 list
->name
, community_direct_str(entry
->direct
),
15528 community_list_config_str(entry
));
15535 static struct cmd_node community_list_node
= {
15536 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15539 static void community_list_vty(void)
15541 install_node(&community_list_node
, community_list_config_write
);
15543 /* Community-list. */
15544 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15545 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15546 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15547 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15548 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15549 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15550 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15551 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15552 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15553 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15554 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15555 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15556 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15557 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15558 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15559 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15561 /* Extcommunity-list. */
15562 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15563 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15564 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15565 install_element(CONFIG_NODE
,
15566 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15567 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15568 install_element(CONFIG_NODE
,
15569 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15570 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15571 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15572 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15573 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15574 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15575 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15576 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15577 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15578 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15579 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15581 /* Large Community List */
15582 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15583 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard1_cmd
);
15584 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15585 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15586 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard1_cmd
);
15587 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15588 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15589 install_element(CONFIG_NODE
,
15590 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15591 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15592 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15593 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15594 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15595 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15596 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15597 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15598 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
15599 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15600 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15601 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
15602 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15603 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15604 install_element(CONFIG_NODE
,
15605 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15606 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15607 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15608 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15609 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15610 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15611 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);